diff mbox series

[v3] lib: set results->lib_pid in the setup_ipc

Message ID 20250514083403.61348-1-liwang@redhat.com
State Accepted
Headers show
Series [v3] lib: set results->lib_pid in the setup_ipc | expand

Checks

Context Check Description
ltpci/debian_stable_s390x-linux-gnu-gcc_s390x success success
ltpci/debian_stable_powerpc64le-linux-gnu-gcc_ppc64el success success
ltpci/debian_stable_gcc success success
ltpci/debian_stable_aarch64-linux-gnu-gcc_arm64 success success
ltpci/ubuntu_jammy_gcc success success
ltpci/ubuntu_bionic_gcc success success
ltpci/debian_stable_gcc success success
ltpci/debian_testing_gcc success success
ltpci/opensuse-archive_42-2_gcc success success
ltpci/quay-io-centos-centos_stream9_gcc success success
ltpci/alpine_latest_gcc success success
ltpci/fedora_latest_clang success success
ltpci/opensuse-leap_latest_gcc success success
ltpci/debian_testing_clang success success
ltpci/debian_oldstable_gcc success success
ltpci/debian_oldstable_clang success success

Commit Message

Li Wang May 14, 2025, 8:34 a.m. UTC
To resolve several problems:

  1. failure from tst_needs_cmd02 in github CI.

  2. tst_run_shell.c segement fault

  3. commit b987b8ac5 introduced an issue that incorrectly identified
     TCONF as TFAIL. This caused quite a few test cases (TCONF from old API)
     to be reported as failures.

  4. https://github.com/linux-test-project/ltp/issues/1240

CI-Job: https://github.com/wangli5665/ltp/actions/runs/15012129791
Follow-up-fix: commit b987b8ac5 ("lib: child process exit with error due to uninitialized lib_pid")
Signed-off-by: Li Wang <liwang@redhat.com>
---

Notes:
    v2 -> v3
        * set the lib pid in setup_ipc as Cyril suggested

 lib/tst_test.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

Comments

Cyril Hrubis May 14, 2025, 9:57 a.m. UTC | #1
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Li Wang May 14, 2025, 12:19 p.m. UTC | #2
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

Thanks, patchset fix pushed.
diff mbox series

Patch

diff --git a/lib/tst_test.c b/lib/tst_test.c
index b666715b9..923ecf7be 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -59,7 +59,6 @@  static const char *tid;
 static int iterations = 1;
 static float duration = -1;
 static float timeout_mul = -1;
-static pid_t lib_pid;
 static int mntpoint_mounted;
 static int ovl_mounted;
 static struct timespec tst_start_time; /* valid only for test pid */
@@ -143,7 +142,9 @@  static void setup_ipc(void)
 		tst_futexes = (char *)results + sizeof(struct results);
 		tst_max_futexes = (size - sizeof(struct results))/sizeof(futex_t);
 	}
-	results->lib_pid = lib_pid;
+
+	memset(results, 0 , size);
+	results->lib_pid = getpid();
 }
 
 static void cleanup_ipc(void)
@@ -394,7 +395,7 @@  void tst_vbrk_(const char *file, const int lineno, int ttype, const char *fmt,
 	 * If tst_brk() is called from some of the C helpers even before the
 	 * library was initialized, just exit.
 	 */
-	if (!results->lib_pid)
+	if (!results || !results->lib_pid)
 		exit(TTYPE_RESULT(ttype));
 
 	update_results(TTYPE_RESULT(ttype));
@@ -1334,6 +1335,8 @@  static void do_setup(int argc, char *argv[])
 		tst_test->forks_child = 1;
 	}
 
+	setup_ipc();
+
 	if (tst_test->needs_kconfigs && tst_kconfig_check(tst_test->needs_kconfigs))
 		tst_brk(TCONF, "Aborting due to unsuitable kernel config, see above!");
 
@@ -1393,8 +1396,6 @@  static void do_setup(int argc, char *argv[])
 	if (tst_test->hugepages.number)
 		tst_reserve_hugepages(&tst_test->hugepages);
 
-	setup_ipc();
-
 	if (tst_test->bufs)
 		tst_buffers_alloc(tst_test->bufs);
 
@@ -1929,7 +1930,6 @@  void tst_run_tcases(int argc, char *argv[], struct tst_test *self)
 	unsigned int test_variants = 1;
 	struct utsname uval;
 
-	lib_pid = getpid();
 	tst_test = self;
 
 	do_setup(argc, argv);
@@ -1940,7 +1940,6 @@  void tst_run_tcases(int argc, char *argv[], struct tst_test *self)
 
 	tst_res(TINFO, "LTP version: "LTP_VERSION);
 
-
 	uname(&uval);
 	tst_res(TINFO, "Tested kernel: %s %s %s", uval.release, uval.version, uval.machine);