public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] clone06 syscall testcase: use PWD instead of TERM environment variable.
@ 2011-02-22  9:52 Cristian Greco
  2011-02-23  8:33 ` Garrett Cooper
  0 siblings, 1 reply; 3+ messages in thread
From: Cristian Greco @ 2011-02-22  9:52 UTC (permalink / raw)
  To: ltp-list


[-- Attachment #1.1.1: Type: text/plain, Size: 720 bytes --]

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 <cristian@regolo.cc>
---
 testcases/kernel/syscalls/clone/clone06.c |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)


Thanks,
--
Cristian Greco
GPG key ID: 0xCF4D32E4

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: 0001-clone06-syscall-testcase-use-PWD-instead-of-TERM-env.patch --]
[-- Type: text/x-patch, Size: 2554 bytes --]

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 #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 427 bytes --]

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

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-02-26 16:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-22  9:52 [LTP] [PATCH] clone06 syscall testcase: use PWD instead of TERM environment variable Cristian Greco
2011-02-23  8:33 ` Garrett Cooper
2011-02-26 16:11   ` Cristian Greco

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox