Skip to contentSkip to conversation

logrotate: remove the test case using ntpdate.

PATCH In review Wang Mingyu 2 participants 6 messages Nov 25, 2019 – Dec 2, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 logrotate: remove the test case using ntpdate.

---
 tests/Functional.logrotate/fuego_test.sh      |  1 -
 .../tests/logrotate_rotation.sh               |  4 +-
 .../tests/logrotate_size.sh                   | 39 -------------------
 3 files changed, 1 insertion(+), 43 deletions(-)
 delete mode 100644 tests/Functional.logrotate/tests/logrotate_size.sh
tests/Functional.logrotate/fuego_test.sh +0 -1
index c6e0579..856871e 100644
@@ -2,7 +2,6 @@ NEED_ROOT=1
 
 function test_pre_check {
     assert_has_program logrotate
-    assert_has_program ntpdate
     assert_has_program date
 }
 
tests/Functional.logrotate/tests/logrotate_rotation.sh +1 -3
index f0d5e92..75616b4 100644
@@ -15,11 +15,9 @@ then
     mv /var/lib/logrotate.status /var/lib/logrotate.status_bak
 fi
 
-ntpdate $test_host
-
 cp data/test.conf /etc/logrotate.d/test.conf
 
-touch /var/log/testlog
+cp data/testlog100k /var/log/testlog
 
 cp data/testlog.sh data/testlog_test.sh
 chmod +x data/testlog_test.sh
tests/Functional.logrotate/tests/logrotate_size.sh deleted +0 -39
deleted file mode 100644
index 2e215cd..0000000
@@ -1,39 +0,0 @@
-#!/bin/sh
-
-#  Verify that the rotate file is created in the specified directory.
-#  option : -v
-
-test="log rotation size"
-
-if [ -f /var/log/testlog* ]
-then
-    rm -f /var/log/testlog*
-fi
-
-if [ -f /var/lib/logrotate.status ]
-then
-    mv /var/lib/logrotate.status /var/lib/logrotate.status_bak
-fi
-cp data/test.conf /etc/logrotate.d/test.conf
-
-cp data/testlog100k /var/log/testlog
-
-cp data/testlog.sh data/testlog_test.sh
-chmod +x data/testlog_test.sh
-data/testlog_test.sh
-chown root /etc/logrotate.d/test.conf
-logrotate -v /etc/logrotate.d/test.conf
-if ls /var/log/testlog.1
-then
-    echo " -> $test: TEST-PASS"
-else
-    echo " -> $test: TEST-FAIL"
-fi
-
-rm -f /etc/logrotate.d/test.conf
-rm -f /var/log/testlog*
-rm -f data/testlog_test.sh
-if [ -f /var/lib/logrotate.status_bak ]
-then
-    mv /var/lib/logrotate.status_bak /var/lib/logrotate.status
-fi
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 openvpn: Add NEED_ROOT and modify testcli.conf

Functional.openvpn does a lot of manipulation of system-wide configuration files, loading/unloading modules and starting/ stopping services. These all require root permissions.

The specific ip address is written in testcli.conf, which does not apply to boards on other network segments. So change it to the variable set in the boad file.

---
 tests/Functional.openvpn/data/testcli.conf |  2 +-
 tests/Functional.openvpn/fuego_test.sh     |  1 +
 tests/Functional.openvpn/test.yaml         | 23 ++++++++++++++++++++++
 3 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100644 tests/Functional.openvpn/test.yaml
tests/Functional.openvpn/data/testcli.conf +1 -1
index 2fab877..db83f84 100644
@@ -1,4 +1,4 @@
-remote  192.168.0.1
+remote  remote_host
 port    5000
 dev     tap
 #dev    tun
tests/Functional.openvpn/fuego_test.sh +1 -0
index 285c008..275a63a 100644
@@ -15,6 +15,7 @@ function test_deploy {
 
 function test_run {
     report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    sed -i 's/remote_host/'"$SRV_IP"'/g' data/testcli.conf;\
     ./openvpn_test.sh"
 }
 
tests/Functional.openvpn/test.yaml new file +23 -0
new file mode 100644
index 0000000..e1cbaa5
@@ -0,0 +1,23 @@
+fuego_package_version: 1
+name: Functional.openvpn
+description: |
+      OpenVPN is a robust and highly flexible VPN daemon.
+      This is a simple test to check the ps/pid/syslog, listening port
+      and device interface of openvpn. 
+license: BSD-3-Clause 
+author: Wang Mingyu <[email protected]>
+maintainer: Wang Mingyu <[email protected]>
+version: 2.00
+fuego_release: 1
+type: Functional
+tags: ['openvpn']
+params:
+    SRV_IP:
+        description: the IP address of host - Defined in board file
+data_files:
+ - openvpn_test.sh
+ - fuego_test.sh
+ - spec.json
+ - test.yaml
+ - data
+ - tests
Signature · 1 line
2.17.1
#2 lore raw

Re: [Fuego] [PATCH] openvpn: Add NEED_ROOT and modify testcli.conf

Quoted 8 lines

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

Functional.openvpn does a lot of manipulation of system-wide configuration files, loading/unloading modules and starting/ stopping services. These all require root permissions.

This patch doesn't affect NEED_ROOT. That was apparently already applied in a previous patch. So I removed the paragraph above from the commit message.

Quoted 4 lines

The specific ip address is written in testcli.conf, which does not apply to boards on other network segments. So change it to the variable set in the boad file.

This patch also adds a test.yaml file, so I added something about that in the commit description and summary line.

Quoted 63 lines
---
 tests/Functional.openvpn/data/testcli.conf |  2 +-
 tests/Functional.openvpn/fuego_test.sh     |  1 +
 tests/Functional.openvpn/test.yaml         | 23 ++++++++++++++++++++++
 3 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100644 tests/Functional.openvpn/test.yaml
tests/Functional.openvpn/data/testcli.conf +1 -1
index 2fab877..db83f84 100644
@@ -1,4 +1,4 @@
-remote  192.168.0.1
+remote  remote_host
 port    5000
 dev     tap
 #dev    tun
tests/Functional.openvpn/fuego_test.sh +1 -0
index 285c008..275a63a 100644
@@ -15,6 +15,7 @@ function test_deploy {
 
 function test_run {
     report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    sed -i 's/remote_host/'"$SRV_IP"'/g' data/testcli.conf;\
     ./openvpn_test.sh"
 }
 
tests/Functional.openvpn/test.yaml new file +23 -1
new file mode 100644
index 0000000..e1cbaa5
@@ -0,0 +1,23 @@
+fuego_package_version: 1
+name: Functional.openvpn
+description: |
+      OpenVPN is a robust and highly flexible VPN daemon.
+      This is a simple test to check the ps/pid/syslog, listening port
+      and device interface of openvpn.
+license: BSD-3-Clause
+author: Wang Mingyu <[email protected]>
+maintainer: Wang Mingyu <[email protected]>
+version: 2.00
+fuego_release: 1
+type: Functional
+tags: ['openvpn']
+params:
+    SRV_IP:
+        description: the IP address of host - Defined in board file
+data_files:
+ - openvpn_test.sh
+ - fuego_test.sh
+ - spec.json
+ - test.yaml
+ - data
+ - tests
--
Quoted 1 line

2.17.1

Looks good. Thanks. Applied.
-- Tim

#3 lore raw

PATCH 1/1 samba: Add test case to access the server on target from host.

In reply to Wang Mingyu
---
 tests/Functional.samba/data/smb04.conf        |   8 +-
 tests/Functional.samba/data/smb05.conf        |  19 ++++
 tests/Functional.samba/data/smb06.conf        |  18 ++++
 tests/Functional.samba/fuego_test.sh          |  19 +++-
 tests/Functional.samba/samba_test.sh          |   8 +-
 tests/Functional.samba/test.yaml              |   8 +-
 .../Functional.samba/tests/restore_target.sh  |  23 ++++
 tests/Functional.samba/tests/test_samba04.sh  |  22 ++--
 tests/Functional.samba/tests/test_samba05.sh  | 102 ++++++++++++++++++
 tests/Functional.samba/tests/test_samba06.sh  |  53 +++++++++
 .../tests/test_samba06_host.sh                |  22 ++++
 11 files changed, 275 insertions(+), 27 deletions(-)
 create mode 100644 tests/Functional.samba/data/smb05.conf
 create mode 100644 tests/Functional.samba/data/smb06.conf
 mode change 100644 => 100755 tests/Functional.samba/fuego_test.sh
 create mode 100644 tests/Functional.samba/tests/restore_target.sh
 create mode 100644 tests/Functional.samba/tests/test_samba05.sh
 create mode 100644 tests/Functional.samba/tests/test_samba06.sh
 create mode 100644 tests/Functional.samba/tests/test_samba06_host.sh
tests/Functional.samba/data/smb04.conf +3 -5
index 94acbbc..fb59410 100644
@@ -2,18 +2,16 @@
    workgroup = MYGROUP
    server string = Samba Server
    security = user
-   hosts allow = 127.0.0.1 test_target
+   hosts allow = test_target
    load printers = yes
    log file = /var/log/samba/log.%m
    max log size = 50
-   max protocol = SMB3_10
-   min protocol = SMB2
-   interfaces = 127.0.0.1 test_target
+   interfaces = localhost
    dns proxy = no
 
 [test]
    comment = samba server
-   path = /home/test_for_fuego/samba
+   path = /home/test/samba
    writable = yes
    browseable = yes
    guest ok = yes
tests/Functional.samba/data/smb05.conf new file +19 -0
new file mode 100644
index 0000000..d52163d
@@ -0,0 +1,19 @@
+[global]
+   workgroup = MYGROUP
+   server string = Samba Server
+   security = user
+   passdb backend = tdbsam
+   hosts allow = test_target
+   load printers = no
+   log file = /var/log/samba/log.%m
+   max log size = 50
+   max protocol = SMB3_10
+   min protocol = SMB2
+   interfaces = localhost
+   dns proxy = no
+
+[test]
+   comment = samba server
+   path = /home/test/samba
+   writable = yes
+   browseable = yes
tests/Functional.samba/data/smb06.conf new file +18 -0
new file mode 100644
index 0000000..1bbacd4
@@ -0,0 +1,18 @@
+[global]
+   workgroup = MYGROUP
+   server string = Samba Server
+   security = user
+   hosts allow = 127.0.0.1 test_host
+   load printers = yes
+   log file = /var/log/samba/log.%m
+   max log size = 50
+   interfaces = 127.0.0.1 test_target
+   dns proxy = no
+
+[test]
+   comment = samba server
+   path = /home/test/samba
+   writable = yes
+   browseable = yes
+   guest ok = yes
+   public = yes
tests/Functional.samba/fuego_test.sh +16 -3
old mode 100644
new mode 100755
index 1f694ef..b840dc1
@@ -1,4 +1,7 @@
+NEED_ROOT=1
+
 function test_pre_check {
+    assert_has_program samba
     assert_has_program expect
     assert_has_program smbclient
     assert_has_program sed
@@ -12,9 +15,19 @@ function test_deploy {
 }
 
 function test_run {
-    report "cd $BOARD_TESTDIR/fuego.$TESTDIR; \
-        export test_target=$IPADDR; \
-        ./samba_test.sh"
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    export test_target=$IPADDR;\
+    export test_host=$SRV_IP;\
+    ./samba_test.sh"
+
+    service_file=/tmp/test_for_fuego
+    report_append "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    sh tests/test_samba06.sh $SRV_IP $IPADDR $service_file"
+
+    log_this "cd $TEST_HOME; sh tests/test_samba06_host.sh $IPADDR"
+
+    cmd "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    sh tests/restore_target.sh $service_file"
 }
 
 function test_processing {
tests/Functional.samba/samba_test.sh +5 -3
index 95c34db..93b0740 100644
@@ -2,6 +2,8 @@
 . ./fuego_board_function_lib.sh
 set_init_manager
 
-for i in tests/*.sh; do
-    source $i
-done
+source tests/test_samba01.sh
+source tests/test_samba02.sh
+source tests/test_samba03.sh
+source tests/test_samba04.sh
+source tests/test_samba05.sh
tests/Functional.samba/test.yaml +5 -3
index bd61de6..9b1ac0c 100644
@@ -1,11 +1,11 @@
 fuego_package_version: 1
 name: Functional.samba
 description: |
-      The Samba software suite is a collection of programs that implements
-      the Server Message Block protocol for UNIX systems.
+      The Samba software suite is a collection of programs
+      that implements the Server Message Block protocol for UNIX systems.
       This is a simple test to check the ps/pid/syslog of samba and use
       smbclient to implement a simple ftp-like client.
-license: BSD-3-Clause
+license: BSD-3-Clause 
 author: Wang Mingyu <[email protected]>
 maintainer: Wang Mingyu <[email protected]>
 version: 1.00
@@ -15,6 +15,8 @@ tags: ['samba']
 params:
     IPADDR:
         description: the IP address of your target board - Defined in board file
+    SRV_IP:
+        description: the IP address of your host - Defined in board file
 data_files:
  - samba_test.sh
  - fuego_test.sh
tests/Functional.samba/tests/restore_target.sh new file +23 -0
new file mode 100644
index 0000000..4883480
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+# restore the status of target when test finished. 
+
+. ./fuego_board_function_lib.sh
+set_init_manager
+
+if [ -f /etc/samba/smb.conf_bak ]
+then
+    mv /etc/samba/smb.conf_bak /etc/samba/smb.conf
+fi
+mv data/smb06.conf_bak data/smb06.conf
+
+if [ "$(tail -n 1 $1)" = "active" -o "$(tail -n 1 $1)" = "unknown" ]
+then
+    exec_service_on_target iptables start
+fi
+if [ "$(head -n 1 $1)" = "inactive" ]
+then
+    exec_service_on_target smb stop
+fi
+
+rm -fr $1
tests/Functional.samba/tests/test_samba04.sh +9 -13
index 2ad6e59..cacc6c0 100644
@@ -1,6 +1,8 @@
 #!/bin/sh
 
-#  Set the server to access the target even if you don't have a password from the server, and make sure the server can access the target.
+#  Set the server to access the target even if
+#  you don't have a password from the server,
+#  and make sure the server can access the target.
 
 test="smbd04"
 
@@ -10,14 +12,12 @@ iptables_status=$(get_service_status iptables)
 exec_service_on_target smb stop
 exec_service_on_target iptables stop
 
-useradd test_for_fuego
+mkdir -p /home/test/samba
+mkdir -p /home/test/samba_test
 
-mkdir -p /home/test_for_fuego/samba
-mkdir -p /home/test_for_fuego/samba_test
+cp data/test1 /home/test/samba/
 
-cp data/test1 /home/test_for_fuego/samba/
-
-chown nobody:nobody -R /home/test_for_fuego/samba
+chown nobody:nobody -R /home/test/samba
 
 if [ -f /etc/samba/smb.conf ]
 then
@@ -29,9 +29,6 @@ restore_target(){
     then
         mv /etc/samba/smb.conf_bak /etc/samba/smb.conf
     fi
-    mv data/smb04.conf_bak data/smb04.conf
-    rm -fr /home/test_for_fuego
-    userdel test_for_fuego
     if [ "$iptables_status" = "active" -o "$iptables_status" = "unknown" ]
     then
         exec_service_on_target iptables start
@@ -42,7 +39,6 @@ restore_target(){
     fi
 }
 
-cp data/smb04.conf data/smb04.conf_bak
 sed -i 's/test_target/'"$test_target"'/g' data/smb04.conf
 cp data/smb04.conf /etc/samba/smb.conf
 
@@ -62,7 +58,7 @@ expect <<-EOF
 spawn smbclient //$test_target/test -N
 expect {
  -re ".*smb: .*" {
-           send "get test1 /home/test_for_fuego/samba_test/test1\n"
+           send "get test1 /home/test/samba_test/test1\n"
           }
  default { send_user "Can not log into the board.\n"}  }
 expect {
@@ -74,7 +70,7 @@ send "exit\n"
 expect eof
 EOF
 
-if ls /home/test_for_fuego/samba_test/test1
+if ls /home/test/samba_test/test1
 then
     echo " -> $test: TEST-PASS"
 else
tests/Functional.samba/tests/test_samba05.sh new file +102 -0

102 lines not on this page · raw message

tests/Functional.samba/tests/test_samba06.sh new file +53 -0

53 lines not on this page · raw message

tests/Functional.samba/tests/test_samba06_host.sh new file +22 -0
new file mode 100644
index 0000000..e04dac3
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# Access the samba server on the target from the host
+
+test="samba06"
+expect <<-EOF
+spawn sh
+expect ".*"
+send "smbclient //$1/test -N\r"
+expect {
+ -re ".*smb:.*" {
+           send "ls\r"
+          }
+ default { send_user "Can't connect to the board"\n"}  }
+expect {
+ -re ".*test1.*" {
+           send_user " -> $test: TEST-PASS\n"
+          }
+ default { send_user " -> $test: TEST-FAIL\n"}  }
+send "exit\n"
+expect eof
+EOF
Signature · 1 line
2.17.1
#4 lore raw

Re: [Fuego] [PATCH] samba: Add test case to access the server on target from host.

Quoted 4 lines

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

This patch is missing a description in the commit body. Please make sure every patch has a description, in addition to the summary line.

Quoted 486 lines
---
 tests/Functional.samba/data/smb04.conf        |   8 +-
 tests/Functional.samba/data/smb05.conf        |  19 ++++
 tests/Functional.samba/data/smb06.conf        |  18 ++++
 tests/Functional.samba/fuego_test.sh          |  19 +++-
 tests/Functional.samba/samba_test.sh          |   8 +-
 tests/Functional.samba/test.yaml              |   8 +-
 .../Functional.samba/tests/restore_target.sh  |  23 ++++
 tests/Functional.samba/tests/test_samba04.sh  |  22 ++--
 tests/Functional.samba/tests/test_samba05.sh  | 102
++++++++++++++++++
 tests/Functional.samba/tests/test_samba06.sh  |  53 +++++++++
 .../tests/test_samba06_host.sh                |  22 ++++
 11 files changed, 275 insertions(+), 27 deletions(-)
 create mode 100644 tests/Functional.samba/data/smb05.conf
 create mode 100644 tests/Functional.samba/data/smb06.conf
 mode change 100644 => 100755 tests/Functional.samba/fuego_test.sh
 create mode 100644 tests/Functional.samba/tests/restore_target.sh
 create mode 100644 tests/Functional.samba/tests/test_samba05.sh
 create mode 100644 tests/Functional.samba/tests/test_samba06.sh
 create mode 100644 tests/Functional.samba/tests/test_samba06_host.sh
tests/Functional.samba/data/smb04.conf +3 -5
index 94acbbc..fb59410 100644
@@ -2,18 +2,16 @@
    workgroup = MYGROUP
    server string = Samba Server
    security = user
-   hosts allow = 127.0.0.1 test_target
+   hosts allow = test_target
    load printers = yes
    log file = /var/log/samba/log.%m
    max log size = 50
-   max protocol = SMB3_10
-   min protocol = SMB2
-   interfaces = 127.0.0.1 test_target
+   interfaces = localhost
    dns proxy = no
 
 [test]
    comment = samba server
-   path = /home/test_for_fuego/samba
+   path = /home/test/samba
    writable = yes
    browseable = yes
    guest ok = yes
tests/Functional.samba/data/smb05.conf new file +19 -0
new file mode 100644
index 0000000..d52163d
@@ -0,0 +1,19 @@
+[global]
+   workgroup = MYGROUP
+   server string = Samba Server
+   security = user
+   passdb backend = tdbsam
+   hosts allow = test_target
+   load printers = no
+   log file = /var/log/samba/log.%m
+   max log size = 50
+   max protocol = SMB3_10
+   min protocol = SMB2
+   interfaces = localhost
+   dns proxy = no
+
+[test]
+   comment = samba server
+   path = /home/test/samba
+   writable = yes
+   browseable = yes
tests/Functional.samba/data/smb06.conf new file +18 -0
new file mode 100644
index 0000000..1bbacd4
@@ -0,0 +1,18 @@
+[global]
+   workgroup = MYGROUP
+   server string = Samba Server
+   security = user
+   hosts allow = 127.0.0.1 test_host
+   load printers = yes
+   log file = /var/log/samba/log.%m
+   max log size = 50
+   interfaces = 127.0.0.1 test_target
+   dns proxy = no
+
+[test]
+   comment = samba server
+   path = /home/test/samba
+   writable = yes
+   browseable = yes
+   guest ok = yes
+   public = yes
tests/Functional.samba/fuego_test.sh +16 -3
old mode 100644
new mode 100755
index 1f694ef..b840dc1
@@ -1,4 +1,7 @@
+NEED_ROOT=1
+
 function test_pre_check {
+    assert_has_program samba
     assert_has_program expect
     assert_has_program smbclient
     assert_has_program sed
@@ -12,9 +15,19 @@ function test_deploy {
 }
 
 function test_run {
-    report "cd $BOARD_TESTDIR/fuego.$TESTDIR; \
-        export test_target=$IPADDR; \
-        ./samba_test.sh"
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    export test_target=$IPADDR;\
+    export test_host=$SRV_IP;\
+    ./samba_test.sh"
+
+    service_file=/tmp/test_for_fuego
+    report_append "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    sh tests/test_samba06.sh $SRV_IP $IPADDR $service_file"
+
+    log_this "cd $TEST_HOME; sh tests/test_samba06_host.sh $IPADDR"
+
+    cmd "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    sh tests/restore_target.sh $service_file"
 }
 
 function test_processing {
tests/Functional.samba/samba_test.sh +5 -3
index 95c34db..93b0740 100644
@@ -2,6 +2,8 @@
 . ./fuego_board_function_lib.sh
 set_init_manager
 
-for i in tests/*.sh; do
-    source $i
-done
+source tests/test_samba01.sh
+source tests/test_samba02.sh
+source tests/test_samba03.sh
+source tests/test_samba04.sh
+source tests/test_samba05.sh
tests/Functional.samba/test.yaml +5 -3
index bd61de6..9b1ac0c 100644
@@ -1,11 +1,11 @@
 fuego_package_version: 1
 name: Functional.samba
 description: |
-      The Samba software suite is a collection of programs that implements
-      the Server Message Block protocol for UNIX systems.
+      The Samba software suite is a collection of programs
+      that implements the Server Message Block protocol for UNIX systems.
       This is a simple test to check the ps/pid/syslog of samba and use
       smbclient to implement a simple ftp-like client.
-license: BSD-3-Clause
+license: BSD-3-Clause
 author: Wang Mingyu <[email protected]>
 maintainer: Wang Mingyu <[email protected]>
 version: 1.00
@@ -15,6 +15,8 @@ tags: ['samba']
 params:
     IPADDR:
         description: the IP address of your target board - Defined in board file
+    SRV_IP:
+        description: the IP address of your host - Defined in board file
 data_files:
  - samba_test.sh
  - fuego_test.sh
tests/Functional.samba/tests/restore_target.sh new file +23 -0
new file mode 100644
index 0000000..4883480
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+# restore the status of target when test finished.
+
+. ./fuego_board_function_lib.sh
+set_init_manager
+
+if [ -f /etc/samba/smb.conf_bak ]
+then
+    mv /etc/samba/smb.conf_bak /etc/samba/smb.conf
+fi
+mv data/smb06.conf_bak data/smb06.conf
+
+if [ "$(tail -n 1 $1)" = "active" -o "$(tail -n 1 $1)" = "unknown" ]
+then
+    exec_service_on_target iptables start
+fi
+if [ "$(head -n 1 $1)" = "inactive" ]
+then
+    exec_service_on_target smb stop
+fi
+
+rm -fr $1
tests/Functional.samba/tests/test_samba04.sh +0 -1
index 2ad6e59..cacc6c0 100644
@@ -1,6 +1,8 @@
 #!/bin/sh
 
-#  Set the server to access the target even if you don't have a password

from the server, and make sure the server can access the target.

tests/Functional.samba/tests/test_samba04.sh +9 -12
+#  Set the server to access the target even if
+#  you don't have a password from the server,
+#  and make sure the server can access the target.
 
 test="smbd04"
@@ -10,14 +12,12 @@ iptables_status=$(get_service_status iptables)
 exec_service_on_target smb stop
 exec_service_on_target iptables stop
 
-useradd test_for_fuego
+mkdir -p /home/test/samba
+mkdir -p /home/test/samba_test
 
-mkdir -p /home/test_for_fuego/samba
-mkdir -p /home/test_for_fuego/samba_test
+cp data/test1 /home/test/samba/
 
-cp data/test1 /home/test_for_fuego/samba/
-
-chown nobody:nobody -R /home/test_for_fuego/samba
+chown nobody:nobody -R /home/test/samba
 
 if [ -f /etc/samba/smb.conf ]
 then
@@ -29,9 +29,6 @@ restore_target(){
     then
         mv /etc/samba/smb.conf_bak /etc/samba/smb.conf
     fi
-    mv data/smb04.conf_bak data/smb04.conf
-    rm -fr /home/test_for_fuego
-    userdel test_for_fuego
     if [ "$iptables_status" = "active" -o "$iptables_status" = "unknown" ]
     then
         exec_service_on_target iptables start
@@ -42,7 +39,6 @@ restore_target(){
     fi
 }
 
-cp data/smb04.conf data/smb04.conf_bak
 sed -i 's/test_target/'"$test_target"'/g' data/smb04.conf
 cp data/smb04.conf /etc/samba/smb.conf
 
@@ -62,7 +58,7 @@ expect <<-EOF
 spawn smbclient //$test_target/test -N
 expect {
  -re ".*smb: .*" {
-           send "get test1 /home/test_for_fuego/samba_test/test1\n"
+           send "get test1 /home/test/samba_test/test1\n"
           }
  default { send_user "Can not log into the board.\n"}  }
 expect {
@@ -74,7 +70,7 @@ send "exit\n"
 expect eof
 EOF
 
-if ls /home/test_for_fuego/samba_test/test1
+if ls /home/test/samba_test/test1
 then
     echo " -> $test: TEST-PASS"
 else
tests/Functional.samba/tests/test_samba05.sh new file +102 -0
new file mode 100644
index 0000000..fe55560
@@ -0,0 +1,102 @@
+#!/bin/sh
+
+#  In the target start samba, set the server to access
+#  the target having password from the server,
+#  and make sure the server can access the target.
+
+test="samba05"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+useradd test_for_fuego
+
+expect <<-EOF
+spawn smbpasswd -a test_for_fuego
+expect "SMB password:"
+send "goodluck\r"
+expect "Retype new SMB password:"
+send "goodluck\r"
+expect "Added user root."
+EOF
+
+smb_status=$(get_service_status smb)
+iptables_status=$(get_service_status iptables)
+
+exec_service_on_target smb stop
+exec_service_on_target iptables stop
+
+mkdir -p /home/test/samba
+
+cp data/test1 /home/test/samba/
+
+chown nobody:nobody -R /home/test/samba
+
+if [ -f /etc/samba/smb.conf ]
+then
+    mv /etc/samba/smb.conf /etc/samba/smb.conf_bak
+fi
+
+restore_target(){
+    if [ -f /etc/samba/smb.conf_bak ]
+    then
+        mv /etc/samba/smb.conf_bak /etc/samba/smb.conf
+    fi
+    smbpasswd -x test_for_fuego
+    rm -fr /home/test_for_fuego
+    userdel test_for_fuego
+    if [ "$iptables_status" = "active" -o "$iptables_status" = "unknown" ]
+    then
+        exec_service_on_target iptables start
+    fi
+    if [ "$smb_status" = "inactive" ]
+    then
+        exec_service_on_target smb stop
+    fi
+}
+
+sed -i 's/test_target/'"$test_target"'/g' data/smb05.conf
+cp data/smb05.conf /etc/samba/smb.conf
+
+if exec_service_on_target smb start
+then
+    echo " -> start of smb succeeded."
+else
+    echo " -> start of smb failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+sleep 5
+
+expect <<-EOF
+spawn sh
+expect ".*"
+send "smbclient //$test_target/test --user=test_for_fuego\r"
+expect {
+ -re ".*Enter.*password:.*" {
+           send "goodluck\r"
+          }
+ default { send_user "Can not access the board.\n"}  }
+expect {
+ -re ".*Password:.*" {
+           send "goodluck\r"
+          }
+ default { send_user "Password is wrong.\n"}  }
+expect {
+ -re ".*smb:.*" {
+           send "ls\r"
+          }
+ default { send_user "Can not log into the board.\n"}  }
+expect {
+ -re ".*test1.*" {
+           send_user " -> $test: TEST-PASS\n"
+          }
+ default { send_user " -> $test: TEST-FAIL\n"}  }
+send "exit\n"
+expect eof
+EOF
+
+restore_target
tests/Functional.samba/tests/test_samba06.sh new file +53 -0
new file mode 100644
index 0000000..000d3ec
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+#  Start the service samba and keep it running on the target
+
+. ./fuego_board_function_lib.sh
+set_init_manager
+
+echo $(get_service_status smb) > $3
+echo $(get_service_status iptables) >> $3
+
+exec_service_on_target smb stop
+exec_service_on_target iptables stop
+
+mkdir -p /home/test/samba
+
+cp data/test1 /home/test/samba/
+
+chown nobody:nobody -R /home/test/samba
+
+if [ -f /etc/samba/smb.conf ]
+then
+    mv /etc/samba/smb.conf /etc/samba/smb.conf_bak
+fi
+
+restore_target(){
+    if [ -f /etc/samba/smb.conf_bak ]
+    then
+        mv /etc/samba/smb.conf_bak /etc/samba/smb.conf
+    fi
+    if [ "$iptables_status" = "active" -o "$iptables_status" = "unknown" ]
+    then
+        exec_service_on_target iptables start
+    fi
+    if [ "$smb_status" = "inactive" ]
+    then
+        exec_service_on_target smb stop
+    fi
+}
+
+sed -i 's/test_target/'"$2"'/g' data/smb06.conf
+sed -i 's/test_host/'"$1"'/g' data/smb06.conf
+cp data/smb06.conf /etc/samba/smb.conf
+
+if exec_service_on_target smb start
+then
+    echo " -> start of smb succeeded."
+else
+    echo " -> start of smb failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+sleep 5
tests/Functional.samba/tests/test_samba06_host.sh new file +22 -1
new file mode 100644
index 0000000..e04dac3
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# Access the samba server on the target from the host
+
+test="samba06"
+expect <<-EOF
+spawn sh
+expect ".*"
+send "smbclient //$1/test -N\r"
+expect {
+ -re ".*smb:.*" {
+           send "ls\r"
+          }
+ default { send_user "Can't connect to the board"\n"}  }
+expect {
+ -re ".*test1.*" {
+           send_user " -> $test: TEST-PASS\n"
+          }
+ default { send_user " -> $test: TEST-FAIL\n"}  }
+send "exit\n"
+expect eof
+EOF
--
Quoted 1 line

2.17.1

I had to remove whitespace at the end of some lines.

Please check for trailing whitespace using something like:
'grep -R " $" *'
before submitting.

~/f/fuego-core/tests/Functional.samba$ grep -R " $" * tests/restore_target.sh:# restore the status of target when test finished.
tests/test_samba05.sh: echo " -> $test: TEST-FAIL"
tests/test_samba05.sh: default { send_user "Can not log into the board.\n"} } test.yaml:license: BSD-3-Clause

I fixed the whitespace this time, but please check this before submitting in the future.

Thanks for the patch. It looks good. I have applied it.
-- Tim

#5 lore raw
In reply to Wang Mingyu

See comments inline below

Quoted 4 lines

-----Original Message-----
From: Wang Mingyu
Subject: [Fuego] [PATCH] logrotate: remove the test case using ntpdate.

This patch is missing a description in the commit message (body).

Please include a description in the body of every commit message.

tests/Functional.logrotate/tests/logrotate_size.sh

Quoted 46 lines
---
 tests/Functional.logrotate/fuego_test.sh      |  1 -
 .../tests/logrotate_rotation.sh               |  4 +-
 .../tests/logrotate_size.sh                   | 39 -------------------
 3 files changed, 1 insertion(+), 43 deletions(-)
 delete mode 100644 tests/Functional.logrotate/tests/logrotate_size.sh
tests/Functional.logrotate/fuego_test.sh +0 -1
index c6e0579..856871e 100644
@@ -2,7 +2,6 @@ NEED_ROOT=1
 
 function test_pre_check {
     assert_has_program logrotate
-    assert_has_program ntpdate
     assert_has_program date
 }
 
tests/Functional.logrotate/tests/logrotate_rotation.sh +1 -3
index f0d5e92..75616b4 100644
@@ -15,11 +15,9 @@ then
     mv /var/lib/logrotate.status /var/lib/logrotate.status_bak
 fi
 
-ntpdate $test_host
-
 cp data/test.conf /etc/logrotate.d/test.conf
 
-touch /var/log/testlog
+cp data/testlog100k /var/log/testlog
 
 cp data/testlog.sh data/testlog_test.sh
 chmod +x data/testlog_test.sh
tests/Functional.logrotate/tests/logrotate_size.sh deleted +0 -0
deleted file mode 100644
index 2e215cd..0000000

I don't know why logrotate_size.sh file was removed. This removal didn't look related to the ntpdate removal. I discarded that part of the patch.

Please explain why that file should be removed, and submit again if the removal is still desired.

Quoted 41 lines
tests/Functional.logrotate/tests/logrotate_size.sh deleted +0 -40
@@ -1,39 +0,0 @@
-#!/bin/sh
-
-#  Verify that the rotate file is created in the specified directory.
-#  option : -v
-
-test="log rotation size"
-
-if [ -f /var/log/testlog* ]
-then
-    rm -f /var/log/testlog*
-fi
-
-if [ -f /var/lib/logrotate.status ]
-then
-    mv /var/lib/logrotate.status /var/lib/logrotate.status_bak
-fi
-cp data/test.conf /etc/logrotate.d/test.conf
-
-cp data/testlog100k /var/log/testlog
-
-cp data/testlog.sh data/testlog_test.sh
-chmod +x data/testlog_test.sh
-data/testlog_test.sh
-chown root /etc/logrotate.d/test.conf
-logrotate -v /etc/logrotate.d/test.conf
-if ls /var/log/testlog.1
-then
-    echo " -> $test: TEST-PASS"
-else
-    echo " -> $test: TEST-FAIL"
-fi
-
-rm -f /etc/logrotate.d/test.conf
-rm -f /var/log/testlog*
-rm -f data/testlog_test.sh
-if [ -f /var/lib/logrotate.status_bak ]
-then
-    mv /var/lib/logrotate.status_bak /var/lib/logrotate.status
-fi
--
Quoted 1 line

2.17.1

I applied and pushed this patch to the master branch, without the removal of the file logrotate_size.sh.

Thanks for the patch.
-- Tim