Skip to contentSkip to conversation

bind: bugfix for tests of service named.

PATCH New Wang Mingyu 2 participants 5 messages Oct 16, 2018 – Oct 18, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bind: bugfix for tests of service named.

1. remove certain addr from db file
2. restore named to the original status
3. restore file to the original status

---
 .../data/bind9/246.168.192.in-addr.arpa.db         | 10 ----
 .../{0.168.192.in-addr.arpa.db => addr.arpa.db}    |  0
 ...{20.24.10.in-addr.arpa.db => linux_test.com.db} |  2 +-
 .../data/bind9/linux_test.com.db_ARMV8             | 10 ----
 .../data/bind9/linux_test.com.db_MPC               | 10 ----
 .../data/bind9/linux_test.com.db_fedora            | 10 ----
 .../data/bind9/linux_test.com.db_p1020             | 10 ----
 .../data/bind9/linux_test.com.db_p2020             | 10 ----
 .../data/bind9/linux_test.com.db_p4080             | 10 ----
 .../data/bind9/linux_test.com.db_pandaboard        | 10 ----
 .../data/bind9/linux_test.com.db_x86               | 10 ----
 .../data/bind9/linux_test.com.db_x86_64            | 10 ----
 .../data/bind9/linux_test.com.db_zunq              | 10 ----
 .../tests/Functional.bind/data/linux_test.com.db   | 10 ----
 .../Functional.bind/data/linux_test.com.db_24      | 10 ----
 .../Functional.bind/data/linux_test.com.db_27      | 10 ----
 .../Functional.bind/data/linux_test.com.db_29      | 10 ----
 .../Functional.bind/data/linux_test.com.db_30      | 10 ----
 .../Functional.bind/data/linux_test.com.db_31      | 10 ----
 .../Functional.bind/data/linux_test.com.db_34      | 10 ----
 .../Functional.bind/data/linux_test.com.db_36      | 10 ----
 .../Functional.bind/data/linux_test.com.db_38      | 10 ----
 .../tests/Functional.bind/data/linux_test.com.db_8 | 10 ----
 engine/tests/Functional.bind/fuego_test.sh         |  6 +-
 .../Functional.bind/tests/bind_chroot_chkconf.sh   | 40 ++++---------
 .../Functional.bind/tests/bind_chroot_dig1.sh      | 64 ++++++++++----------
 .../Functional.bind/tests/bind_chroot_dig2.sh      | 65 ++++++++++----------
 .../Functional.bind/tests/bind_chroot_lport.sh     | 68 ++++++++++-----------
 .../tests/Functional.bind/tests/bind_chroot_pid.sh | 70 ++++++++++------------
 .../tests/Functional.bind/tests/bind_chroot_ps.sh  | 42 +++++++------
 .../tests/bind_chroot_rndc-confgen.sh              | 45 +++++++-------
 .../Functional.bind/tests/bind_chroot_syslog-ng.sh | 52 ++++++++--------
 .../Functional.bind/tests/bind_named_chkconf.sh    | 11 ++++
 .../Functional.bind/tests/bind_named_chkzone1.sh   | 18 +++++-
 .../Functional.bind/tests/bind_named_chkzone2.sh   | 18 +++++-
 .../tests/Functional.bind/tests/bind_named_dig1.sh | 31 ++++++++--
 .../tests/Functional.bind/tests/bind_named_dig2.sh | 28 +++++++--
 .../Functional.bind/tests/bind_named_lport.sh      | 16 ++++-
 .../Functional.bind/tests/bind_named_pidfile.sh    | 18 +++++-
 .../tests/Functional.bind/tests/bind_named_ps.sh   | 17 +++++-
 .../Functional.bind/tests/bind_named_syslog.sh     | 14 ++++-
 .../Functional.bind/tests/bind_rndc-confgen.sh     | 11 ++++
 42 files changed, 379 insertions(+), 467 deletions(-)
 delete mode 100644 engine/tests/Functional.bind/data/bind9/246.168.192.in-addr.arpa.db
 rename engine/tests/Functional.bind/data/bind9/{0.168.192.in-addr.arpa.db => addr.arpa.db} (100%)
 rename engine/tests/Functional.bind/data/bind9/{20.24.10.in-addr.arpa.db => linux_test.com.db} (94%)
 delete mode 100644 engine/tests/Functional.bind/data/bind9/linux_test.com.db_ARMV8
 delete mode 100644 engine/tests/Functional.bind/data/bind9/linux_test.com.db_MPC
 delete mode 100644 engine/tests/Functional.bind/data/bind9/linux_test.com.db_fedora
 delete mode 100644 engine/tests/Functional.bind/data/bind9/linux_test.com.db_p1020
 delete mode 100644 engine/tests/Functional.bind/data/bind9/linux_test.com.db_p2020
 delete mode 100644 engine/tests/Functional.bind/data/bind9/linux_test.com.db_p4080
 delete mode 100644 engine/tests/Functional.bind/data/bind9/linux_test.com.db_pandaboard
 delete mode 100644 engine/tests/Functional.bind/data/bind9/linux_test.com.db_x86
 delete mode 100644 engine/tests/Functional.bind/data/bind9/linux_test.com.db_x86_64
 delete mode 100644 engine/tests/Functional.bind/data/bind9/linux_test.com.db_zunq
 delete mode 100644 engine/tests/Functional.bind/data/linux_test.com.db
 delete mode 100644 engine/tests/Functional.bind/data/linux_test.com.db_24
 delete mode 100644 engine/tests/Functional.bind/data/linux_test.com.db_27
 delete mode 100644 engine/tests/Functional.bind/data/linux_test.com.db_29
 delete mode 100644 engine/tests/Functional.bind/data/linux_test.com.db_30
 delete mode 100644 engine/tests/Functional.bind/data/linux_test.com.db_31
 delete mode 100644 engine/tests/Functional.bind/data/linux_test.com.db_34
 delete mode 100644 engine/tests/Functional.bind/data/linux_test.com.db_36
 delete mode 100644 engine/tests/Functional.bind/data/linux_test.com.db_38
 delete mode 100644 engine/tests/Functional.bind/data/linux_test.com.db_8
engine/tests/Functional.bind/data/bind9/246.168.192.in-addr.arpa.db deleted +0 -10
deleted file mode 100644
index 3100047..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-1		IN PTR		linux-test.com.
engine/tests/Functional.bind/data/bind9/addr.arpa.db renamed from engine/tests/Functional.bind/data/bind9/0.168.192.in-addr.arpa.db +0 -0
similarity index 100%
rename from engine/tests/Functional.bind/data/bind9/0.168.192.in-addr.arpa.db
rename to engine/tests/Functional.bind/data/bind9/addr.arpa.db
engine/tests/Functional.bind/data/bind9/linux_test.com.db renamed from engine/tests/Functional.bind/data/bind9/20.24.10.in-addr.arpa.db +1 -1
similarity index 94%
rename from engine/tests/Functional.bind/data/bind9/20.24.10.in-addr.arpa.db
rename to engine/tests/Functional.bind/data/bind9/linux_test.com.db
index 3100047..6a163c3 100644
@@ -7,4 +7,4 @@ $TTL    86400
                                         1D )            ; minimum
                 IN NS           linux-test.com.
 		IN MX 10	linux-test.com.
-1		IN PTR		linux-test.com.
+@		IN A	        remotehost
engine/tests/Functional.bind/data/bind9/linux_test.com.db_ARMV8 deleted +0 -10
deleted file mode 100644
index 880166b..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-@		IN A	        192.168.246.59
engine/tests/Functional.bind/data/bind9/linux_test.com.db_MPC deleted +0 -10
deleted file mode 100644
index 02b6086..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-@		IN A	        192.168.246.87
engine/tests/Functional.bind/data/bind9/linux_test.com.db_fedora deleted +0 -10
deleted file mode 100644
index 7846fd5..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-@		IN A	        192.168.246.41
engine/tests/Functional.bind/data/bind9/linux_test.com.db_p1020 deleted +0 -10
deleted file mode 100644
index f39f5fb..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-@		IN A	        192.168.246.85
engine/tests/Functional.bind/data/bind9/linux_test.com.db_p2020 deleted +0 -10
deleted file mode 100644
index f4a8377..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-@		IN A	        192.168.246.86
engine/tests/Functional.bind/data/bind9/linux_test.com.db_p4080 deleted +0 -10
deleted file mode 100644
index 9f942f2..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-@		IN A	        192.168.246.90
engine/tests/Functional.bind/data/bind9/linux_test.com.db_pandaboard deleted +0 -10
deleted file mode 100644
index dc373bb..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-@		IN A	        192.168.246.129
engine/tests/Functional.bind/data/bind9/linux_test.com.db_x86 deleted +0 -10
deleted file mode 100644
index 7846fd5..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-@		IN A	        192.168.246.41
engine/tests/Functional.bind/data/bind9/linux_test.com.db_x86_64 deleted +0 -10
deleted file mode 100644
index ca836b5..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-@		IN A	        192.168.246.61
engine/tests/Functional.bind/data/bind9/linux_test.com.db_zunq deleted +0 -10
deleted file mode 100644
index d24501f..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-@		IN A	        192.168.246.136
engine/tests/Functional.bind/data/linux_test.com.db deleted +0 -10
deleted file mode 100644
index 7846fd5..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-@		IN A	        192.168.246.41
engine/tests/Functional.bind/data/linux_test.com.db_24 deleted +0 -10
deleted file mode 100644
index 02b6086..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-@		IN A	        192.168.246.87
engine/tests/Functional.bind/data/linux_test.com.db_27 deleted +0 -10
deleted file mode 100644
index ca836b5..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-@		IN A	        192.168.246.61
engine/tests/Functional.bind/data/linux_test.com.db_29 deleted +0 -10
deleted file mode 100644
index f4a8377..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-@		IN A	        192.168.246.86
engine/tests/Functional.bind/data/linux_test.com.db_30 deleted +0 -10
deleted file mode 100644
index dc373bb..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-@		IN A	        192.168.246.129
engine/tests/Functional.bind/data/linux_test.com.db_31 deleted +0 -10
deleted file mode 100644
index f39f5fb..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-@		IN A	        192.168.246.85
engine/tests/Functional.bind/data/linux_test.com.db_34 deleted +0 -10
deleted file mode 100644
index 9f942f2..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-@		IN A	        192.168.246.90
engine/tests/Functional.bind/data/linux_test.com.db_36 deleted +0 -10
deleted file mode 100644
index d24501f..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-@		IN A	        192.168.246.136
engine/tests/Functional.bind/data/linux_test.com.db_38 deleted +0 -10
deleted file mode 100644
index 880166b..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-@		IN A	        192.168.246.59
engine/tests/Functional.bind/data/linux_test.com.db_8 deleted +0 -10
deleted file mode 100644
index 7846fd5..0000000
@@ -1,10 +0,0 @@
-$TTL    86400
-@               IN SOA  linux-test.com. root.linux-test.com. (
-                                        42              ; serial (d. adams)
-                                        3H              ; refresh
-                                        15M             ; retry
-                                        1W              ; expiry
-                                        1D )            ; minimum
-                IN NS           linux-test.com.
-		IN MX 10	linux-test.com.
-@		IN A	        192.168.246.41
engine/tests/Functional.bind/fuego_test.sh +4 -2
index 7e4fa2d..82e29b7 100644
@@ -1,3 +1,5 @@
+NEED_ROOT=1
+
 function test_pre_check {
     is_on_target_path named-checkconf PROGRAM_CHECKCONF
     assert_define PROGRAM_CHECKCONF "Missing 'bind' program on target board"
@@ -22,8 +24,8 @@ function test_deploy {
 
 function test_run {
     report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
-    export tst_bind_file=246.168.192.in-addr.arpa.db;\
-    export test_target_conf=x86_64;\
+    export tst_bind_file=$ADDR.in-addr.arpa.db;\
+    export test_target_conf=$TARGET_ARCH;\
     export remotehost=$IPADDR;\
     ./bind_test.sh"
 }
engine/tests/Functional.bind/tests/bind_chroot_chkconf.sh +12 -28
index 5a6fbb7..e69ce30 100644
@@ -4,40 +4,20 @@
 
 test="chroot_chkconf"
 
-kill -9 $(pgrep named)
-
-if [ ! -d /var/named/chroot/etc/bind ]
+if [ -d /var/named/ ]
 then
-    mkdir -p /var/named/chroot/etc/bind
-fi
-
-if [ ! $(ls /var/named/chroot/etc/bind/) ]
-then
-    cp -f /etc/bind/* /var/named/chroot/etc/bind/
-fi
-
-if [ ! -d /var/named/chroot/var/named ]
-then
-    mkdir -p /var/named/chroot/var/named
-fi
-
-if [ ! -d /var/named/chroot/var/cache/bind ]
-then
-    mkdir -p /var/named/chroot/var/cache/bind
-fi
-
-if [ ! -d /var/named/chroot/var/run/named ]
-then
-    mkdir -p /var/named/chroot/var/run/named
+    mv /var/named/ /var/named_bak
 fi
 
+mkdir -p /var/named/chroot/etc/bind
+cp -f /etc/bind/* /var/named/chroot/etc/bind/
+mkdir -p /var/named/chroot/var/named
+mkdir -p /var/named/chroot/var/cache/bind
+mkdir -p /var/named/chroot/var/run/named
 cp /etc/sysconfig/named /etc/sysconfig/named_bak
 cp data/bind9/sysconfig/named /etc/sysconfig/named
 
-if [ ! -f /var/named/chroot/etc/bind/named.conf ]
-then
-    touch /var/named/chroot/etc/bind/named.conf
-fi
+touch /var/named/chroot/etc/bind/named.conf
 
 cp data/bind9/named.conf /var/named/chroot/etc/bind/named.conf
 
@@ -49,4 +29,8 @@ else
 fi
 
 rm -rf /var/named
+if [ -d /var/named_bak ]
+then
+    mv /var/named_bak /var/named
+fi
 mv /etc/sysconfig/named_bak /etc/sysconfig/named
engine/tests/Functional.bind/tests/bind_chroot_dig1.sh +31 -33

119 lines not on this page · raw message

engine/tests/Functional.bind/tests/bind_chroot_dig2.sh +32 -33

121 lines not on this page · raw message

engine/tests/Functional.bind/tests/bind_chroot_lport.sh +33 -35

128 lines not on this page · raw message

engine/tests/Functional.bind/tests/bind_chroot_pid.sh +31 -39

129 lines not on this page · raw message

engine/tests/Functional.bind/tests/bind_chroot_ps.sh +23 -19

60 lines not on this page · raw message

engine/tests/Functional.bind/tests/bind_chroot_rndc-confgen.sh +22 -23

70 lines not on this page · raw message

engine/tests/Functional.bind/tests/bind_chroot_syslog-ng.sh +28 -24

77 lines not on this page · raw message

engine/tests/Functional.bind/tests/bind_named_chkconf.sh +11 -0
index 7914e0d..38d28e8 100644
@@ -8,6 +8,12 @@ test="named_chkconf"
 
 set_init_manager
 
+named_status=0
+if exec_service_on_target named status | grep "running"
+then
+    named_status=1
+fi
+
 exec_service_on_target named stop
 
 if [ -f /etc/bind/named.conf ]
@@ -28,3 +34,8 @@ if [ -f /etc/bind/named.conf_bak ]
 then
     mv /etc/bind/named.conf_bak /etc/bind/named.conf
 fi
+
+if named_status=1
+then
+    exec_service_on_target named start
+fi
engine/tests/Functional.bind/tests/bind_named_chkzone1.sh +16 -2
index 40a6387..637d4bd 100644
@@ -8,6 +8,12 @@ test="named_chkzone1"
 
 set_init_manager
 
+named_status=0
+if exec_service_on_target named status | grep "running"
+then
+    named_status=1
+fi
+
 exec_service_on_target named stop
 
 if [ ! -d /var/named ]
@@ -15,8 +21,10 @@ then
     mkdir -p /var/named
 fi
 
-cp data/bind9/$tst_bind_file /var/named/$tst_bind_file
-cp data/bind9/linux_test.com.db_$test_target_conf /var/named/linux_test.com.db
+cp data/bind9/addr.arpa.db /var/named/$tst_bind_file
+cp data/bind9/linux_test.com.db data/bind9/linux_test.com.db_bak
+sed -i 's/remotehost/'"$remotehost"'/g' data/bind9/linux_test.com.db
+cp data/bind9/linux_test.com.db /var/named/linux_test.com.db
 
 if named-checkzone linux-test.com /var/named/linux_test.com.db
 then
@@ -26,3 +34,9 @@ else
 fi
 
 rm -f /var/named/$tst_bind_file /var/named/linux_test.com.db
+mv data/bind9/linux_test.com.db_bak data/bind9/linux_test.com.db
+
+if named_status=1
+then
+    exec_service_on_target named start
+fi
engine/tests/Functional.bind/tests/bind_named_chkzone2.sh +16 -2
index 6a3da22..3b14b3b 100644
@@ -8,6 +8,12 @@ test="named_chkzone2"
 
 set_init_manager
 
+named_status=0
+if exec_service_on_target named status | grep "running"
+then
+    named_status=1
+fi
+
 exec_service_on_target named stop
 
 if [ ! -d /var/named ]
@@ -15,8 +21,10 @@ then
     mkdir -p /var/named
 fi
 
-cp data/bind9/$tst_bind_file /var/named/$tst_bind_file
-cp data/bind9/linux_test.com.db_$test_target_conf /var/named/linux_test.com.db
+cp data/bind9/addr.arpa.db /var/named/$tst_bind_file
+cp data/bind9/linux_test.com.db data/bind9/linux_test.com.db_bak
+sed -i 's/remotehost/'"$remotehost"'/g' data/bind9/linux_test.com.db
+cp data/bind9/linux_test.com.db /var/named/linux_test.com.db
 
 if named-checkzone 192.168.0.0 /var/named/$tst_bind_file
 then
@@ -26,3 +34,9 @@ else
 fi
 
 rm -f /var/named/$tst_bind_file /var/named/linux_test.com.db
+mv data/bind9/linux_test.com.db_bak data/bind9/linux_test.com.db
+
+if named_status=1
+then
+    exec_service_on_target named start
+fi
engine/tests/Functional.bind/tests/bind_named_dig1.sh +26 -5
index 8cbbdb1..c4c8a15 100644
@@ -2,13 +2,18 @@
 
 # Start the named on target.
 # Check the IP address.
-
 test="named_dig1"
 
 . ./fuego_board_function_lib.sh
 
 set_init_manager
 
+named_status=0
+if exec_service_on_target named status | grep "running"
+then
+    named_status=1
+fi
+
 exec_service_on_target named stop
 
 if [ ! -f /etc/bind/named.conf ]
@@ -36,13 +41,17 @@ cp data/bind9/named.conf /etc/bind/named.conf
 mv /etc/bind/rndc.conf /etc/bind/rndc.conf_bak
 cp data/bind9/rndc.conf /etc/bind/rndc.conf
 
-if [ ! -d /var/named ]
+if [ -d /var/named/ ]
 then
-    mkdir -p /var/named
+    mv /var/named /var/named_bak
 fi
 
-cp data/bind9/$tst_bind_file /var/named/$tst_bind_file
-cp data/bind9/linux_test.com.db_$test_target_conf /var/named/linux_test.com.db
+mkdir -p /var/named
+
+cp data/bind9/addr.arpa.db /var/named/$tst_bind_file
+cp data/bind9/linux_test.com.db data/bind9/linux_test.com.db_bak
+sed -i 's/remotehost/'"$remotehost"'/g' data/bind9/linux_test.com.db
+cp data/bind9/linux_test.com.db /var/named/linux_test.com.db
 if [ ! -f /etc/hosts ]
 then
     touch /etc/hosts
@@ -50,6 +59,8 @@ fi
 mv /etc/hosts /etc/hosts_bak
 cp data/bind9/hosts /etc/hosts
 
+sleep 10
+
 exec_service_on_target named start
 
 if dig linux-test.com | grep $remotehost
@@ -64,5 +75,15 @@ exec_service_on_target named stop
 mv /etc/resolv.conf_bak /etc/resolv.conf
 mv /etc/bind/named.conf_bak /etc/bind/named.conf
 mv /etc/bind/rndc.conf_bak /etc/bind/rndc.conf
+mv data/bind9/linux_test.com.db_bak data/bind9/linux_test.com.db
 rm -fr /var/named
+if [ -d /var/named_bak ]
+then
+    mv /var/named_bak /var/named
+fi
 mv /etc/hosts_bak /etc/hosts
+
+if named_status=1
+then
+    exec_service_on_target named start
+fi
engine/tests/Functional.bind/tests/bind_named_dig2.sh +24 -4
index 1259f3e..bbca187 100644
@@ -9,6 +9,12 @@ test="named_dig2"
 
 set_init_manager
 
+named_status=0
+if exec_service_on_target named status | grep "running"
+then
+    named_status=1
+fi
+
 exec_service_on_target named stop
 
 if [ ! -f /etc/bind/named.conf ]
@@ -49,13 +55,17 @@ fi
 mv /etc/bind/rndc.key /etc/bind/rndc.key_bak
 cp data/bind9/rndc.key /etc/bind/rndc.key
 
-if [ ! -d /var/named ]
+if [ -d /var/named/ ]
 then
-    mkdir -p /var/named
+    mv /var/named /var/named_bak
 fi
 
-cp data/bind9/$tst_bind_file /var/named/$tst_bind_file
-cp data/bind9/linux_test.com.db_$test_target_conf /var/named/linux_test.com.db
+mkdir -p /var/named
+
+cp data/bind9/addr.arpa.db /var/named/$tst_bind_file
+cp data/bind9/linux_test.com.db data/bind9/linux_test.com.db_bak
+sed -i 's/remotehost/'"$remotehost"'/g' data/bind9/linux_test.com.db
+cp data/bind9/linux_test.com.db /var/named/linux_test.com.db
 if [ ! -f /etc/hosts ]
 then
     touch /etc/hosts
@@ -80,6 +90,16 @@ mv /etc/resolv.conf_bak /etc/resolv.conf
 mv /etc/bind/named.conf_bak /etc/bind/named.conf
 mv /etc/bind/rndc.conf_bak /etc/bind/rndc.conf
 mv /etc/bind/rndc.key_bak /etc/bind/rndc.key
+mv data/bind9/linux_test.com.db_bak data/bind9/linux_test.com.db
 
 rm -fr /var/named
+if [ -d /var/named_bak ]
+then
+    mv /var/named_bak /var/named
+fi
 mv /etc/hosts_bak /etc/hosts
+
+if named_status=1
+then
+    exec_service_on_target named start
+fi
engine/tests/Functional.bind/tests/bind_named_lport.sh +14 -2
index 0a171a6..bb40608 100644
@@ -9,6 +9,12 @@ test="named_lport"
 
 set_init_manager
 
+named_status=0
+if exec_service_on_target named status | grep "running"
+then
+    named_status=1
+fi
+
 if [ -f /etc/bind/rndc.key ]
 then
     rm -f /etc/bind/rndc.key
@@ -31,7 +37,10 @@ then
 else
     echo " -> port 53 is not exist."
     echo " -> $test: TEST-FAIL"
-    exec_service_on_target named stop
+    if named_status=0
+    then
+        exec_service_on_target named stop
+    fi
     exit
 fi
 
@@ -43,4 +52,7 @@ else
     echo " -> $test: TEST-FAIL"
 fi
 
-exec_service_on_target named stop
+if named_status=0
+then
+    exec_service_on_target named stop
+fi
engine/tests/Functional.bind/tests/bind_named_pidfile.sh +17 -1
index be2fc89..c92f3d5 100644
@@ -9,6 +9,12 @@ test="named_pidfile"
 
 set_init_manager
 
+named_status=0
+if exec_service_on_target named status | grep "running"
+then
+    named_status=1
+fi
+
 if [ -f /etc/bind/rndc.key ]
 then
     rm -f /etc/bind/rndc.key
@@ -16,6 +22,8 @@ fi
 
 exec_service_on_target named stop
 
+sleep 5
+
 if exec_service_on_target named start
 then
     echo " -> start of named succeeded."
@@ -31,7 +39,10 @@ then
 else
     echo " -> pid file of named is not exist."
     echo " -> $test: TEST-FAIL"
-    exec_service_on_target named stop
+    if named_status=0
+    then
+        exec_service_on_target named stop
+    fi
     exit
 fi
 
@@ -50,3 +61,8 @@ then
 else
     echo " -> $test: TEST-FAIL"
 fi
+
+if named_status=1
+then
+    exec_service_on_target named start
+fi
engine/tests/Functional.bind/tests/bind_named_ps.sh +16 -1
index cd5fcc0..b6abc02 100644
@@ -8,8 +8,16 @@ test="named_ps"
 
 set_init_manager
 
+named_status=0
+if exec_service_on_target named status | grep "running"
+then
+    named_status=1
+fi
+
 exec_service_on_target named stop
 
+sleep 5
+
 if exec_service_on_target named start
 then
     echo " -> start of named succeeded."
@@ -27,7 +35,10 @@ then
 else
     echo " -> can't get the process of named."
     echo " -> $test: TEST-FAIL"
-    exec_service_on_target named stop
+    if named_status=0
+    then
+        exec_service_on_target named stop
+    fi
     exit
 fi
 
@@ -39,3 +50,7 @@ then
 else
     echo " -> $test: TEST-PASS"
 fi
+if named_status=1
+then
+    exec_service_on_target named start
+fi
engine/tests/Functional.bind/tests/bind_named_syslog.sh +11 -3
index 0b7c690..50cd931 100644
@@ -10,6 +10,12 @@ test="named_syslog"
 set_init_manager
 logger_service=$(detect_logger_service)
 
+named_status=0
+if exec_service_on_target named status | grep "running"
+then
+    named_status=1
+fi
+
 if [ -f /etc/bind/rndc.key ]
 then
     rm -f /etc/bind/rndc.key
@@ -33,7 +39,6 @@ then
 else
     echo " -> start of named failed."
     echo " -> $test: TEST-FAIL"
-    exec_service_on_target named stop
     if [ -f /var/log/syslog_bak ]
     then
         mv /var/log/syslog_bak /var/log/syslog
@@ -49,9 +54,12 @@ else
     echo " -> $test: TEST-FAIL"
 fi
 
-exec_service_on_target named stop
+if named_status=0
+then
+    exec_service_on_target named stop
+fi
+
 if [ -f /var/log/syslog_bak ]
 then
     mv /var/log/syslog_bak /var/log/syslog
 fi
-
engine/tests/Functional.bind/tests/bind_rndc-confgen.sh +11 -0
index adc38ca..da3e8a7 100644
@@ -8,6 +8,12 @@ test="rndc-confgen"
 
 set_init_manager
 
+named_status=0
+if exec_service_on_target named status | grep "running"
+then
+    named_status=1
+fi
+
 exec_service_on_target named stop
 
 if [ -f /etc/bind/rndc.key ]
@@ -33,3 +39,8 @@ then
 else
     rm -f /etc/bind/rndc.key
 fi
+
+if named_status=1
+then
+    exec_service_on_target named start
+fi
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 Add a core function: assert_has_program().

This function is used to combine the code that check whether a program or file exists, from 2 lines into a single function call. Called like so:
assert_has_program expect

---
 engine/scripts/functions.sh | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
engine/scripts/functions.sh +25 -0
index ff7b272..fe236c4 100644
@@ -961,3 +961,28 @@ function is_on_sdk {
     export $2=$LOCATION
     rm -f $tmpfile
 }
+
+# check for a program or file on the target, and send message if the program or file is missing
+# $1 - file, dir or program on target
+function assert_has_program {
+    # FIXTHIS: race condition
+    tmpfile=$(mktemp /tmp/found_loc.XXXXXX)
+    cmd "touch $tmpfile"
+    if [ -z "$PATH" ] ; then
+        safe_cmd "find / -name \"$1\" | head -n 1 >$tmpfile"
+    else
+        # split search path on colon
+        for d in $(echo "$PATH" | tr ":" "\n") ; do
+            # execute a command on the target to detect $d/$1
+            cmd "if [ -z \"\$(cat $tmpfile)\" -a -e \"$d/$1\" ] ; then echo \"$d/$1\" >$tmpfile ; fi"
+        done
+    fi
+    get $tmpfile $tmpfile
+    varname=$(cat $tmpfile)
+    cmd "rm $tmpfile"
+    rm -f $tmpfile # -f for tests running on the host
+    if [ -z "$varname" ]
+    then
+        abort_job "$1 is not defined. Missing '$1' program on target board"
+    fi
+}
Signature · 1 line
1.8.3.1
#2 lore raw

Re: [Fuego] [PATCH] Add a core function: assert_has_program().

Thanks for working on this.

This was a bit more complicated of an solution that I expected.

Some feedback below...

Quoted 23 lines

-----Original Message-----
From: Wang Mingyu

This function is used to combine the code that check whether a program or file exists, from 2 lines into a single function call.
Called like so:
assert_has_program expect

---
 engine/scripts/functions.sh | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
engine/scripts/functions.sh +2 -0
index ff7b272..fe236c4 100644
@@ -961,3 +961,28 @@ function is_on_sdk {
     export $2=$LOCATION
     rm -f $tmpfile
 }
+
+# check for a program or file on the target, and send message if the
Quoted 2 lines

program or file is missing
+# $1 - file, dir or program on target

It looks like what you've done is copied is_on_target, (which is OK), but it would have been better, IMHO to just re-use is_on_target_path (without copying it).

engine/scripts/functions.sh function is_on_sdk { · line 971

Quoted 5 lines
engine/scripts/functions.sh +5 -0
+function assert_has_program {
+    # FIXTHIS: race condition
+    tmpfile=$(mktemp /tmp/found_loc.XXXXXX)
+    cmd "touch $tmpfile"
+    if [ -z "$PATH" ] ; then

$PATH is the path on the host, not on the board.

Quoted 19 lines
engine/scripts/functions.sh +6 -0
+        safe_cmd "find / -name \"$1\" | head -n 1 >$tmpfile"
+    else
+        # split search path on colon
+        for d in $(echo "$PATH" | tr ":" "\n") ; do
+            # execute a command on the target to detect $d/$1
+            cmd "if [ -z \"\$(cat $tmpfile)\" -a -e \"$d/$1\" ] ; then echo \"$d/$1\"
Quoted 1 line

$tmpfile ; fi"

engine/scripts/functions.sh +11 -1
+        done
+    fi
+    get $tmpfile $tmpfile
+    varname=$(cat $tmpfile)
+    cmd "rm $tmpfile"
+    rm -f $tmpfile # -f for tests running on the host
+    if [ -z "$varname" ]
+    then
+        abort_job "$1 is not defined. Missing '$1' program on target board"
+    fi
+}
--
Quoted 1 line

1.8.3.1

I think this can be simplified to something like this:
I haven't tested this.

#$1 has the program that is required on the target board

# this has the side effect of defining PROGRAM_$1 (uppercased)
# with the value as the directory where $1 is found on the board.
function assert_has_program {
   upName="$(echo "$1" | tr '.' '_')"
   progVar="PROGRAM_${upName}"
   is_on_target_path $1 ${!progVAR}
   assert_define ${!progVar} "Missing '$1' program on target board"
}

Can you try this approach and let me know if it works?
-- Tim

#3 lore raw

Re: [Fuego] [PATCH] Add a core function: assert_has_program().

Hi Tim

Some modifications to the code have been made as follows:

function assert_has_program {
upName="$(echo "$1" | tr '.' '_')"
progVar_orig="PROGRAM_${upName}"
progVar=${progVar_orig//-/_}
================> The export variable name cannot contain '-', so it has been
replaced. I'm not sure if this is a good solution.
is_on_target_path $1 ${progVar}
assert_define ${progVar} "Missing '$1' program on target board"
}

by Wangmy

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Thursday, October 18, 2018 5:31 AM
To: Wang, Mingyu/王 鸣瑜 <[email protected]>; [email protected]
Subject: RE: [Fuego] [PATCH] Add a core function: assert_has_program().

Thanks for working on this.

This was a bit more complicated of an solution that I expected.

Some feedback below...

Quoted 23 lines

-----Original Message-----
From: Wang Mingyu

This function is used to combine the code that check whether a program or file exists, from 2 lines into a single function call. Called like so:
assert_has_program expect

---
 engine/scripts/functions.sh | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
engine/scripts/functions.sh +2 -0
index ff7b272..fe236c4 100644
@@ -961,3 +961,28 @@ function is_on_sdk {
     export $2=$LOCATION
     rm -f $tmpfile
 }
+
+# check for a program or file on the target, and send message if the
Quoted 2 lines

program or file is missing
+# $1 - file, dir or program on target

It looks like what you've done is copied is_on_target, (which is OK), but it would have been better, IMHO to just re-use is_on_target_path (without copying it).

engine/scripts/functions.sh function is_on_sdk { · line 971

Quoted 5 lines
engine/scripts/functions.sh +5 -0
+function assert_has_program {
+    # FIXTHIS: race condition
+    tmpfile=$(mktemp /tmp/found_loc.XXXXXX)
+    cmd "touch $tmpfile"
+    if [ -z "$PATH" ] ; then

$PATH is the path on the host, not on the board.

Quoted 19 lines
engine/scripts/functions.sh +6 -0
+        safe_cmd "find / -name \"$1\" | head -n 1 >$tmpfile"
+    else
+        # split search path on colon
+        for d in $(echo "$PATH" | tr ":" "\n") ; do
+            # execute a command on the target to detect $d/$1
+            cmd "if [ -z \"\$(cat $tmpfile)\" -a -e \"$d/$1\" ] ; then echo \"$d/$1\"
Quoted 1 line

$tmpfile ; fi"

engine/scripts/functions.sh +11 -1
+        done
+    fi
+    get $tmpfile $tmpfile
+    varname=$(cat $tmpfile)
+    cmd "rm $tmpfile"
+    rm -f $tmpfile # -f for tests running on the host
+    if [ -z "$varname" ]
+    then
+        abort_job "$1 is not defined. Missing '$1' program on target board"
+    fi
+}
--
Quoted 1 line

1.8.3.1

I think this can be simplified to something like this:
I haven't tested this.

#$1 has the program that is required on the target board # this has the side effect of defining PROGRAM_$1 (uppercased) # with the value as the directory where $1 is found on the board. function assert_has_program {
upName="$(echo "$1" | tr '.' '_')"
progVar="PROGRAM_${upName}"
is_on_target_path $1 ${!progVAR}
assert_define ${!progVar} "Missing '$1' program on target board"
}

Can you try this approach and let me know if it works?
-- Tim

#4 lore raw

Re: [Fuego] [PATCH] Add a core function: assert_has_program().

Quoted 9 lines

-----Original Message-----
From: Wang, Mingyu

Hi Tim

Some modifications to the code have been made as follows:

Quoted 8 lines
function assert_has_program {
   upName="$(echo "$1" | tr '.' '_')"
   progVar_orig="PROGRAM_${upName}"
   progVar=${progVar_orig//-/_}
                              ================> The export variable name cannot

contain '-', so it has been
replaced. I'm not sure if this is a good
solution.

Looks good to me. This shell substitution looks more efficient than the 'echo | tr' that I used, so we should use it there also:
upName=${1//./_}

Quoted 3 lines

is_on_target_path $1 ${progVar}
assert_define ${progVar} "Missing '$1' program on target board"
}

Nice catch on the variables here. They shouldn't have been ${!progVar}, but ${progVar} as you have them.

Can you re-submit the patch with the changes?

Thanks,
-- Tim

Quoted 91 lines

by Wangmy

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Thursday, October 18, 2018 5:31 AM
To: Wang, Mingyu/王 鸣瑜 <[email protected]>; [email protected]
Subject: RE: [Fuego] [PATCH] Add a core function: assert_has_program().

Thanks for working on this.

This was a bit more complicated of an solution that I expected.

Some feedback below...

Quoted 23 lines

-----Original Message-----
From: Wang Mingyu

This function is used to combine the code that check whether a program or file exists, from 2 lines into a single function call. Called like so:
assert_has_program expect

---
 engine/scripts/functions.sh | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
engine/scripts/functions.sh +2 -0
index ff7b272..fe236c4 100644
@@ -961,3 +961,28 @@ function is_on_sdk {
     export $2=$LOCATION
     rm -f $tmpfile
 }
+
+# check for a program or file on the target, and send message if the
Quoted 2 lines

program or file is missing
+# $1 - file, dir or program on target

It looks like what you've done is copied is_on_target, (which is OK), but it would have been better, IMHO to just re-use is_on_target_path (without copying it).

engine/scripts/functions.sh function is_on_sdk { · line 971

Quoted 5 lines
engine/scripts/functions.sh +5 -0
+function assert_has_program {
+    # FIXTHIS: race condition
+    tmpfile=$(mktemp /tmp/found_loc.XXXXXX)
+    cmd "touch $tmpfile"
+    if [ -z "$PATH" ] ; then

$PATH is the path on the host, not on the board.

engine/scripts/functions.sh function is_on_sdk {

Quoted 6 lines
engine/scripts/functions.sh +6 -0
+        safe_cmd "find / -name \"$1\" | head -n 1 >$tmpfile"
+    else
+        # split search path on colon
+        for d in $(echo "$PATH" | tr ":" "\n") ; do
+            # execute a command on the target to detect $d/$1
+            cmd "if [ -z \"\$(cat $tmpfile)\" -a -e \"$d/$1\" ] ; then echo

\"$d/$1\"

Quoted 13 lines
Quoted 1 line

$tmpfile ; fi"

engine/scripts/functions.sh +11 -1
+        done
+    fi
+    get $tmpfile $tmpfile
+    varname=$(cat $tmpfile)
+    cmd "rm $tmpfile"
+    rm -f $tmpfile # -f for tests running on the host
+    if [ -z "$varname" ]
+    then
+        abort_job "$1 is not defined. Missing '$1' program on target board"
+    fi
+}
--
Quoted 1 line

1.8.3.1

I think this can be simplified to something like this:
I haven't tested this.

#$1 has the program that is required on the target board # this has the side effect of defining PROGRAM_$1 (uppercased) # with the value as the directory where $1 is found on the board.

function assert_has_program {
   upName="$(echo "$1" | tr '.' '_')"
   progVar="PROGRAM_${upName}"
   is_on_target_path $1 ${!progVAR}
   assert_define ${!progVar} "Missing '$1' program on target board"
}

Can you try this approach and let me know if it works?
-- Tim