All of lore.kernel.org
 help / color / mirror / Atom feed
* [Fuego] [PATCH v2] atmtcp: Add test cases for command atmtcp.
@ 2019-03-25  9:19 Wang Mingyu
  2019-03-25  9:19 ` [Fuego] [PATCH v2] lm_sensors: Add test cases for commands of lm_sensors Wang Mingyu
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Wang Mingyu @ 2019-03-25  9:19 UTC (permalink / raw)
  To: fuego

This test set is used to check option help and subcommand virtual of atmtcp.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 tests/Functional.atmtcp/atmtcp_test.sh          |  4 ++++
 tests/Functional.atmtcp/fuego_test.sh           | 17 +++++++++++++++++
 tests/Functional.atmtcp/parser.py               | 20 ++++++++++++++++++++
 tests/Functional.atmtcp/spec.json               |  6 ++++++
 tests/Functional.atmtcp/tests/atmtcp_help.sh    | 16 ++++++++++++++++
 tests/Functional.atmtcp/tests/atmtcp_virtual.sh | 24 ++++++++++++++++++++++++
 6 files changed, 87 insertions(+)
 create mode 100755 tests/Functional.atmtcp/atmtcp_test.sh
 create mode 100644 tests/Functional.atmtcp/fuego_test.sh
 create mode 100644 tests/Functional.atmtcp/parser.py
 create mode 100644 tests/Functional.atmtcp/spec.json
 create mode 100644 tests/Functional.atmtcp/tests/atmtcp_help.sh
 create mode 100644 tests/Functional.atmtcp/tests/atmtcp_virtual.sh

diff --git a/tests/Functional.atmtcp/atmtcp_test.sh b/tests/Functional.atmtcp/atmtcp_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/tests/Functional.atmtcp/atmtcp_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/tests/Functional.atmtcp/fuego_test.sh b/tests/Functional.atmtcp/fuego_test.sh
new file mode 100644
index 0000000..f4fefe9
--- /dev/null
+++ b/tests/Functional.atmtcp/fuego_test.sh
@@ -0,0 +1,17 @@
+function test_pre_check {
+    assert_has_program atmtcp
+}
+
+function test_deploy {
+    put $TEST_HOME/atmtcp_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./atmtcp_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.atmtcp/parser.py b/tests/Functional.atmtcp/parser.py
new file mode 100644
index 0000000..f25a608
--- /dev/null
+++ b/tests/Functional.atmtcp/parser.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+import common as plib
+
+measurements = {}
+measurements = collections.OrderedDict()
+
+regex_string = '^ -> (.*): TEST-(.*)$'
+matches = plib.parse_log(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
+
+# split the output for each testcase
+plib.split_output_per_testcase(regex_string, measurements)
+
+sys.exit(plib.process(measurements))
diff --git a/tests/Functional.atmtcp/spec.json b/tests/Functional.atmtcp/spec.json
new file mode 100644
index 0000000..423ae88
--- /dev/null
+++ b/tests/Functional.atmtcp/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.atmtcp",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.atmtcp/tests/atmtcp_help.sh b/tests/Functional.atmtcp/tests/atmtcp_help.sh
new file mode 100644
index 0000000..e019355
--- /dev/null
+++ b/tests/Functional.atmtcp/tests/atmtcp_help.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+#  In target, run command atmtcp.
+#  option: -h
+
+test="help"
+
+expect <<-EOF
+spawn atmtcp -h
+expect {
+ "usage:" {
+           send_user " -> $test: TEST-PASS\n"
+          }
+ default { send_user " -> $test: TEST-FAIL\n" }
+}
+EOF
diff --git a/tests/Functional.atmtcp/tests/atmtcp_virtual.sh b/tests/Functional.atmtcp/tests/atmtcp_virtual.sh
new file mode 100644
index 0000000..8b7c55d
--- /dev/null
+++ b/tests/Functional.atmtcp/tests/atmtcp_virtual.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+#  In target, run command atmtcp.
+#  option: virtual
+
+test="virtual"
+
+if modprobe -v atmtcp
+then
+    echo " -> $test: modprobe atmtcp execution succeeded."
+else
+    echo " -> $test: modprobe atmtcp execution failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+if [ ! -n "$(atmtcp virtual connect 127.0.0.1 | grep "virtual interface 0")" ]
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+killall atmtcp
-- 
1.8.3.1




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

* [Fuego] [PATCH v2] lm_sensors: Add test cases for commands of lm_sensors.
  2019-03-25  9:19 [Fuego] [PATCH v2] atmtcp: Add test cases for command atmtcp Wang Mingyu
@ 2019-03-25  9:19 ` Wang Mingyu
  2019-03-25  9:19 ` [Fuego] [PATCH v2] logrotate: Add test cases for command logrotate Wang Mingyu
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Wang Mingyu @ 2019-03-25  9:19 UTC (permalink / raw)
  To: fuego

This test set is used to monitor hardware and check the process of lm_sensors.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 tests/Functional.lm_sensors/fuego_test.sh          | 19 ++++++
 tests/Functional.lm_sensors/lm_sensors_test.sh     |  4 ++
 tests/Functional.lm_sensors/parser.py              | 20 ++++++
 tests/Functional.lm_sensors/spec.json              |  6 ++
 .../tests/lm_sensors_detect.sh                     | 51 ++++++++++++++++
 .../Functional.lm_sensors/tests/lm_sensors_help.sh | 13 ++++
 tests/Functional.lm_sensors/tests/lm_sensors_ps.sh | 71 ++++++++++++++++++++++
 7 files changed, 184 insertions(+)
 create mode 100644 tests/Functional.lm_sensors/fuego_test.sh
 create mode 100755 tests/Functional.lm_sensors/lm_sensors_test.sh
 create mode 100644 tests/Functional.lm_sensors/parser.py
 create mode 100644 tests/Functional.lm_sensors/spec.json
 create mode 100644 tests/Functional.lm_sensors/tests/lm_sensors_detect.sh
 create mode 100644 tests/Functional.lm_sensors/tests/lm_sensors_help.sh
 create mode 100644 tests/Functional.lm_sensors/tests/lm_sensors_ps.sh

diff --git a/tests/Functional.lm_sensors/fuego_test.sh b/tests/Functional.lm_sensors/fuego_test.sh
new file mode 100644
index 0000000..b514528
--- /dev/null
+++ b/tests/Functional.lm_sensors/fuego_test.sh
@@ -0,0 +1,19 @@
+function test_pre_check {
+    assert_has_program sensors
+    assert_has_program sensors-detect
+}
+
+function test_deploy {
+    put $TEST_HOME/lm_sensors_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put $FUEGO_CORE/scripts/fuego_board_function_lib.sh $BOARD_TESTDIR/fuego.$TESTDIR
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./lm_sensors_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.lm_sensors/lm_sensors_test.sh b/tests/Functional.lm_sensors/lm_sensors_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/tests/Functional.lm_sensors/lm_sensors_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/tests/Functional.lm_sensors/parser.py b/tests/Functional.lm_sensors/parser.py
new file mode 100644
index 0000000..f25a608
--- /dev/null
+++ b/tests/Functional.lm_sensors/parser.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+import common as plib
+
+measurements = {}
+measurements = collections.OrderedDict()
+
+regex_string = '^ -> (.*): TEST-(.*)$'
+matches = plib.parse_log(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
+
+# split the output for each testcase
+plib.split_output_per_testcase(regex_string, measurements)
+
+sys.exit(plib.process(measurements))
diff --git a/tests/Functional.lm_sensors/spec.json b/tests/Functional.lm_sensors/spec.json
new file mode 100644
index 0000000..d1afe34
--- /dev/null
+++ b/tests/Functional.lm_sensors/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.lm_sensors",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.lm_sensors/tests/lm_sensors_detect.sh b/tests/Functional.lm_sensors/tests/lm_sensors_detect.sh
new file mode 100644
index 0000000..0a60472
--- /dev/null
+++ b/tests/Functional.lm_sensors/tests/lm_sensors_detect.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+#  In target, run command sensors-detect to scan hardware monitoring chips, or sensors.
+#  option: none
+
+test="sensors-detect"
+
+flag=0
+
+expect <<-EOF
+spawn sensors-detect
+expect {
+    -re ".*YES/no.*" {
+        exp_send "\r"
+        exp_continue
+    }
+    -re ".*YES/no/selectively.*" {
+        exp_send "\r"
+        exp_continue
+    }
+    -re ".*yes/NO/selectively.*" {
+        exp_send "\r"
+        exp_continue
+    }
+    -re ".*yes/NO.*" {
+        exp_send "\r"
+        exp_continue
+    }
+    -re ".*Just press ENTER to continue.*" {
+        exp_send "\r"
+        exp_continue
+    }
+    -re ".*root # " {
+        exp_send "\r"
+        if { $flag=0 } {
+            flag=1
+            exp_continue
+        }
+    }
+    timeout {
+        exp_send "\003\r"
+    }
+}
+EOF
+
+if sensors | grep "Adapter"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
diff --git a/tests/Functional.lm_sensors/tests/lm_sensors_help.sh b/tests/Functional.lm_sensors/tests/lm_sensors_help.sh
new file mode 100644
index 0000000..7c27cbb
--- /dev/null
+++ b/tests/Functional.lm_sensors/tests/lm_sensors_help.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run command sensors.
+#  option: -h
+
+test="help"
+
+if sensors -h | grep Usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
diff --git a/tests/Functional.lm_sensors/tests/lm_sensors_ps.sh b/tests/Functional.lm_sensors/tests/lm_sensors_ps.sh
new file mode 100644
index 0000000..9c51647
--- /dev/null
+++ b/tests/Functional.lm_sensors/tests/lm_sensors_ps.sh
@@ -0,0 +1,71 @@
+#!/bin/sh
+
+#  In the target start lm_sensors, and confirm the process condition by command ps.
+
+test="ps"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+flag=0
+
+expect <<-EOF
+spawn sensors-detect
+expect {
+    -re ".*YES/no.*" {
+        exp_send "\r"
+        exp_continue
+    }
+    -re ".*YES/no/selectively.*" {
+        exp_send "\r"
+        exp_continue
+    }
+    -re ".*yes/NO/selectively.*" {
+        exp_send "\r"
+        exp_continue
+    }
+    -re ".*yes/NO.*" {
+        exp_send "\r"
+        exp_continue
+    }
+    -re ".*Just press ENTER to continue.*" {
+        exp_send "\r"
+        exp_continue
+    }
+    -re ".*root # " {
+        exp_send "\r"
+        if { $flag=0 } {
+            flag=1
+            exp_continue
+        }
+    }
+    timeout {
+        exp_send "\003\r"
+    }
+}
+EOF
+
+sleep 5
+
+service_status=$(get_service_status lm_sensors)
+if exec_service_on_target lm_sensors start
+then
+    echo " -> start of lm_sensors succeeded."
+else
+    echo " -> start of lm_sensors failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+if exec_service_on_target lm_sensors stop
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+then
+    exec_service_on_target lm_sensors start
+fi
-- 
1.8.3.1




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

* [Fuego] [PATCH v2] logrotate: Add test cases for command logrotate.
  2019-03-25  9:19 [Fuego] [PATCH v2] atmtcp: Add test cases for command atmtcp Wang Mingyu
  2019-03-25  9:19 ` [Fuego] [PATCH v2] lm_sensors: Add test cases for commands of lm_sensors Wang Mingyu
@ 2019-03-25  9:19 ` Wang Mingyu
  2019-03-25  9:19 ` [Fuego] [PATCH v2] m4: Add test cases for command m4 Wang Mingyu
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Wang Mingyu @ 2019-03-25  9:19 UTC (permalink / raw)
  To: fuego

This test set is used to check log file is created.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 tests/Functional.logrotate/data/test.conf        |   8 +++++
 tests/Functional.logrotate/data/testlog.sh       |   6 ++++
 tests/Functional.logrotate/data/testlog100k      | Bin 0 -> 105984 bytes
 tests/Functional.logrotate/fuego_test.sh         |  18 ++++++++++
 tests/Functional.logrotate/logrotate_test.sh     |   4 +++
 tests/Functional.logrotate/parser.py             |  20 +++++++++++
 tests/Functional.logrotate/spec.json             |   6 ++++
 tests/Functional.logrotate/tests/logrotate_01.sh |  13 +++++++
 tests/Functional.logrotate/tests/logrotate_02.sh |  23 ++++++++++++
 tests/Functional.logrotate/tests/logrotate_03.sh |  19 ++++++++++
 tests/Functional.logrotate/tests/logrotate_04.sh |  43 +++++++++++++++++++++++
 tests/Functional.logrotate/tests/logrotate_05.sh |  30 ++++++++++++++++
 12 files changed, 190 insertions(+)
 create mode 100644 tests/Functional.logrotate/data/test.conf
 create mode 100644 tests/Functional.logrotate/data/testlog.sh
 create mode 100644 tests/Functional.logrotate/data/testlog100k
 create mode 100644 tests/Functional.logrotate/fuego_test.sh
 create mode 100755 tests/Functional.logrotate/logrotate_test.sh
 create mode 100644 tests/Functional.logrotate/parser.py
 create mode 100644 tests/Functional.logrotate/spec.json
 create mode 100644 tests/Functional.logrotate/tests/logrotate_01.sh
 create mode 100644 tests/Functional.logrotate/tests/logrotate_02.sh
 create mode 100644 tests/Functional.logrotate/tests/logrotate_03.sh
 create mode 100644 tests/Functional.logrotate/tests/logrotate_04.sh
 create mode 100644 tests/Functional.logrotate/tests/logrotate_05.sh

diff --git a/tests/Functional.logrotate/data/test.conf b/tests/Functional.logrotate/data/test.conf
new file mode 100644
index 0000000..a346adf
--- /dev/null
+++ b/tests/Functional.logrotate/data/test.conf
@@ -0,0 +1,8 @@
+/var/log/testlog {
+        create 600 root root
+        ifempty
+        daily
+        nocompress
+        missingok
+        rotate 1
+}
diff --git a/tests/Functional.logrotate/data/testlog.sh b/tests/Functional.logrotate/data/testlog.sh
new file mode 100644
index 0000000..e258480
--- /dev/null
+++ b/tests/Functional.logrotate/data/testlog.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+ddch=`date --date ' 1 days ago' '+%Y-%m-%d'`
+echo "logrotate state -- version 2" >> /var/lib/logrotate.status
+echo "\"/var/log/testlog\" $ddch" >> /var/lib/logrotate.status
+EOF
diff --git a/tests/Functional.logrotate/data/testlog100k b/tests/Functional.logrotate/data/testlog100k
new file mode 100644
index 0000000000000000000000000000000000000000..1dc679f54731568a9cbda775a663b7ea51595fe3
GIT binary patch
literal 105984
zcmeI5d0-U9^2b*N!X;-EJdh;28zdV8yGaO9L{XdL$K@>wVs7M00!a`-{fUA^e4r2f
z0X{&`=Zyl&Q#|l~hzE+OPr(y!P(TqC1(8=ZGs|u^JKbNze|~PwA7rMhr<;7HQr%Ns
zU6bVTc!qWHcq*%_x`gQ5?O<8e*uv_n8n+rAPq1rNC?_k_H7l6i&ArxNU$S6WifZ-y
zk)EdQlWR@CZ4y=Z>I|EIwx%-6guez*l;{ECU-I)25dX$>-%vpRqnejf1A)hgf1_4M
z7;4#K*8gz@nEk0KzI>#vQI=m>IJPjWrn;)EB&)b8tE^_!NHSSj#T8kjDs{L1rDXps
zN>PjQT9E#?9bo#!nE#v+Hvb$=WtJ6=FRjv4@sw9omsS?%BszZ2C1ok<`|`us{*>!@
zv5fgIclhUODzi-ZYXC)wiirR24b5QwUpV}AlNOc<|0u|s(+c80cS&=Yzvpt>{^V)e
zWSQ{S0E!Y#CjN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q%>VNf9Q&i$|H$)y)A$?l
z|0nkM*XHyJs7rcS@juY|mvZ*sg)|#rSSI=(Ux#B$pCkTL?zX;vWYmA2|9lAOe{3Ie
z?M~o>3j%6KCoKM)`IiCvzubEhNi2b1hXhpl#n}9l`FD5bKf3ta*goXioxr%_fSNk9
zxqF2u3G=@JSbvGSMNSO_<`Vx$ZZ=eM#LPbjh=0aflUht*en~)G_Zpsm=0a!xg`^+;
zbM)sv;@@!!_Ws5CKi{$cn%A#C=RcMptrUz3sOfXDUzYjb?&!Z}`5kLaYFPw691~Cv
z`SASPX94eDf)*#RbZkJ~*%+VyoCElO@ZP27a^l}43D<ul{$Hr#1RlO4poXl(^Pl|I
z!}h;v+&>;#|C0Py;3IgH_)oqQ+ke61FTx+}TB;F&;rCGd!(M#<9kTyLz~Tf-i2qHG
z;p^}Jp{g8zCH4nrtgAUOH&b2o631Ve^S|->%THndv!+qro@a`GW_iLVpCN|V5&!)s
zHG=uCJl58KP58NoWwQTBqo7fuTk|v3yKgt)`19JR;<%@*|LYz8I{y#LgnwLw^$PDH
z{`XT-ZG=D1e;xt!zg{O&;7Z^T;$Jfh^S`nF|8OE^e@yG|vj4(<B<=cUs&Nmp{ZB4%
zeMpXg`ENbi=C51-LiYa(e;ewu!I|pPVw`_YJDb1G|H(3w{!9Fc&HwOoGS%BFt@!^+
zyTtup*8c~F*!*c3()D1OjK8jU>Ieo8$yB>*t^M!N{HG|{=C50Sq4|HF%>V0PcD*>M
rFjK9XhUMR8{oi(p%|EDl0jAe4@xQqeuPfMaO{VH_1<yat@4x>AP`)FD

literal 0
HcmV?d00001

diff --git a/tests/Functional.logrotate/fuego_test.sh b/tests/Functional.logrotate/fuego_test.sh
new file mode 100644
index 0000000..8be0eb3
--- /dev/null
+++ b/tests/Functional.logrotate/fuego_test.sh
@@ -0,0 +1,18 @@
+function test_pre_check {
+    assert_has_program logrotate
+}
+
+function test_deploy {
+    put $TEST_HOME/logrotate_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/data $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./logrotate_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.logrotate/logrotate_test.sh b/tests/Functional.logrotate/logrotate_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/tests/Functional.logrotate/logrotate_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/tests/Functional.logrotate/parser.py b/tests/Functional.logrotate/parser.py
new file mode 100644
index 0000000..f25a608
--- /dev/null
+++ b/tests/Functional.logrotate/parser.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+import common as plib
+
+measurements = {}
+measurements = collections.OrderedDict()
+
+regex_string = '^ -> (.*): TEST-(.*)$'
+matches = plib.parse_log(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
+
+# split the output for each testcase
+plib.split_output_per_testcase(regex_string, measurements)
+
+sys.exit(plib.process(measurements))
diff --git a/tests/Functional.logrotate/spec.json b/tests/Functional.logrotate/spec.json
new file mode 100644
index 0000000..cfd6646
--- /dev/null
+++ b/tests/Functional.logrotate/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.logrotate",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.logrotate/tests/logrotate_01.sh b/tests/Functional.logrotate/tests/logrotate_01.sh
new file mode 100644
index 0000000..e40647b
--- /dev/null
+++ b/tests/Functional.logrotate/tests/logrotate_01.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In the target to execute command logrotate and confirm the result.
+#  option : --help
+
+test="logrotate"
+
+if xmlcatalog --help | grep "Usage"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/tests/Functional.logrotate/tests/logrotate_02.sh b/tests/Functional.logrotate/tests/logrotate_02.sh
new file mode 100644
index 0000000..4e16d0b
--- /dev/null
+++ b/tests/Functional.logrotate/tests/logrotate_02.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+#  In the target to execute command logrotate and confirm the result.
+#  option : -dv
+
+test="logrotate2"
+
+if [ -f /var/lib/logrotate.status ]
+then
+    rm -f /var/lib/logrotate.status
+fi
+
+cp data/test.conf /etc/logrotate.d/test.conf
+
+chown root /etc/logrotate.d/test.conf
+
+if logrotate -dv /etc/logrotate.d/test.conf
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm -f /etc/logrotate.d/test.conf
diff --git a/tests/Functional.logrotate/tests/logrotate_03.sh b/tests/Functional.logrotate/tests/logrotate_03.sh
new file mode 100644
index 0000000..98a850d
--- /dev/null
+++ b/tests/Functional.logrotate/tests/logrotate_03.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+#  In the target to execute command logrotate and confirm the result.
+#  option : -v
+
+test="logrotate3"
+
+cp data/test.conf /etc/logrotate.d/test.conf
+
+logrotate -v /etc/logrotate.d/test.conf
+
+if tail /var/lib/logrotate.status | grep testlog
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm -f /etc/logrotate.d/test.conf
+sed -i '/testlog/d' /var/lib/logrotate.status
diff --git a/tests/Functional.logrotate/tests/logrotate_04.sh b/tests/Functional.logrotate/tests/logrotate_04.sh
new file mode 100644
index 0000000..a9a570b
--- /dev/null
+++ b/tests/Functional.logrotate/tests/logrotate_04.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+#  In the target to execute command logrotate. Verify that the rotate file is created in the specified directory.
+#  option : -v
+
+test="logrotate4"
+
+if [ -f /var/log/testlog* ]
+then
+    rm -f /var/log/testlog*
+fi
+
+if [ -f /home/test/testlog.sh ]
+then
+    rm -f /home/test/testlog.sh
+fi
+
+if [ -f /var/lib/logrotate.status ]
+then
+    rm -f /var/lib/logrotate.status
+fi
+
+ntpdate 192.168.246.1
+
+cp data/test.conf /etc/logrotate.d/test.conf
+
+touch /var/log/testlog
+
+chmod +x data/testlog.sh
+data/testlog.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*
+sed -i '/testlog/d' /var/lib/logrotate.status
+sed -i '/logrotate/d' /var/lib/logrotate.status
diff --git a/tests/Functional.logrotate/tests/logrotate_05.sh b/tests/Functional.logrotate/tests/logrotate_05.sh
new file mode 100644
index 0000000..a5f61dc
--- /dev/null
+++ b/tests/Functional.logrotate/tests/logrotate_05.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+#  In the target to execute command logrotate.Verify that the rotate file is created in the specified directory(Specify the file size).
+#  option : -v
+
+test="logrotate5"
+
+if [ -f /var/log/testlog* ]
+then
+    rm -f /var/log/testlog*
+fi
+
+cp data/test.conf /etc/logrotate.d/test.conf
+
+cp data/testlog100k /var/log/testlog
+
+chmod +x data/testlog.sh
+data/testlog.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*
+sed -i '/testlog/d' /var/lib/logrotate.status
-- 
1.8.3.1




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

* [Fuego] [PATCH v2] m4: Add test cases for command m4.
  2019-03-25  9:19 [Fuego] [PATCH v2] atmtcp: Add test cases for command atmtcp Wang Mingyu
  2019-03-25  9:19 ` [Fuego] [PATCH v2] lm_sensors: Add test cases for commands of lm_sensors Wang Mingyu
  2019-03-25  9:19 ` [Fuego] [PATCH v2] logrotate: Add test cases for command logrotate Wang Mingyu
@ 2019-03-25  9:19 ` Wang Mingyu
  2019-03-25  9:19 ` [Fuego] [PATCH v2] ntp: Add test cases for commands of ntp Wang Mingyu
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Wang Mingyu @ 2019-03-25  9:19 UTC (permalink / raw)
  To: fuego

This test set is used to process macros by m4.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 tests/Functional.m4/fuego_test.sh  | 17 +++++++++++++++++
 tests/Functional.m4/m4_test.sh     |  4 ++++
 tests/Functional.m4/parser.py      | 20 ++++++++++++++++++++
 tests/Functional.m4/spec.json      |  6 ++++++
 tests/Functional.m4/tests/m4_01.sh | 13 +++++++++++++
 tests/Functional.m4/tests/m4_02.sh | 19 +++++++++++++++++++
 6 files changed, 79 insertions(+)
 create mode 100644 tests/Functional.m4/fuego_test.sh
 create mode 100755 tests/Functional.m4/m4_test.sh
 create mode 100644 tests/Functional.m4/parser.py
 create mode 100644 tests/Functional.m4/spec.json
 create mode 100644 tests/Functional.m4/tests/m4_01.sh
 create mode 100644 tests/Functional.m4/tests/m4_02.sh

diff --git a/tests/Functional.m4/fuego_test.sh b/tests/Functional.m4/fuego_test.sh
new file mode 100644
index 0000000..9e9a556
--- /dev/null
+++ b/tests/Functional.m4/fuego_test.sh
@@ -0,0 +1,17 @@
+function test_pre_check {
+    assert_has_program m4
+}
+
+function test_deploy {
+    put $TEST_HOME/m4_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./m4_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.m4/m4_test.sh b/tests/Functional.m4/m4_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/tests/Functional.m4/m4_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/tests/Functional.m4/parser.py b/tests/Functional.m4/parser.py
new file mode 100644
index 0000000..f25a608
--- /dev/null
+++ b/tests/Functional.m4/parser.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+import common as plib
+
+measurements = {}
+measurements = collections.OrderedDict()
+
+regex_string = '^ -> (.*): TEST-(.*)$'
+matches = plib.parse_log(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
+
+# split the output for each testcase
+plib.split_output_per_testcase(regex_string, measurements)
+
+sys.exit(plib.process(measurements))
diff --git a/tests/Functional.m4/spec.json b/tests/Functional.m4/spec.json
new file mode 100644
index 0000000..4a3b807
--- /dev/null
+++ b/tests/Functional.m4/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.m4",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.m4/tests/m4_01.sh b/tests/Functional.m4/tests/m4_01.sh
new file mode 100644
index 0000000..4a553d1
--- /dev/null
+++ b/tests/Functional.m4/tests/m4_01.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run command m4.
+#  option: --help
+
+test="m4_01"
+
+if m4 --help | grep Usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
diff --git a/tests/Functional.m4/tests/m4_02.sh b/tests/Functional.m4/tests/m4_02.sh
new file mode 100644
index 0000000..4bdaf7a
--- /dev/null
+++ b/tests/Functional.m4/tests/m4_02.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+#  In target, run command m4.
+#  option: none
+
+test="m4_02"
+
+mkdir m4
+echo "define(\`STR', \`hello world')" > m4/m4.test
+echo "syscmd(\`echo' STR)" >> m4/m4.test
+
+if m4 m4/m4.test | grep "hello world"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+
+rm -fr m4
-- 
1.8.3.1




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

* [Fuego] [PATCH v2] ntp: Add test cases for commands of ntp.
  2019-03-25  9:19 [Fuego] [PATCH v2] atmtcp: Add test cases for command atmtcp Wang Mingyu
                   ` (2 preceding siblings ...)
  2019-03-25  9:19 ` [Fuego] [PATCH v2] m4: Add test cases for command m4 Wang Mingyu
@ 2019-03-25  9:19 ` Wang Mingyu
  2019-03-25  9:19 ` [Fuego] [PATCH v2] openvpn: Add test cases of service openvpn Wang Mingyu
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Wang Mingyu @ 2019-03-25  9:19 UTC (permalink / raw)
  To: fuego

This test set is used to check the service ntpd and command ntpdate/ntpdc/ntpq/ntptime/tickadj.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 tests/Functional.ntp/data/hosts               |  4 ++
 tests/Functional.ntp/data/ntp.conf            | 82 +++++++++++++++++++++++++++
 tests/Functional.ntp/fuego_test.sh            | 24 ++++++++
 tests/Functional.ntp/ntp_test.sh              |  7 +++
 tests/Functional.ntp/parser.py                | 20 +++++++
 tests/Functional.ntp/spec.json                |  6 ++
 tests/Functional.ntp/test.yaml                | 34 +++++++++++
 tests/Functional.ntp/tests/ntp_ntpdate1.sh    | 13 +++++
 tests/Functional.ntp/tests/ntp_ntpdate2.sh    | 21 +++++++
 tests/Functional.ntp/tests/ntp_ntpdc.sh       | 50 ++++++++++++++++
 tests/Functional.ntp/tests/ntp_ntpq.sh        | 49 ++++++++++++++++
 tests/Functional.ntp/tests/ntp_ntptime.sh_bak | 28 +++++++++
 tests/Functional.ntp/tests/ntp_pid.sh         | 57 +++++++++++++++++++
 tests/Functional.ntp/tests/ntp_ps.sh          | 47 +++++++++++++++
 tests/Functional.ntp/tests/ntp_syslog.sh      | 51 +++++++++++++++++
 tests/Functional.ntp/tests/ntp_tickadj.sh     | 28 +++++++++
 16 files changed, 521 insertions(+)
 create mode 100644 tests/Functional.ntp/data/hosts
 create mode 100644 tests/Functional.ntp/data/ntp.conf
 create mode 100644 tests/Functional.ntp/fuego_test.sh
 create mode 100755 tests/Functional.ntp/ntp_test.sh
 create mode 100644 tests/Functional.ntp/parser.py
 create mode 100644 tests/Functional.ntp/spec.json
 create mode 100644 tests/Functional.ntp/test.yaml
 create mode 100644 tests/Functional.ntp/tests/ntp_ntpdate1.sh
 create mode 100644 tests/Functional.ntp/tests/ntp_ntpdate2.sh
 create mode 100644 tests/Functional.ntp/tests/ntp_ntpdc.sh
 create mode 100644 tests/Functional.ntp/tests/ntp_ntpq.sh
 create mode 100644 tests/Functional.ntp/tests/ntp_ntptime.sh_bak
 create mode 100644 tests/Functional.ntp/tests/ntp_pid.sh
 create mode 100644 tests/Functional.ntp/tests/ntp_ps.sh
 create mode 100644 tests/Functional.ntp/tests/ntp_syslog.sh
 create mode 100644 tests/Functional.ntp/tests/ntp_tickadj.sh

diff --git a/tests/Functional.ntp/data/hosts b/tests/Functional.ntp/data/hosts
new file mode 100644
index 0000000..3c8d41d
--- /dev/null
+++ b/tests/Functional.ntp/data/hosts
@@ -0,0 +1,4 @@
+#
+#Template of /etc/hosts
+#
+127.0.0.1       localhost
diff --git a/tests/Functional.ntp/data/ntp.conf b/tests/Functional.ntp/data/ntp.conf
new file mode 100644
index 0000000..99f8d02
--- /dev/null
+++ b/tests/Functional.ntp/data/ntp.conf
@@ -0,0 +1,82 @@
+# Prohibit general access to this service.
+restrict default ignore
+
+# Permit all access over the loopback interface.  This could
+# be tightened as well, but to do so would effect some of
+# the administrative functions.
+restrict 127.0.0.1 
+
+
+# -- CLIENT NETWORK -------
+# Permit systems on this network to synchronize with this
+# time service.  Do not permit those systems to modify the
+# configuration of this service.  Also, do not use those
+# systems as peers for synchronization.
+# restrict 192.168.1.0 mask 255.255.255.0 notrust nomodify notrap
+
+
+# --- OUR TIMESERVERS ----- 
+# or remove the default restrict line 
+# Permit time synchronization with our time source, but do not
+# permit the source to query or modify the service on this system.
+
+# restrict mytrustedtimeserverip mask 255.255.255.255 nomodify notrap noquery
+# server mytrustedtimeserverip
+
+
+
+# --- NTP MULTICASTCLIENT ---
+#multicastclient			# listen on default 224.0.1.1
+# restrict 224.0.1.1 mask 255.255.255.255 notrust nomodify notrap
+# restrict 192.168.1.0 mask 255.255.255.0 notrust nomodify notrap
+
+
+
+# --- GENERAL CONFIGURATION ---
+#
+# Undisciplined Local Clock. This is a fake driver intended for backup
+# and when no outside source of synchronized time is available. The
+# default stratum is usually 3, but in this case we elect to use stratum
+# 0. Since the server line does not have the prefer keyword, this driver
+# is never used for synchronization, unless no other other
+# synchronization source is available. In case the local host is
+# controlled by some external source, such as an external oscillator or
+# another protocol, the prefer keyword would cause the local host to
+# disregard all other synchronization sources, unless the kernel
+# modifications are in use and declare an unsynchronized condition.
+#
+server	127.127.1.0	# local clock
+fudge	127.127.1.0 stratum 10	
+
+#
+# Drift file.  Put this in a directory which the daemon can write to.
+# No symbolic links allowed, either, since the daemon updates the file
+# by creating a temporary in the same directory and then rename()'ing
+# it to the file.
+#
+driftfile /var/lib/ntp/drift
+broadcastdelay	0.008
+
+#
+# Authentication delay.  If you use, or plan to use someday, the
+# authentication facility you should make the programs in the auth_stuff
+# directory and figure out what this number should be on your machine.
+#
+## authenticate yes
+
+#
+# Keys file.  If you want to diddle your server at run time, make a
+# keys file (mode 600 for sure) and define the key number to be
+# used for making requests.
+#
+# PLEASE DO NOT USE THE DEFAULT VALUES HERE. Pick your own, or remote
+# systems might be able to reset your clock at will. Note also that
+# ntpd is started with a -A flag, disabling authentication, that
+# will have to be removed as well.
+#
+keys		/etc/ntp/keys
+# server 192.168.0.1
+#server 192.168.246.1
+#server 192.168.0.2
+restrict 192.68.0.2 mask 255.255.255.255 nomodify notrap noquery
+
diff --git a/tests/Functional.ntp/fuego_test.sh b/tests/Functional.ntp/fuego_test.sh
new file mode 100644
index 0000000..c5ac056
--- /dev/null
+++ b/tests/Functional.ntp/fuego_test.sh
@@ -0,0 +1,24 @@
+function test_pre_check {
+    assert_has_program ntpdate
+    assert_has_program ntpdc
+    assert_has_program ntpq
+    assert_has_program ntptime
+    assert_has_program tickadj
+}
+
+function test_deploy {
+    put $TEST_HOME/ntp_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put $FUEGO_CORE/scripts/fuego_board_function_lib.sh $BOARD_TESTDIR/fuego.$TESTDIR
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/data $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    export test_tcpip_host=$SRV_IP;\
+    ./ntp_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.ntp/ntp_test.sh b/tests/Functional.ntp/ntp_test.sh
new file mode 100755
index 0000000..95c34db
--- /dev/null
+++ b/tests/Functional.ntp/ntp_test.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+. ./fuego_board_function_lib.sh
+set_init_manager
+
+for i in tests/*.sh; do
+    source $i
+done
diff --git a/tests/Functional.ntp/parser.py b/tests/Functional.ntp/parser.py
new file mode 100644
index 0000000..f25a608
--- /dev/null
+++ b/tests/Functional.ntp/parser.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+import common as plib
+
+measurements = {}
+measurements = collections.OrderedDict()
+
+regex_string = '^ -> (.*): TEST-(.*)$'
+matches = plib.parse_log(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
+
+# split the output for each testcase
+plib.split_output_per_testcase(regex_string, measurements)
+
+sys.exit(plib.process(measurements))
diff --git a/tests/Functional.ntp/spec.json b/tests/Functional.ntp/spec.json
new file mode 100644
index 0000000..c537ede
--- /dev/null
+++ b/tests/Functional.ntp/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.ntp",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.ntp/test.yaml b/tests/Functional.ntp/test.yaml
new file mode 100644
index 0000000..e331e1e
--- /dev/null
+++ b/tests/Functional.ntp/test.yaml
@@ -0,0 +1,34 @@
+fuego_package_version: 1
+name: Functional.ntp
+description: |
+      The Network Time Protocol (NTP) is a networking protocol for clock synchronization between computer
+      systems over packet-switched, variable-latency data networks.
+      This is a simple test to check the service and commands of ntp.
+license: Unknown
+author: Wang Mingyu <wangmy@cn.fujitsu.com>
+maintainer: Tim Bird <tim.bird@sony.com>
+version: 2.00
+fuego_release: 1
+type: Functional
+tags: ['time']
+params:
+      SRV_IP="The IP address of host" Defined in board file
+data_files:
+ - ntp_test.sh
+ - fuego_test.sh
+ - parser.py
+ - spec.json
+ - test.yaml
+ - data
+   hosts
+   ntp.data
+ - tests
+   ntp_ntpdate1.sh
+   ntp_ntpdate2.sh
+   ntp_ntpdc.sh
+   ntp_ntpq.sh
+   ntp_ntptime.sh
+   ntp_pid.sh
+   ntp_ps.sh
+   ntp_syslog.sh
+   ntp_tickadj.sh
diff --git a/tests/Functional.ntp/tests/ntp_ntpdate1.sh b/tests/Functional.ntp/tests/ntp_ntpdate1.sh
new file mode 100644
index 0000000..8b0b18a
--- /dev/null
+++ b/tests/Functional.ntp/tests/ntp_ntpdate1.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run command netpdate.
+#  option: -q
+
+test="ntpdate1"
+
+if ntpdate -q $test_tcpip_host | grep "server $test_tcpip_host"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/tests/Functional.ntp/tests/ntp_ntpdate2.sh b/tests/Functional.ntp/tests/ntp_ntpdate2.sh
new file mode 100644
index 0000000..c6d1b81
--- /dev/null
+++ b/tests/Functional.ntp/tests/ntp_ntpdate2.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+#  In target, run command netpdate.
+#  option: -q.
+
+test="ntpdate2"
+
+service_status=$(get_service_status ntpd)
+
+exec_service_on_target ntpd start
+if ntpdate -q $test_tcpip_host | grep "server $test_tcpip_host"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+if [ "$service_status" = "inactive" ]
+then
+    exec_service_on_target ntpd stop
+fi
diff --git a/tests/Functional.ntp/tests/ntp_ntpdc.sh b/tests/Functional.ntp/tests/ntp_ntpdc.sh
new file mode 100644
index 0000000..bdbbfeb
--- /dev/null
+++ b/tests/Functional.ntp/tests/ntp_ntpdc.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+#  In target, run command ntpdc.
+#  option: -p
+
+test="ntpdc"
+
+service_status=$(get_service_status ntpd)
+
+cp data/hosts data/hosts_$test_tcpip_host
+echo "$test_tcpip_host   $test_tcpip_host" >> data/hosts_$test_tcpip_host
+mv /etc/hosts /etc/hosts_bak
+cp data/hosts_$test_tcpip_host /etc/hosts
+
+exec_service_on_target ntpd stop
+
+cp data/ntp.conf data/ntp.conf_$test_tcpip_host
+echo "server $test_tcpip_host" >> data/ntp.conf_$test_tcpip_host
+mv /etc/ntp.conf /etc/ntp.conf_bak
+cp data/ntp.conf_$test_tcpip_host /etc/ntp.conf
+echo enable mode7 >> /etc/ntp.conf
+
+restore_target() {
+    mv /etc/ntp.conf_bak /etc/ntp.conf
+    mv /etc/hosts_bak /etc/hosts
+    rm data/hosts_$test_tcpip_host data/ntp.conf_$test_tcpip_host
+}
+
+if exec_service_on_target ntpd restart
+then
+    echo " -> $test: ntpd restart succeeded."
+else
+    echo " -> $test: ntpd restart failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+if ntpdc -p 127.0.0.1 | grep "$test_tcpip_host"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+if [ "$service_status" = "inactive" ]
+then
+    exec_service_on_target ntpd stop
+fi
+restore_target
diff --git a/tests/Functional.ntp/tests/ntp_ntpq.sh b/tests/Functional.ntp/tests/ntp_ntpq.sh
new file mode 100644
index 0000000..cdf816b
--- /dev/null
+++ b/tests/Functional.ntp/tests/ntp_ntpq.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+#  In target, run command ntpq.
+#  option: -p.
+
+test="ntpq"
+
+service_status=$(get_service_status ntpd)
+
+cp data/hosts data/hosts_$test_tcpip_host
+echo "$test_tcpip_host   $test_tcpip_host" >> data/hosts_$test_tcpip_host
+mv /etc/hosts /etc/hosts_bak
+cp data/hosts_$test_tcpip_host /etc/hosts
+
+exec_service_on_target ntpd stop
+
+cp data/ntp.conf data/ntp.conf_$test_tcpip_host
+echo "server $test_tcpip_host" >> data/ntp.conf_$test_tcpip_host
+mv /etc/ntp.conf /etc/ntp.conf_bak
+cp data/ntp.conf_$test_tcpip_host /etc/ntp.conf
+echo enable mode7 >> /etc/ntp.conf
+
+restore_target() {
+    mv /etc/ntp.conf_bak /etc/ntp.conf
+    mv /etc/hosts_bak /etc/hosts
+    rm data/hosts_$test_tcpip_host data/ntp.conf_$test_tcpip_host
+}
+
+if exec_service_on_target ntpd restart
+then
+    echo " -> $test: ntpd restart succeeded."
+else
+    echo " -> $test: ntpd restart failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+if ntpq -p 127.0.0.1 | grep "$test_tcpip_host"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+if [ "$service_status" = "inactive" ]
+then
+    exec_service_on_target ntpd stop
+fi
+restore_target
diff --git a/tests/Functional.ntp/tests/ntp_ntptime.sh_bak b/tests/Functional.ntp/tests/ntp_ntptime.sh_bak
new file mode 100644
index 0000000..4d5f961
--- /dev/null
+++ b/tests/Functional.ntp/tests/ntp_ntptime.sh_bak
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+#  In target, run command ntptime.
+#  option: none
+
+test="ntptime"
+
+service_status=$(get_service_status ntpd)
+
+if exec_service_on_target ntpd restart
+then
+    echo " -> $test: ntpd restart succeeded."
+else
+    echo " -> $test: ntpd restart failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+if ntptime | grep OK
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
+if [ "$service_status" = "inactive" ]
+then
+    exec_service_on_target ntpd stop
+fi
diff --git a/tests/Functional.ntp/tests/ntp_pid.sh b/tests/Functional.ntp/tests/ntp_pid.sh
new file mode 100644
index 0000000..61e5a9a
--- /dev/null
+++ b/tests/Functional.ntp/tests/ntp_pid.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+#  In target start ntpd and verify the process of creating the process ID file by ntpd.
+#  option: none.
+
+test="pid"
+
+service_status=$(get_service_status ntpd)
+
+exec_service_on_target ntpd stop
+
+if [ -f /var/run/ntpd.pid ]
+then
+   rm -f /var/run/ntpd.pid
+fi
+
+if exec_service_on_target ntpd start
+then
+    echo " -> $test: ntpd start succeeded."
+else
+    echo " -> $test: ntpd start failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+if ls /var/run/ntpd.pid
+then
+    echo " -> $test: ntpd pid is exist."
+else
+    echo " -> $test: ntpd pid is not exist."
+    echo " -> $test: TEST-FAIL"
+    if [ "$service_status" = "inactive" ]
+    then
+        exec_service_on_target ntpd stop
+    fi
+    exit
+fi
+
+if exec_service_on_target ntpd stop
+then
+    echo " -> $test: ntpd stop succeeded."
+else
+    echo " -> $test: ntpd stop failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+if test ! -f /var/run/ntpd.pid
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+then
+    exec_service_on_target ntpd start
+fi
diff --git a/tests/Functional.ntp/tests/ntp_ps.sh b/tests/Functional.ntp/tests/ntp_ps.sh
new file mode 100644
index 0000000..0c3e4fb
--- /dev/null
+++ b/tests/Functional.ntp/tests/ntp_ps.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+#  In the target start ntpd, and confirm the process condition by command ps.
+
+test="ps"
+
+service_status=$(get_service_status ntpd)
+
+exec_service_on_target ntpd stop
+
+if exec_service_on_target ntpd start
+then
+    echo " -> start of ntpd succeeded."
+else
+    echo " -> start of ntpd failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+sleep 5
+
+if ps aux | grep "[/]usr/sbin/ntpd"
+then
+    echo " -> get the process of ntpd."
+else
+    echo " -> can't get the process of ntpd."
+    echo " -> $test: TEST-FAIL"
+    if [ "$service_status" = "inactive" ]
+    then
+        exec_service_on_target ntpd stop
+    fi
+    exit
+fi
+
+exec_service_on_target ntpd stop
+
+if ps aux | grep "[/]usr/sbin/ntpd"
+then
+    echo " -> $test: TEST-FAIL"
+else
+    echo " -> $test: TEST-PASS"
+fi
+
+if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+then
+    exec_service_on_target ntpd start
+fi
diff --git a/tests/Functional.ntp/tests/ntp_syslog.sh b/tests/Functional.ntp/tests/ntp_syslog.sh
new file mode 100644
index 0000000..c6c778a
--- /dev/null
+++ b/tests/Functional.ntp/tests/ntp_syslog.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+#  In target, start ntpd and verify the ntpd syslog.
+#  option: none
+
+test="syslog"
+
+service_status=$(get_service_status ntpd)
+logger_service=$(detect_logger_service)
+
+exec_service_on_target ntpd stop
+exec_service_on_target $logger_service stop
+
+if [ -f /var/log/syslog ]
+then
+    mv /var/log/syslog /var/log/syslog_bak
+fi
+
+restore_target() {
+    if [ -f /var/log/syslog_bak ]
+    then
+        mv /var/log/syslog_bak /var/log/syslog
+    fi
+}
+
+exec_service_on_target $logger_service restart
+
+if exec_service_on_target ntpd start
+then
+    echo " -> $test: ntpd start succeeded."
+else
+    echo " -> $test: ntpd start failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+sleep 10
+
+if cat /var/log/syslog | grep ntpd
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+if [ "$service_status" = "inactive" ]
+then
+    exec_service_on_target ntpd stop
+fi
+restore_target
diff --git a/tests/Functional.ntp/tests/ntp_tickadj.sh b/tests/Functional.ntp/tests/ntp_tickadj.sh
new file mode 100644
index 0000000..27e6e62
--- /dev/null
+++ b/tests/Functional.ntp/tests/ntp_tickadj.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+#  In target, run command tickadj.
+#  option: none
+
+test="tickadj"
+
+service_status=$(get_service_status ntpd )
+if exec_service_on_target ntpd stop
+then
+    echo " -> $test: ntpd stop succeeded."
+else
+    echo " -> $test: ntpd stop failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+if tickadj | grep tick
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+then
+    exec_service_on_target ntpd start
+fi
-- 
1.8.3.1




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

* [Fuego] [PATCH v2] openvpn: Add test cases of service openvpn.
  2019-03-25  9:19 [Fuego] [PATCH v2] atmtcp: Add test cases for command atmtcp Wang Mingyu
                   ` (3 preceding siblings ...)
  2019-03-25  9:19 ` [Fuego] [PATCH v2] ntp: Add test cases for commands of ntp Wang Mingyu
@ 2019-03-25  9:19 ` Wang Mingyu
  2019-03-25  9:19 ` [Fuego] [PATCH v2] parted: Add test cases for command parted Wang Mingyu
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Wang Mingyu @ 2019-03-25  9:19 UTC (permalink / raw)
  To: fuego

This test set is used to check if the service openvpn can be started.
And check the process file, syslog file, tap0 can be created or not.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 tests/Functional.openvpn/data/host-target.key      | 22 +++++++++
 tests/Functional.openvpn/data/testcli.conf         |  7 +++
 tests/Functional.openvpn/data/testenv.sh           | 18 +++++++
 tests/Functional.openvpn/data/testsrv.conf         | 16 +++++++
 tests/Functional.openvpn/fuego_test.sh             | 19 ++++++++
 tests/Functional.openvpn/openvpn_test.sh           |  9 ++++
 tests/Functional.openvpn/parser.py                 | 20 ++++++++
 tests/Functional.openvpn/spec.json                 |  6 +++
 tests/Functional.openvpn/tests/openvpn_genkey.sh   | 15 ++++++
 .../tests/openvpn_lport_client.sh                  | 53 +++++++++++++++++++++
 .../tests/openvpn_lport_server.sh                  | 51 ++++++++++++++++++++
 .../Functional.openvpn/tests/openvpn_pid_client.sh | 50 ++++++++++++++++++++
 .../Functional.openvpn/tests/openvpn_pid_server.sh | 51 ++++++++++++++++++++
 .../Functional.openvpn/tests/openvpn_ps_client.sh  | 55 ++++++++++++++++++++++
 .../Functional.openvpn/tests/openvpn_ps_server.sh  | 55 ++++++++++++++++++++++
 .../tests/openvpn_syslog-ng_client.sh              | 54 +++++++++++++++++++++
 .../tests/openvpn_syslog-ng_server.sh              | 52 ++++++++++++++++++++
 .../Functional.openvpn/tests/openvpn_tun_client.sh | 44 +++++++++++++++++
 .../Functional.openvpn/tests/openvpn_tun_server.sh | 44 +++++++++++++++++
 19 files changed, 641 insertions(+)
 create mode 100644 tests/Functional.openvpn/data/host-target.key
 create mode 100644 tests/Functional.openvpn/data/testcli.conf
 create mode 100644 tests/Functional.openvpn/data/testenv.sh
 create mode 100644 tests/Functional.openvpn/data/testsrv.conf
 create mode 100644 tests/Functional.openvpn/fuego_test.sh
 create mode 100755 tests/Functional.openvpn/openvpn_test.sh
 create mode 100644 tests/Functional.openvpn/parser.py
 create mode 100644 tests/Functional.openvpn/spec.json
 create mode 100644 tests/Functional.openvpn/tests/openvpn_genkey.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_lport_client.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_lport_server.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_pid_client.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_pid_server.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_ps_client.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_ps_server.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_syslog-ng_client.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_syslog-ng_server.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_tun_client.sh
 create mode 100644 tests/Functional.openvpn/tests/openvpn_tun_server.sh

diff --git a/tests/Functional.openvpn/data/host-target.key b/tests/Functional.openvpn/data/host-target.key
new file mode 100644
index 0000000..99743bf
--- /dev/null
+++ b/tests/Functional.openvpn/data/host-target.key
@@ -0,0 +1,22 @@
+#
+# 2048 bit OpenVPN static key
+#
+-----BEGIN OpenVPN Static key V1-----
+debe9557c7eb224c5cf4f3369d5211ff
+fb9c375a4784759edf6b0f6eb8f5da31
+bb280394d40382cc8e02d6cbb3e47492
+3509eac6b48965078e3d317b0791dea2
+dbcf0eddcab0fb20780fcf0908ce94cd
+7cb65a913fea73ac6bfe0ab34f085aa3
+a6c8b89a97d189e5145c3199955c4b34
+6d51f864f2b49f3252d1548c3b3510ec
+0ecd4b9f17f2039439a79f41a46f6a54
+c0385b962b2b94fcbe73e0108b224a5b
+2efae27d872f0efef67b244c7eb6f525
+581e4c2b4e6aa193fb1d37798bdb46ff
+7c6727f08e9601c10ac7478d73d731e6
+f4b652252f3e5309cd1d6d30c7a433cc
+134bd6dd50fa6a6fc7a843fdc058d38d
+fb8679b48eb09745badf004fbf4a434c
+-----END OpenVPN Static key V1-----
+
diff --git a/tests/Functional.openvpn/data/testcli.conf b/tests/Functional.openvpn/data/testcli.conf
new file mode 100644
index 0000000..2c252bb
--- /dev/null
+++ b/tests/Functional.openvpn/data/testcli.conf
@@ -0,0 +1,7 @@
+remote  192.168.0.1
+port    5000
+dev     tap
+#dev    tun
+verb    3
+ping    60
+
diff --git a/tests/Functional.openvpn/data/testenv.sh b/tests/Functional.openvpn/data/testenv.sh
new file mode 100644
index 0000000..8c01d58
--- /dev/null
+++ b/tests/Functional.openvpn/data/testenv.sh
@@ -0,0 +1,18 @@
+#set the variable
+if [ "$init_manager" == "systemd" ]
+then
+        service_name="openvpn@loopback-server.service"
+        config_file="/etc/openvpn/loopback-server.conf"
+        pid_file="/var/run/openvpn/loopback-server.pid"
+else
+        service_name="openvpn"
+        if [ "$test_type" == "client" ]
+        then
+                config_file="/etc/openvpn/testcli.conf"
+                pid_file="/var/run/openvpn.testcli.pid"
+        elif [ "$test_type" == "server" ]
+        then
+                config_file="/etc/openvpn/testsrv.conf"
+                pid_file="/var/run/openvpn.testsrv.pid"
+        fi
+fi
diff --git a/tests/Functional.openvpn/data/testsrv.conf b/tests/Functional.openvpn/data/testsrv.conf
new file mode 100644
index 0000000..0c18a40
--- /dev/null
+++ b/tests/Functional.openvpn/data/testsrv.conf
@@ -0,0 +1,16 @@
+#
+proto           udp
+port            5000
+
+dev             tap
+
+secret          /etc/openvpn/host-target.key
+#link-mtu       1200
+
+ping            10
+ping-restart    60
+ping-timer-rem
+persist-key
+persist-tun
+verb            3
+
diff --git a/tests/Functional.openvpn/fuego_test.sh b/tests/Functional.openvpn/fuego_test.sh
new file mode 100644
index 0000000..65d2991
--- /dev/null
+++ b/tests/Functional.openvpn/fuego_test.sh
@@ -0,0 +1,19 @@
+function test_pre_check {
+    assert_has_program openvpn
+}
+
+function test_deploy {
+    put $TEST_HOME/openvpn_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put $FUEGO_CORE/scripts/fuego_board_function_lib.sh $BOARD_TESTDIR/fuego.$TESTDIR
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/data $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./openvpn_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.openvpn/openvpn_test.sh b/tests/Functional.openvpn/openvpn_test.sh
new file mode 100755
index 0000000..42f41ea
--- /dev/null
+++ b/tests/Functional.openvpn/openvpn_test.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+. ./fuego_board_function_lib.sh
+set_init_manager
+
+. data/testenv.sh
+
+for i in tests/*.sh; do
+    source $i
+done
diff --git a/tests/Functional.openvpn/parser.py b/tests/Functional.openvpn/parser.py
new file mode 100644
index 0000000..f25a608
--- /dev/null
+++ b/tests/Functional.openvpn/parser.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+import common as plib
+
+measurements = {}
+measurements = collections.OrderedDict()
+
+regex_string = '^ -> (.*): TEST-(.*)$'
+matches = plib.parse_log(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
+
+# split the output for each testcase
+plib.split_output_per_testcase(regex_string, measurements)
+
+sys.exit(plib.process(measurements))
diff --git a/tests/Functional.openvpn/spec.json b/tests/Functional.openvpn/spec.json
new file mode 100644
index 0000000..e9fdc5a
--- /dev/null
+++ b/tests/Functional.openvpn/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.openvpn",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.openvpn/tests/openvpn_genkey.sh b/tests/Functional.openvpn/tests/openvpn_genkey.sh
new file mode 100644
index 0000000..d951589
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_genkey.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#  In target, run command openvpn.
+#  option: --genkey
+
+test="genkey"
+
+openvpn --genkey --secret /etc/openvpn/host-target.key
+if ls /etc/openvpn/host-target.key
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+rm -f /etc/openvpn/host-target.key
diff --git a/tests/Functional.openvpn/tests/openvpn_lport_client.sh b/tests/Functional.openvpn/tests/openvpn_lport_client.sh
new file mode 100644
index 0000000..783aa10
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_lport_client.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+#  In the target, run openvpn and check the Listening port.
+
+test="lport_client"
+
+test_type="client"
+
+service_status=$(get_service_status $service_name)
+exec_service_on_target $service_name stop
+if [ ! -f $config_file ]
+then
+    touch $config_file
+fi
+
+mv $config_file $config_file"_bak"
+cp data/testcli.conf $config_file
+cp data/host-target.key /etc/openvpn/host-target.key
+
+mkdir -m 755 /dev/net
+mknod /dev/net/tun c 10 200
+
+restore_target() {
+    rm -fr /dev/net
+    mv $config_file"_bak" $config_file
+    rm -r /etc/openvpn/host-target.key
+    modprobe -r tun
+}
+
+if exec_service_on_target $service_name start
+then
+    echo " -> $test: service start succeeded."
+else
+    echo " -> $test: service start failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+sleep 5
+
+if netstat -ln | grep ":5000"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+if [ "$service_status" = "inactive" ]
+then
+    exec_service_on_target $service_name stop
+fi
+restore_target
diff --git a/tests/Functional.openvpn/tests/openvpn_lport_server.sh b/tests/Functional.openvpn/tests/openvpn_lport_server.sh
new file mode 100644
index 0000000..ba94aee
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_lport_server.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+#  In the target, run openvpn and check the Listening port.
+
+test="lport_server"
+
+test_type="server"
+
+service_status=$(get_service_status $service_name)
+if [ ! -f $config_file ]
+then
+    touch $config_file
+fi
+
+mv $config_file $config_file"_bak"
+cp data/testsrv.conf $config_file
+cp data/host-target.key /etc/openvpn/host-target.key
+
+mkdir -m 755 /dev/net
+mknod /dev/net/tun c 10 200
+
+restore_target() {
+    rm -fr /dev/net
+    mv $config_file"_bak" $config_file
+    rm -r /etc/openvpn/host-target.key
+    modprobe -r tun
+}
+
+if exec_service_on_target $service_name start
+then
+    echo " -> $test: service start succeeded."
+else
+    echo " -> $test: service start failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+sleep 5
+
+if netstat -ln | grep ":5000"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+if [ "$service_status" = "inactive" ]
+then
+    exec_service_on_target $service_name stop
+fi
+restore_target
diff --git a/tests/Functional.openvpn/tests/openvpn_pid_client.sh b/tests/Functional.openvpn/tests/openvpn_pid_client.sh
new file mode 100644
index 0000000..7ffcdc6
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_pid_client.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+#  In the target, run openvpn and check the pidfile.
+
+test="pid_client"
+
+test_type="client"
+
+service_status=$(get_service_status $service_name)
+exec_service_on_target $service_name stop
+if [ ! -f $config_file ]
+then
+    touch $config_file
+fi
+
+mv $config_file $config_file"_bak"
+cp data/testcli.conf $config_file
+cp data/host-target.key /etc/openvpn/host-target.key
+
+mkdir -m 755 /dev/net
+mknod /dev/net/tun c 10 200
+
+restore_target() {
+    rm -fr /dev/net
+    mv $config_file"_bak" $config_file
+    rm -r /etc/openvpn/host-target.key
+    modprobe -r tun
+}
+
+if exec_service_on_target $service_name start
+then
+    echo " -> $test: service start succeeded."
+else
+    echo " -> $test: service start failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+if ls $pid_file
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+if [ "$service_status" = "inactive" ]
+then
+    exec_service_on_target $service_name stop
+fi
+restore_target
diff --git a/tests/Functional.openvpn/tests/openvpn_pid_server.sh b/tests/Functional.openvpn/tests/openvpn_pid_server.sh
new file mode 100644
index 0000000..9f57d0a
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_pid_server.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+#  In the target, run openvpn and check the pidfile.
+
+test="pid_server"
+
+test_type="server"
+
+service_status=$(get_service_status $service_name)
+exec_service_on_target $service_name stop
+if [ ! -f $config_file ]
+then
+    touch $config_file
+fi
+
+mv $config_file $config_file"_bak"
+cp data/testsrv.conf $config_file
+cp data/host-target.key /etc/openvpn/host-target.key
+
+mkdir -m 755 /dev/net
+mknod /dev/net/tun c 10 200
+
+restore_target() {
+    rm -fr /dev/net
+    mv $config_file"_bak" $config_file
+    rm -r /etc/openvpn/host-target.key
+    modprobe -r tun
+}
+
+if exec_service_on_target $service_name start
+then
+    echo " -> $test: service start succeeded."
+else
+    echo " -> $test: service start failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+if ls $pid_file
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+if [ "$service_status" = "inactive" ]
+then
+    exec_service_on_target $service_name stop
+fi
+restore_target
diff --git a/tests/Functional.openvpn/tests/openvpn_ps_client.sh b/tests/Functional.openvpn/tests/openvpn_ps_client.sh
new file mode 100644
index 0000000..78a292a
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_ps_client.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+#  In the target, run openvpn and check the status of process.
+
+test="ps_client"
+
+test_type="client"
+
+service_status=$(get_service_status $service_name)
+exec_service_on_target $service_name stop
+if [ ! -f $config_file ]
+then
+    touch $config_file
+fi
+
+mv $config_file $config_file"_bak"
+cp data/testcli.conf $config_file
+cp data/host-target.key /etc/openvpn/host-target.key
+
+mkdir -m 755 /dev/net
+mknod /dev/net/tun c 10 200
+
+restore_target() {
+    rm -fr /dev/net
+    mv $config_file"_bak" $config_file
+    rm -r /etc/openvpn/host-target.key
+    modprobe -r tun
+}
+
+exec_service_on_target $service_name start
+
+if ps aux | grep "[/]usr/sbin/openvpn"
+then
+    echo " -> $test: get the process of openvpn succeeded."
+else
+    echo " -> $test: get the process of openvpn failed."
+    echo " -> $test: TEST-FAIL"
+    exec_service_on_target $service_name stop
+    restore_target
+    exit
+fi
+
+exec_service_on_target $service_name stop
+
+if ! ps aux | grep "[/]usr/sbin/openvpn"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+restore_target
+if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+then
+    exec_service_on_target $service_name start
+fi
diff --git a/tests/Functional.openvpn/tests/openvpn_ps_server.sh b/tests/Functional.openvpn/tests/openvpn_ps_server.sh
new file mode 100644
index 0000000..99591b2
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_ps_server.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+#  In the target, run openvpn and check the status of process.
+
+test="ps_server"
+
+test_type="server"
+
+service_status=$(get_service_status $service_name)
+exec_service_on_target $service_name stop
+if [ ! -f $config_file ]
+then
+    touch $config_file
+fi
+
+mv $config_file $config_file"_bak"
+cp data/testsrv.conf $config_file
+cp data/host-target.key /etc/openvpn/host-target.key
+
+mkdir -m 755 /dev/net
+mknod /dev/net/tun c 10 200
+
+restore_target() {
+    rm -fr /dev/net
+    mv $config_file"_bak" $config_file
+    rm -r /etc/openvpn/host-target.key
+    modprobe -r tun
+}
+
+exec_service_on_target $service_name start
+
+if ps aux | grep "[/]usr/sbin/openvpn"
+then
+    echo " -> $test: get the process of openvpn succeeded."
+else
+    echo " -> $test: get the process of openvpn failed."
+    echo " -> $test: TEST-FAIL"
+    exec_service_on_target $service_name stop
+    restore_target
+    exit
+fi
+
+exec_service_on_target $service_name stop
+
+if ! ps aux | grep "[/]usr/sbin/openvpn"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+restore_target
+if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+then
+    exec_service_on_target $service_name start
+fi
diff --git a/tests/Functional.openvpn/tests/openvpn_syslog-ng_client.sh b/tests/Functional.openvpn/tests/openvpn_syslog-ng_client.sh
new file mode 100644
index 0000000..4a7a97f
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_syslog-ng_client.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+#  In the target, run openvpn and check the message of syslog-ng.
+
+test="syslog-ng_client"
+
+test_type="client"
+
+service_status=$(get_service_status $service_name)
+exec_service_on_target $service_name stop
+rm -f /var/log/syslog
+if [ -e /var/run/syslog-ng.pid ]
+then
+    exec_service_on_target syslog-ng stop
+fi
+
+exec_service_on_target syslog-ng restart
+
+if [ ! -f $config_file ]
+then
+    touch $config_file
+fi
+
+mv $config_file $config_file"_bak"
+cp data/testcli.conf $config_file
+cp data/host-target.key /etc/openvpn/host-target.key
+
+mkdir -m 755 /dev/net
+mknod /dev/net/tun c 10 200
+
+exec_service_on_target $service_name start
+
+sleep 5
+
+if cat /var/log/syslog | grep OpenVPN
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+exec_service_on_target $service_name stop
+
+rm -fr /dev/net
+
+mv $config_file"_bak" $config_file
+
+rm -r /etc/openvpn/host-target.key
+
+modprobe -r tun
+if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+then
+    exec_service_on_target $service_name start
+fi
diff --git a/tests/Functional.openvpn/tests/openvpn_syslog-ng_server.sh b/tests/Functional.openvpn/tests/openvpn_syslog-ng_server.sh
new file mode 100644
index 0000000..8d25502
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_syslog-ng_server.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+#  In the target, run openvpn and check the message of syslog-ng.
+
+test="syslog-ng_server"
+
+service_status=$(get_service_status $service_name)
+exec_service_on_target $service_name stop
+rm -f /var/log/syslog
+if [ -e /var/run/syslog-ng.pid ]
+then
+    exec_service_on_target syslog-ng stop
+fi
+
+exec_service_on_target syslog-ng restart
+
+if [ ! -f $config_file ]
+then
+    touch $config_file
+fi
+
+mv $config_file $config_file"_bak"
+cp data/testsrv.conf $config_file
+cp data/host-target.key /etc/openvpn/host-target.key
+
+mkdir -m 755 /dev/net
+mknod /dev/net/tun c 10 200
+
+exec_service_on_target $service_name start
+
+sleep 5
+
+if cat /var/log/syslog | grep OpenVPN
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+exec_service_on_target $service_name stop
+
+rm -fr /dev/net
+
+mv $config_file"_bak" $config_file
+
+rm -r /etc/openvpn/host-target.key
+
+modprobe -r tun
+if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+then
+    exec_service_on_target $service_name start
+fi
diff --git a/tests/Functional.openvpn/tests/openvpn_tun_client.sh b/tests/Functional.openvpn/tests/openvpn_tun_client.sh
new file mode 100644
index 0000000..d7addc3
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_tun_client.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+# Verify the creation of the tun device (tap0) interface by openvpn.
+
+test="tun_client"
+
+test_type="client"
+
+service_status=$(get_service_status $service_name)
+exec_service_on_target $service_name stop
+if [ ! -f $config_file ]
+then
+    touch $config_file
+fi
+
+mv $config_file $config_file"_bak"
+cp data/testcli.conf $config_file
+cp data/host-target.key /etc/openvpn/host-target.key
+
+mkdir -m 755 /dev/net
+mknod /dev/net/tun c 10 200
+
+exec_service_on_target $service_name start
+
+if ifconfig tap0
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+exec_service_on_target $service_name stop
+
+rm -fr /dev/net
+
+mv $config_file"_bak" $config_file
+
+rm -r /etc/openvpn/host-target.key
+
+modprobe -r tun
+if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+then
+    exec_service_on_target $service_name start
+fi
diff --git a/tests/Functional.openvpn/tests/openvpn_tun_server.sh b/tests/Functional.openvpn/tests/openvpn_tun_server.sh
new file mode 100644
index 0000000..17eae66
--- /dev/null
+++ b/tests/Functional.openvpn/tests/openvpn_tun_server.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+# Verify the creation of the tun device (tap0) interface by openvpn.
+
+test="tun_server"
+
+test_type="server"
+
+service_status=$(get_service_status $service_name)
+exec_service_on_target $service_name stop
+if [ ! -f $config_file ]
+then
+    touch $config_file
+fi
+
+mv $config_file $config_file"_bak"
+cp data/testsrv.conf $config_file
+cp data/host-target.key /etc/openvpn/host-target.key
+
+mkdir -m 755 /dev/net
+mknod /dev/net/tun c 10 200
+
+exec_service_on_target $service_name start
+
+if ifconfig tap0
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+exec_service_on_target $service_name stop
+
+rm -fr /dev/net
+
+mv $config_file"_bak" $config_file
+
+rm -r /etc/openvpn/host-target.key
+
+modprobe -r tun
+if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+then
+    exec_service_on_target $service_name start
+fi
-- 
1.8.3.1




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

* [Fuego] [PATCH v2] parted: Add test cases for command parted.
  2019-03-25  9:19 [Fuego] [PATCH v2] atmtcp: Add test cases for command atmtcp Wang Mingyu
                   ` (4 preceding siblings ...)
  2019-03-25  9:19 ` [Fuego] [PATCH v2] openvpn: Add test cases of service openvpn Wang Mingyu
@ 2019-03-25  9:19 ` Wang Mingyu
  2019-03-25  9:19 ` [Fuego] [PATCH v2] powertop: Add test cases for command powertop Wang Mingyu
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Wang Mingyu @ 2019-03-25  9:19 UTC (permalink / raw)
  To: fuego

This test set is used to display machine parseable output, help message and version of command parted.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 tests/Functional.parted/fuego_test.sh           | 18 ++++++++++++++++++
 tests/Functional.parted/parser.py               | 20 ++++++++++++++++++++
 tests/Functional.parted/parted_test.sh          |  4 ++++
 tests/Functional.parted/spec.json               |  6 ++++++
 tests/Functional.parted/tests/parted_help.sh    | 13 +++++++++++++
 tests/Functional.parted/tests/parted_machine.sh | 19 +++++++++++++++++++
 tests/Functional.parted/tests/parted_summary.sh | 13 +++++++++++++
 tests/Functional.parted/tests/parted_version.sh | 13 +++++++++++++
 8 files changed, 106 insertions(+)
 create mode 100644 tests/Functional.parted/fuego_test.sh
 create mode 100644 tests/Functional.parted/parser.py
 create mode 100755 tests/Functional.parted/parted_test.sh
 create mode 100644 tests/Functional.parted/spec.json
 create mode 100644 tests/Functional.parted/tests/parted_help.sh
 create mode 100644 tests/Functional.parted/tests/parted_machine.sh
 create mode 100644 tests/Functional.parted/tests/parted_summary.sh
 create mode 100644 tests/Functional.parted/tests/parted_version.sh

diff --git a/tests/Functional.parted/fuego_test.sh b/tests/Functional.parted/fuego_test.sh
new file mode 100644
index 0000000..3c94d6a
--- /dev/null
+++ b/tests/Functional.parted/fuego_test.sh
@@ -0,0 +1,18 @@
+function test_pre_check {
+    assert_has_program parted
+    assert_has_program partprobe
+}
+
+function test_deploy {
+    put $TEST_HOME/parted_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./parted_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.parted/parser.py b/tests/Functional.parted/parser.py
new file mode 100644
index 0000000..f25a608
--- /dev/null
+++ b/tests/Functional.parted/parser.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+import common as plib
+
+measurements = {}
+measurements = collections.OrderedDict()
+
+regex_string = '^ -> (.*): TEST-(.*)$'
+matches = plib.parse_log(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
+
+# split the output for each testcase
+plib.split_output_per_testcase(regex_string, measurements)
+
+sys.exit(plib.process(measurements))
diff --git a/tests/Functional.parted/parted_test.sh b/tests/Functional.parted/parted_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/tests/Functional.parted/parted_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/tests/Functional.parted/spec.json b/tests/Functional.parted/spec.json
new file mode 100644
index 0000000..f44c21e
--- /dev/null
+++ b/tests/Functional.parted/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.parted",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.parted/tests/parted_help.sh b/tests/Functional.parted/tests/parted_help.sh
new file mode 100644
index 0000000..1460cfe
--- /dev/null
+++ b/tests/Functional.parted/tests/parted_help.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run command parted.
+#  option: --help.
+
+test="help"
+
+if parted --help | grep Usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
diff --git a/tests/Functional.parted/tests/parted_machine.sh b/tests/Functional.parted/tests/parted_machine.sh
new file mode 100644
index 0000000..6cdca7e
--- /dev/null
+++ b/tests/Functional.parted/tests/parted_machine.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+#  In target, run command parted to displays machine parseable output.
+#  option: --machine.
+
+test="machine"
+
+expect <<-EOF
+spawn parted --machine
+expect {
+ -re ".*GNU Parted.*" {
+           send_user " -> $test: TEST-PASS\n"
+          }
+ default {
+            send_user " -> can't displays machine parseable output.\n"
+            send_user " -> $test: TEST-FAIL\n"}  }
+send "q\n"
+expect eof
+EOF
diff --git a/tests/Functional.parted/tests/parted_summary.sh b/tests/Functional.parted/tests/parted_summary.sh
new file mode 100644
index 0000000..2df576a
--- /dev/null
+++ b/tests/Functional.parted/tests/parted_summary.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run command partprobe.
+#  option: -s
+
+test="summary"
+
+if partprobe -s
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/tests/Functional.parted/tests/parted_version.sh b/tests/Functional.parted/tests/parted_version.sh
new file mode 100644
index 0000000..5fb7136
--- /dev/null
+++ b/tests/Functional.parted/tests/parted_version.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run command partprobe.
+#  option: -v
+
+test="version"
+
+if partprobe -v | grep Copyright
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
-- 
1.8.3.1




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

* [Fuego] [PATCH v2] powertop: Add test cases for command powertop.
  2019-03-25  9:19 [Fuego] [PATCH v2] atmtcp: Add test cases for command atmtcp Wang Mingyu
                   ` (5 preceding siblings ...)
  2019-03-25  9:19 ` [Fuego] [PATCH v2] parted: Add test cases for command parted Wang Mingyu
@ 2019-03-25  9:19 ` Wang Mingyu
  2019-03-25  9:19 ` [Fuego] [PATCH v2] quota: Add test cases of quota Wang Mingyu
  2019-05-20 20:18 ` [Fuego] [PATCH v2] atmtcp: Add test cases for command atmtcp Tim.Bird
  8 siblings, 0 replies; 10+ messages in thread
From: Wang Mingyu @ 2019-03-25  9:19 UTC (permalink / raw)
  To: fuego

This test set is used to analyze power consumption and show help message of command powertop.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 tests/Functional.powertop/fuego_test.sh          | 17 +++++++++++++++++
 tests/Functional.powertop/parser.py              | 20 ++++++++++++++++++++
 tests/Functional.powertop/powertop_test.sh       |  4 ++++
 tests/Functional.powertop/spec.json              |  6 ++++++
 tests/Functional.powertop/tests/powertop_csv.sh  | 13 +++++++++++++
 tests/Functional.powertop/tests/powertop_help.sh | 13 +++++++++++++
 6 files changed, 73 insertions(+)
 create mode 100644 tests/Functional.powertop/fuego_test.sh
 create mode 100644 tests/Functional.powertop/parser.py
 create mode 100755 tests/Functional.powertop/powertop_test.sh
 create mode 100644 tests/Functional.powertop/spec.json
 create mode 100644 tests/Functional.powertop/tests/powertop_csv.sh
 create mode 100644 tests/Functional.powertop/tests/powertop_help.sh

diff --git a/tests/Functional.powertop/fuego_test.sh b/tests/Functional.powertop/fuego_test.sh
new file mode 100644
index 0000000..377fc62
--- /dev/null
+++ b/tests/Functional.powertop/fuego_test.sh
@@ -0,0 +1,17 @@
+function test_pre_check {
+    assert_has_program powertop
+}
+
+function test_deploy {
+    put $TEST_HOME/powertop_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./powertop_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.powertop/parser.py b/tests/Functional.powertop/parser.py
new file mode 100644
index 0000000..f25a608
--- /dev/null
+++ b/tests/Functional.powertop/parser.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+import common as plib
+
+measurements = {}
+measurements = collections.OrderedDict()
+
+regex_string = '^ -> (.*): TEST-(.*)$'
+matches = plib.parse_log(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
+
+# split the output for each testcase
+plib.split_output_per_testcase(regex_string, measurements)
+
+sys.exit(plib.process(measurements))
diff --git a/tests/Functional.powertop/powertop_test.sh b/tests/Functional.powertop/powertop_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/tests/Functional.powertop/powertop_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/tests/Functional.powertop/spec.json b/tests/Functional.powertop/spec.json
new file mode 100644
index 0000000..3c5e680
--- /dev/null
+++ b/tests/Functional.powertop/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.powertop",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.powertop/tests/powertop_csv.sh b/tests/Functional.powertop/tests/powertop_csv.sh
new file mode 100644
index 0000000..9199a89
--- /dev/null
+++ b/tests/Functional.powertop/tests/powertop_csv.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run command powertop.
+#  option: --csv
+
+test="csv"
+
+if powertop --csv --time=1 | grep powertop
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
diff --git a/tests/Functional.powertop/tests/powertop_help.sh b/tests/Functional.powertop/tests/powertop_help.sh
new file mode 100644
index 0000000..5128289
--- /dev/null
+++ b/tests/Functional.powertop/tests/powertop_help.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run command powertop.
+#  option: --help
+
+test="help"
+
+if powertop --help | grep Usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
-- 
1.8.3.1




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

* [Fuego] [PATCH v2] quota: Add test cases of quota.
  2019-03-25  9:19 [Fuego] [PATCH v2] atmtcp: Add test cases for command atmtcp Wang Mingyu
                   ` (6 preceding siblings ...)
  2019-03-25  9:19 ` [Fuego] [PATCH v2] powertop: Add test cases for command powertop Wang Mingyu
@ 2019-03-25  9:19 ` Wang Mingyu
  2019-05-20 20:18 ` [Fuego] [PATCH v2] atmtcp: Add test cases for command atmtcp Tim.Bird
  8 siblings, 0 replies; 10+ messages in thread
From: Wang Mingyu @ 2019-03-25  9:19 UTC (permalink / raw)
  To: fuego

This test case is used to display disk usage and limits.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 tests/Functional.quota/fuego_test.sh             | 18 ++++++++++++++++++
 tests/Functional.quota/parser.py                 | 20 ++++++++++++++++++++
 tests/Functional.quota/quota_test.sh             |  4 ++++
 tests/Functional.quota/spec.json                 |  6 ++++++
 tests/Functional.quota/tests/quota_help.sh       | 13 +++++++++++++
 tests/Functional.quota/tests/quota_quotastats.sh | 13 +++++++++++++
 6 files changed, 74 insertions(+)
 create mode 100644 tests/Functional.quota/fuego_test.sh
 create mode 100644 tests/Functional.quota/parser.py
 create mode 100755 tests/Functional.quota/quota_test.sh
 create mode 100644 tests/Functional.quota/spec.json
 create mode 100644 tests/Functional.quota/tests/quota_help.sh
 create mode 100644 tests/Functional.quota/tests/quota_quotastats.sh

diff --git a/tests/Functional.quota/fuego_test.sh b/tests/Functional.quota/fuego_test.sh
new file mode 100644
index 0000000..1bdf334
--- /dev/null
+++ b/tests/Functional.quota/fuego_test.sh
@@ -0,0 +1,18 @@
+function test_pre_check {
+    assert_has_program quota
+    assert_has_program quotastats
+}
+
+function test_deploy {
+    put $TEST_HOME/quota_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./quota_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.quota/parser.py b/tests/Functional.quota/parser.py
new file mode 100644
index 0000000..f25a608
--- /dev/null
+++ b/tests/Functional.quota/parser.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+import common as plib
+
+measurements = {}
+measurements = collections.OrderedDict()
+
+regex_string = '^ -> (.*): TEST-(.*)$'
+matches = plib.parse_log(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
+
+# split the output for each testcase
+plib.split_output_per_testcase(regex_string, measurements)
+
+sys.exit(plib.process(measurements))
diff --git a/tests/Functional.quota/quota_test.sh b/tests/Functional.quota/quota_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/tests/Functional.quota/quota_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/tests/Functional.quota/spec.json b/tests/Functional.quota/spec.json
new file mode 100644
index 0000000..c5b371f
--- /dev/null
+++ b/tests/Functional.quota/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.quota",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.quota/tests/quota_help.sh b/tests/Functional.quota/tests/quota_help.sh
new file mode 100644
index 0000000..b775421
--- /dev/null
+++ b/tests/Functional.quota/tests/quota_help.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run command quota.
+#  option: --help
+
+test="help"
+
+if quota --help 2>&1| grep Usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
diff --git a/tests/Functional.quota/tests/quota_quotastats.sh b/tests/Functional.quota/tests/quota_quotastats.sh
new file mode 100644
index 0000000..aae4655
--- /dev/null
+++ b/tests/Functional.quota/tests/quota_quotastats.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run command quotastats.
+#  option: --help
+
+test="quotastats"
+
+if quotastats | grep "Kernel quota version"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
-- 
1.8.3.1




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

* Re: [Fuego] [PATCH v2] atmtcp: Add test cases for command atmtcp.
  2019-03-25  9:19 [Fuego] [PATCH v2] atmtcp: Add test cases for command atmtcp Wang Mingyu
                   ` (7 preceding siblings ...)
  2019-03-25  9:19 ` [Fuego] [PATCH v2] quota: Add test cases of quota Wang Mingyu
@ 2019-05-20 20:18 ` Tim.Bird
  8 siblings, 0 replies; 10+ messages in thread
From: Tim.Bird @ 2019-05-20 20:18 UTC (permalink / raw)
  To: wangmy, fuego

Sorry this response is so late.  See inline below for a review of this patch.

> -----Original Message-----
> From: Wang Mingyu
> 
> This test set is used to check option help and subcommand virtual of atmtcp.
> 
> Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
> ---
>  tests/Functional.atmtcp/atmtcp_test.sh          |  4 ++++
>  tests/Functional.atmtcp/fuego_test.sh           | 17 +++++++++++++++++
>  tests/Functional.atmtcp/parser.py               | 20 ++++++++++++++++++++
>  tests/Functional.atmtcp/spec.json               |  6 ++++++
>  tests/Functional.atmtcp/tests/atmtcp_help.sh    | 16 ++++++++++++++++
>  tests/Functional.atmtcp/tests/atmtcp_virtual.sh | 24
> ++++++++++++++++++++++++
>  6 files changed, 87 insertions(+)
>  create mode 100755 tests/Functional.atmtcp/atmtcp_test.sh
>  create mode 100644 tests/Functional.atmtcp/fuego_test.sh
>  create mode 100644 tests/Functional.atmtcp/parser.py
>  create mode 100644 tests/Functional.atmtcp/spec.json
>  create mode 100644 tests/Functional.atmtcp/tests/atmtcp_help.sh
>  create mode 100644 tests/Functional.atmtcp/tests/atmtcp_virtual.sh
> 
> diff --git a/tests/Functional.atmtcp/atmtcp_test.sh
> b/tests/Functional.atmtcp/atmtcp_test.sh
> new file mode 100755
> index 0000000..dd5ce37
> --- /dev/null
> +++ b/tests/Functional.atmtcp/atmtcp_test.sh
> @@ -0,0 +1,4 @@
> +#!/bin/sh
> +for i in tests/*.sh; do
> +    sh $i
> +done
> diff --git a/tests/Functional.atmtcp/fuego_test.sh
> b/tests/Functional.atmtcp/fuego_test.sh
> new file mode 100644
> index 0000000..f4fefe9
> --- /dev/null
> +++ b/tests/Functional.atmtcp/fuego_test.sh
> @@ -0,0 +1,17 @@
> +function test_pre_check {
> +    assert_has_program atmtcp
> +}
> +
> +function test_deploy {
> +    put $TEST_HOME/atmtcp_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
> +    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
> +}
> +
> +function test_run {
> +    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
> +    ./atmtcp_test.sh"
> +}
> +
> +function test_processing {
> +    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
> +}
> diff --git a/tests/Functional.atmtcp/parser.py
> b/tests/Functional.atmtcp/parser.py
> new file mode 100644
> index 0000000..f25a608
> --- /dev/null
> +++ b/tests/Functional.atmtcp/parser.py
> @@ -0,0 +1,20 @@
> +#!/usr/bin/python
> +# See common.py for description of command-line arguments
> +
> +import os, sys, collections
> +import common as plib
> +
> +measurements = {}
> +measurements = collections.OrderedDict()
> +
> +regex_string = '^ -> (.*): TEST-(.*)$'
> +matches = plib.parse_log(regex_string)
> +
> +if matches:
> +    for m in matches:
> +        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
> +
> +# split the output for each testcase
> +plib.split_output_per_testcase(regex_string, measurements)
> +
> +sys.exit(plib.process(measurements))
> diff --git a/tests/Functional.atmtcp/spec.json
> b/tests/Functional.atmtcp/spec.json
> new file mode 100644
> index 0000000..423ae88
> --- /dev/null
> +++ b/tests/Functional.atmtcp/spec.json
> @@ -0,0 +1,6 @@
> +{
> +    "testName": "Functional.atmtcp",
> +    "specs": {
> +        "default": {}
> +    }
> +}
> diff --git a/tests/Functional.atmtcp/tests/atmtcp_help.sh
> b/tests/Functional.atmtcp/tests/atmtcp_help.sh
> new file mode 100644
> index 0000000..e019355
> --- /dev/null
> +++ b/tests/Functional.atmtcp/tests/atmtcp_help.sh
> @@ -0,0 +1,16 @@
> +#!/bin/sh
> +
> +#  In target, run command atmtcp.
> +#  option: -h
> +
> +test="help"
> +
> +expect <<-EOF
> +spawn atmtcp -h
> +expect {
> + "usage:" {
> +           send_user " -> $test: TEST-PASS\n"
> +          }
> + default { send_user " -> $test: TEST-FAIL\n" }
> +}
> +EOF

Please change this to not require 'expect'.  I think the same thing
could be accomplished with:
if atmtcp -h | grep "usage:" ; then
   echo "$test: TEST-PASS"
else
   echo "$test: TEST-FAIL"

> diff --git a/tests/Functional.atmtcp/tests/atmtcp_virtual.sh
> b/tests/Functional.atmtcp/tests/atmtcp_virtual.sh
> new file mode 100644
> index 0000000..8b7c55d
> --- /dev/null
> +++ b/tests/Functional.atmtcp/tests/atmtcp_virtual.sh
> @@ -0,0 +1,24 @@
> +#!/bin/sh
> +
> +#  In target, run command atmtcp.
> +#  option: virtual
> +
> +test="virtual"
> +
> +if modprobe -v atmtcp
This is interesting.  We may want a general mechanism in Fuego
to check that a module is available and insertable, for test_precheck.

maybe something like:
assert_has_module atmtcp
However, that would essentially duplicate the functionality performed here.

> +then
> +    echo " -> $test: modprobe atmtcp execution succeeded."
> +else
> +    echo " -> $test: modprobe atmtcp execution failed."
> +    echo " -> $test: TEST-FAIL"
> +    exit
> +fi
> +
> +if [ ! -n "$(atmtcp virtual connect 127.0.0.1 | grep "virtual interface 0")" ]
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +
> +killall atmtcp
> --
> 1.8.3.1

OK - looks mostly good.  Please remove the use of 'expect' and re-submit.
 -- Tim


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

end of thread, other threads:[~2019-05-20 20:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-25  9:19 [Fuego] [PATCH v2] atmtcp: Add test cases for command atmtcp Wang Mingyu
2019-03-25  9:19 ` [Fuego] [PATCH v2] lm_sensors: Add test cases for commands of lm_sensors Wang Mingyu
2019-03-25  9:19 ` [Fuego] [PATCH v2] logrotate: Add test cases for command logrotate Wang Mingyu
2019-03-25  9:19 ` [Fuego] [PATCH v2] m4: Add test cases for command m4 Wang Mingyu
2019-03-25  9:19 ` [Fuego] [PATCH v2] ntp: Add test cases for commands of ntp Wang Mingyu
2019-03-25  9:19 ` [Fuego] [PATCH v2] openvpn: Add test cases of service openvpn Wang Mingyu
2019-03-25  9:19 ` [Fuego] [PATCH v2] parted: Add test cases for command parted Wang Mingyu
2019-03-25  9:19 ` [Fuego] [PATCH v2] powertop: Add test cases for command powertop Wang Mingyu
2019-03-25  9:19 ` [Fuego] [PATCH v2] quota: Add test cases of quota Wang Mingyu
2019-05-20 20:18 ` [Fuego] [PATCH v2] atmtcp: Add test cases for command atmtcp Tim.Bird

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.