clone06 syscall testcase: use PWD instead of TERM environment variable.
PATCH 1/1 clone06 syscall testcase: use PWD instead of TERM environment variable.
Hi,
please consider the following patch for the 'clone06' syscall test.
When running the test on a remote host with an ssh command the TERM environment variable is not available. Use PWD instead, with a buffer size of MAXPATHLEN.
This is to show how using the TERM variable results in unexpected behavior:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
cristian@regolo:~$ ssh aiolia env | grep TERM cristian@regolo:~$ ssh aiolia
Last login: ...
Quoted 1 line
Quoted 1 line
Quoted 1 line
cristian@aiolia:~$ env | grep TERM
TERM=xterm
--- testcases/kernel/syscalls/clone/clone06.c | 23 +++++++++++------------ 1 files changed, 11 insertions(+), 12 deletions(-)
Thanks,
--
Cristian Greco
GPG key ID: 0xCF4D32E4
testcases/kernel/syscalls/clone/clone06.c +11 -12
@@ -42,12 +42,12 @@* Call clone() * * CHILD: -* get the value for environment variable, TERM and write it +* get the value for environment variable PWD and write it * to pipe. * * PARENT: -* Reads the value for environment variable, TERM from pipe. -* Compare child's TERM value with that of parent, +* Reads the value for environment variable PWD from pipe. +* Compare child's PWD value with that of parent, * if same, * Test Passed. * else
@@ -77,14 +77,13 @@#include <errno.h> #include <sched.h> +#include <sys/param.h> /* for MAXPATHLEN */ #include <sys/wait.h> #include <fcntl.h> #include "test.h" #include "usctest.h" #include "clone_platform.h" -#define MAX_LINE_LENGTH 256 -static void setup ();static void cleanup ();static int child_environ ();
@@ -101,7 +100,7 @@ int main(int ac, char **av)char *msg;/* message returned from parse_opts */ void *child_stack;/* stack for child */ char *parent_env; -char buff[MAX_LINE_LENGTH ]; +char buff[MAXPATHLEN ];/* parse standard options */ if ((msg =parse_opts (ac, av,NULL ,NULL )) !=NULL )
@@ -146,7 +145,7 @@ int main(int ac, char **av)tst_resm (TWARN |TERRNO ,"close(pfd[0]) failed" ); } - parent_env =getenv ("TERM" ); + parent_env =getenv ("PWD" );if ((strcmp (buff, parent_env)) ==0 ) {tst_resm (TPASS ,"Test Passed" );
@@ -186,24 +185,24 @@ void cleanup()/* * child_environ() - function executed by child. -* Gets the value for environment variable,TERM & +* Gets the value for environment variable PWD and * writes it to a pipe. */ int child_environ (void ) { -char var[MAX_LINE_LENGTH ]; +char var[MAXPATHLEN ];/* Close read end from child */ if ((close (pfd[0 ])) ==-1 ) {tst_brkm (TBROK |TERRNO , cleanup,"close(pfd[0]) failed" ); } -if ((sprintf (var,"%s" ,getenv ("TERM" ) ? :"" )) <=0 ) { +if ((sprintf (var,"%s" ,getenv ("PWD" ) ? :"" )) <=0 ) {tst_resm (TWARN |TERRNO ,"sprintf() failed" ); } -if ((write (pfd[1 ], var,MAX_LINE_LENGTH )) ==-1 ) { +if ((write (pfd[1 ], var,MAXPATHLEN )) ==-1 ) {tst_resm (TWARN |TERRNO ,"write to pipe failed" ); }
@@ -213,4 +212,4 @@ int child_environ(void) }exit (0 ); -} +}
------------------------------------------------------------------------------
Index, Search & Analyze Logs and other IT data in Real-Time with Splunk Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. Free Software Download: http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 8 lines · Cristian Greco
Hi,
please consider the following patch for the 'clone06' syscall test.
When running the test on a remote host with an ssh command the TERM environment variable is not available. Use PWD instead, with a buffer size of MAXPATHLEN.
This is to show how using the TERM variable results in unexpected behavior:
Depending on $PWD, $TERM, etc isn't smart as they're controlled by
the shell and external sources and can be modified out from under you (there's some recent discussion on the opengroup list that has transpired related to $PATH, $PWD, etc).
How about this instead:
1. unset a predetermined env variable if it's present.
2. set it to a known value
3. Make sure that the env variable set in 2. matches both in the child and parent.
If you submit this patch, I'll gladly commit it because it's more
sane than the current test code.
Thanks,
-Garrett
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 21 lines · On Wed, 23 Feb 2011 00:33:08 -0800 Garrett Cooper <[email protected]> wrote:
Quoted 8 lines · Cristian Greco
Hi,
please consider the following patch for the 'clone06' syscall test.
When running the test on a remote host with an ssh command the TERM environment variable is not available. Use PWD instead, with a buffer size of MAXPATHLEN.
This is to show how using the TERM variable results in unexpected behavior:
Depending on $PWD, $TERM, etc isn't smart as they're controlled by
the shell and external sources and can be modified out from under you (there's some recent discussion on the opengroup list that has transpired related to $PATH, $PWD, etc).
How about this instead:1. unset a predetermined env variable if it's present.
2. set it to a known value
3. Make sure that the env variable set in 2. matches both in the child and parent.
Quoted 4 lines
If you submit this patch, I'll gladly commit it because it's more
sane than the current test code.
Thanks,
-Garrett
Ok, will do ASAP!
Thanks,
--
Cristian Greco
GPG key ID: 0xCF4D32E4
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list