From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 3/3] tst_test_macros: Add test_macros05 tests
Date: Mon, 23 Aug 2021 17:05:20 +0200 [thread overview]
Message-ID: <20210823150520.25614-4-chrubis@suse.cz> (raw)
In-Reply-To: <20210823150520.25614-1-chrubis@suse.cz>
That tests the two corner cases with default message and macro
stringification.
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
lib/newlib_tests/.gitignore | 1 +
lib/newlib_tests/test_macros05.c | 46 ++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
create mode 100644 lib/newlib_tests/test_macros05.c
diff --git a/lib/newlib_tests/.gitignore b/lib/newlib_tests/.gitignore
index 807e510ee..a0bad78c1 100644
--- a/lib/newlib_tests/.gitignore
+++ b/lib/newlib_tests/.gitignore
@@ -41,6 +41,7 @@ test_macros01
test_macros02
test_macros03
test_macros04
+test_macros05
tst_fuzzy_sync01
tst_fuzzy_sync02
tst_fuzzy_sync03
diff --git a/lib/newlib_tests/test_macros05.c b/lib/newlib_tests/test_macros05.c
new file mode 100644
index 000000000..a164f23ac
--- /dev/null
+++ b/lib/newlib_tests/test_macros05.c
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2021 Cyril Hrubis <chrubis@suse.cz>
+ */
+
+/*
+ * Tests various corner conditions:
+ *
+ * - default message, i.e. first argument stringification
+ * - macro indirection, i.e. we have to stringify early
+ *
+ * The output should include the MACRO_FAIL() as the either fail of pass
+ * message. If it's missing or if it has been replaced by the function name
+ * there is a bug in the TST_EXP_*() macro.
+ */
+
+#include "tst_test.h"
+
+static int fail_fn_should_not_be_seen_in_output(void)
+{
+ errno = EINVAL;
+ return -1;
+}
+
+#define MACRO_FAIL() fail_fn_should_not_be_seen_in_output()
+
+static void do_test(void)
+{
+ TST_EXP_FAIL(MACRO_FAIL(), EINVAL);
+ TST_EXP_FAIL2(MACRO_FAIL(), EINVAL);
+
+ TST_EXP_PASS(MACRO_FAIL());
+ TST_EXP_PASS_SILENT(MACRO_FAIL());
+
+ TST_EXP_PID(MACRO_FAIL());
+ TST_EXP_PID_SILENT(MACRO_FAIL());
+
+ TST_EXP_FD(MACRO_FAIL());
+ TST_EXP_FD_SILENT(MACRO_FAIL());
+
+ TST_EXP_POSITIVE(MACRO_FAIL());
+}
+
+static struct tst_test test = {
+ .test_all = do_test,
+};
--
2.31.1
prev parent reply other threads:[~2021-08-23 15:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-23 15:05 [LTP] [PATCH 0/3] TST_EXP_*() macros fixes Cyril Hrubis
2021-08-23 15:05 ` [LTP] [PATCH 1/3] tst_test_macros: Fix TST_EXP_*() default message Cyril Hrubis
2021-08-24 7:35 ` Li Wang
2021-08-24 8:48 ` Cyril Hrubis
2021-08-24 9:29 ` Li Wang
2021-08-24 12:46 ` Richard Palethorpe
2021-08-24 11:48 ` Petr Vorel
2021-08-24 13:37 ` Cyril Hrubis
2021-08-23 15:05 ` [LTP] [PATCH 2/3] tst_test_macros: Stringify early Cyril Hrubis
2021-08-23 15:05 ` Cyril Hrubis [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210823150520.25614-4-chrubis@suse.cz \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox