diff mbox series

[v2] newlib_tests/test_exec.c: Fix compiler error before glibc v2.11

Message ID 1535328355-16759-1-git-send-email-yangx.jy@cn.fujitsu.com
State Accepted
Delegated to: Petr Vorel
Headers show
Series [v2] newlib_tests/test_exec.c: Fix compiler error before glibc v2.11 | expand

Commit Message

Xiao Yang Aug. 27, 2018, 12:05 a.m. UTC
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 | 8 ++++++--
 lib/newlib_tests/test_exec.c    | 8 ++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

Comments

Jan Stancek Aug. 28, 2018, 11:38 a.m. UTC | #1
----- Original Message -----
> 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>

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
Xiao Yang Aug. 28, 2018, 11:54 p.m. UTC | #2
On 2018/08/28 19:38, Jan Stancek wrote:
> ----- Original Message -----
>> 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>
> 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
> Regards,
> Jan
>
>
>
Petr Vorel Aug. 31, 2018, 12:10 p.m. UTC | #3
Hi Xiao,

> 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.
Oh, that's a history :). But as it's forward compatible, why not.

> Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>


Kind regards,
Petr
Xiao Yang Sept. 4, 2018, 6:37 a.m. UTC | #4
Hi,

Could you help me push the v2 patch? Thanks a lot.  :-) 

Thanks,
Xiao Yang

On 2018/08/27 8:05, Xiao Yang wrote:

> 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 | 8 ++++++--
>  lib/newlib_tests/test_exec.c    | 8 ++++++--
>  2 files changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
> index a169724..0b89cf9 100644
> --- a/doc/test-writing-guidelines.txt
> +++ b/doc/test-writing-guidelines.txt
> @@ -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!");
>  }
> diff --git a/lib/newlib_tests/test_exec.c b/lib/newlib_tests/test_exec.c
> index 8aef621..2c86568 100644
> --- a/lib/newlib_tests/test_exec.c
> +++ b/lib/newlib_tests/test_exec.c
> @@ -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!");
>  }
Petr Vorel Sept. 10, 2018, 10:41 p.m. UTC | #5
Hi Xiao,

> 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>

Pushed, thanks!


Kind regards,
Petr
diff mbox series

Patch

diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index a169724..0b89cf9 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -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!");
 }
diff --git a/lib/newlib_tests/test_exec.c b/lib/newlib_tests/test_exec.c
index 8aef621..2c86568 100644
--- a/lib/newlib_tests/test_exec.c
+++ b/lib/newlib_tests/test_exec.c
@@ -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!");
 }