Skip to contentSkip to conversation

lib/tst_test: setup TCID earlier in do_setup()

PATCH New Alexey Kodanev 3 participants 5 messages Jun 24, 2021 – Jun 28, 2021 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 lib/tst_test: setup TCID earlier in do_setup()

TCID can be NULL in tst_tmpdir() because it is set after do_setup():

    tst_run_tcases()
        do_setup()
            ...
            tid = get_tid();
            ...
            tst_tmpdir()  /* using TCID here */
        TCID = tid;
---
 lib/tst_test.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
lib/tst_test.c +1 -3
index 36a4809c7..55449c80b 100644
@@ -915,7 +915,7 @@ static void do_setup(int argc, char *argv[])
 
 	assert_test_fn();
 
-	tid = get_tid(argv);
+	TCID = tid = get_tid(argv);
 
 	if (tst_test->sample)
 		tst_test = tst_timer_test_setup(tst_test);
@@ -1412,8 +1412,6 @@ void tst_run_tcases(int argc, char *argv[], struct tst_test *self)
 
 	do_setup(argc, argv);
 
-	TCID = tid;
-
 	SAFE_SIGNAL(SIGALRM, alarm_handler);
 	SAFE_SIGNAL(SIGUSR1, heartbeat_handler);
 
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 fcntl38: check required kernel config option for dnotify

---
 testcases/kernel/syscalls/fcntl/fcntl38.c | 1 +
 1 file changed, 1 insertion(+)
testcases/kernel/syscalls/fcntl/fcntl38.c +1 -0
index 6185d3209..fae2ab4f7 100644
@@ -93,4 +93,5 @@ static struct tst_test test = {
 	.setup = setup,
 	.cleanup = cleanup,
 	.test_all = verify_dnotify,
+	.needs_kconfigs = (const char *[]) { "CONFIG_DNOTIFY=y", NULL },
 };
Signature · 1 line
2.25.1
#2 lore raw

PATCH 1/2 lib/tst_test: setup TCID earlier in do_setup()

In reply to Alexey Kodanev

Hi Alexey,

Good catch.

Quoted 10 lines · Alexey Kodanev

TCID can be NULL in tst_tmpdir() because it is set after do_setup():

    tst_run_tcases()
        do_setup()
            ...
            tid = get_tid();
            ...
            tst_tmpdir()  /* using TCID here */
        TCID = tid;
Quoted 2 lines
Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210624/342af4b5/attachment-0001.htm>
author Applied
#4 lore raw

PATCH 1/2 lib/tst_test: setup TCID earlier in do_setup()

Hi Li, Cyril,

Quoted 11 lines · Cyril Hrubis

Hi!

Quoted 9 lines

TCID can be NULL in tst_tmpdir() because it is set after do_setup():

    tst_run_tcases()
        do_setup()
            ...
            tid = get_tid();
            ...
            tst_tmpdir()  /* using TCID here */
        TCID = tid;
Quoted 1 line

Good catch, I wonder how we missed this for so long...

Ran into this with musl, it pastes "(null)" to the tmpdir path if TCID is NULL, so the final template looked like "/tmp/(nuXXXXXX". But glibc skips it because the same string doesn't fit in 3 chars template in snprintf(..., "%s/%.3sXXXXXX",...).

Applied the patch. Thanks for review!