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:

>>> cristian@regolo:~$ ssh aiolia env | grep TERM
>>> cristian@regolo:~$ ssh aiolia
Last login: ...
>>> cristian@aiolia:~$ env | grep TERM
TERM=xterm


Signed-off-by: Cristian Greco <[email protected]>
---
 testcases/kernel/syscalls/clone/clone06.c |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)


Thanks,
--
Cristian Greco
GPG key ID: 0xCF4D32E4
diff --git a/testcases/kernel/syscalls/clone/clone06.c b/testcases/kernel/syscalls/clone/clone06.c
index d79b302..8f797e3 100644
--- a/testcases/kernel/syscalls/clone/clone06.c
+++ b/testcases/kernel/syscalls/clone/clone06.c
@@ -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);
-}
\ No newline at end of file
+}

Attachment: signature.asc
Description: PGP signature

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

Reply via email to