Skip to contentSkip to conversation

xinetd_tests.sh: support systemd restart

PATCH In review Simon Xu 2 participants 7 messages Mar 26, 2014 – Mar 27, 2014

lore
Share & tools
lore

Simon Xu

author
#0 lore raw

PATCH 1/1 xinetd_tests.sh: support systemd restart

Support xinetd service restart by systemd, which is used in recent Linux releases, e.g. RHEL7.

---
 testcases/network/xinetd/xinetd_tests.sh | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
testcases/network/xinetd/xinetd_tests.sh +9 -3
index dac23a8..14b5c21 100755
@@ -59,6 +59,12 @@ chk_ifexists()
 #               - non-zero on failure.
 init()
 {
+    if [ -f "/usr/lib/systemd/system/xinetd.service" ]; then
+        RESTARTCMD="systemctl restart xinetd.service"
+    else
+        RESTARTCMD="/etc/init.d/xinetd restart"
+    fi
+
     # Initialize global variables.
     export TST_TOTAL=2
     export TCID="xinetd"
@@ -226,7 +232,7 @@ cleanup()
         sleep 1s
 
         # restoring original services
-        /etc/init.d/xinetd restart > $LTPTMP/tst_xinetd.err 2>&1
+        $RESTARTCMD > $LTPTMP/tst_xinetd.err 2>&1
         RC=$?
         if [ $RC -ne 0 ]
         then
@@ -285,7 +291,7 @@ test01()
     sleep 1s
 
     # restart xinetd to re-start the services
-    /etc/init.d/xinetd restart > $LTPTMP/tst_xinetd.out 2>&1
+    $RESTARTCMD > $LTPTMP/tst_xinetd.out 2>&1
     RC=$?
     if [ $RC -ne 0 ]
     then
@@ -352,7 +358,7 @@ test01()
     sleep 1s
 
     # restart services.
-    /etc/init.d/xinetd restart > $LTPTMP/tst_xinetd.out 2>&1
+    $RESTARTCMD > $LTPTMP/tst_xinetd.out 2>&1
     RC=$?
     if [ $RC -ne 0 ]
     then
Signature · 13 lines
1.8.5.4


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#1 lore raw

Hi!

Quoted 2 lines

Support xinetd service restart by systemd, which is used in recent Linux releases, e.g. RHEL7.

We allready have solution to this problem in testcases/lib/cmdlib.sh see restart_daemon().

I guess that the code to control daemons should be isolated from the rest of the cmdlib.sh (that is obsoleted by the test.sh). I will move the code to separate library, source it from the cmdlib.sh to retain compatibility and add docs to test-writing-guidelines. Once that is done, can you fix the test using the library code?

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#2 lore raw

Hi!

Quoted 5 lines

I guess that the code to control daemons should be isolated from the rest of the cmdlib.sh (that is obsoleted by the test.sh). I will move the code to separate library, source it from the cmdlib.sh to retain compatibility and add docs to test-writing-guidelines. Once that is done, can you fix the test using the library code?

I've pushed the changes now, the docs can be read at:

https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines

in 2.3.4 Restarting daemons

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
author
#3 lore raw

PATCH 1/1 xinetd_test.sh: restart xinetd by restart_daemon()

---
 testcases/network/xinetd/xinetd_tests.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
testcases/network/xinetd/xinetd_tests.sh +5 -3
index dac23a8..38cd7b0 100755
@@ -63,6 +63,8 @@ init()
     export TST_TOTAL=2
     export TCID="xinetd"
     export TST_COUNT=0
+    export XINETD_DAEMON='xinetd'
+    . daemonlib.sh
 
     # Inititalize cleanup function.
     trap "cleanup" 0
@@ -226,7 +228,7 @@ cleanup()
         sleep 1s
 
         # restoring original services
-        /etc/init.d/xinetd restart > $LTPTMP/tst_xinetd.err 2>&1
+        restart_daemon $XINETD_DAEMON > $LTPTMP/tst_xinetd.err 2>&1
         RC=$?
         if [ $RC -ne 0 ]
         then
@@ -285,7 +287,7 @@ test01()
     sleep 1s
 
     # restart xinetd to re-start the services
-    /etc/init.d/xinetd restart > $LTPTMP/tst_xinetd.out 2>&1
+    restart_daemon $XINETD_DAEMON > $LTPTMP/tst_xinetd.out 2>&1
     RC=$?
     if [ $RC -ne 0 ]
     then
@@ -352,7 +354,7 @@ test01()
     sleep 1s
 
     # restart services.
-    /etc/init.d/xinetd restart > $LTPTMP/tst_xinetd.out 2>&1
+    restart_daemon $XINETD_DAEMON > $LTPTMP/tst_xinetd.out 2>&1
     RC=$?
     if [ $RC -ne 0 ]
     then
Signature · 13 lines
1.9.1


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#4 lore raw

Re: [LTP] [PATCH] xinetd_test.sh: restart xinetd by restart_daemon()

Hi!

Quoted 10 lines
---
 testcases/network/xinetd/xinetd_tests.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
testcases/network/xinetd/xinetd_tests.sh +0 -0
index dac23a8..38cd7b0 100755

testcases/network/xinetd/xinetd_tests.sh init() · line 66

Quoted 4 lines
testcases/network/xinetd/xinetd_tests.sh +1 -0
@@ -63,6 +63,8 @@ init()
     export TST_TOTAL=2
     export TCID="xinetd"
     export TST_COUNT=0
+    export XINETD_DAEMON='xinetd'

I would be for passing the xinetd directly to the restart_daemon (just calling restart_daemon xinetd) function unless you know that there is a distribution that named it differently and we will need the runtime name detection.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
author
#5 lore raw

PATCH v2 1/1 xinetd_test.sh: restart xinetd by restart_daemon()

---
 testcases/network/xinetd/xinetd_tests.sh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
testcases/network/xinetd/xinetd_tests.sh +4 -3
index dac23a8..813a3f3 100755
@@ -63,6 +63,7 @@ init()
     export TST_TOTAL=2
     export TCID="xinetd"
     export TST_COUNT=0
+    . daemonlib.sh
 
     # Inititalize cleanup function.
     trap "cleanup" 0
@@ -226,7 +227,7 @@ cleanup()
         sleep 1s
 
         # restoring original services
-        /etc/init.d/xinetd restart > $LTPTMP/tst_xinetd.err 2>&1
+        restart_daemon xinetd > $LTPTMP/tst_xinetd.err 2>&1
         RC=$?
         if [ $RC -ne 0 ]
         then
@@ -285,7 +286,7 @@ test01()
     sleep 1s
 
     # restart xinetd to re-start the services
-    /etc/init.d/xinetd restart > $LTPTMP/tst_xinetd.out 2>&1
+    restart_daemon xinetd > $LTPTMP/tst_xinetd.out 2>&1
     RC=$?
     if [ $RC -ne 0 ]
     then
@@ -352,7 +353,7 @@ test01()
     sleep 1s
 
     # restart services.
-    /etc/init.d/xinetd restart > $LTPTMP/tst_xinetd.out 2>&1
+    restart_daemon xinetd > $LTPTMP/tst_xinetd.out 2>&1
     RC=$?
     if [ $RC -ne 0 ]
     then
Signature · 8 lines
1.9.1


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

Re: [LTP] [PATCH V2] xinetd_test.sh: restart xinetd by restart_daemon()

Hi!

Quoted 1 line

Pushed, thanks.

Signature · 8 lines
Cyril Hrubis
[email protected]

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