* [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* [LTP] [PATCH] newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
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
1 sibling, 0 replies; 10+ messages in thread
From: Xiao Yang @ 2018-08-23 9:18 UTC (permalink / raw)
To: ltp
On 2018/08/23 17:06, Xiao Yang wrote:
> 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>
Hi,
Sorry for the wrong signature.
The correct one:
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Thanks,
Xiao Yang
> ---
> 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!");
> }
^ permalink raw reply [flat|nested] 10+ messages in thread* [LTP] [PATCH] newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
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
1 sibling, 2 replies; 10+ messages in thread
From: Cyril Hrubis @ 2018-08-24 14:56 UTC (permalink / raw)
To: ltp
Hi!
> 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;
Looking at this the only change here should be:
> -#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?
> 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;
Here as well.
> 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!");
> }
Otherwise it looks good.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 10+ messages in thread* [LTP] [PATCH] newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
2018-08-24 14:56 ` Cyril Hrubis
@ 2018-08-26 23:51 ` Xiao Yang
2018-08-27 0:05 ` [LTP] [PATCH v2] " Xiao Yang
1 sibling, 0 replies; 10+ messages in thread
From: Xiao Yang @ 2018-08-26 23:51 UTC (permalink / raw)
To: ltp
On 2018/08/24 22:56, Cyril Hrubis wrote:
> Hi!
>> 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;
> Looking at this the only change here should be:
>
>> -#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?
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
>> 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;
> Here as well.
>
>> 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!");
>> }
> Otherwise it looks good.
>
^ permalink raw reply [flat|nested] 10+ messages in thread* [LTP] [PATCH v2] newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
2018-08-24 14:56 ` Cyril Hrubis
2018-08-26 23:51 ` Xiao Yang
@ 2018-08-27 0:05 ` Xiao Yang
2018-08-28 11:38 ` Jan Stancek
` (3 more replies)
1 sibling, 4 replies; 10+ messages in thread
From: Xiao Yang @ 2018-08-27 0:05 UTC (permalink / raw)
To: ltp
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!");
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [LTP] [PATCH v2] newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
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
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Jan Stancek @ 2018-08-28 11:38 UTC (permalink / raw)
To: ltp
----- 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
^ permalink raw reply [flat|nested] 10+ messages in thread* [LTP] [PATCH v2] newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
2018-08-28 11:38 ` Jan Stancek
@ 2018-08-28 23:54 ` Xiao Yang
0 siblings, 0 replies; 10+ messages in thread
From: Xiao Yang @ 2018-08-28 23:54 UTC (permalink / raw)
To: ltp
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
>
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [LTP] [PATCH v2] newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
2018-08-27 0:05 ` [LTP] [PATCH v2] " Xiao Yang
2018-08-28 11:38 ` Jan Stancek
@ 2018-08-31 12:10 ` Petr Vorel
2018-09-04 6:37 ` Xiao Yang
2018-09-10 22:41 ` Petr Vorel
3 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2018-08-31 12:10 UTC (permalink / raw)
To: ltp
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* [LTP] [PATCH v2] newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
2018-08-27 0:05 ` [LTP] [PATCH v2] " Xiao Yang
2018-08-28 11:38 ` Jan Stancek
2018-08-31 12:10 ` Petr Vorel
@ 2018-09-04 6:37 ` Xiao Yang
2018-09-10 22:41 ` Petr Vorel
3 siblings, 0 replies; 10+ messages in thread
From: Xiao Yang @ 2018-09-04 6:37 UTC (permalink / raw)
To: ltp
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!");
> }
^ permalink raw reply [flat|nested] 10+ messages in thread* [LTP] [PATCH v2] newlib_tests/test_exec.c: Fix compiler error before glibc v2.11
2018-08-27 0:05 ` [LTP] [PATCH v2] " Xiao Yang
` (2 preceding siblings ...)
2018-09-04 6:37 ` Xiao Yang
@ 2018-09-10 22:41 ` Petr Vorel
3 siblings, 0 replies; 10+ messages in thread
From: Petr Vorel @ 2018-09-10 22:41 UTC (permalink / raw)
To: ltp
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
^ permalink raw reply [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