public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
@ 2018-08-23  9:06 Xiao Yang
  2018-08-23  9:18 ` Xiao Yang
  2018-08-24 14:56 ` Cyril Hrubis
  0 siblings, 2 replies; 10+ messages in thread
From: Xiao Yang @ 2018-08-23  9:06 UTC (permalink / raw)
  To: ltp

From: xiao yang <yangx.jy@cn.fujitsu.com>

Before glibc v2.11, execvpe() was not introduced and resulted in
compiler error, so we replace execvpe() with execve() and update
test-writing-guidelines.txt.

Signed-off-by: xiao yang <yangx.jy@cn.fujitsu.com>
---
 doc/test-writing-guidelines.txt | 11 ++++++++---
 lib/newlib_tests/test_exec.c    | 11 ++++++++---
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index a169724..f62e16e 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -696,15 +696,20 @@ a non zero exit code.
 [source,c]
 -------------------------------------------------------------------------------
 /* test.c */
-#define _GNU_SOURCE
-#include <stdlib.h>
+#include <unistd.h>
 #include "tst_test.h"
 
+extern char **environ;
+
 static void do_test(void)
 {
 	char *const argv[] = {"test_exec_child", NULL};
+	char path[4096];
+
+	if (tst_get_path("test_exec_child", path, sizeof(path)))
+		tst_brk(TCONF, "Couldn't find test_exec_child in $PATH");
 
-	execvpe(argv[0], argv, environ);
+	execve(path, argv, environ);
 
 	tst_res(TBROK | TERRNO, "EXEC!");
 }
diff --git a/lib/newlib_tests/test_exec.c b/lib/newlib_tests/test_exec.c
index 8aef621..e70080e 100644
--- a/lib/newlib_tests/test_exec.c
+++ b/lib/newlib_tests/test_exec.c
@@ -24,15 +24,20 @@
  * $ PATH=$PATH:$PWD ./test_exec
  */
 
-#define _GNU_SOURCE
-#include <stdlib.h>
+#include <unistd.h>
 #include "tst_test.h"
 
+extern char **environ;
+
 static void do_test(void)
 {
 	char *const argv[] = {"test_exec_child", NULL};
+	char path[4096];
+
+	if (tst_get_path("test_exec_child", path, sizeof(path)))
+		tst_brk(TCONF, "Couldn't find test_exec_child in $PATH");
 
-	execvpe(argv[0], argv, environ);
+	execve(path, argv, environ);
 
 	tst_res(TBROK | TERRNO, "EXEC!");
 }
-- 
1.7.11.rc0




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

end of thread, other threads:[~2018-09-10 22:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-23  9:06 [LTP] [PATCH] newlib_tests/test_exec.c: Fix compiler error before glibc v2.11 Xiao Yang
2018-08-23  9:18 ` Xiao Yang
2018-08-24 14:56 ` Cyril Hrubis
2018-08-26 23:51   ` Xiao Yang
2018-08-27  0:05   ` [LTP] [PATCH v2] " Xiao Yang
2018-08-28 11:38     ` Jan Stancek
2018-08-28 23:54       ` Xiao Yang
2018-08-31 12:10     ` Petr Vorel
2018-09-04  6:37     ` Xiao Yang
2018-09-10 22:41     ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox