public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Andrea Cervesato <andrea.cervesato@suse.de>
To: Linux Test Project <ltp@lists.linux.it>
Subject: [LTP] [PATCH v2 3/7] lib: add TST_EXP_PASS_PTR_NULL() macro
Date: Thu, 16 Apr 2026 16:33:37 +0200	[thread overview]
Message-ID: <20260416-stream_refactoring-v2-3-8321b1ec6f68@suse.com> (raw)
In-Reply-To: <20260416-stream_refactoring-v2-0-8321b1ec6f68@suse.com>

From: Andrea Cervesato <andrea.cervesato@suse.com>

Add a variant of TST_EXP_PASS_PTR_VOID() that checks the return
value against NULL instead of (void *)-1. This is useful for libc
functions such as fopen() that return NULL on failure, allowing
tests to report TFAIL instead of TBROK when the call fails.

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 include/tst_test_macros.h | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index 3d2287753b0419c82b1a878e8779def99d4bb4ca..2cfbdb5869af5c871e7086236a17b3a76e34b5d3 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -370,7 +370,20 @@ extern int TST_PASS;
  * is converted to a string and used instead.
  */
 #define TST_EXP_PASS_PTR_VOID(SCALL, ...)                                      \
-               TST_EXP_PASS_PTR_(SCALL, #SCALL, (void *)-1, ##__VA_ARGS__);
+	TST_EXP_PASS_PTR_(SCALL, #SCALL, (void *)-1, ##__VA_ARGS__);
+
+/**
+ * TST_EXP_PASS_PTR_NULL() - Test call to return a non-NULL pointer.
+ *
+ * @SCALL: Tested call.
+ * @...: A printf-like parameters.
+ *
+ * This macro works like TST_EXP_PASS_PTR_VOID() but checks the return
+ * value against NULL instead of (void *)-1. Use this for libc functions
+ * such as fopen() that return NULL on failure.
+ */
+#define TST_EXP_PASS_PTR_NULL(SCALL, ...)                                      \
+	TST_EXP_PASS_PTR_(SCALL, #SCALL, NULL, ##__VA_ARGS__)
 
 /*
  * Returns true if err is in the exp_err array.

-- 
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2026-04-16 14:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-16 14:33 [LTP] [PATCH v2 0/7] Rewrite fs stream testing suite Andrea Cervesato
2026-04-16 14:33 ` [LTP] [PATCH v2 1/7] lib: add safe macros for " Andrea Cervesato
2026-04-16 15:34   ` [LTP] " linuxtestproject.agent
2026-04-16 14:33 ` [LTP] [PATCH v2 2/7] fs: rewrite stream01 test using new API Andrea Cervesato
2026-04-16 15:26   ` Cyril Hrubis
2026-04-16 14:33 ` Andrea Cervesato [this message]
2026-04-16 15:15   ` [LTP] [PATCH v2 3/7] lib: add TST_EXP_PASS_PTR_NULL() macro Cyril Hrubis
2026-04-16 14:33 ` [LTP] [PATCH v2 4/7] fs: rewrite stream02 test using new API Andrea Cervesato
2026-04-16 15:32   ` Cyril Hrubis
2026-04-16 14:33 ` [LTP] [PATCH v2 5/7] fs: rewrite stream03 " Andrea Cervesato
2026-04-16 14:33 ` [LTP] [PATCH v2 6/7] fs: rewrite stream04 " Andrea Cervesato
2026-04-16 14:33 ` [LTP] [PATCH v2 7/7] fs: rewrite stream05 " Andrea Cervesato
2026-04-16 18:21 ` [LTP] [PATCH v2 0/7] Rewrite fs stream testing suite Andrea Cervesato via ltp

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=20260416-stream_refactoring-v2-3-8321b1ec6f68@suse.com \
    --to=andrea.cervesato@suse.de \
    --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