newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
PATCH 1/1 newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
From: xiao yang <[email protected]>
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.
--- doc/test-writing-guidelines.txt | 11 ++++++++--- lib/newlib_tests/test_exec.c | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-)
doc/test-writing-guidelines.txt +8 -3
@@ -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!"); }
lib/newlib_tests/test_exec.c +8 -3
@@ -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!" ); }
Signature · 1 line
1.7.11.rc0
PATCH 1/1 newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
Quoted 7 lines · Xiao Yang
From: xiao yang <[email protected]>
Before glibc v2.11,
execvpe()was not introduced and resulted in compiler error, so we replaceexecvpe()withexecve()and update test-writing-guidelines.txt.Signed-off-by xiao yang <[email protected]>
Hi,
Sorry for the wrong signature.
The correct one:
Thanks,
Xiao Yang
Quoted 61 lines
--- doc/test-writing-guidelines.txt | 11 ++++++++--- lib/newlib_tests/test_exec.c | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-)doc/test-writing-guidelines.txt +8
-3@@ -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!"); }lib/newlib_tests/test_exec.c +8
-3@@ -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!" ); }
PATCH 1/1 newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
In reply to Xiao YangHi!
Quoted 15 lines
Before glibc v2.11,
execvpe()was not introduced and resulted in compiler error, so we replaceexecvpe()withexecve()and update test-writing-guidelines.txt.Signed-off-by xiao yang <[email protected]>--- doc/test-writing-guidelines.txt | 11 ++++++++--- lib/newlib_tests/test_exec.c | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-)doc/test-writing-guidelines.txt +0
-0
doc/test-writing-guidelines.txt a non zero exit code. · line 702
Quoted 9 lines
doc/test-writing-guidelines.txt +2
-2@@ -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;
Looking at this the only change here should be:
doc/test-writing-guidelines.txt a non zero exit code. · line 703
Quoted 2 lines
doc/test-writing-guidelines.txt +1
-1-#include <stdlib.h> +#include <unistd.h>
As man 7 environ says:
(This variable must be declared in the user program, but is declared in the header file <unistd.h> if the _GNU_SOURCE feature test macro is defined.)
Or is environ not defined with _GNU_SOURCE for older libc?
Quoted 17 lines
doc/test-writing-guidelines.txt +5
-1static 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!"); }lib/newlib_tests/test_exec.c +0
-0
lib/newlib_tests/test_exec.c line 30
Quoted 9 lines
lib/newlib_tests/test_exec.c +2
-2@@ -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;
Here as well.
lib/newlib_tests/test_exec.c line 42
Quoted 13 lines
lib/newlib_tests/test_exec.c +5
-1static 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!" ); }
Otherwise it looks good.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
Quoted 31 lines · Cyril Hrubis
Hi!
Quoted 15 lines
Before glibc v2.11,
execvpe()was not introduced and resulted in compiler error, so we replaceexecvpe()withexecve()and update test-writing-guidelines.txt.Signed-off-by xiao yang<[email protected]>--- doc/test-writing-guidelines.txt | 11 ++++++++--- lib/newlib_tests/test_exec.c | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-)doc/test-writing-guidelines.txt +0
-0doc/test-writing-guidelines.txt a non zero exit code. · line 702
Quoted 9 lines
doc/test-writing-guidelines.txt +2
-2@@ -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;Looking at this the only change here should be:
doc/test-writing-guidelines.txt a non zero exit code. · line 703
Quoted 2 lines
doc/test-writing-guidelines.txt +1
-1-#include<stdlib.h> +#include<unistd.h>As man 7 environ says:
Quoted 5 lines
(This variable must be declared in the user program, but is declared in the header file<unistd.h> if the
_GNU_SOURCEfeature test macro is defined.)Or is environ not defined with
_GNU_SOURCEfor older libc?
Hi, Cyril
Older libc declares environ when _GNU_SOURCE is defined, so only repalcing stdlib.h with unistd.h seems simpler.
I will send the v2 patch soon.
Thanks,
Xiao Yang
Quoted 43 lines
Quoted 17 lines
doc/test-writing-guidelines.txt +5
-1static 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!"); }lib/newlib_tests/test_exec.c +0
-0lib/newlib_tests/test_exec.c line 30
Quoted 9 lines
lib/newlib_tests/test_exec.c +2
-2@@ -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;Here as well.
lib/newlib_tests/test_exec.c line 42
Quoted 13 lines
lib/newlib_tests/test_exec.c +5
-1static 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!" ); }Otherwise it looks good.
PATCH v2 1/1 newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
In reply to Cyril HrubisBefore glibc v2.11, execvpe() was not introduced and resulted in compiler error, so we replace execvpe() with execve() and update test-writing-guidelines.txt.
--- doc/test-writing-guidelines.txt | 8 ++++++-- lib/newlib_tests/test_exec.c | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-)
doc/test-writing-guidelines.txt +6 -2
@@ -697,14 +697,18 @@ a non zero exit code. ------------------------------------------------------------------------------- /* test.c */ #define _GNU_SOURCE -#include <stdlib.h> +#include <unistd.h> #include "tst_test.h" static void do_test(void) { char *const argv[] = {"test_exec_child", NULL}; + char path[4096]; - execvpe(argv[0], argv, environ); + if (tst_get_path("test_exec_child", path, sizeof(path))) + tst_brk(TCONF, "Couldn't find test_exec_child in $PATH"); + + execve(path, argv, environ); tst_res(TBROK | TERRNO, "EXEC!"); }
lib/newlib_tests/test_exec.c +6 -2
@@ -25,14 +25,18 @@*/ #define _GNU_SOURCE -#include <stdlib.h> +#include <unistd.h> #include "tst_test.h" static void do_test (void ) {char *const argv[] = {"test_exec_child" ,NULL }; +char path[4096 ]; -execvpe (argv[0 ], argv, environ); +if (tst_get_path ("test_exec_child" , path,sizeof (path))) +tst_brk (TCONF ,"Couldn't find test_exec_child in $PATH" ); + +execve (path, argv, environ);tst_res (TBROK |TERRNO ,"EXEC!" ); }
Signature · 1 line
1.8.3.1
PATCH v2 1/1 newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
----- Original Message -----
Quoted 5 lines
Before glibc v2.11,
execvpe()was not introduced and resulted in compiler error, so we replaceexecvpe()withexecve()and update test-writing-guidelines.txt.Signed-off-by Xiao Yang <[email protected]>
This is older than oldest RHEL distro I still use to check LTP builds, but it works fine on more recent ones, so ACK.
Regards,
Jan
PATCH v2 1/1 newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
Quoted 8 lines · Jan Stancek
----- Original Message -----
Quoted 5 lines
Before glibc v2.11,
execvpe()was not introduced and resulted in compiler error, so we replaceexecvpe()withexecve()and update test-writing-guidelines.txt.Signed-off-by Xiao Yang<[email protected]>This is older than oldest RHEL distro I still use to check LTP builds, but it works fine on more recent ones, so ACK.
Hi Jan,
Thanks for your review.
I saw this issue on RHEL5.
Thanks,
Xiao Yang
Quoted 5 lines
Regards,
Jan
PATCH v2 1/1 newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
In reply to Xiao YangHi Xiao,
Quoted 3 lines
Before glibc v2.11,
execvpe()was not introduced and resulted in compiler error, so we replaceexecvpe()withexecve()and update test-writing-guidelines.txt.
Oh, that's a history :). But as it's forward compatible, why not.
Quoted 1 line
Signed-off-by Xiao Yang <[email protected]>
Kind regards,
Petr
PATCH v2 1/1 newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
In reply to Xiao YangHi,
Could you help me push the v2 patch? Thanks a lot. :-)
Thanks,
Xiao Yang
Quoted 60 lines · Xiao Yang
Before glibc v2.11,
execvpe()was not introduced and resulted in compiler error, so we replaceexecvpe()withexecve()and update test-writing-guidelines.txt.Signed-off-by Xiao Yang <[email protected]>--- doc/test-writing-guidelines.txt | 8 ++++++-- lib/newlib_tests/test_exec.c | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-)doc/test-writing-guidelines.txt +6
-2@@ -697,14 +697,18 @@ a non zero exit code. ------------------------------------------------------------------------------- /* test.c */ #define _GNU_SOURCE -#include <stdlib.h> +#include <unistd.h> #include "tst_test.h" static void do_test(void) { char *const argv[] = {"test_exec_child", NULL}; + char path[4096]; - execvpe(argv[0], argv, environ); + if (tst_get_path("test_exec_child", path, sizeof(path))) + tst_brk(TCONF, "Couldn't find test_exec_child in $PATH"); + + execve(path, argv, environ); tst_res(TBROK | TERRNO, "EXEC!"); }lib/newlib_tests/test_exec.c +6
-2@@ -25,14 +25,18 @@*/ #define _GNU_SOURCE -#include <stdlib.h> +#include <unistd.h> #include "tst_test.h" static void do_test (void ) {char *const argv[] = {"test_exec_child" ,NULL }; +char path[4096 ]; -execvpe (argv[0 ], argv, environ); +if (tst_get_path ("test_exec_child" , path,sizeof (path))) +tst_brk (TCONF ,"Couldn't find test_exec_child in $PATH" ); + +execve (path, argv, environ);tst_res (TBROK |TERRNO ,"EXEC!" ); }
PATCH v2 1/1 newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
In reply to Xiao YangHi Xiao,
Quoted 5 lines
Before glibc v2.11,
execvpe()was not introduced and resulted in compiler error, so we replaceexecvpe()withexecve()and update test-writing-guidelines.txt.Signed-off-by Xiao Yang <[email protected]>
Pushed, thanks!
Kind regards,
Petr