All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 0/5] C API: .needs_cmds and SAFE_CMD()
@ 2020-03-30 12:43 Petr Vorel
  2020-03-30 12:43 ` [LTP] [PATCH v2 1/5] lib: Rename tst_run_cmd*() to tst_cmd*() Petr Vorel
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Petr Vorel @ 2020-03-30 12:43 UTC (permalink / raw)
  To: ltp

Hi,

just in case due massive rename I'm posting the changes.

Kind regards,
Petr

Petr Vorel (5):
  lib: Rename tst_run_cmd*() to tst_cmd*()
  lib/tst_cmd_*(): Turn int pass_exit_val into enum
  lib/tst_cmd_*(): Search for program in $PATH
  lib: Implement SAFE_CMD() macro (new API only)
  Use SAFE_CMD()

 doc/test-writing-guidelines.txt               | 20 +++---
 include/tst_cmd.h                             | 61 +++++++++++--------
 include/tst_safe_macros.h                     | 17 ++++++
 lib/{tst_run_cmd.c => tst_cmd.c}              | 32 ++++++----
 lib/tst_kernel.c                              |  3 +-
 lib/tst_mkfs.c                                |  2 +-
 lib/tst_module.c                              |  5 +-
 lib/tst_virt.c                                |  2 +-
 testcases/cve/stack_clash.c                   |  2 +-
 testcases/kernel/input/input_helper.c         |  4 +-
 testcases/kernel/syscalls/acct/acct02.c       |  2 +-
 testcases/kernel/syscalls/add_key/add_key05.c | 16 ++---
 .../copy_file_range/copy_file_range02.c       |  2 +-
 .../kernel/syscalls/quotactl/quotactl01.c     | 11 +---
 .../kernel/syscalls/quotactl/quotactl06.c     |  9 +--
 .../syscalls/setpriority/setpriority01.c      |  4 +-
 testcases/kernel/syscalls/swapon/libswapon.c  |  2 +-
 testcases/network/netstress/netstress.c       |  2 +-
 .../network/nfs/nfs_stress/nfs05_make_tree.c  |  6 +-
 tools/apicmds/ltpapicmd.c                     |  2 +-
 20 files changed, 111 insertions(+), 93 deletions(-)
 rename lib/{tst_run_cmd.c => tst_cmd.c} (86%)

-- 
2.26.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v2 1/5] lib: Rename tst_run_cmd*() to tst_cmd*()
  2020-03-30 12:43 [LTP] [PATCH v2 0/5] C API: .needs_cmds and SAFE_CMD() Petr Vorel
@ 2020-03-30 12:43 ` Petr Vorel
  2020-03-30 12:43 ` [LTP] [PATCH v2 2/5] lib/tst_cmd_*(): Turn int pass_exit_val into enum Petr Vorel
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Petr Vorel @ 2020-03-30 12:43 UTC (permalink / raw)
  To: ltp

in function names and also C source file.
This is a preparation for next commit.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 doc/test-writing-guidelines.txt               | 10 ++++-----
 include/tst_cmd.h                             | 22 +++++++++----------
 lib/{tst_run_cmd.c => tst_cmd.c}              |  6 ++---
 lib/tst_kernel.c                              |  2 +-
 lib/tst_mkfs.c                                |  2 +-
 lib/tst_module.c                              |  4 ++--
 lib/tst_virt.c                                |  2 +-
 testcases/cve/stack_clash.c                   |  2 +-
 testcases/kernel/input/input_helper.c         |  4 ++--
 testcases/kernel/syscalls/acct/acct02.c       |  2 +-
 testcases/kernel/syscalls/add_key/add_key05.c |  4 ++--
 .../copy_file_range/copy_file_range02.c       |  2 +-
 .../kernel/syscalls/quotactl/quotactl01.c     |  2 +-
 .../kernel/syscalls/quotactl/quotactl06.c     |  2 +-
 .../syscalls/setpriority/setpriority01.c      |  4 ++--
 testcases/kernel/syscalls/swapon/libswapon.c  |  2 +-
 testcases/network/netstress/netstress.c       |  2 +-
 .../network/nfs/nfs_stress/nfs05_make_tree.c  |  6 ++---
 tools/apicmds/ltpapicmd.c                     |  2 +-
 19 files changed, 41 insertions(+), 41 deletions(-)
 rename lib/{tst_run_cmd.c => tst_cmd.c} (96%)

diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index cff42f515..3956e2c4c 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -1260,20 +1260,20 @@ different once the call returns and should be used only for rough estimates.
 -------------------------------------------------------------------------------
 #include "tst_test.h"
 
-int tst_run_cmd(const char *const argv[],
+int tst_cmd(const char *const argv[],
 	        const char *stdout_path,
 	        const char *stderr_path,
 	        int pass_exit_val);
 -------------------------------------------------------------------------------
 
-'tst_run_cmd' is a wrapper for 'vfork() + execvp()' which provides a way
+'tst_cmd' is a wrapper for 'vfork() + execvp()' which provides a way
 to execute an external program.
 
 'argv[]' is a 'NULL' terminated array of strings starting with the program name
 which is followed by optional arguments.
 
-A non-zero 'pass_exit_val' makes 'tst_run_cmd' return the program exit code to
-the caller. A zero for 'pass_exit_val' makes 'tst_run_cmd' exit the tests
+A non-zero 'pass_exit_val' makes 'tst_cmd' return the program exit code to
+the caller. A zero for 'pass_exit_val' makes 'tst_cmd' exit the tests
 on failure.
 
 In case that 'execvp()' has failed and the 'pass_exit_val' flag was set, the
@@ -1291,7 +1291,7 @@ const char *const cmd[] = { "ls", "-l", NULL };
 
 ...
 	/* Store output of 'ls -l' into log.txt */
-	tst_run_cmd(cmd, "log.txt", NULL, 0);
+	tst_cmd(cmd, "log.txt", NULL, 0);
 ...
 -------------------------------------------------------------------------------
 
diff --git a/include/tst_cmd.h b/include/tst_cmd.h
index d0a3573f4..b8b86eb28 100644
--- a/include/tst_cmd.h
+++ b/include/tst_cmd.h
@@ -18,13 +18,13 @@
  * exit code, otherwise it will call cleanup_fn() if the program
  * exit code is not zero.
  */
-int tst_run_cmd_fds_(void (cleanup_fn)(void),
+int tst_cmd_fds_(void (cleanup_fn)(void),
 			const char *const argv[],
 			int stdout_fd,
 			int stderr_fd,
 			int pass_exit_val);
 
-/* Executes tst_run_cmd_fds() and redirects its output to a file
+/* Executes tst_cmd_fds() and redirects its output to a file
  * @stdout_path: path where to redirect stdout. Set NULL if redirection is
  * not needed.
  * @stderr_path: path where to redirect stderr. Set NULL if redirection is
@@ -33,48 +33,48 @@ int tst_run_cmd_fds_(void (cleanup_fn)(void),
  * exit code, otherwise it will call cleanup_fn() if the program
  * exit code is not zero.
  */
-int tst_run_cmd_(void (cleanup_fn)(void),
+int tst_cmd_(void (cleanup_fn)(void),
 		const char *const argv[],
 		const char *stdout_path,
 		const char *stderr_path,
 		int pass_exit_val);
 
 #ifdef TST_TEST_H__
-static inline int tst_run_cmd_fds(const char *const argv[],
+static inline int tst_cmd_fds(const char *const argv[],
 				  int stdout_fd,
 				  int stderr_fd,
 				  int pass_exit_val)
 {
-	return tst_run_cmd_fds_(NULL, argv,
+	return tst_cmd_fds_(NULL, argv,
 	                        stdout_fd, stderr_fd, pass_exit_val);
 }
 
-static inline int tst_run_cmd(const char *const argv[],
+static inline int tst_cmd(const char *const argv[],
 			      const char *stdout_path,
 			      const char *stderr_path,
 			      int pass_exit_val)
 {
-	return tst_run_cmd_(NULL, argv,
+	return tst_cmd_(NULL, argv,
 	                    stdout_path, stderr_path, pass_exit_val);
 }
 #else
-static inline int tst_run_cmd_fds(void (cleanup_fn)(void),
+static inline int tst_cmd_fds(void (cleanup_fn)(void),
 				  const char *const argv[],
 				  int stdout_fd,
 				  int stderr_fd,
 				  int pass_exit_val)
 {
-	return tst_run_cmd_fds_(cleanup_fn, argv,
+	return tst_cmd_fds_(cleanup_fn, argv,
 	                        stdout_fd, stderr_fd, pass_exit_val);
 }
 
-static inline int tst_run_cmd(void (cleanup_fn)(void),
+static inline int tst_cmd(void (cleanup_fn)(void),
 			      const char *const argv[],
 			      const char *stdout_path,
 			      const char *stderr_path,
 			      int pass_exit_val)
 {
-	return tst_run_cmd_(cleanup_fn, argv,
+	return tst_cmd_(cleanup_fn, argv,
 	                    stdout_path, stderr_path, pass_exit_val);
 }
 #endif
diff --git a/lib/tst_run_cmd.c b/lib/tst_cmd.c
similarity index 96%
rename from lib/tst_run_cmd.c
rename to lib/tst_cmd.c
index 8e4bf6ba3..1964ff784 100644
--- a/lib/tst_run_cmd.c
+++ b/lib/tst_cmd.c
@@ -31,7 +31,7 @@
 #define OPEN_MODE	(S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
 #define OPEN_FLAGS	(O_WRONLY | O_APPEND | O_CREAT)
 
-int tst_run_cmd_fds_(void (cleanup_fn)(void),
+int tst_cmd_fds_(void (cleanup_fn)(void),
 		const char *const argv[],
 		int stdout_fd,
 		int stderr_fd,
@@ -107,7 +107,7 @@ int tst_run_cmd_fds_(void (cleanup_fn)(void),
 	return rc;
 }
 
-int tst_run_cmd_(void (cleanup_fn)(void),
+int tst_cmd_(void (cleanup_fn)(void),
 		const char *const argv[],
 		const char *stdout_path,
 		const char *stderr_path,
@@ -137,7 +137,7 @@ int tst_run_cmd_(void (cleanup_fn)(void),
 				stderr_path, __FILE__, __LINE__);
 	}
 
-	rc = tst_run_cmd_fds(cleanup_fn, argv, stdout_fd, stderr_fd,
+	rc = tst_cmd_fds(cleanup_fn, argv, stdout_fd, stderr_fd,
 			     pass_exit_val);
 
 	if ((stdout_fd != -1) && (close(stdout_fd) == -1))
diff --git a/lib/tst_kernel.c b/lib/tst_kernel.c
index 73ab9f1b1..210675b15 100644
--- a/lib/tst_kernel.c
+++ b/lib/tst_kernel.c
@@ -85,7 +85,7 @@ int tst_check_driver(const char *name)
 {
 #ifndef __ANDROID__
 	const char * const argv[] = { "modprobe", "-n", name, NULL };
-	int res = tst_run_cmd_(NULL, argv, "/dev/null", "/dev/null", 1);
+	int res = tst_cmd_(NULL, argv, "/dev/null", "/dev/null", 1);
 
 	/* 255 - it looks like modprobe not available */
 	return (res == 255) ? 0 : res;
diff --git a/lib/tst_mkfs.c b/lib/tst_mkfs.c
index 5d208eceb..9cdd35472 100644
--- a/lib/tst_mkfs.c
+++ b/lib/tst_mkfs.c
@@ -88,7 +88,7 @@ void tst_mkfs_(const char *file, const int lineno, void (cleanup_fn)(void),
 
 	tst_resm(TINFO, "Formatting %s with %s opts='%s' extra opts='%s'",
 	         dev, fs_type, fs_opts_str, extra_opts_str);
-	ret = tst_run_cmd(cleanup_fn, argv, "/dev/null", NULL, 1);
+	ret = tst_cmd(cleanup_fn, argv, "/dev/null", NULL, 1);
 
 	switch (ret) {
 	case 0:
diff --git a/lib/tst_module.c b/lib/tst_module.c
index ed39952ee..a9ce90e8a 100644
--- a/lib/tst_module.c
+++ b/lib/tst_module.c
@@ -97,7 +97,7 @@ void tst_module_load(void (cleanup_fn)(void),
 	for (i = offset; i < size; ++i)
 		mod_argv[i] = argv[i - offset];
 
-	tst_run_cmd(cleanup_fn, mod_argv, NULL, NULL, 0);
+	tst_cmd(cleanup_fn, mod_argv, NULL, NULL, 0);
 	free(mod_path);
 }
 
@@ -109,7 +109,7 @@ void tst_module_unload(void (cleanup_fn)(void), const char *mod_name)
 
 	rc = 1;
 	for (i = 0; i < 50; i++) {
-		rc = tst_run_cmd(NULL, argv, "/dev/null", "/dev/null", 1);
+		rc = tst_cmd(NULL, argv, "/dev/null", "/dev/null", 1);
 		if (!rc)
 			break;
 
diff --git a/lib/tst_virt.c b/lib/tst_virt.c
index e95cf5e70..090e6334c 100644
--- a/lib/tst_virt.c
+++ b/lib/tst_virt.c
@@ -70,7 +70,7 @@ static int try_systemd_detect_virt(void)
 	char virt_type[64];
 	int ret;
 
-	/* See tst_run_cmd.c */
+	/* See tst_cmd.c */
 	void *old_handler = signal(SIGCHLD, SIG_DFL);
 
 	f = popen("systemd-detect-virt", "r");
diff --git a/testcases/cve/stack_clash.c b/testcases/cve/stack_clash.c
index ecbf5f6da..cd7f148c2 100644
--- a/testcases/cve/stack_clash.c
+++ b/testcases/cve/stack_clash.c
@@ -119,7 +119,7 @@ void dump_proc_self_maps(void)
 	static char buf[64];
 	static const char *cmd[] = {"cat", buf, NULL};
 	sprintf(buf, "/proc/%d/maps", getpid());
-	tst_run_cmd(cmd, NULL, NULL, 0);
+	tst_cmd(cmd, NULL, NULL, 0);
 }
 
 void __attribute__((noinline)) preallocate_stack(unsigned long required)
diff --git a/testcases/kernel/input/input_helper.c b/testcases/kernel/input/input_helper.c
index f6ae9c9b6..bd9c715ed 100644
--- a/testcases/kernel/input/input_helper.c
+++ b/testcases/kernel/input/input_helper.c
@@ -92,7 +92,7 @@ static int try_load_uinput(void)
 
 	tst_resm(TINFO, "Trying to load uinput kernel module");
 
-	ret = tst_run_cmd(NULL, argv, NULL, NULL, 1);
+	ret = tst_cmd(NULL, argv, NULL, NULL, 1);
 	if (ret) {
 		tst_resm(TINFO, "Failed to load the uinput module");
 		return 0;
@@ -108,7 +108,7 @@ static void unload_uinput(void)
 
 	tst_resm(TINFO, "Unloading uinput kernel module");
 
-	ret = tst_run_cmd(NULL, argv, NULL, NULL, 1);
+	ret = tst_cmd(NULL, argv, NULL, NULL, 1);
 	if (ret)
 		tst_resm(TWARN, "Failed to unload uinput module");
 }
diff --git a/testcases/kernel/syscalls/acct/acct02.c b/testcases/kernel/syscalls/acct/acct02.c
index 2f1290fa2..22303dc3f 100644
--- a/testcases/kernel/syscalls/acct/acct02.c
+++ b/testcases/kernel/syscalls/acct/acct02.c
@@ -67,7 +67,7 @@ static void run_command(void)
 {
 	const char *const cmd[] = {COMMAND, NULL};
 
-	rc = tst_run_cmd(cmd, NULL, NULL, 1) << 8;
+	rc = tst_cmd(cmd, NULL, NULL, 1) << 8;
 }
 
 static int verify_acct(void *acc, int elap_time)
diff --git a/testcases/kernel/syscalls/add_key/add_key05.c b/testcases/kernel/syscalls/add_key/add_key05.c
index 7443a4970..191889a58 100644
--- a/testcases/kernel/syscalls/add_key/add_key05.c
+++ b/testcases/kernel/syscalls/add_key/add_key05.c
@@ -38,7 +38,7 @@ static void add_user(void)
 	const char *const cmd_useradd[] = {"useradd", username, NULL};
 	int rc;
 
-	switch ((rc = tst_run_cmd(cmd_useradd, NULL, NULL, 1))) {
+	switch ((rc = tst_cmd(cmd_useradd, NULL, NULL, 1))) {
 	case 0:
 		user_added = 1;
 		ltpuser = SAFE_GETPWNAM(username);
@@ -56,7 +56,7 @@ static void clean_user(void)
 
 	const char *const cmd_userdel[] = {"userdel", "-r", username, NULL};
 
-	if (tst_run_cmd(cmd_userdel, NULL, NULL, 1))
+	if (tst_cmd(cmd_userdel, NULL, NULL, 1))
 		tst_res(TWARN | TERRNO, "'userdel -r %s' failed", username);
 	else
 		user_added = 0;
diff --git a/testcases/kernel/syscalls/copy_file_range/copy_file_range02.c b/testcases/kernel/syscalls/copy_file_range/copy_file_range02.c
index c09766fe6..52a703b2b 100644
--- a/testcases/kernel/syscalls/copy_file_range/copy_file_range02.c
+++ b/testcases/kernel/syscalls/copy_file_range/copy_file_range02.c
@@ -87,7 +87,7 @@ static int run_command(char *command, char *option, char *file)
 	const char *const cmd[] = {command, option, file, NULL};
 	int ret;
 
-	ret = tst_run_cmd(cmd, NULL, NULL, 1);
+	ret = tst_cmd(cmd, NULL, NULL, 1);
 	switch (ret) {
 	case 0:
 	return 0;
diff --git a/testcases/kernel/syscalls/quotactl/quotactl01.c b/testcases/kernel/syscalls/quotactl/quotactl01.c
index 6cc1deeb8..d1c4657b3 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl01.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl01.c
@@ -164,7 +164,7 @@ static void setup(void)
 	const char *const cmd[] = {"quotacheck", "-ugF", "vfsv0", MNTPOINT, NULL};
 	int ret;
 
-	ret = tst_run_cmd(cmd, NULL, NULL, 1);
+	ret = tst_cmd(cmd, NULL, NULL, 1);
 	switch (ret) {
 	case 0:
 		break;
diff --git a/testcases/kernel/syscalls/quotactl/quotactl06.c b/testcases/kernel/syscalls/quotactl/quotactl06.c
index 758bd84cd..b5d59b706 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl06.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl06.c
@@ -149,7 +149,7 @@ static void setup(void)
 	int ret;
 	unsigned int i;
 
-	ret = tst_run_cmd(cmd, NULL, NULL, 1);
+	ret = tst_cmd(cmd, NULL, NULL, 1);
 	switch (ret) {
 	case 0:
 		break;
diff --git a/testcases/kernel/syscalls/setpriority/setpriority01.c b/testcases/kernel/syscalls/setpriority/setpriority01.c
index ffd7499c4..70c015f18 100644
--- a/testcases/kernel/syscalls/setpriority/setpriority01.c
+++ b/testcases/kernel/syscalls/setpriority/setpriority01.c
@@ -112,7 +112,7 @@ static void setup(void)
 	struct passwd *ltpuser;
 	int rc;
 
-	switch ((rc = tst_run_cmd(cmd_useradd, NULL, NULL, 1))) {
+	switch ((rc = tst_cmd(cmd_useradd, NULL, NULL, 1))) {
 	case 0:
 		user_added = 1;
 		ltpuser = SAFE_GETPWNAM(username);
@@ -133,7 +133,7 @@ static void cleanup(void)
 
 	const char *const cmd_userdel[] = {"userdel", "-r", username, NULL};
 
-	if (tst_run_cmd(cmd_userdel, NULL, NULL, 1))
+	if (tst_cmd(cmd_userdel, NULL, NULL, 1))
 		tst_res(TWARN | TERRNO, "'userdel -r %s' failed", username);
 }
 
diff --git a/testcases/kernel/syscalls/swapon/libswapon.c b/testcases/kernel/syscalls/swapon/libswapon.c
index 0a4501bdd..d5bbfa567 100644
--- a/testcases/kernel/syscalls/swapon/libswapon.c
+++ b/testcases/kernel/syscalls/swapon/libswapon.c
@@ -47,7 +47,7 @@ int make_swapfile(void (cleanup)(void), const char *swapfile, int safe)
 	argv[1] = swapfile;
 	argv[2] = NULL;
 
-	return tst_run_cmd(cleanup, argv, "/dev/null", "/dev/null", safe);
+	return tst_cmd(cleanup, argv, "/dev/null", "/dev/null", safe);
 }
 
 /*
diff --git a/testcases/network/netstress/netstress.c b/testcases/network/netstress/netstress.c
index 76d2fdb04..fca476198 100644
--- a/testcases/network/netstress/netstress.c
+++ b/testcases/network/netstress/netstress.c
@@ -967,7 +967,7 @@ static void setup(void)
 		/* dccp* modules can be blacklisted, load them manually */
 		const char * const argv[] = {"modprobe", "dccp_ipv6", NULL};
 
-		if (tst_run_cmd(argv, NULL, NULL, 1))
+		if (tst_cmd(argv, NULL, NULL, 1))
 			tst_brk(TCONF, "Failed to load dccp_ipv6 module");
 
 		tst_res(TINFO, "DCCP %s", (client_mode) ? "client" : "server");
diff --git a/testcases/network/nfs/nfs_stress/nfs05_make_tree.c b/testcases/network/nfs/nfs_stress/nfs05_make_tree.c
index 25809e1a3..12c86799d 100644
--- a/testcases/network/nfs/nfs_stress/nfs05_make_tree.c
+++ b/testcases/network/nfs/nfs_stress/nfs05_make_tree.c
@@ -82,7 +82,7 @@ static void run_targets(const char *dirname, char *cfile, pid_t tid)
 			snprintf(cfile, PATH_MAX, "%s%s/%d.%d.%d",
 				 dirname, subdir, tid, i, k);
 
-			tst_run_cmd(cmd_run, output_file, NULL, 0);
+			tst_cmd(cmd_run, output_file, NULL, 0);
 
 			fd = SAFE_OPEN(output_file, O_RDONLY);
 			SAFE_READ(1, fd, buf, 11);
@@ -179,11 +179,11 @@ static void *thread_fn(LTP_ATTRIBUTE_UNUSED void *args)
 	const char *const cmd_make_clean[] = {
 		"make", "-C", dirname, "-s", "clean", NULL};
 
-	tst_run_cmd(cmd_make, NULL, NULL, 0);
+	tst_cmd(cmd_make, NULL, NULL, 0);
 
 	run_targets(dirname, cfile, tid);
 
-	tst_run_cmd(cmd_make_clean, NULL, NULL, 0);
+	tst_cmd(cmd_make_clean, NULL, NULL, 0);
 
 	free(dirname);
 
diff --git a/tools/apicmds/ltpapicmd.c b/tools/apicmds/ltpapicmd.c
index c4fab3218..ac58c90cc 100644
--- a/tools/apicmds/ltpapicmd.c
+++ b/tools/apicmds/ltpapicmd.c
@@ -108,7 +108,7 @@ void tst_cat_file(const char *filename)
 {
 	const char *cmd[] = {"cat", filename, NULL};
 
-	tst_run_cmd(NULL, cmd, NULL, NULL, 0);
+	tst_cmd(NULL, cmd, NULL, NULL, 0);
 }
 
 void apicmd_brk(int argc, char *argv[])
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v2 2/5] lib/tst_cmd_*(): Turn int pass_exit_val into enum
  2020-03-30 12:43 [LTP] [PATCH v2 0/5] C API: .needs_cmds and SAFE_CMD() Petr Vorel
  2020-03-30 12:43 ` [LTP] [PATCH v2 1/5] lib: Rename tst_run_cmd*() to tst_cmd*() Petr Vorel
@ 2020-03-30 12:43 ` Petr Vorel
  2020-03-30 12:43 ` [LTP] [PATCH v2 3/5] lib/tst_cmd_*(): Search for program in $PATH Petr Vorel
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Petr Vorel @ 2020-03-30 12:43 UTC (permalink / raw)
  To: ltp

This is a preparation for next commit.
Now uses the only flag TST_CMD_PASS_RETVAL.

Reviewed-by: Li Wang <liwang@redhat.com>
Reviewed-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 doc/test-writing-guidelines.txt               | 12 +++----
 include/tst_cmd.h                             | 36 ++++++++++---------
 lib/tst_cmd.c                                 | 12 +++----
 lib/tst_kernel.c                              |  3 +-
 lib/tst_mkfs.c                                |  2 +-
 lib/tst_module.c                              |  3 +-
 testcases/kernel/input/input_helper.c         |  4 +--
 testcases/kernel/syscalls/acct/acct02.c       |  2 +-
 testcases/kernel/syscalls/add_key/add_key05.c |  4 +--
 .../copy_file_range/copy_file_range02.c       |  2 +-
 .../kernel/syscalls/quotactl/quotactl01.c     |  2 +-
 .../kernel/syscalls/quotactl/quotactl06.c     |  2 +-
 .../syscalls/setpriority/setpriority01.c      |  4 +--
 testcases/network/netstress/netstress.c       |  2 +-
 14 files changed, 48 insertions(+), 42 deletions(-)

diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index 3956e2c4c..e48168dfb 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -1263,20 +1263,20 @@ different once the call returns and should be used only for rough estimates.
 int tst_cmd(const char *const argv[],
 	        const char *stdout_path,
 	        const char *stderr_path,
-	        int pass_exit_val);
+			enum tst_cmd_flags flags);
 -------------------------------------------------------------------------------
 
-'tst_cmd' is a wrapper for 'vfork() + execvp()' which provides a way
+'tst_cmd()' is a wrapper for 'vfork() + execvp()' which provides a way
 to execute an external program.
 
 'argv[]' is a 'NULL' terminated array of strings starting with the program name
 which is followed by optional arguments.
 
-A non-zero 'pass_exit_val' makes 'tst_cmd' return the program exit code to
-the caller. A zero for 'pass_exit_val' makes 'tst_cmd' exit the tests
-on failure.
+'TST_CMD_PASS_RETVAL' enum 'tst_cmd_flags' makes 'tst_cmd()'
+return the program exit code to the caller, otherwise 'tst_cmd()' exit the
+tests on failure.
 
-In case that 'execvp()' has failed and the 'pass_exit_val' flag was set, the
+In case that 'execvp()' has failed and the enum 'TST_CMD_PASS_RETVAL' flag was set, the
 return value is '255' if 'execvp()' failed with 'ENOENT' and '254' otherwise.
 
 'stdout_path' and 'stderr_path' determine where to redirect the program
diff --git a/include/tst_cmd.h b/include/tst_cmd.h
index b8b86eb28..bba530e50 100644
--- a/include/tst_cmd.h
+++ b/include/tst_cmd.h
@@ -5,6 +5,14 @@
 #ifndef TST_CMD_H__
 #define TST_CMD_H__
 
+enum tst_cmd_flags {
+	/*
+	 * return the program exit code, otherwise it will call cleanup_fn() if the
+	 * program exit code is not zero.
+	 */
+	TST_CMD_PASS_RETVAL = 1,
+};
+
 /*
  * vfork() + execvp() specified program.
  * @argv: a list of two (at least program name + NULL) or more pointers that
@@ -14,68 +22,64 @@
  * redirection is not needed.
  * @stderr_fd: file descriptor where to redirect stderr. Set -1 if
  * redirection is not needed.
- * @pass_exit_val: if it's non-zero, this function will return the program
- * exit code, otherwise it will call cleanup_fn() if the program
- * exit code is not zero.
+ * @flags: enum tst_cmd_flags
  */
 int tst_cmd_fds_(void (cleanup_fn)(void),
 			const char *const argv[],
 			int stdout_fd,
 			int stderr_fd,
-			int pass_exit_val);
+			enum tst_cmd_flags flags);
 
 /* Executes tst_cmd_fds() and redirects its output to a file
  * @stdout_path: path where to redirect stdout. Set NULL if redirection is
  * not needed.
  * @stderr_path: path where to redirect stderr. Set NULL if redirection is
  * not needed.
- * @pass_exit_val: if it's non-zero, this function will return the program
- * exit code, otherwise it will call cleanup_fn() if the program
- * exit code is not zero.
+ * @flags: enum tst_cmd_flags
  */
 int tst_cmd_(void (cleanup_fn)(void),
 		const char *const argv[],
 		const char *stdout_path,
 		const char *stderr_path,
-		int pass_exit_val);
+		enum tst_cmd_flags flags);
 
 #ifdef TST_TEST_H__
 static inline int tst_cmd_fds(const char *const argv[],
 				  int stdout_fd,
 				  int stderr_fd,
-				  int pass_exit_val)
+				  enum tst_cmd_flags flags)
 {
 	return tst_cmd_fds_(NULL, argv,
-	                        stdout_fd, stderr_fd, pass_exit_val);
+	                        stdout_fd, stderr_fd, flags);
 }
 
 static inline int tst_cmd(const char *const argv[],
 			      const char *stdout_path,
 			      const char *stderr_path,
-			      int pass_exit_val)
+			      enum tst_cmd_flags flags)
 {
 	return tst_cmd_(NULL, argv,
-	                    stdout_path, stderr_path, pass_exit_val);
+	                    stdout_path, stderr_path, flags);
 }
 #else
 static inline int tst_cmd_fds(void (cleanup_fn)(void),
 				  const char *const argv[],
 				  int stdout_fd,
 				  int stderr_fd,
-				  int pass_exit_val)
+				  enum tst_cmd_flags flags)
 {
 	return tst_cmd_fds_(cleanup_fn, argv,
-	                        stdout_fd, stderr_fd, pass_exit_val);
+	                        stdout_fd, stderr_fd, flags);
 }
 
 static inline int tst_cmd(void (cleanup_fn)(void),
 			      const char *const argv[],
 			      const char *stdout_path,
 			      const char *stderr_path,
-			      int pass_exit_val)
+			      enum tst_cmd_flags flags)
 {
 	return tst_cmd_(cleanup_fn, argv,
-	                    stdout_path, stderr_path, pass_exit_val);
+	                    stdout_path, stderr_path, flags);
 }
 #endif
 
diff --git a/lib/tst_cmd.c b/lib/tst_cmd.c
index 1964ff784..012c2a32b 100644
--- a/lib/tst_cmd.c
+++ b/lib/tst_cmd.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved.
+ * Copyright (c) 2020 Petr Vorel <pvorel@suse.cz>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -16,7 +17,6 @@
  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
  * Author: Alexey Kodanev <alexey.kodanev@oracle.com>
- *
  */
 
 #include <errno.h>
@@ -27,6 +27,7 @@
 #include <unistd.h>
 #include <signal.h>
 #include "test.h"
+#include "tst_cmd.h"
 
 #define OPEN_MODE	(S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
 #define OPEN_FLAGS	(O_WRONLY | O_APPEND | O_CREAT)
@@ -35,7 +36,7 @@ int tst_cmd_fds_(void (cleanup_fn)(void),
 		const char *const argv[],
 		int stdout_fd,
 		int stderr_fd,
-		int pass_exit_val)
+		enum tst_cmd_flags flags)
 {
 	int rc;
 
@@ -97,7 +98,7 @@ int tst_cmd_fds_(void (cleanup_fn)(void),
 
 	rc = WEXITSTATUS(ret);
 
-	if ((!pass_exit_val) && rc) {
+	if (!(flags & TST_CMD_PASS_RETVAL) && rc) {
 		tst_brkm(TBROK, cleanup_fn,
 			 "'%s' exited with a non-zero code %d at %s:%d",
 			 argv[0], rc, __FILE__, __LINE__);
@@ -111,7 +112,7 @@ int tst_cmd_(void (cleanup_fn)(void),
 		const char *const argv[],
 		const char *stdout_path,
 		const char *stderr_path,
-		int pass_exit_val)
+		enum tst_cmd_flags flags)
 {
 	int stdout_fd = -1;
 	int stderr_fd = -1;
@@ -137,8 +138,7 @@ int tst_cmd_(void (cleanup_fn)(void),
 				stderr_path, __FILE__, __LINE__);
 	}
 
-	rc = tst_cmd_fds(cleanup_fn, argv, stdout_fd, stderr_fd,
-			     pass_exit_val);
+	rc = tst_cmd_fds(cleanup_fn, argv, stdout_fd, stderr_fd, flags);
 
 	if ((stdout_fd != -1) && (close(stdout_fd) == -1))
 		tst_resm(TWARN | TERRNO,
diff --git a/lib/tst_kernel.c b/lib/tst_kernel.c
index 210675b15..57fa4b2be 100644
--- a/lib/tst_kernel.c
+++ b/lib/tst_kernel.c
@@ -85,7 +85,8 @@ int tst_check_driver(const char *name)
 {
 #ifndef __ANDROID__
 	const char * const argv[] = { "modprobe", "-n", name, NULL };
-	int res = tst_cmd_(NULL, argv, "/dev/null", "/dev/null", 1);
+	int res = tst_cmd_(NULL, argv, "/dev/null", "/dev/null",
+			       TST_CMD_PASS_RETVAL);
 
 	/* 255 - it looks like modprobe not available */
 	return (res == 255) ? 0 : res;
diff --git a/lib/tst_mkfs.c b/lib/tst_mkfs.c
index 9cdd35472..b71ce4155 100644
--- a/lib/tst_mkfs.c
+++ b/lib/tst_mkfs.c
@@ -88,7 +88,7 @@ void tst_mkfs_(const char *file, const int lineno, void (cleanup_fn)(void),
 
 	tst_resm(TINFO, "Formatting %s with %s opts='%s' extra opts='%s'",
 	         dev, fs_type, fs_opts_str, extra_opts_str);
-	ret = tst_cmd(cleanup_fn, argv, "/dev/null", NULL, 1);
+	ret = tst_cmd(cleanup_fn, argv, "/dev/null", NULL, TST_CMD_PASS_RETVAL);
 
 	switch (ret) {
 	case 0:
diff --git a/lib/tst_module.c b/lib/tst_module.c
index a9ce90e8a..eda61872f 100644
--- a/lib/tst_module.c
+++ b/lib/tst_module.c
@@ -109,7 +109,8 @@ void tst_module_unload(void (cleanup_fn)(void), const char *mod_name)
 
 	rc = 1;
 	for (i = 0; i < 50; i++) {
-		rc = tst_cmd(NULL, argv, "/dev/null", "/dev/null", 1);
+		rc = tst_cmd(NULL, argv, "/dev/null", "/dev/null",
+				 TST_CMD_PASS_RETVAL);
 		if (!rc)
 			break;
 
diff --git a/testcases/kernel/input/input_helper.c b/testcases/kernel/input/input_helper.c
index bd9c715ed..a014861da 100644
--- a/testcases/kernel/input/input_helper.c
+++ b/testcases/kernel/input/input_helper.c
@@ -92,7 +92,7 @@ static int try_load_uinput(void)
 
 	tst_resm(TINFO, "Trying to load uinput kernel module");
 
-	ret = tst_cmd(NULL, argv, NULL, NULL, 1);
+	ret = tst_cmd(NULL, argv, NULL, NULL, TST_CMD_PASS_RETVAL);
 	if (ret) {
 		tst_resm(TINFO, "Failed to load the uinput module");
 		return 0;
@@ -108,7 +108,7 @@ static void unload_uinput(void)
 
 	tst_resm(TINFO, "Unloading uinput kernel module");
 
-	ret = tst_cmd(NULL, argv, NULL, NULL, 1);
+	ret = tst_cmd(NULL, argv, NULL, NULL, TST_CMD_PASS_RETVAL);
 	if (ret)
 		tst_resm(TWARN, "Failed to unload uinput module");
 }
diff --git a/testcases/kernel/syscalls/acct/acct02.c b/testcases/kernel/syscalls/acct/acct02.c
index 22303dc3f..d6b16b8c1 100644
--- a/testcases/kernel/syscalls/acct/acct02.c
+++ b/testcases/kernel/syscalls/acct/acct02.c
@@ -67,7 +67,7 @@ static void run_command(void)
 {
 	const char *const cmd[] = {COMMAND, NULL};
 
-	rc = tst_cmd(cmd, NULL, NULL, 1) << 8;
+	rc = tst_cmd(cmd, NULL, NULL, TST_CMD_PASS_RETVAL) << 8;
 }
 
 static int verify_acct(void *acc, int elap_time)
diff --git a/testcases/kernel/syscalls/add_key/add_key05.c b/testcases/kernel/syscalls/add_key/add_key05.c
index 191889a58..aa2b9cb2f 100644
--- a/testcases/kernel/syscalls/add_key/add_key05.c
+++ b/testcases/kernel/syscalls/add_key/add_key05.c
@@ -38,7 +38,7 @@ static void add_user(void)
 	const char *const cmd_useradd[] = {"useradd", username, NULL};
 	int rc;
 
-	switch ((rc = tst_cmd(cmd_useradd, NULL, NULL, 1))) {
+	switch ((rc = tst_cmd(cmd_useradd, NULL, NULL, TST_CMD_PASS_RETVAL))) {
 	case 0:
 		user_added = 1;
 		ltpuser = SAFE_GETPWNAM(username);
@@ -56,7 +56,7 @@ static void clean_user(void)
 
 	const char *const cmd_userdel[] = {"userdel", "-r", username, NULL};
 
-	if (tst_cmd(cmd_userdel, NULL, NULL, 1))
+	if (tst_cmd(cmd_userdel, NULL, NULL, TST_CMD_PASS_RETVAL))
 		tst_res(TWARN | TERRNO, "'userdel -r %s' failed", username);
 	else
 		user_added = 0;
diff --git a/testcases/kernel/syscalls/copy_file_range/copy_file_range02.c b/testcases/kernel/syscalls/copy_file_range/copy_file_range02.c
index 52a703b2b..fa679c4d3 100644
--- a/testcases/kernel/syscalls/copy_file_range/copy_file_range02.c
+++ b/testcases/kernel/syscalls/copy_file_range/copy_file_range02.c
@@ -87,7 +87,7 @@ static int run_command(char *command, char *option, char *file)
 	const char *const cmd[] = {command, option, file, NULL};
 	int ret;
 
-	ret = tst_cmd(cmd, NULL, NULL, 1);
+	ret = tst_cmd(cmd, NULL, NULL, TST_CMD_PASS_RETVAL);
 	switch (ret) {
 	case 0:
 	return 0;
diff --git a/testcases/kernel/syscalls/quotactl/quotactl01.c b/testcases/kernel/syscalls/quotactl/quotactl01.c
index d1c4657b3..6f0b60ffc 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl01.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl01.c
@@ -164,7 +164,7 @@ static void setup(void)
 	const char *const cmd[] = {"quotacheck", "-ugF", "vfsv0", MNTPOINT, NULL};
 	int ret;
 
-	ret = tst_cmd(cmd, NULL, NULL, 1);
+	ret = tst_cmd(cmd, NULL, NULL, TST_CMD_PASS_RETVAL);
 	switch (ret) {
 	case 0:
 		break;
diff --git a/testcases/kernel/syscalls/quotactl/quotactl06.c b/testcases/kernel/syscalls/quotactl/quotactl06.c
index b5d59b706..773114dfd 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl06.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl06.c
@@ -149,7 +149,7 @@ static void setup(void)
 	int ret;
 	unsigned int i;
 
-	ret = tst_cmd(cmd, NULL, NULL, 1);
+	ret = tst_cmd(cmd, NULL, NULL, TST_CMD_PASS_RETVAL);
 	switch (ret) {
 	case 0:
 		break;
diff --git a/testcases/kernel/syscalls/setpriority/setpriority01.c b/testcases/kernel/syscalls/setpriority/setpriority01.c
index 70c015f18..22fbe1ae5 100644
--- a/testcases/kernel/syscalls/setpriority/setpriority01.c
+++ b/testcases/kernel/syscalls/setpriority/setpriority01.c
@@ -112,7 +112,7 @@ static void setup(void)
 	struct passwd *ltpuser;
 	int rc;
 
-	switch ((rc = tst_cmd(cmd_useradd, NULL, NULL, 1))) {
+	switch ((rc = tst_cmd(cmd_useradd, NULL, NULL, TST_CMD_PASS_RETVAL))) {
 	case 0:
 		user_added = 1;
 		ltpuser = SAFE_GETPWNAM(username);
@@ -133,7 +133,7 @@ static void cleanup(void)
 
 	const char *const cmd_userdel[] = {"userdel", "-r", username, NULL};
 
-	if (tst_cmd(cmd_userdel, NULL, NULL, 1))
+	if (tst_cmd(cmd_userdel, NULL, NULL, TST_CMD_PASS_RETVAL))
 		tst_res(TWARN | TERRNO, "'userdel -r %s' failed", username);
 }
 
diff --git a/testcases/network/netstress/netstress.c b/testcases/network/netstress/netstress.c
index fca476198..6797be018 100644
--- a/testcases/network/netstress/netstress.c
+++ b/testcases/network/netstress/netstress.c
@@ -967,7 +967,7 @@ static void setup(void)
 		/* dccp* modules can be blacklisted, load them manually */
 		const char * const argv[] = {"modprobe", "dccp_ipv6", NULL};
 
-		if (tst_cmd(argv, NULL, NULL, 1))
+		if (tst_cmd(argv, NULL, NULL, TST_CMD_PASS_RETVAL))
 			tst_brk(TCONF, "Failed to load dccp_ipv6 module");
 
 		tst_res(TINFO, "DCCP %s", (client_mode) ? "client" : "server");
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v2 3/5] lib/tst_cmd_*(): Search for program in $PATH
  2020-03-30 12:43 [LTP] [PATCH v2 0/5] C API: .needs_cmds and SAFE_CMD() Petr Vorel
  2020-03-30 12:43 ` [LTP] [PATCH v2 1/5] lib: Rename tst_run_cmd*() to tst_cmd*() Petr Vorel
  2020-03-30 12:43 ` [LTP] [PATCH v2 2/5] lib/tst_cmd_*(): Turn int pass_exit_val into enum Petr Vorel
@ 2020-03-30 12:43 ` Petr Vorel
  2020-03-30 12:43 ` [LTP] [PATCH v2 4/5] lib: Implement SAFE_CMD() macro (new API only) Petr Vorel
  2020-03-30 12:43 ` [LTP] [PATCH v2 5/5] Use SAFE_CMD() Petr Vorel
  4 siblings, 0 replies; 14+ messages in thread
From: Petr Vorel @ 2020-03-30 12:43 UTC (permalink / raw)
  To: ltp

before calling execvp(). This is slightly safer than checking errno ENOENT.
TST_CMD_TCONF_ON_MISSING flag cause TCONF when program not found.

Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Reviewed-by: Li Wang <liwang@redhat.com>
Reviewed-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 doc/test-writing-guidelines.txt |  3 ++-
 include/tst_cmd.h               |  3 +++
 lib/tst_cmd.c                   | 16 ++++++++++++----
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index e48168dfb..7069d3c8f 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -1274,7 +1274,8 @@ which is followed by optional arguments.
 
 'TST_CMD_PASS_RETVAL' enum 'tst_cmd_flags' makes 'tst_cmd()'
 return the program exit code to the caller, otherwise 'tst_cmd()' exit the
-tests on failure.
+tests on failure. 'TST_CMD_TCONF_ON_MISSING' check for program in '$PATH' and exit
+with 'TCONF' if not found.
 
 In case that 'execvp()' has failed and the enum 'TST_CMD_PASS_RETVAL' flag was set, the
 return value is '255' if 'execvp()' failed with 'ENOENT' and '254' otherwise.
diff --git a/include/tst_cmd.h b/include/tst_cmd.h
index bba530e50..1f39f690f 100644
--- a/include/tst_cmd.h
+++ b/include/tst_cmd.h
@@ -11,6 +11,9 @@ enum tst_cmd_flags {
 	 * program exit code is not zero.
 	 */
 	TST_CMD_PASS_RETVAL = 1,
+
+	/* exit with TCONF if program is not in path */
+	TST_CMD_TCONF_ON_MISSING = 2,
 };
 
 /*
diff --git a/lib/tst_cmd.c b/lib/tst_cmd.c
index 012c2a32b..ba79806ce 100644
--- a/lib/tst_cmd.c
+++ b/lib/tst_cmd.c
@@ -56,6 +56,17 @@ int tst_cmd_fds_(void (cleanup_fn)(void),
 	 */
 	void *old_handler = signal(SIGCHLD, SIG_DFL);
 
+	const char *cmd;
+	char path[PATH_MAX];
+
+	if (tst_get_path(argv[0], path, sizeof(path))) {
+		if (flags & TST_CMD_TCONF_ON_MISSING)
+			tst_brkm(TCONF, "Couldn't find '%s' in $PATH at %s:%d", argv[0],
+				 __FILE__, __LINE__);
+		else
+			_exit(255);
+	}
+
 	pid_t pid = vfork();
 	if (pid == -1) {
 		tst_brkm(TBROK | TERRNO, cleanup_fn, "vfork failed at %s:%d",
@@ -74,10 +85,7 @@ int tst_cmd_fds_(void (cleanup_fn)(void),
 			dup2(stderr_fd, STDERR_FILENO);
 		}
 
-		if (execvp(argv[0], (char *const *)argv)) {
-			if (errno == ENOENT)
-				_exit(255);
-		}
+		execvp(argv[0], (char *const *)argv);
 		_exit(254);
 	}
 
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v2 4/5] lib: Implement SAFE_CMD() macro (new API only)
  2020-03-30 12:43 [LTP] [PATCH v2 0/5] C API: .needs_cmds and SAFE_CMD() Petr Vorel
                   ` (2 preceding siblings ...)
  2020-03-30 12:43 ` [LTP] [PATCH v2 3/5] lib/tst_cmd_*(): Search for program in $PATH Petr Vorel
@ 2020-03-30 12:43 ` Petr Vorel
  2020-03-30 13:01   ` Li Wang
  2020-03-30 12:43 ` [LTP] [PATCH v2 5/5] Use SAFE_CMD() Petr Vorel
  4 siblings, 1 reply; 14+ messages in thread
From: Petr Vorel @ 2020-03-30 12:43 UTC (permalink / raw)
  To: ltp

Reviewed-by: Li Wang <liwang@redhat.com>
Reviewed-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 doc/test-writing-guidelines.txt |  3 +++
 include/tst_safe_macros.h       | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index 7069d3c8f..6f1eee490 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -1283,6 +1283,9 @@ return value is '255' if 'execvp()' failed with 'ENOENT' and '254' otherwise.
 'stdout_path' and 'stderr_path' determine where to redirect the program
 stdout and stderr I/O streams.
 
+The 'SAFE_CMD()' macro can be used automatic handling non zero exits (exits
+with 'TBROK') or 'ENOENT' (exits with 'TCONF').
+
 .Example
 [source,c]
 -------------------------------------------------------------------------------
diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index d95d26219..38eb67d1d 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -21,6 +21,7 @@
 #include <grp.h>
 
 #include "safe_macros_fn.h"
+#include "tst_cmd.h"
 
 #define SAFE_BASENAME(path) \
 	safe_basename(__FILE__, __LINE__, NULL, (path))
@@ -534,4 +535,21 @@ int safe_personality(const char *filename, unsigned int lineno,
 void safe_unshare(const char *file, const int lineno, int flags);
 #define SAFE_UNSHARE(flags) safe_unshare(__FILE__, __LINE__, (flags))
 
+void safe_cmd(const char *file, const int lineno, const char *const argv[],
+				  const char *stdout_path, const char *stderr_path)
+{
+	int rval;
+
+	switch ((rval = tst_run_cmd(argv, stdout_path, stderr_path,
+				    TST_RUN_CMD_PASS_EXIT_VAL |
+				    TST_RUN_CMD_CHECK_CMD))) {
+	case 0:
+		break;
+	default:
+		tst_brk(TBROK, "%s:%d: %s failed (%d)", file, lineno, argv[0], rval);
+	}
+}
+#define SAFE_CMD(argv, stdout_path, stderr_path) \
+	safe_cmd(__FILE__, __LINE__, (argv), (stdout_path), (stderr_path))
+
 #endif /* SAFE_MACROS_H__ */
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v2 5/5] Use SAFE_CMD()
  2020-03-30 12:43 [LTP] [PATCH v2 0/5] C API: .needs_cmds and SAFE_CMD() Petr Vorel
                   ` (3 preceding siblings ...)
  2020-03-30 12:43 ` [LTP] [PATCH v2 4/5] lib: Implement SAFE_CMD() macro (new API only) Petr Vorel
@ 2020-03-30 12:43 ` Petr Vorel
  2020-03-30 13:23   ` Li Wang
  4 siblings, 1 reply; 14+ messages in thread
From: Petr Vorel @ 2020-03-30 12:43 UTC (permalink / raw)
  To: ltp

Reviewed-by: Li Wang <liwang@redhat.com>
Reviewed-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 doc/test-writing-guidelines.txt                 |  4 ++--
 include/tst_safe_macros.h                       |  5 ++---
 testcases/kernel/syscalls/add_key/add_key05.c   | 14 ++++----------
 testcases/kernel/syscalls/quotactl/quotactl01.c | 11 ++---------
 testcases/kernel/syscalls/quotactl/quotactl06.c |  9 +--------
 5 files changed, 11 insertions(+), 32 deletions(-)

diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index 6f1eee490..75c2e517a 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -1283,8 +1283,8 @@ return value is '255' if 'execvp()' failed with 'ENOENT' and '254' otherwise.
 'stdout_path' and 'stderr_path' determine where to redirect the program
 stdout and stderr I/O streams.
 
-The 'SAFE_CMD()' macro can be used automatic handling non zero exits (exits
-with 'TBROK') or 'ENOENT' (exits with 'TCONF').
+The 'SAFE_CMD()' macro can be used automatic handling non-zero exits (exits
+with 'TBROK') and 'ENOENT' (exits with 'TCONF').
 
 .Example
 [source,c]
diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index 38eb67d1d..bcd4b9c9e 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -540,9 +540,8 @@ void safe_cmd(const char *file, const int lineno, const char *const argv[],
 {
 	int rval;
 
-	switch ((rval = tst_run_cmd(argv, stdout_path, stderr_path,
-				    TST_RUN_CMD_PASS_EXIT_VAL |
-				    TST_RUN_CMD_CHECK_CMD))) {
+	switch ((rval = tst_cmd(argv, stdout_path, stderr_path, TST_CMD_PASS_RETVAL
+							| TST_CMD_CHECK_CMD))) {
 	case 0:
 		break;
 	default:
diff --git a/testcases/kernel/syscalls/add_key/add_key05.c b/testcases/kernel/syscalls/add_key/add_key05.c
index aa2b9cb2f..f64c359bb 100644
--- a/testcases/kernel/syscalls/add_key/add_key05.c
+++ b/testcases/kernel/syscalls/add_key/add_key05.c
@@ -36,16 +36,10 @@ static void add_user(void)
 		return;
 
 	const char *const cmd_useradd[] = {"useradd", username, NULL};
-	int rc;
-
-	switch ((rc = tst_cmd(cmd_useradd, NULL, NULL, TST_CMD_PASS_RETVAL))) {
-	case 0:
-		user_added = 1;
-		ltpuser = SAFE_GETPWNAM(username);
-		break;
-	default:
-		tst_brk(TBROK, "useradd failed (%d)", rc);
-	}
+
+	SAFE_CMD(cmd_useradd, NULL, NULL);
+	user_added = 1;
+	ltpuser = SAFE_GETPWNAM(username);
 	sprintf(fmt, "%5u: %%*5d %%*d/%%*d %%d/%%d %%d/%%d", ltpuser->pw_uid);
 }
 
diff --git a/testcases/kernel/syscalls/quotactl/quotactl01.c b/testcases/kernel/syscalls/quotactl/quotactl01.c
index 6f0b60ffc..e1ec22529 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl01.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl01.c
@@ -162,15 +162,8 @@ static struct tcase {
 static void setup(void)
 {
 	const char *const cmd[] = {"quotacheck", "-ugF", "vfsv0", MNTPOINT, NULL};
-	int ret;
-
-	ret = tst_cmd(cmd, NULL, NULL, TST_CMD_PASS_RETVAL);
-	switch (ret) {
-	case 0:
-		break;
-	default:
-		tst_brk(TBROK, "quotacheck exited with %i", ret);
-	}
+
+	SAFE_CMD(cmd, NULL, NULL);
 
 	test_id = geteuid();
 	if (access(USRPATH, F_OK) == -1)
diff --git a/testcases/kernel/syscalls/quotactl/quotactl06.c b/testcases/kernel/syscalls/quotactl/quotactl06.c
index 773114dfd..0a36c97a4 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl06.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl06.c
@@ -146,16 +146,9 @@ static void verify_quotactl(unsigned int n)
 static void setup(void)
 {
 	const char *const cmd[] = {"quotacheck", "-uF", "vfsv0", MNTPOINT, NULL};
-	int ret;
 	unsigned int i;
 
-	ret = tst_cmd(cmd, NULL, NULL, TST_CMD_PASS_RETVAL);
-	switch (ret) {
-	case 0:
-		break;
-	default:
-		tst_brk(TBROK, "quotacheck exited with %i", ret);
-	}
+	SAFE_CMD(cmd, NULL, NULL);
 
 	if (access(USRPATH, F_OK) == -1)
 		tst_brk(TFAIL | TERRNO, "user quotafile didn't exist");
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v2 4/5] lib: Implement SAFE_CMD() macro (new API only)
  2020-03-30 12:43 ` [LTP] [PATCH v2 4/5] lib: Implement SAFE_CMD() macro (new API only) Petr Vorel
@ 2020-03-30 13:01   ` Li Wang
  2020-03-30 13:07     ` Li Wang
  2020-03-30 18:48     ` Petr Vorel
  0 siblings, 2 replies; 14+ messages in thread
From: Li Wang @ 2020-03-30 13:01 UTC (permalink / raw)
  To: ltp

On Mon, Mar 30, 2020 at 8:43 PM Petr Vorel <pvorel@suse.cz> wrote:

> Reviewed-by: Li Wang <liwang@redhat.com>
> Reviewed-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  doc/test-writing-guidelines.txt |  3 +++
>  include/tst_safe_macros.h       | 18 ++++++++++++++++++
>  2 files changed, 21 insertions(+)
>
> diff --git a/doc/test-writing-guidelines.txt
> b/doc/test-writing-guidelines.txt
> index 7069d3c8f..6f1eee490 100644
> --- a/doc/test-writing-guidelines.txt
> +++ b/doc/test-writing-guidelines.txt
> @@ -1283,6 +1283,9 @@ return value is '255' if 'execvp()' failed with
> 'ENOENT' and '254' otherwise.
>  'stdout_path' and 'stderr_path' determine where to redirect the program
>  stdout and stderr I/O streams.
>
> +The 'SAFE_CMD()' macro can be used automatic handling non zero exits
> (exits
> +with 'TBROK') or 'ENOENT' (exits with 'TCONF').
> +
>  .Example
>  [source,c]
>
>  -------------------------------------------------------------------------------
> diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
> index d95d26219..38eb67d1d 100644
> --- a/include/tst_safe_macros.h
> +++ b/include/tst_safe_macros.h
> @@ -21,6 +21,7 @@
>  #include <grp.h>
>
>  #include "safe_macros_fn.h"
> +#include "tst_cmd.h"
>
>  #define SAFE_BASENAME(path) \
>         safe_basename(__FILE__, __LINE__, NULL, (path))
> @@ -534,4 +535,21 @@ int safe_personality(const char *filename, unsigned
> int lineno,
>  void safe_unshare(const char *file, const int lineno, int flags);
>  #define SAFE_UNSHARE(flags) safe_unshare(__FILE__, __LINE__, (flags))
>
> +void safe_cmd(const char *file, const int lineno, const char *const
> argv[],
> +                                 const char *stdout_path, const char
> *stderr_path)
> +{
> +       int rval;
> +
> +       switch ((rval = tst_run_cmd(argv, stdout_path, stderr_path,
> +                                   TST_RUN_CMD_PASS_EXIT_VAL |
> +                                   TST_RUN_CMD_CHECK_CMD))) {
>

This should be TST_CMD_TCONF_ON_MISSING ^.

I'd help to build&run the whole patches tomorrow, anything wrong if I can
find will reply to you then.

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200330/d9c5a717/attachment.htm>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v2 4/5] lib: Implement SAFE_CMD() macro (new API only)
  2020-03-30 13:01   ` Li Wang
@ 2020-03-30 13:07     ` Li Wang
  2020-03-30 18:48     ` Petr Vorel
  1 sibling, 0 replies; 14+ messages in thread
From: Li Wang @ 2020-03-30 13:07 UTC (permalink / raw)
  To: ltp

On Mon, Mar 30, 2020 at 9:01 PM Li Wang <liwang@redhat.com> wrote:

>
>
> On Mon, Mar 30, 2020 at 8:43 PM Petr Vorel <pvorel@suse.cz> wrote:
>
>> Reviewed-by: Li Wang <liwang@redhat.com>
>> Reviewed-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
>> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
>> Signed-off-by: Petr Vorel <pvorel@suse.cz>
>> ---
>>  doc/test-writing-guidelines.txt |  3 +++
>>  include/tst_safe_macros.h       | 18 ++++++++++++++++++
>>  2 files changed, 21 insertions(+)
>>
>> diff --git a/doc/test-writing-guidelines.txt
>> b/doc/test-writing-guidelines.txt
>> index 7069d3c8f..6f1eee490 100644
>> --- a/doc/test-writing-guidelines.txt
>> +++ b/doc/test-writing-guidelines.txt
>> @@ -1283,6 +1283,9 @@ return value is '255' if 'execvp()' failed with
>> 'ENOENT' and '254' otherwise.
>>  'stdout_path' and 'stderr_path' determine where to redirect the program
>>  stdout and stderr I/O streams.
>>
>> +The 'SAFE_CMD()' macro can be used automatic handling non zero exits
>> (exits
>> +with 'TBROK') or 'ENOENT' (exits with 'TCONF').
>> +
>>  .Example
>>  [source,c]
>>
>>  -------------------------------------------------------------------------------
>> diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
>> index d95d26219..38eb67d1d 100644
>> --- a/include/tst_safe_macros.h
>> +++ b/include/tst_safe_macros.h
>> @@ -21,6 +21,7 @@
>>  #include <grp.h>
>>
>>  #include "safe_macros_fn.h"
>> +#include "tst_cmd.h"
>>
>>  #define SAFE_BASENAME(path) \
>>         safe_basename(__FILE__, __LINE__, NULL, (path))
>> @@ -534,4 +535,21 @@ int safe_personality(const char *filename, unsigned
>> int lineno,
>>  void safe_unshare(const char *file, const int lineno, int flags);
>>  #define SAFE_UNSHARE(flags) safe_unshare(__FILE__, __LINE__, (flags))
>>
>> +void safe_cmd(const char *file, const int lineno, const char *const
>> argv[],
>> +                                 const char *stdout_path, const char
>> *stderr_path)
>> +{
>> +       int rval;
>> +
>> +       switch ((rval = tst_run_cmd(argv, stdout_path, stderr_path,
>>
>
tst_cmd ^

> +                                   TST_RUN_CMD_PASS_EXIT_VAL |
>> +                                   TST_RUN_CMD_CHECK_CMD))) {
>>
>
> This should be TST_CMD_TCONF_ON_MISSING ^.
>
> I'd help to build&run the whole patches tomorrow, anything wrong if I can
> find will reply to you then.
>
> --
> Regards,
> Li Wang
>


-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200330/b7d3f24f/attachment-0001.htm>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v2 5/5] Use SAFE_CMD()
  2020-03-30 12:43 ` [LTP] [PATCH v2 5/5] Use SAFE_CMD() Petr Vorel
@ 2020-03-30 13:23   ` Li Wang
  2020-03-30 20:02     ` Petr Vorel
  0 siblings, 1 reply; 14+ messages in thread
From: Li Wang @ 2020-03-30 13:23 UTC (permalink / raw)
  To: ltp

On Mon, Mar 30, 2020 at 8:43 PM Petr Vorel <pvorel@suse.cz> wrote:

> Reviewed-by: Li Wang <liwang@redhat.com>
> Reviewed-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  doc/test-writing-guidelines.txt                 |  4 ++--
>  include/tst_safe_macros.h                       |  5 ++---
>  testcases/kernel/syscalls/add_key/add_key05.c   | 14 ++++----------
>  testcases/kernel/syscalls/quotactl/quotactl01.c | 11 ++---------
>  testcases/kernel/syscalls/quotactl/quotactl06.c |  9 +--------
>  5 files changed, 11 insertions(+), 32 deletions(-)
>
> diff --git a/doc/test-writing-guidelines.txt
> b/doc/test-writing-guidelines.txt
> index 6f1eee490..75c2e517a 100644
> --- a/doc/test-writing-guidelines.txt
> +++ b/doc/test-writing-guidelines.txt
> @@ -1283,8 +1283,8 @@ return value is '255' if 'execvp()' failed with
> 'ENOENT' and '254' otherwise.
>  'stdout_path' and 'stderr_path' determine where to redirect the program
>  stdout and stderr I/O streams.
>
> -The 'SAFE_CMD()' macro can be used automatic handling non zero exits
> (exits
> -with 'TBROK') or 'ENOENT' (exits with 'TCONF').
> +The 'SAFE_CMD()' macro can be used automatic handling non-zero exits
> (exits
> +with 'TBROK') and 'ENOENT' (exits with 'TCONF').
>
>  .Example
>  [source,c]
> diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
> index 38eb67d1d..bcd4b9c9e 100644
> --- a/include/tst_safe_macros.h
> +++ b/include/tst_safe_macros.h
> @@ -540,9 +540,8 @@ void safe_cmd(const char *file, const int lineno,
> const char *const argv[],
>  {
>         int rval;
>
> -       switch ((rval = tst_run_cmd(argv, stdout_path, stderr_path,
> -                                   TST_RUN_CMD_PASS_EXIT_VAL |
> -                                   TST_RUN_CMD_CHECK_CMD))) {
> +       switch ((rval = tst_cmd(argv, stdout_path, stderr_path,
> TST_CMD_PASS_RETVAL
> +                                                       |
> TST_CMD_CHECK_CMD))) {
>

Oh, you did the renaming in patch 5/5, but pity that the
TST_CMD_TCONF_ON_MISSING still not being used:). I guess this modification
should belong to patch4/5.

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200330/6433524c/attachment.htm>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v2 4/5] lib: Implement SAFE_CMD() macro (new API only)
  2020-03-30 13:01   ` Li Wang
  2020-03-30 13:07     ` Li Wang
@ 2020-03-30 18:48     ` Petr Vorel
  1 sibling, 0 replies; 14+ messages in thread
From: Petr Vorel @ 2020-03-30 18:48 UTC (permalink / raw)
  To: ltp

Hi Li,

> > +       switch ((rval = tst_run_cmd(argv, stdout_path, stderr_path,
> > +                                   TST_RUN_CMD_PASS_EXIT_VAL |
> > +                                   TST_RUN_CMD_CHECK_CMD))) {


> This should be TST_CMD_TCONF_ON_MISSING ^.

> I'd help to build&run the whole patches tomorrow, anything wrong if I can
> find will reply to you then.

Thanks for fixes. Here is following diff from v2 (addressing issues you found,
fixed tst_run_cmd() being replaced in later commit, fix doc formatting),
code available also on:
https://github.com/pevik/ltp/tree/needs_cmds.v2.fixes

I'm going to test each commit if it builds and wait for your ack tomorrow.

Kind regards,
Petr

diff --git doc/test-writing-guidelines.txt doc/test-writing-guidelines.txt
index 75c2e517a..895f6c99d 100644
--- doc/test-writing-guidelines.txt
+++ doc/test-writing-guidelines.txt
@@ -1263,7 +1263,7 @@ different once the call returns and should be used only for rough estimates.
 int tst_cmd(const char *const argv[],
 	        const char *stdout_path,
 	        const char *stderr_path,
-			enum tst_cmd_flags flags);
+	        enum tst_cmd_flags flags);
 -------------------------------------------------------------------------------
 
 'tst_cmd()' is a wrapper for 'vfork() + execvp()' which provides a way
diff --git include/tst_safe_macros.h include/tst_safe_macros.h
index d050c5990..295800c1b 100644
--- include/tst_safe_macros.h
+++ include/tst_safe_macros.h
@@ -543,8 +543,8 @@ void safe_cmd(const char *file, const int lineno, const char *const argv[],
 {
 	int rval;
 
-	switch ((rval = tst_cmd(argv, stdout_path, stderr_path, TST_CMD_PASS_RETVAL
-							| TST_CMD_CHECK_CMD))) {
+	switch ((rval = tst_cmd(argv, stdout_path, stderr_path,
+				TST_CMD_PASS_EXIT_VAL | TST_CMD_TCONF_ON_MISSING))) {
 	case 0:
 		break;
 	default:

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v2 5/5] Use SAFE_CMD()
  2020-03-30 13:23   ` Li Wang
@ 2020-03-30 20:02     ` Petr Vorel
  2020-03-30 20:29       ` Petr Vorel
  2020-03-31  3:59       ` Li Wang
  0 siblings, 2 replies; 14+ messages in thread
From: Petr Vorel @ 2020-03-30 20:02 UTC (permalink / raw)
  To: ltp

Hi Li,

> Oh, you did the renaming in patch 5/5, but pity that the
> TST_CMD_TCONF_ON_MISSING still not being used:). I guess this modification
> should belong to patch4/5.
Thanks for careful review. Yes, I found that as well + the other problem you
reported - tst_run_cmd() during one more check.

+ I needed to put back static inline for safe_cmd() (it was in previous version,
it's really needed). So there is latest version available on
https://github.com/pevik/ltp/tree/needs_cmds.v2.fixes

which passed some travis jobs (I'll check that tomorrow)
https://travis-ci.org/github/pevik/ltp/builds/668925599

Diff from v2 below.

IMHO now it should be ok, but I'm waiting for your or anybody else ack/review.

Kind regards,
Petr

diff --git doc/test-writing-guidelines.txt doc/test-writing-guidelines.txt
index 75c2e517a..895f6c99d 100644
--- doc/test-writing-guidelines.txt
+++ doc/test-writing-guidelines.txt
@@ -1263,7 +1263,7 @@ different once the call returns and should be used only for rough estimates.
 int tst_cmd(const char *const argv[],
 	        const char *stdout_path,
 	        const char *stderr_path,
-			enum tst_cmd_flags flags);
+	        enum tst_cmd_flags flags);
 -------------------------------------------------------------------------------
 
 'tst_cmd()' is a wrapper for 'vfork() + execvp()' which provides a way
diff --git include/tst_safe_macros.h include/tst_safe_macros.h
index d050c5990..8126179f4 100644
--- include/tst_safe_macros.h
+++ include/tst_safe_macros.h
@@ -538,13 +538,13 @@ void safe_unshare(const char *file, const int lineno, int flags);
 void safe_setns(const char *file, const int lineno, int fd, int nstype);
 #define SAFE_SETNS(fd, nstype) safe_setns(__FILE__, __LINE__, (fd), (nstype));
 
-void safe_cmd(const char *file, const int lineno, const char *const argv[],
+static inline void safe_cmd(const char *file, const int lineno, const char *const argv[],
 				  const char *stdout_path, const char *stderr_path)
 {
 	int rval;
 
-	switch ((rval = tst_cmd(argv, stdout_path, stderr_path, TST_CMD_PASS_RETVAL
-							| TST_CMD_CHECK_CMD))) {
+	switch ((rval = tst_cmd(argv, stdout_path, stderr_path,
+				TST_CMD_PASS_RETVAL | TST_CMD_TCONF_ON_MISSING))) {
 	case 0:
 		break;
 	default:

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v2 5/5] Use SAFE_CMD()
  2020-03-30 20:02     ` Petr Vorel
@ 2020-03-30 20:29       ` Petr Vorel
  2020-03-31  3:59       ` Li Wang
  1 sibling, 0 replies; 14+ messages in thread
From: Petr Vorel @ 2020-03-30 20:29 UTC (permalink / raw)
  To: ltp

Hi Li,

...
> + I needed to put back static inline for safe_cmd() (it was in previous version,
> it's really needed). So there is latest version available on
> https://github.com/pevik/ltp/tree/needs_cmds.v2.fixes

> which passed some travis jobs (I'll check that tomorrow)
> https://travis-ci.org/github/pevik/ltp/builds/668925599
Working. Just opensuse/tumbleweed fails, but that's due bug in the distro
(it also broke CI on master, I'll report it tomorrow).

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v2 5/5] Use SAFE_CMD()
  2020-03-30 20:02     ` Petr Vorel
  2020-03-30 20:29       ` Petr Vorel
@ 2020-03-31  3:59       ` Li Wang
  2020-03-31  5:03         ` Petr Vorel
  1 sibling, 1 reply; 14+ messages in thread
From: Li Wang @ 2020-03-31  3:59 UTC (permalink / raw)
  To: ltp

Hi Petr,

On Tue, Mar 31, 2020 at 4:03 AM Petr Vorel <pvorel@suse.cz> wrote:

+ I needed to put back static inline for safe_cmd() (it was in previous
> version,
> it's really needed). So there is latest version available on
> https://github.com/pevik/ltp/tree/needs_cmds.v2.fixes
>
> Diff from v2 below.
>

Awesome work! ACK for this(needs_cmds.v2.fixes + Diff).

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200331/53c49c96/attachment.htm>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v2 5/5] Use SAFE_CMD()
  2020-03-31  3:59       ` Li Wang
@ 2020-03-31  5:03         ` Petr Vorel
  0 siblings, 0 replies; 14+ messages in thread
From: Petr Vorel @ 2020-03-31  5:03 UTC (permalink / raw)
  To: ltp

Hi Li,

> Awesome work! ACK for this(needs_cmds.v2.fixes + Diff).
Thanks a lot for your extensive review!
Merged.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-03-31  5:03 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-30 12:43 [LTP] [PATCH v2 0/5] C API: .needs_cmds and SAFE_CMD() Petr Vorel
2020-03-30 12:43 ` [LTP] [PATCH v2 1/5] lib: Rename tst_run_cmd*() to tst_cmd*() Petr Vorel
2020-03-30 12:43 ` [LTP] [PATCH v2 2/5] lib/tst_cmd_*(): Turn int pass_exit_val into enum Petr Vorel
2020-03-30 12:43 ` [LTP] [PATCH v2 3/5] lib/tst_cmd_*(): Search for program in $PATH Petr Vorel
2020-03-30 12:43 ` [LTP] [PATCH v2 4/5] lib: Implement SAFE_CMD() macro (new API only) Petr Vorel
2020-03-30 13:01   ` Li Wang
2020-03-30 13:07     ` Li Wang
2020-03-30 18:48     ` Petr Vorel
2020-03-30 12:43 ` [LTP] [PATCH v2 5/5] Use SAFE_CMD() Petr Vorel
2020-03-30 13:23   ` Li Wang
2020-03-30 20:02     ` Petr Vorel
2020-03-30 20:29       ` Petr Vorel
2020-03-31  3:59       ` Li Wang
2020-03-31  5:03         ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.