Skip to contentSkip to conversation

NetNS test fixes

PATCH In review Dan Smith 3 participants 6 messages May 5, 2010 – May 9, 2010

lore
Share & tools
lore

Dan Smith

author
#0 lore raw

PATCH 1/1 NetNS test fixes

This patch fixes a couple of netns test issues that cause invalid failures relating to exiting with a status variable that doesn't exist. It also fixes an instance of inverted logic and a failure to exec sshd with the full path (as required).

Additionally, it makes the common child exec function more descriptive of what it tried to do and why it failed to ease debugging.

---
 testcases/kernel/containers/netns/child_1.sh  |    1 +
 testcases/kernel/containers/netns/child_2.sh  |    1 +
 testcases/kernel/containers/netns/childns.sh  |    4 +++-
 testcases/kernel/containers/netns/common.c    |    3 +--
 testcases/kernel/containers/netns/par_ftp.sh  |    3 +++
 testcases/kernel/containers/netns/parent_1.sh |    2 +-
 testcases/kernel/containers/netns/parent_2.sh |    2 +-
 7 files changed, 11 insertions(+), 5 deletions(-)
testcases/kernel/containers/netns/child_1.sh +1 -0
index 1fa71a7..7fb9a4f 100755
@@ -68,6 +68,7 @@ export TST_TOTAL
         if [ $? = 0 ];
         then
             tst_resm TINFO "PASS: Child2 is pinging from CHILD1 !" 
+	    status=0
         else 
             tst_resm TFAIL "FAIL: Unable to Ping Child2 from CHILD1 !"
             status=-1
testcases/kernel/containers/netns/child_2.sh +1 -0
index d73b785..3098028 100755
@@ -66,6 +66,7 @@ status=0
         # Using /tmp/FIFO5 to synchronize with CHILD1
         echo 0 > /tmp/FIFO5
         sleep 2
+	status=0
     else
         tst_resm TFAIL "FAIL: Unable to ping Child1NS from Child2NS !"
         echo 1 > /tmp/FIFO5
testcases/kernel/containers/netns/childns.sh +3 -1
index 3634d81..16fc7e8 100755
@@ -38,6 +38,8 @@ exists awk grep ip ping sshd
 . initialize.sh
 status=0
     
+SSHD=`which sshd`
+
 if [ $# -eq 1 ] ; then
     childscrpt=$1
     debug "INFO: The script to be executed in child NS is $childscrpt"
@@ -58,7 +60,7 @@ ifconfig lo up
 sleep 2
 
 #starting the sshd inside the child NS
-if ! sshd -p $PORT; then
+if $SSHD -p $PORT; then
     debug "INFO: started the sshd @ port no $PORT"
     sshpid=`ps -ef | grep "sshd -p $PORT" | grep -v grep | awk '{ print $2 ; exit 0} ' `
 else
testcases/kernel/containers/netns/common.c +1 -2
index 22d0e99..6d3b02e 100644
@@ -48,8 +48,7 @@ int crtchild(char *s1 , char *s2)
 {
 	char *cmd[] = { "--", s1, s2, (char *)0 };
 	execve("/bin/sh", cmd, __environ);
-	printf("The code would not reach here on success\n");
-	perror("execve");
+	fprintf(stderr, "Failed to execve(%s, %s): %m\n", s1, s2);
 	return 1;
 }
 
testcases/kernel/containers/netns/par_ftp.sh +3 -0
index 3bfb47b..bb65db4 100755
@@ -37,6 +37,7 @@ export TST_TOTAL
     
     if [ $? = 0 ] ; then
         tst_resm TINFO "Pinging ChildNS from ParentNS"
+	status=0
     else
         tst_resm TFAIL "Error: Unable to ping ChildNS from ParentNS"
         status=-1
@@ -45,3 +46,5 @@ export TST_TOTAL
     if [ $stat != 0 ] ; then
         status=$stat
     fi
+
+    exit $status
testcases/kernel/containers/netns/parent_1.sh +1 -1
index 8577bf2..32f1a47 100755
@@ -55,4 +55,4 @@ export TST_TOTAL
     echo $vnet1 > /tmp/FIFO1
 
     debug "INFO: PARENT_1: End of $0"
-    exit $status
+    exit 0
testcases/kernel/containers/netns/parent_2.sh +1 -1
index 57d3974..f72c16d 100755
@@ -51,4 +51,4 @@ export TST_TOTAL
     echo $vnet3 > /tmp/FIFO3
 
     debug "INFO: PARENT-2: End of $0"
-    exit $status
+    exit 0
Signature · 8 lines
1.7.0.4


------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#1 lore raw
Quoted 9 lines · Dan Smith

This patch fixes a couple of netns test issues that cause invalid failures relating to exiting with a status variable that doesn't exist. It also fixes an instance of inverted logic and a failure to exec sshd with the full path (as required).

Additionally, it makes the common child exec function more descriptive of what it tried to do and why it failed to ease debugging.

Thanks Dan. Hope it helps(coupled with other fix from Serge) to fix those netns issues i found on my F13 system.

Regards--
Subrata

Quoted 103 lines
---
 testcases/kernel/containers/netns/child_1.sh  |    1 +
 testcases/kernel/containers/netns/child_2.sh  |    1 +
 testcases/kernel/containers/netns/childns.sh  |    4 +++-
 testcases/kernel/containers/netns/common.c    |    3 +--
 testcases/kernel/containers/netns/par_ftp.sh  |    3 +++
 testcases/kernel/containers/netns/parent_1.sh |    2 +-
 testcases/kernel/containers/netns/parent_2.sh |    2 +-
 7 files changed, 11 insertions(+), 5 deletions(-)
testcases/kernel/containers/netns/child_1.sh +1 -0
index 1fa71a7..7fb9a4f 100755
@@ -68,6 +68,7 @@ export TST_TOTAL
         if [ $? = 0 ];
         then
             tst_resm TINFO "PASS: Child2 is pinging from CHILD1 !" 
+	    status=0
         else 
             tst_resm TFAIL "FAIL: Unable to Ping Child2 from CHILD1 !"
             status=-1
testcases/kernel/containers/netns/child_2.sh +1 -0
index d73b785..3098028 100755
@@ -66,6 +66,7 @@ status=0
         # Using /tmp/FIFO5 to synchronize with CHILD1
         echo 0 > /tmp/FIFO5
         sleep 2
+	status=0
     else
         tst_resm TFAIL "FAIL: Unable to ping Child1NS from Child2NS !"
         echo 1 > /tmp/FIFO5
testcases/kernel/containers/netns/childns.sh +3 -1
index 3634d81..16fc7e8 100755
@@ -38,6 +38,8 @@ exists awk grep ip ping sshd
 . initialize.sh
 status=0
 
+SSHD=`which sshd`
+
 if [ $# -eq 1 ] ; then
     childscrpt=$1
     debug "INFO: The script to be executed in child NS is $childscrpt"
@@ -58,7 +60,7 @@ ifconfig lo up
 sleep 2
 
 #starting the sshd inside the child NS
-if ! sshd -p $PORT; then
+if $SSHD -p $PORT; then
     debug "INFO: started the sshd @ port no $PORT"
     sshpid=`ps -ef | grep "sshd -p $PORT" | grep -v grep | awk '{ print $2 ; exit 0} ' `
 else
testcases/kernel/containers/netns/common.c +1 -2
index 22d0e99..6d3b02e 100644
@@ -48,8 +48,7 @@ int crtchild(char *s1 , char *s2)
 {
 	char *cmd[] = { "--", s1, s2, (char *)0 };
 	execve("/bin/sh", cmd, __environ);
-	printf("The code would not reach here on success\n");
-	perror("execve");
+	fprintf(stderr, "Failed to execve(%s, %s): %m\n", s1, s2);
 	return 1;
 }
 
testcases/kernel/containers/netns/par_ftp.sh +3 -0
index 3bfb47b..bb65db4 100755
@@ -37,6 +37,7 @@ export TST_TOTAL
 
     if [ $? = 0 ] ; then
         tst_resm TINFO "Pinging ChildNS from ParentNS"
+	status=0
     else
         tst_resm TFAIL "Error: Unable to ping ChildNS from ParentNS"
         status=-1
@@ -45,3 +46,5 @@ export TST_TOTAL
     if [ $stat != 0 ] ; then
         status=$stat
     fi
+
+    exit $status
testcases/kernel/containers/netns/parent_1.sh +1 -1
index 8577bf2..32f1a47 100755
@@ -55,4 +55,4 @@ export TST_TOTAL
     echo $vnet1 > /tmp/FIFO1
 
     debug "INFO: PARENT_1: End of $0"
-    exit $status
+    exit 0
testcases/kernel/containers/netns/parent_2.sh +0 -0
index 57d3974..f72c16d 100755

testcases/kernel/containers/netns/parent_2.sh export TST_TOTAL · line 54

Quoted 5 lines
testcases/kernel/containers/netns/parent_2.sh +1 -1
@@ -51,4 +51,4 @@ export TST_TOTAL
     echo $vnet3 > /tmp/FIFO3
 
     debug "INFO: PARENT-2: End of $0"
-    exit $status
+    exit 0

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#2 lore raw
In reply to Dan Smith
Quoted 9 lines · Dan Smith

This patch fixes a couple of netns test issues that cause invalid failures relating to exiting with a status variable that doesn't exist. It also fixes an instance of inverted logic and a failure to exec sshd with the full path (as required).

Additionally, it makes the common child exec function more descriptive of what it tried to do and why it failed to ease debugging.

Serge,

Can you please ack this patch.

Regards--
Subrata

Quoted 103 lines
---
 testcases/kernel/containers/netns/child_1.sh  |    1 +
 testcases/kernel/containers/netns/child_2.sh  |    1 +
 testcases/kernel/containers/netns/childns.sh  |    4 +++-
 testcases/kernel/containers/netns/common.c    |    3 +--
 testcases/kernel/containers/netns/par_ftp.sh  |    3 +++
 testcases/kernel/containers/netns/parent_1.sh |    2 +-
 testcases/kernel/containers/netns/parent_2.sh |    2 +-
 7 files changed, 11 insertions(+), 5 deletions(-)
testcases/kernel/containers/netns/child_1.sh +1 -0
index 1fa71a7..7fb9a4f 100755
@@ -68,6 +68,7 @@ export TST_TOTAL
         if [ $? = 0 ];
         then
             tst_resm TINFO "PASS: Child2 is pinging from CHILD1 !" 
+	    status=0
         else 
             tst_resm TFAIL "FAIL: Unable to Ping Child2 from CHILD1 !"
             status=-1
testcases/kernel/containers/netns/child_2.sh +1 -0
index d73b785..3098028 100755
@@ -66,6 +66,7 @@ status=0
         # Using /tmp/FIFO5 to synchronize with CHILD1
         echo 0 > /tmp/FIFO5
         sleep 2
+	status=0
     else
         tst_resm TFAIL "FAIL: Unable to ping Child1NS from Child2NS !"
         echo 1 > /tmp/FIFO5
testcases/kernel/containers/netns/childns.sh +3 -1
index 3634d81..16fc7e8 100755
@@ -38,6 +38,8 @@ exists awk grep ip ping sshd
 . initialize.sh
 status=0
 
+SSHD=`which sshd`
+
 if [ $# -eq 1 ] ; then
     childscrpt=$1
     debug "INFO: The script to be executed in child NS is $childscrpt"
@@ -58,7 +60,7 @@ ifconfig lo up
 sleep 2
 
 #starting the sshd inside the child NS
-if ! sshd -p $PORT; then
+if $SSHD -p $PORT; then
     debug "INFO: started the sshd @ port no $PORT"
     sshpid=`ps -ef | grep "sshd -p $PORT" | grep -v grep | awk '{ print $2 ; exit 0} ' `
 else
testcases/kernel/containers/netns/common.c +1 -2
index 22d0e99..6d3b02e 100644
@@ -48,8 +48,7 @@ int crtchild(char *s1 , char *s2)
 {
 	char *cmd[] = { "--", s1, s2, (char *)0 };
 	execve("/bin/sh", cmd, __environ);
-	printf("The code would not reach here on success\n");
-	perror("execve");
+	fprintf(stderr, "Failed to execve(%s, %s): %m\n", s1, s2);
 	return 1;
 }
 
testcases/kernel/containers/netns/par_ftp.sh +3 -0
index 3bfb47b..bb65db4 100755
@@ -37,6 +37,7 @@ export TST_TOTAL
 
     if [ $? = 0 ] ; then
         tst_resm TINFO "Pinging ChildNS from ParentNS"
+	status=0
     else
         tst_resm TFAIL "Error: Unable to ping ChildNS from ParentNS"
         status=-1
@@ -45,3 +46,5 @@ export TST_TOTAL
     if [ $stat != 0 ] ; then
         status=$stat
     fi
+
+    exit $status
testcases/kernel/containers/netns/parent_1.sh +1 -1
index 8577bf2..32f1a47 100755
@@ -55,4 +55,4 @@ export TST_TOTAL
     echo $vnet1 > /tmp/FIFO1
 
     debug "INFO: PARENT_1: End of $0"
-    exit $status
+    exit 0
testcases/kernel/containers/netns/parent_2.sh +0 -0
index 57d3974..f72c16d 100755

testcases/kernel/containers/netns/parent_2.sh export TST_TOTAL · line 54

Quoted 5 lines
testcases/kernel/containers/netns/parent_2.sh +1 -1
@@ -51,4 +51,4 @@ export TST_TOTAL
     echo $vnet3 > /tmp/FIFO3
 
     debug "INFO: PARENT-2: End of $0"
-    exit $status
+    exit 0

------------------------------------------------------------------------------

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

author
#3 lore raw

SM> Can you please ack this patch.

Ack the revised one below instead :)

By the way, these tests appear to start up sshd for no reason other than possibly checking that basic sockets work in the netns. Given the frailty and required setup of the "ftp" test, I think it would be better to replace it with a test using netcat and then yank the sshd bits from the ping tests.

Signature · 19 lines
Dan Smith
IBM Linux Technology Center
email: [email protected]

NetNS test fixes (v2)

This patch fixes a couple of netns test issues that cause invalid failures
relating to exiting with a status variable that doesn't exist.  It also
fixes an instance of inverted logic and a failure to exec sshd with the
full path (as required).

Additionally, it makes the common child exec function more descriptive of
what it tried to do and why it failed to ease debugging.

Changes in v2:
- Initialize status=0 at the top of child_1.sh to prevent overshadowing
  a (meaningless) sshd failure

Signed-off-by: Dan Smith <[email protected]>
testcases/kernel/containers/netns/child_1.sh +1 -0
index 1fa71a7..a63e834 100755
@@ -30,6 +30,7 @@ export TST_COUNT
 export TST_TOTAL
 
 . initialize.sh
+status=0
 
     # Writing child PID number into /tmp/FIFO
     echo $$ > /tmp/FIFO2
testcases/kernel/containers/netns/childns.sh +3 -1
index 3634d81..16fc7e8 100755
@@ -38,6 +38,8 @@ exists awk grep ip ping sshd
 . initialize.sh
 status=0
     
+SSHD=`which sshd`
+
 if [ $# -eq 1 ] ; then
     childscrpt=$1
     debug "INFO: The script to be executed in child NS is $childscrpt"
@@ -58,7 +60,7 @@ ifconfig lo up
 sleep 2
 
 #starting the sshd inside the child NS
-if ! sshd -p $PORT; then
+if $SSHD -p $PORT; then
     debug "INFO: started the sshd @ port no $PORT"
     sshpid=`ps -ef | grep "sshd -p $PORT" | grep -v grep | awk '{ print $2 ; exit 0} ' `
 else
testcases/kernel/containers/netns/common.c +1 -2
index 22d0e99..6d3b02e 100644
@@ -48,8 +48,7 @@ int crtchild(char *s1 , char *s2)
 {
 	char *cmd[] = { "--", s1, s2, (char *)0 };
 	execve("/bin/sh", cmd, __environ);
-	printf("The code would not reach here on success\n");
-	perror("execve");
+	fprintf(stderr, "Failed to execve(%s, %s): %m\n", s1, s2);
 	return 1;
 }
 
testcases/kernel/containers/netns/par_ftp.sh +3 -0
index 3bfb47b..bb65db4 100755
@@ -37,6 +37,7 @@ export TST_TOTAL
     
     if [ $? = 0 ] ; then
         tst_resm TINFO "Pinging ChildNS from ParentNS"
+	status=0
     else
         tst_resm TFAIL "Error: Unable to ping ChildNS from ParentNS"
         status=-1
@@ -45,3 +46,5 @@ export TST_TOTAL
     if [ $stat != 0 ] ; then
         status=$stat
     fi
+
+    exit $status
testcases/kernel/containers/netns/parent_1.sh +1 -1
index 8577bf2..32f1a47 100755
@@ -55,4 +55,4 @@ export TST_TOTAL
     echo $vnet1 > /tmp/FIFO1
 
     debug "INFO: PARENT_1: End of $0"
-    exit $status
+    exit 0
testcases/kernel/containers/netns/parent_2.sh +1 -1
index 57d3974..f72c16d 100755
@@ -51,4 +51,4 @@ export TST_TOTAL
     echo $vnet3 > /tmp/FIFO3
 
     debug "INFO: PARENT-2: End of $0"
-    exit $status
+    exit 0

------------------------------------------------------------------------------

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#4 lore raw
Quoted 9 lines · Dan Smith

SM> Can you please ack this patch.

Ack the revised one below instead :)

By the way, these tests appear to start up sshd for no reason other than possibly checking that basic sockets work in the netns. Given the frailty and required setup of the "ftp" test, I think it would be better to replace it with a test using netcat and then yank the sshd bits from the ping tests.

Ack that.

Quoted 11 lines

Dan Smith
IBM Linux Technology Center
email: [email protected]

NetNS test fixes (v2)

This patch fixes a couple of netns test issues that cause invalid failures relating to exiting with a status variable that doesn't exist. It also fixes an instance of inverted logic and a failure to exec sshd with the full path (as required).

Quoted 8 lines

Additionally, it makes the common child exec function more descriptive of what it tried to do and why it failed to ease debugging.

Changes in v2:
- Initialize status=0 at the top of child_1.sh to prevent overshadowing a (meaningless) sshd failure

thanks,
-serge

------------------------------------------------------------------------------

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#5 lore raw
Quoted 27 lines · Serge E. Hallyn
Quoted 9 lines · Dan Smith

SM> Can you please ack this patch.

Ack the revised one below instead :)

By the way, these tests appear to start up sshd for no reason other than possibly checking that basic sockets work in the netns. Given the frailty and required setup of the "ftp" test, I think it would be better to replace it with a test using netcat and then yank the sshd bits from the ping tests.

Ack that.

Quoted 14 lines

Dan Smith
IBM Linux Technology Center
email: [email protected]

NetNS test fixes (v2)

This patch fixes a couple of netns test issues that cause invalid failures relating to exiting with a status variable that doesn't exist. It also fixes an instance of inverted logic and a failure to exec sshd with the full path (as required).

Additionally, it makes the common child exec function more descriptive of what it tried to do and why it failed to ease debugging.

Quoted 7 lines
Quoted 5 lines

Changes in v2:
- Initialize status=0 at the top of child_1.sh to prevent overshadowing a (meaningless) sshd failure

Thats Great. Thanks :-)

Regards--
Subrata

Quoted 3 lines

thanks,
-serge

------------------------------------------------------------------------------

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list