public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cristian Greco <cristian@regolo.cc>
To: ltp-list@lists.sourceforge.net
Subject: [LTP] [PATCH] clone06 syscall testcase: use PWD instead of TERM environment variable.
Date: Tue, 22 Feb 2011 10:52:30 +0100	[thread overview]
Message-ID: <20110222105230.0f9fe24b@regolo> (raw)


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

             reply	other threads:[~2011-02-22  9:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-22  9:52 Cristian Greco [this message]
2011-02-23  8:33 ` [LTP] [PATCH] clone06 syscall testcase: use PWD instead of TERM environment variable Garrett Cooper
2011-02-26 16:11   ` Cristian Greco

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110222105230.0f9fe24b@regolo \
    --to=cristian@regolo.cc \
    --cc=ltp-list@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox