All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v2] xinetd/xinetd_tests.sh: add IPv6 test for xinetd
@ 2013-07-09  6:17 Xie Lingyun
  2013-07-09 10:59 ` Hangbin Liu
  2013-07-10  2:25 ` Caspar Zhang
  0 siblings, 2 replies; 5+ messages in thread
From: Xie Lingyun @ 2013-07-09  6:17 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: LTP List


[-- Attachment #1.1: Type: text/plain, Size: 5400 bytes --]

If IPv6 is enabled, telnet ::1 will be tested. Otherwise, IPv4 only.

Signed-off-by: Xie Lingyun <lingyun.xie@bj.cs2c.com.cn>
---
 testcases/network/xinetd/xinetd_tests.sh | 90
++++++++++++++++++++++++++++----
 1 file changed, 79 insertions(+), 11 deletions(-)

diff --git a/testcases/network/xinetd/xinetd_tests.sh
b/testcases/network/xinetd/xinetd_tests.sh
index 83eb8a7..0fb6598 100755
--- a/testcases/network/xinetd/xinetd_tests.sh
+++ b/testcases/network/xinetd/xinetd_tests.sh
@@ -84,12 +84,23 @@ init()
          return $RC
     fi

+ # sometimes the default telnet may be /usr/kerberos/bin/telnet
+ TELNET_COMM='/usr/bin/telnet'
+
     # check if commands tst_*, xinetd, awk exists.
     chk_ifexists INIT tst_resm   || return $RC
     chk_ifexists INIT xinetd     || return $RC
     chk_ifexists INIT diff       || return $RC
-    chk_ifexists INIT telnet     || return $RC
-
+    chk_ifexists INIT $TELNET_COMM     || return $RC
+    chk_ifexists INIT ip || return $RC
+
+    IPV6_ENABLED=0
+    ip a | grep inet6 > /dev/null 2>&1
+    if [ $? -eq 0 ]
+    then
+     IPV6_ENABLED=1
+    fi
+
  # Create custom xinetd.conf file.
  # tst_xinetd.conf.1 config file has telnet service disabled.
  cat > $LTPTMP/tst_xinetd.conf.1 <<-EOF || RC=$?
@@ -128,7 +139,7 @@ init()

     # Create expected file with telnet disabled.
     cat > $LTPTMP/tst_xinetd.exp.1 <<-EOF || RC=$?
- telnet: Unable to connect to remote host: Connection refused
+ telnet: connect to address 127.0.0.1: Connection refused
  EOF

     if [ $RC -ne 0 ]
@@ -137,11 +148,25 @@ init()
             "INIT: unable to create expected file $LTPTMP/tst_xinetd.exp.1"
         return $RC
     fi
+
+    if [ $IPV6_ENABLED -eq 1 ]
+    then
+     cat > $LTPTMP/tst_xinetd.exp.1.ipv6 <<-EOF || RC=$?
+ telnet: connect to address ::1: Connection refused
+ EOF
+
+     if [ $RC -ne 0 ]
+   then
+         tst_brkm TBROK  NULL \
+             "INIT: unable to create expected file
$LTPTMP/tst_xinetd.exp.1.ipv6"
+         return $RC
+     fi
+    fi

     # Create expected file with telnet enabled.
  cat > $LTPTMP/tst_xinetd.exp.2 <<-EOF || RC=$?
  Trying 127.0.0.1...
- Connected to localhost (127.0.0.1).
+ Connected to 127.0.0.1.
  Escape character is '^]'.
  Connection closed by foreign host.
  EOF
@@ -149,10 +174,27 @@ init()
     if [ $RC -ne 0 ]
     then
         tst_brkm TBROK  NULL \
-            "INIT: unable to create expected file $LTPTMP/tst_xinetd.exp.1"
+            "INIT: unable to create expected file $LTPTMP/tst_xinetd.exp.2"
         return $RC
     fi

+ if [ $IPV6_ENABLED -eq 1 ]
+    then
+     cat > $LTPTMP/tst_xinetd.exp.2.ipv6 <<-EOF || RC=$?
+ Trying ::1...
+ Connected to ::1.
+ Escape character is '^]'.
+ Connection closed by foreign host.
+ EOF
+
+     if [ $RC -ne 0 ]
+     then
+         tst_brkm TBROK  NULL \
+             "INIT: unable to create expected file
$LTPTMP/tst_xinetd.exp.2.ipv6"
+         return $RC
+     fi
+    fi
+
     return $RC
 }

@@ -263,7 +305,7 @@ test01()

  # Not checking for exit code from telnet command because telnet is
  # not terminated by the test gracefully.
- echo " " | telnet localhost 2>$LTPTMP/tst_xinetd.out 1>/dev/null
+ echo " " | $TELNET_COMM 127.0.0.1 2>$LTPTMP/tst_xinetd.out 1>/dev/null
  diff -iwB $LTPTMP/tst_xinetd.out  $LTPTMP/tst_xinetd.exp.1 \
  > $LTPTMP/tst_xinetd.err 2>&1 || RC=$?
     if [ $RC -ne 0 ]
@@ -272,7 +314,20 @@ test01()
             "Test #1: with telnet diabled expected out differs RC=$RC.
Details:"
         return $RC
     fi
-
+
+    if [ $IPV6_ENABLED -eq 1 ]
+    then
+     echo " " | $TELNET_COMM ::1 2>$LTPTMP/tst_xinetd.out.ipv6 1>/dev/null
+ diff -iwB $LTPTMP/tst_xinetd.out.ipv6  $LTPTMP/tst_xinetd.exp.1.ipv6 \
+ > $LTPTMP/tst_xinetd.err.ipv6 2>&1 || RC=$?
+     if [ $RC -ne 0 ]
+     then
+         tst_res TFAIL $LTPTMP/tst_xinetd.err.ipv6 \
+             "Test #1: with telnet diabled of IPv6 expected out differs
RC=$RC. Details:"
+         return $RC
+     fi
+    fi
+
     tst_resm TINFO "Test #1: restart xinetd with telnet enabled."
  # install the xinetd config file with telnet enabled.
  mv $LTPTMP/tst_xinetd.conf.2 /etc/xinetd.conf > $LTPTMP/tst_xinetd.err
2>&1 \
@@ -312,7 +367,7 @@ test01()

  # Not checking for exit code from telnet command because telnet is
  # not terminated by the test gracefully.
- echo " " | telnet localhost > $LTPTMP/tst_xinetd.out 2>&1
+ echo " " | $TELNET_COMM 127.0.0.1 > $LTPTMP/tst_xinetd.out 2>&1

  diff -iwB $LTPTMP/tst_xinetd.out  $LTPTMP/tst_xinetd.exp.2 \
  > $LTPTMP/tst_xinetd.err 2>&1 || RC=$?
@@ -321,11 +376,24 @@ test01()
         tst_res TFAIL $LTPTMP/tst_xinetd.err \
             "Test #1: expected output differes from actual. Details:"
         return $RC
- else
- tst_resm TPASS \
- "Test #1: xinetd reads the config file and starts or stops services."
     fi

+ if [ $IPV6_ENABLED -eq 1 ]
+    then
+     echo " " | $TELNET_COMM ::1 > $LTPTMP/tst_xinetd.out.ipv6 2>&1
+
+ diff -iwB $LTPTMP/tst_xinetd.out.ipv6  $LTPTMP/tst_xinetd.exp.2.ipv6 \
+ > $LTPTMP/tst_xinetd.err.ipv6 2>&1 || RC=$?
+     if [ $RC -ne 0 ]
+     then
+         tst_res TFAIL $LTPTMP/tst_xinetd.err.ipv6 \
+             "Test #1: expected output differes from actual. Details:"
+         return $RC
+     fi
+    fi
+
+ tst_resm TPASS \
+ "Test #1: xinetd reads the config file and starts or stops services."
     return $RC
 }

-- 
1.8.3.1



Thanks,
Lingyun Xie

[-- Attachment #1.2: Type: text/html, Size: 15607 bytes --]

[-- Attachment #2: 0001-xinetd-xinetd_tests.sh-add-IPv6-test-for-xinetd.patch --]
[-- Type: application/octet-stream, Size: 5647 bytes --]

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

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk

[-- Attachment #4: 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] 5+ messages in thread

* Re: [LTP] [PATCH v2] xinetd/xinetd_tests.sh: add IPv6 test for xinetd
  2013-07-09  6:17 [LTP] [PATCH v2] xinetd/xinetd_tests.sh: add IPv6 test for xinetd Xie Lingyun
@ 2013-07-09 10:59 ` Hangbin Liu
  2013-07-10  2:09   ` Xie Lingyun
  2013-07-10  2:25 ` Caspar Zhang
  1 sibling, 1 reply; 5+ messages in thread
From: Hangbin Liu @ 2013-07-09 10:59 UTC (permalink / raw)
  To: Xie Lingyun; +Cc: LTP List

2013/7/9 Xie Lingyun <lingyun.xie@bj.cs2c.com.cn>:
> If IPv6 is enabled, telnet ::1 will be tested. Otherwise, IPv4 only.
>
> Signed-off-by: Xie Lingyun <lingyun.xie@bj.cs2c.com.cn>
> ---
>  testcases/network/xinetd/xinetd_tests.sh | 90
> ++++++++++++++++++++++++++++----
>  1 file changed, 79 insertions(+), 11 deletions(-)
>
> diff --git a/testcases/network/xinetd/xinetd_tests.sh
> b/testcases/network/xinetd/xinetd_tests.sh
> index 83eb8a7..0fb6598 100755
> --- a/testcases/network/xinetd/xinetd_tests.sh
> +++ b/testcases/network/xinetd/xinetd_tests.sh
> @@ -84,12 +84,23 @@ init()
>           return $RC
>      fi
>
> + # sometimes the default telnet may be /usr/kerberos/bin/telnet
> + TELNET_COMM='/usr/bin/telnet'
> +
>      # check if commands tst_*, xinetd, awk exists.
>      chk_ifexists INIT tst_resm   || return $RC
>      chk_ifexists INIT xinetd     || return $RC
>      chk_ifexists INIT diff       || return $RC
> -    chk_ifexists INIT telnet     || return $RC
> -
> +    chk_ifexists INIT $TELNET_COMM     || return $RC
> +    chk_ifexists INIT ip || return $RC
> +
> +    IPV6_ENABLED=0
> +    ip a | grep inet6 > /dev/null 2>&1
> +    if [ $? -eq 0 ]
> +    then
> +     IPV6_ENABLED=1
> +    fi
> +
>   # Create custom xinetd.conf file.
>   # tst_xinetd.conf.1 config file has telnet service disabled.
>   cat > $LTPTMP/tst_xinetd.conf.1 <<-EOF || RC=$?
> @@ -128,7 +139,7 @@ init()
>
>      # Create expected file with telnet disabled.
>      cat > $LTPTMP/tst_xinetd.exp.1 <<-EOF || RC=$?
> - telnet: Unable to connect to remote host: Connection refused
> + telnet: connect to address 127.0.0.1: Connection refused
>   EOF
>
>      if [ $RC -ne 0 ]
> @@ -137,11 +148,25 @@ init()
>              "INIT: unable to create expected file $LTPTMP/tst_xinetd.exp.1"
>          return $RC
>      fi
> +
> +    if [ $IPV6_ENABLED -eq 1 ]
> +    then
> +     cat > $LTPTMP/tst_xinetd.exp.1.ipv6 <<-EOF || RC=$?
> + telnet: connect to address ::1: Connection refused
> + EOF
> +
> +     if [ $RC -ne 0 ]
> +   then
> +         tst_brkm TBROK  NULL \
> +             "INIT: unable to create expected file
> $LTPTMP/tst_xinetd.exp.1.ipv6"
> +         return $RC
> +     fi
> +    fi
>
>      # Create expected file with telnet enabled.
>   cat > $LTPTMP/tst_xinetd.exp.2 <<-EOF || RC=$?
>   Trying 127.0.0.1...
> - Connected to localhost (127.0.0.1).
> + Connected to 127.0.0.1.
>   Escape character is '^]'.
>   Connection closed by foreign host.
>   EOF
> @@ -149,10 +174,27 @@ init()
>      if [ $RC -ne 0 ]
>      then
>          tst_brkm TBROK  NULL \
> -            "INIT: unable to create expected file $LTPTMP/tst_xinetd.exp.1"
> +            "INIT: unable to create expected file $LTPTMP/tst_xinetd.exp.2"
>          return $RC
>      fi
>
> + if [ $IPV6_ENABLED -eq 1 ]
> +    then
> +     cat > $LTPTMP/tst_xinetd.exp.2.ipv6 <<-EOF || RC=$?
> + Trying ::1...
> + Connected to ::1.
> + Escape character is '^]'.
> + Connection closed by foreign host.
> + EOF
> +
> +     if [ $RC -ne 0 ]
> +     then
> +         tst_brkm TBROK  NULL \
> +             "INIT: unable to create expected file
> $LTPTMP/tst_xinetd.exp.2.ipv6"
> +         return $RC
> +     fi
> +    fi
> +
>      return $RC
>  }
>
> @@ -263,7 +305,7 @@ test01()
>
>   # Not checking for exit code from telnet command because telnet is
>   # not terminated by the test gracefully.
> - echo " " | telnet localhost 2>$LTPTMP/tst_xinetd.out 1>/dev/null
> + echo " " | $TELNET_COMM 127.0.0.1 2>$LTPTMP/tst_xinetd.out 1>/dev/null

Should there be a "^D" ? I can't see it here, does gmail support this
kind of special character ?

>   diff -iwB $LTPTMP/tst_xinetd.out  $LTPTMP/tst_xinetd.exp.1 \
>   > $LTPTMP/tst_xinetd.err 2>&1 || RC=$?
>      if [ $RC -ne 0 ]
> @@ -272,7 +314,20 @@ test01()
>              "Test #1: with telnet diabled expected out differs RC=$RC.
> Details:"
>          return $RC
>      fi
> -
> +
> +    if [ $IPV6_ENABLED -eq 1 ]
> +    then
> +     echo " " | $TELNET_COMM ::1 2>$LTPTMP/tst_xinetd.out.ipv6 1>/dev/null

Also here and other echo lines.

> + diff -iwB $LTPTMP/tst_xinetd.out.ipv6  $LTPTMP/tst_xinetd.exp.1.ipv6 \
> + > $LTPTMP/tst_xinetd.err.ipv6 2>&1 || RC=$?
> +     if [ $RC -ne 0 ]
> +     then
> +         tst_res TFAIL $LTPTMP/tst_xinetd.err.ipv6 \
> +             "Test #1: with telnet diabled of IPv6 expected out differs
> RC=$RC. Details:"
> +         return $RC
> +     fi
> +    fi
> +
>      tst_resm TINFO "Test #1: restart xinetd with telnet enabled."
>   # install the xinetd config file with telnet enabled.
>   mv $LTPTMP/tst_xinetd.conf.2 /etc/xinetd.conf > $LTPTMP/tst_xinetd.err
> 2>&1 \
> @@ -312,7 +367,7 @@ test01()
>
>   # Not checking for exit code from telnet command because telnet is
>   # not terminated by the test gracefully.
> - echo " " | telnet localhost > $LTPTMP/tst_xinetd.out 2>&1
> + echo " " | $TELNET_COMM 127.0.0.1 > $LTPTMP/tst_xinetd.out 2>&1
>
>   diff -iwB $LTPTMP/tst_xinetd.out  $LTPTMP/tst_xinetd.exp.2 \
>   > $LTPTMP/tst_xinetd.err 2>&1 || RC=$?
> @@ -321,11 +376,24 @@ test01()
>          tst_res TFAIL $LTPTMP/tst_xinetd.err \
>              "Test #1: expected output differes from actual. Details:"
>          return $RC
> - else
> - tst_resm TPASS \
> - "Test #1: xinetd reads the config file and starts or stops services."
>      fi
>
> + if [ $IPV6_ENABLED -eq 1 ]
> +    then
> +     echo " " | $TELNET_COMM ::1 > $LTPTMP/tst_xinetd.out.ipv6 2>&1
> +
> + diff -iwB $LTPTMP/tst_xinetd.out.ipv6  $LTPTMP/tst_xinetd.exp.2.ipv6 \
> + > $LTPTMP/tst_xinetd.err.ipv6 2>&1 || RC=$?
> +     if [ $RC -ne 0 ]
> +     then
> +         tst_res TFAIL $LTPTMP/tst_xinetd.err.ipv6 \
> +             "Test #1: expected output differes from actual. Details:"
> +         return $RC
> +     fi
> +    fi
> +
> + tst_resm TPASS \
> + "Test #1: xinetd reads the config file and starts or stops services."

This will PASS the test anyway. The previous test only pass when $RC eq 0.

>      return $RC
>  }
>
> --
> 1.8.3.1
>
>
>
> Thanks,
> Lingyun Xie


Regards
Hangbin Liu

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH v2] xinetd/xinetd_tests.sh: add IPv6 test for xinetd
  2013-07-09 10:59 ` Hangbin Liu
@ 2013-07-10  2:09   ` Xie Lingyun
  0 siblings, 0 replies; 5+ messages in thread
From: Xie Lingyun @ 2013-07-10  2:09 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: LTP List


[-- Attachment #1.1: Type: text/plain, Size: 6763 bytes --]

Yes, there should be a "^D" in each "echo " line. It seems that the
terminal which I copied from doesn't support the special character.

2013/7/9 Hangbin Liu <liuhangbin@gmail.com>

> 2013/7/9 Xie Lingyun <lingyun.xie@bj.cs2c.com.cn>:
> > If IPv6 is enabled, telnet ::1 will be tested. Otherwise, IPv4 only.
> >
> > Signed-off-by: Xie Lingyun <lingyun.xie@bj.cs2c.com.cn>
> > ---
> >  testcases/network/xinetd/xinetd_tests.sh | 90
> > ++++++++++++++++++++++++++++----
> >  1 file changed, 79 insertions(+), 11 deletions(-)
> >
> > diff --git a/testcases/network/xinetd/xinetd_tests.sh
> > b/testcases/network/xinetd/xinetd_tests.sh
> > index 83eb8a7..0fb6598 100755
> > --- a/testcases/network/xinetd/xinetd_tests.sh
> > +++ b/testcases/network/xinetd/xinetd_tests.sh
> > @@ -84,12 +84,23 @@ init()
> >           return $RC
> >      fi
> >
> > + # sometimes the default telnet may be /usr/kerberos/bin/telnet
> > + TELNET_COMM='/usr/bin/telnet'
> > +
> >      # check if commands tst_*, xinetd, awk exists.
> >      chk_ifexists INIT tst_resm   || return $RC
> >      chk_ifexists INIT xinetd     || return $RC
> >      chk_ifexists INIT diff       || return $RC
> > -    chk_ifexists INIT telnet     || return $RC
> > -
> > +    chk_ifexists INIT $TELNET_COMM     || return $RC
> > +    chk_ifexists INIT ip || return $RC
> > +
> > +    IPV6_ENABLED=0
> > +    ip a | grep inet6 > /dev/null 2>&1
> > +    if [ $? -eq 0 ]
> > +    then
> > +     IPV6_ENABLED=1
> > +    fi
> > +
> >   # Create custom xinetd.conf file.
> >   # tst_xinetd.conf.1 config file has telnet service disabled.
> >   cat > $LTPTMP/tst_xinetd.conf.1 <<-EOF || RC=$?
> > @@ -128,7 +139,7 @@ init()
> >
> >      # Create expected file with telnet disabled.
> >      cat > $LTPTMP/tst_xinetd.exp.1 <<-EOF || RC=$?
> > - telnet: Unable to connect to remote host: Connection refused
> > + telnet: connect to address 127.0.0.1: Connection refused
> >   EOF
> >
> >      if [ $RC -ne 0 ]
> > @@ -137,11 +148,25 @@ init()
> >              "INIT: unable to create expected file
> $LTPTMP/tst_xinetd.exp.1"
> >          return $RC
> >      fi
> > +
> > +    if [ $IPV6_ENABLED -eq 1 ]
> > +    then
> > +     cat > $LTPTMP/tst_xinetd.exp.1.ipv6 <<-EOF || RC=$?
> > + telnet: connect to address ::1: Connection refused
> > + EOF
> > +
> > +     if [ $RC -ne 0 ]
> > +   then
> > +         tst_brkm TBROK  NULL \
> > +             "INIT: unable to create expected file
> > $LTPTMP/tst_xinetd.exp.1.ipv6"
> > +         return $RC
> > +     fi
> > +    fi
> >
> >      # Create expected file with telnet enabled.
> >   cat > $LTPTMP/tst_xinetd.exp.2 <<-EOF || RC=$?
> >   Trying 127.0.0.1...
> > - Connected to localhost (127.0.0.1).
> > + Connected to 127.0.0.1.
> >   Escape character is '^]'.
> >   Connection closed by foreign host.
> >   EOF
> > @@ -149,10 +174,27 @@ init()
> >      if [ $RC -ne 0 ]
> >      then
> >          tst_brkm TBROK  NULL \
> > -            "INIT: unable to create expected file
> $LTPTMP/tst_xinetd.exp.1"
> > +            "INIT: unable to create expected file
> $LTPTMP/tst_xinetd.exp.2"
> >          return $RC
> >      fi
> >
> > + if [ $IPV6_ENABLED -eq 1 ]
> > +    then
> > +     cat > $LTPTMP/tst_xinetd.exp.2.ipv6 <<-EOF || RC=$?
> > + Trying ::1...
> > + Connected to ::1.
> > + Escape character is '^]'.
> > + Connection closed by foreign host.
> > + EOF
> > +
> > +     if [ $RC -ne 0 ]
> > +     then
> > +         tst_brkm TBROK  NULL \
> > +             "INIT: unable to create expected file
> > $LTPTMP/tst_xinetd.exp.2.ipv6"
> > +         return $RC
> > +     fi
> > +    fi
> > +
> >      return $RC
> >  }
> >
> > @@ -263,7 +305,7 @@ test01()
> >
> >   # Not checking for exit code from telnet command because telnet is
> >   # not terminated by the test gracefully.
> > - echo " " | telnet localhost 2>$LTPTMP/tst_xinetd.out 1>/dev/null
> > + echo " " | $TELNET_COMM 127.0.0.1 2>$LTPTMP/tst_xinetd.out 1>/dev/null
>
> Should there be a "^D" ? I can't see it here, does gmail support this
> kind of special character ?
>
> >   diff -iwB $LTPTMP/tst_xinetd.out  $LTPTMP/tst_xinetd.exp.1 \
> >   > $LTPTMP/tst_xinetd.err 2>&1 || RC=$?
> >      if [ $RC -ne 0 ]
> > @@ -272,7 +314,20 @@ test01()
> >              "Test #1: with telnet diabled expected out differs RC=$RC.
> > Details:"
> >          return $RC
> >      fi
> > -
> > +
> > +    if [ $IPV6_ENABLED -eq 1 ]
> > +    then
> > +     echo " " | $TELNET_COMM ::1 2>$LTPTMP/tst_xinetd.out.ipv6
> 1>/dev/null
>
> Also here and other echo lines.
>
> > + diff -iwB $LTPTMP/tst_xinetd.out.ipv6  $LTPTMP/tst_xinetd.exp.1.ipv6 \
> > + > $LTPTMP/tst_xinetd.err.ipv6 2>&1 || RC=$?
> > +     if [ $RC -ne 0 ]
> > +     then
> > +         tst_res TFAIL $LTPTMP/tst_xinetd.err.ipv6 \
> > +             "Test #1: with telnet diabled of IPv6 expected out differs
> > RC=$RC. Details:"
> > +         return $RC
> > +     fi
> > +    fi
> > +
> >      tst_resm TINFO "Test #1: restart xinetd with telnet enabled."
> >   # install the xinetd config file with telnet enabled.
> >   mv $LTPTMP/tst_xinetd.conf.2 /etc/xinetd.conf > $LTPTMP/tst_xinetd.err
> > 2>&1 \
> > @@ -312,7 +367,7 @@ test01()
> >
> >   # Not checking for exit code from telnet command because telnet is
> >   # not terminated by the test gracefully.
> > - echo " " | telnet localhost > $LTPTMP/tst_xinetd.out 2>&1
> > + echo " " | $TELNET_COMM 127.0.0.1 > $LTPTMP/tst_xinetd.out 2>&1
> >
> >   diff -iwB $LTPTMP/tst_xinetd.out  $LTPTMP/tst_xinetd.exp.2 \
> >   > $LTPTMP/tst_xinetd.err 2>&1 || RC=$?
> > @@ -321,11 +376,24 @@ test01()
> >          tst_res TFAIL $LTPTMP/tst_xinetd.err \
> >              "Test #1: expected output differes from actual. Details:"
> >          return $RC
> > - else
> > - tst_resm TPASS \
> > - "Test #1: xinetd reads the config file and starts or stops services."
> >      fi
> >
> > + if [ $IPV6_ENABLED -eq 1 ]
> > +    then
> > +     echo " " | $TELNET_COMM ::1 > $LTPTMP/tst_xinetd.out.ipv6 2>&1
> > +
> > + diff -iwB $LTPTMP/tst_xinetd.out.ipv6  $LTPTMP/tst_xinetd.exp.2.ipv6 \
> > + > $LTPTMP/tst_xinetd.err.ipv6 2>&1 || RC=$?
> > +     if [ $RC -ne 0 ]
> > +     then
> > +         tst_res TFAIL $LTPTMP/tst_xinetd.err.ipv6 \
> > +             "Test #1: expected output differes from actual. Details:"
> > +         return $RC
> > +     fi
> > +    fi
> > +
> > + tst_resm TPASS \
> > + "Test #1: xinetd reads the config file and starts or stops services."
>
> This will PASS the test anyway. The previous test only pass when $RC eq 0.
>
In fact, if $RC -ne 0, the script should exit before this line. So I simply
move this line from if statement to here.


>
> >      return $RC
> >  }
> >
> > --
> > 1.8.3.1
> >
> >
> >
> > Thanks,
> > Lingyun Xie
>
>
> Regards
> Hangbin Liu
>
>
>
Thanks,
Lingyun Xie

[-- Attachment #1.2: Type: text/html, Size: 9905 bytes --]

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

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk

[-- 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	[flat|nested] 5+ messages in thread

* Re: [LTP] [PATCH v2] xinetd/xinetd_tests.sh: add IPv6 test for xinetd
  2013-07-09  6:17 [LTP] [PATCH v2] xinetd/xinetd_tests.sh: add IPv6 test for xinetd Xie Lingyun
  2013-07-09 10:59 ` Hangbin Liu
@ 2013-07-10  2:25 ` Caspar Zhang
  2013-07-10  9:49   ` Hangbin Liu
  1 sibling, 1 reply; 5+ messages in thread
From: Caspar Zhang @ 2013-07-10  2:25 UTC (permalink / raw)
  To: Xie Lingyun; +Cc: LTP List

On 07/09/2013 02:17 PM, Xie Lingyun wrote:
> +	# sometimes the default telnet may be /usr/kerberos/bin/telnet
> +	TELNET_COMM='/usr/bin/telnet'
> +	
>       # check if commands tst_*, xinetd, awk exists.
>       chk_ifexists INIT tst_resm   || return $RC
>       chk_ifexists INIT xinetd     || return $RC
>       chk_ifexists INIT diff       || return $RC
> -    chk_ifexists INIT telnet     || return $RC
> -
> +    chk_ifexists INIT $TELNET_COMM     || return $RC
> +    chk_ifexists INIT ip		 || return $RC
> +
> +    IPV6_ENABLED=0
> +    ip a | grep inet6 > /dev/null 2>&1
> +    if [ $? -eq 0 ]
> +    then
> +    	IPV6_ENABLED=1
> +    fi
> +
>   	# Create custom xinetd.conf file.
>   	# tst_xinetd.conf.1 config file has telnet service disabled.
>   	cat > $LTPTMP/tst_xinetd.conf.1 <<-EOF || RC=$?
> @@ -128,7 +139,7 @@ init()
>
>       # Create expected file with telnet disabled.
>       cat > $LTPTMP/tst_xinetd.exp.1 <<-EOF || RC=$?
> -	telnet: Unable to connect to remote host: Connection refused
> +	telnet: connect to address 127.0.0.1: Connection refused
>   	EOF
>
>       if [ $RC -ne 0 ]
> @@ -137,11 +148,25 @@ init()
>               "INIT: unable to create expected file $LTPTMP/tst_xinetd.exp.1"
>           return $RC
>       fi
> +
> +    if [ $IPV6_ENABLED -eq 1 ]
> +    then
> +    	cat > $LTPTMP/tst_xinetd.exp.1.ipv6 <<-EOF || RC=$?
> +		telnet: connect to address ::1: Connection refused
> +		EOF
> +
> +    	if [ $RC -ne 0 ]
> +   		then
> +        	tst_brkm TBROK  NULL \
> +            	"INIT: unable to create expected file $LTPTMP/tst_xinetd.exp.1.ipv6"
> +        	return $RC
> +    	fi
> +    fi
>
>       # Create expected file with telnet enabled.
>   	cat > $LTPTMP/tst_xinetd.exp.2 <<-EOF || RC=$?
>   	Trying 127.0.0.1...
> -	Connected to localhost (127.0.0.1).
> +	Connected to 127.0.0.1.
>   	Escape character is '^]'.
>   	Connection closed by foreign host.
>   	EOF
> @@ -149,10 +174,27 @@ init()
>       if [ $RC -ne 0 ]
>       then
>           tst_brkm TBROK  NULL \
> -            "INIT: unable to create expected file $LTPTMP/tst_xinetd.exp.1"
> +            "INIT: unable to create expected file $LTPTMP/tst_xinetd.exp.2"
>           return $RC
>       fi
>
> +	if [ $IPV6_ENABLED -eq 1 ]
> +    then
> +    	cat > $LTPTMP/tst_xinetd.exp.2.ipv6 <<-EOF || RC=$?
> +		Trying ::1...
> +		Connected to ::1.
> +		Escape character is '^]'.
> +		Connection closed by foreign host.
> +		EOF
> +
> +    	if [ $RC -ne 0 ]
> +    	then
> +        	tst_brkm TBROK  NULL \
> +            	"INIT: unable to create expected file $LTPTMP/tst_xinetd.exp.2.ipv6"
> +        	return $RC
> +    	fi
> +    fi
> +
>       return $RC
>   }
>
> @@ -263,7 +305,7 @@ test01()
>
>   	# Not checking for exit code from telnet command because telnet is
>   	# not terminated by the test gracefully.
> -	echo "\x04" | telnet localhost 2>$LTPTMP/tst_xinetd.out 1>/dev/null
> +	echo "\x04" | $TELNET_COMM 127.0.0.1 2>$LTPTMP/tst_xinetd.out 1>/dev/null
>   	diff -iwB $LTPTMP/tst_xinetd.out  $LTPTMP/tst_xinetd.exp.1 \
>   		> $LTPTMP/tst_xinetd.err 2>&1 || RC=$?
>       if [ $RC -ne 0 ]
> @@ -272,7 +314,20 @@ test01()
>               "Test #1: with telnet diabled expected out differs RC=$RC. Details:"
>           return $RC
>       fi
> -
> +
> +    if [ $IPV6_ENABLED -eq 1 ]
> +    then
> +    	echo "\x04" | $TELNET_COMM ::1 2>$LTPTMP/tst_xinetd.out.ipv6 1>/dev/null
> +		diff -iwB $LTPTMP/tst_xinetd.out.ipv6  $LTPTMP/tst_xinetd.exp.1.ipv6 \
> +			> $LTPTMP/tst_xinetd.err.ipv6 2>&1 || RC=$?
> +    	if [ $RC -ne 0 ]
> +    	then
> +        	tst_res TFAIL $LTPTMP/tst_xinetd.err.ipv6 \
> +            	"Test #1: with telnet diabled of IPv6 expected out differs RC=$RC. Details:"
> +        	return $RC
> +    	fi
> +    fi
> +
>       tst_resm TINFO "Test #1: restart xinetd with telnet enabled."
>   	# install the xinetd config file with telnet enabled.
>   	mv $LTPTMP/tst_xinetd.conf.2 /etc/xinetd.conf > $LTPTMP/tst_xinetd.err 2>&1 \
> @@ -312,7 +367,7 @@ test01()
>
>   	# Not checking for exit code from telnet command because telnet is
>   	# not terminated by the test gracefully.
> -	echo "\x04" | telnet localhost > $LTPTMP/tst_xinetd.out 2>&1
> +	echo "\x04" | $TELNET_COMM 127.0.0.1 > $LTPTMP/tst_xinetd.out 2>&1
>
>   	diff -iwB $LTPTMP/tst_xinetd.out  $LTPTMP/tst_xinetd.exp.2 \
>   		> $LTPTMP/tst_xinetd.err 2>&1 || RC=$?
> @@ -321,11 +376,24 @@ test01()
>           tst_res TFAIL $LTPTMP/tst_xinetd.err \
>               "Test #1: expected output differes from actual. Details:"
>           return $RC
> -	else
> -		tst_resm TPASS \
> -		"Test #1: xinetd reads the config file and starts or stops services."
>       fi
>
> +	if [ $IPV6_ENABLED -eq 1 ]
> +    then
> +    	echo "\x04" | $TELNET_COMM ::1 > $LTPTMP/tst_xinetd.out.ipv6 2>&1
> +
> +		diff -iwB $LTPTMP/tst_xinetd.out.ipv6  $LTPTMP/tst_xinetd.exp.2.ipv6 \
> +			> $LTPTMP/tst_xinetd.err.ipv6 2>&1 || RC=$?
> +    	if [ $RC -ne 0 ]
> +    	then
> +        	tst_res TFAIL $LTPTMP/tst_xinetd.err.ipv6 \
> +            	"Test #1: expected output differes from actual. Details:"
> +        	return $RC
> +    	fi
> +    fi
> +
> +	tst_resm TPASS \
> +		"Test #1: xinetd reads the config file and starts or stops services."
>       return $RC
>   }

IIRC there is no style guide for shell scripts for now, but I suggest 
keep the consistency of indentations in each line, i.e. either using 4 
spaces or 1 tab per level indentation, rather than mixed using of them. 
Reading from this script, I think using 4-space will be a better choice.

Thanks,
Caspar

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH v2] xinetd/xinetd_tests.sh: add IPv6 test for xinetd
  2013-07-10  2:25 ` Caspar Zhang
@ 2013-07-10  9:49   ` Hangbin Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Hangbin Liu @ 2013-07-10  9:49 UTC (permalink / raw)
  To: Caspar Zhang; +Cc: LTP List, Xie Lingyun

2013/7/10 Caspar Zhang <caspar@casparzhang.com>:
> On 07/09/2013 02:17 PM, Xie Lingyun wrote:
>>
>> +       # sometimes the default telnet may be /usr/kerberos/bin/telnet
>> +       TELNET_COMM='/usr/bin/telnet'
>> +
>>       # check if commands tst_*, xinetd, awk exists.
>>       chk_ifexists INIT tst_resm   || return $RC
>>       chk_ifexists INIT xinetd     || return $RC
>>       chk_ifexists INIT diff       || return $RC
>> -    chk_ifexists INIT telnet     || return $RC
>> -
>> +    chk_ifexists INIT $TELNET_COMM     || return $RC
>> +    chk_ifexists INIT ip                || return $RC
>> +
>> +    IPV6_ENABLED=0
>> +    ip a | grep inet6 > /dev/null 2>&1
>> +    if [ $? -eq 0 ]
>> +    then
>> +       IPV6_ENABLED=1
>> +    fi
>> +
>>         # Create custom xinetd.conf file.
>>         # tst_xinetd.conf.1 config file has telnet service disabled.
>>         cat > $LTPTMP/tst_xinetd.conf.1 <<-EOF || RC=$?
>> @@ -128,7 +139,7 @@ init()
>>
>>       # Create expected file with telnet disabled.
>>       cat > $LTPTMP/tst_xinetd.exp.1 <<-EOF || RC=$?
>> -       telnet: Unable to connect to remote host: Connection refused
>> +       telnet: connect to address 127.0.0.1: Connection refused
>>         EOF
>>
>>       if [ $RC -ne 0 ]
>> @@ -137,11 +148,25 @@ init()
>>               "INIT: unable to create expected file
>> $LTPTMP/tst_xinetd.exp.1"
>>           return $RC
>>       fi
>> +
>> +    if [ $IPV6_ENABLED -eq 1 ]
>> +    then
>> +       cat > $LTPTMP/tst_xinetd.exp.1.ipv6 <<-EOF || RC=$?
>> +               telnet: connect to address ::1: Connection refused
>> +               EOF
>> +
>> +       if [ $RC -ne 0 ]
>> +               then
>> +               tst_brkm TBROK  NULL \
>> +               "INIT: unable to create expected file
>> $LTPTMP/tst_xinetd.exp.1.ipv6"
>> +               return $RC
>> +       fi
>> +    fi
>>
>>       # Create expected file with telnet enabled.
>>         cat > $LTPTMP/tst_xinetd.exp.2 <<-EOF || RC=$?
>>         Trying 127.0.0.1...
>> -       Connected to localhost (127.0.0.1).
>> +       Connected to 127.0.0.1.
>>         Escape character is '^]'.
>>         Connection closed by foreign host.
>>         EOF
>> @@ -149,10 +174,27 @@ init()
>>       if [ $RC -ne 0 ]
>>       then
>>           tst_brkm TBROK  NULL \
>> -            "INIT: unable to create expected file
>> $LTPTMP/tst_xinetd.exp.1"
>> +            "INIT: unable to create expected file
>> $LTPTMP/tst_xinetd.exp.2"
>>           return $RC
>>       fi
>>
>> +       if [ $IPV6_ENABLED -eq 1 ]
>> +    then
>> +       cat > $LTPTMP/tst_xinetd.exp.2.ipv6 <<-EOF || RC=$?
>> +               Trying ::1...
>> +               Connected to ::1.
>> +               Escape character is '^]'.
>> +               Connection closed by foreign host.
>> +               EOF
>> +
>> +       if [ $RC -ne 0 ]
>> +       then
>> +               tst_brkm TBROK  NULL \
>> +               "INIT: unable to create expected file
>> $LTPTMP/tst_xinetd.exp.2.ipv6"
>> +               return $RC
>> +       fi
>> +    fi
>> +
>>       return $RC
>>   }
>>
>> @@ -263,7 +305,7 @@ test01()
>>
>>         # Not checking for exit code from telnet command because telnet is
>>         # not terminated by the test gracefully.
>> -       echo " " | telnet localhost 2>$LTPTMP/tst_xinetd.out 1>/dev/null
>> +       echo " " | $TELNET_COMM 127.0.0.1 2>$LTPTMP/tst_xinetd.out
>> 1>/dev/null
>>         diff -iwB $LTPTMP/tst_xinetd.out  $LTPTMP/tst_xinetd.exp.1 \
>>                 > $LTPTMP/tst_xinetd.err 2>&1 || RC=$?
>>       if [ $RC -ne 0 ]
>> @@ -272,7 +314,20 @@ test01()
>>               "Test #1: with telnet diabled expected out differs RC=$RC.
>> Details:"
>>           return $RC
>>       fi
>> -
>> +
>> +    if [ $IPV6_ENABLED -eq 1 ]
>> +    then
>> +       echo " " | $TELNET_COMM ::1 2>$LTPTMP/tst_xinetd.out.ipv6
>> 1>/dev/null
>> +               diff -iwB $LTPTMP/tst_xinetd.out.ipv6
>> $LTPTMP/tst_xinetd.exp.1.ipv6 \
>> +                       > $LTPTMP/tst_xinetd.err.ipv6 2>&1 || RC=$?
>> +       if [ $RC -ne 0 ]
>> +       then
>> +               tst_res TFAIL $LTPTMP/tst_xinetd.err.ipv6 \
>> +               "Test #1: with telnet diabled of IPv6 expected out differs
>> RC=$RC. Details:"
>> +               return $RC
>> +       fi
>> +    fi
>> +
>>       tst_resm TINFO "Test #1: restart xinetd with telnet enabled."
>>         # install the xinetd config file with telnet enabled.
>>         mv $LTPTMP/tst_xinetd.conf.2 /etc/xinetd.conf >
>> $LTPTMP/tst_xinetd.err 2>&1 \
>> @@ -312,7 +367,7 @@ test01()
>>
>>         # Not checking for exit code from telnet command because telnet is
>>         # not terminated by the test gracefully.
>> -       echo " " | telnet localhost > $LTPTMP/tst_xinetd.out 2>&1
>> +       echo " " | $TELNET_COMM 127.0.0.1 > $LTPTMP/tst_xinetd.out 2>&1
>>
>>         diff -iwB $LTPTMP/tst_xinetd.out  $LTPTMP/tst_xinetd.exp.2 \
>>                 > $LTPTMP/tst_xinetd.err 2>&1 || RC=$?
>> @@ -321,11 +376,24 @@ test01()
>>           tst_res TFAIL $LTPTMP/tst_xinetd.err \
>>               "Test #1: expected output differes from actual. Details:"
>>           return $RC
>> -       else
>> -               tst_resm TPASS \
>> -               "Test #1: xinetd reads the config file and starts or stops
>> services."
>>       fi
>>
>> +       if [ $IPV6_ENABLED -eq 1 ]
>> +    then
>> +       echo " " | $TELNET_COMM ::1 > $LTPTMP/tst_xinetd.out.ipv6 2>&1
>> +
>> +               diff -iwB $LTPTMP/tst_xinetd.out.ipv6
>> $LTPTMP/tst_xinetd.exp.2.ipv6 \
>> +                       > $LTPTMP/tst_xinetd.err.ipv6 2>&1 || RC=$?
>> +       if [ $RC -ne 0 ]
>> +       then
>> +               tst_res TFAIL $LTPTMP/tst_xinetd.err.ipv6 \
>> +               "Test #1: expected output differes from actual. Details:"
>> +               return $RC
>> +       fi
>> +    fi
>> +
>> +       tst_resm TPASS \
>> +               "Test #1: xinetd reads the config file and starts or stops
>> services."
>>       return $RC
>>   }
>
>
> IIRC there is no style guide for shell scripts for now, but I suggest keep
> the consistency of indentations in each line, i.e. either using 4 spaces or
> 1 tab per level indentation, rather than mixed using of them. Reading from
> this script, I think using 4-space will be a better choice.

Yes, I discussed this with zhouping before, and I want to give a patch
to format all network shell scripts.

Thanks
Hangbin Liu

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2013-07-10  9:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-09  6:17 [LTP] [PATCH v2] xinetd/xinetd_tests.sh: add IPv6 test for xinetd Xie Lingyun
2013-07-09 10:59 ` Hangbin Liu
2013-07-10  2:09   ` Xie Lingyun
2013-07-10  2:25 ` Caspar Zhang
2013-07-10  9:49   ` Hangbin Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.