All of lore.kernel.org
 help / color / mirror / Atom feed
* [Fuego] [PATCH v2] Add test cases of command ecryptfs-manager.
@ 2019-05-21 11:06 Wang Mingyu
  2019-05-21 11:06 ` [Fuego] [PATCH] Add test cases of service crond Wang Mingyu
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Wang Mingyu @ 2019-05-21 11:06 UTC (permalink / raw)
  To: fuego

This test set is used to ask key modules to generate new keys.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 .../ecryptfs_manager_test.sh                       |  4 ++++
 tests/Functional.ecryptfs_manager/fuego_test.sh    | 17 ++++++++++++++++
 tests/Functional.ecryptfs_manager/parser.py        | 20 +++++++++++++++++++
 tests/Functional.ecryptfs_manager/spec.json        |  6 ++++++
 .../tests/ecryptfs-manager01.sh                    | 23 ++++++++++++++++++++++
 .../tests/ecryptfs-manager02.sh                    | 23 ++++++++++++++++++++++
 6 files changed, 93 insertions(+)
 create mode 100644 tests/Functional.ecryptfs_manager/ecryptfs_manager_test.sh
 create mode 100644 tests/Functional.ecryptfs_manager/fuego_test.sh
 create mode 100644 tests/Functional.ecryptfs_manager/parser.py
 create mode 100644 tests/Functional.ecryptfs_manager/spec.json
 create mode 100644 tests/Functional.ecryptfs_manager/tests/ecryptfs-manager01.sh
 create mode 100644 tests/Functional.ecryptfs_manager/tests/ecryptfs-manager02.sh

diff --git a/tests/Functional.ecryptfs_manager/ecryptfs_manager_test.sh b/tests/Functional.ecryptfs_manager/ecryptfs_manager_test.sh
new file mode 100644
index 0000000..dd5ce37
--- /dev/null
+++ b/tests/Functional.ecryptfs_manager/ecryptfs_manager_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/tests/Functional.ecryptfs_manager/fuego_test.sh b/tests/Functional.ecryptfs_manager/fuego_test.sh
new file mode 100644
index 0000000..8e34104
--- /dev/null
+++ b/tests/Functional.ecryptfs_manager/fuego_test.sh
@@ -0,0 +1,17 @@
+function test_pre_check {
+    assert_has_program ecryptfs-manager
+}
+
+function test_deploy {
+    put $TEST_HOME/ecryptfs_manager_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    ./ecryptfs_manager_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.ecryptfs_manager/parser.py b/tests/Functional.ecryptfs_manager/parser.py
new file mode 100644
index 0000000..f25a608
--- /dev/null
+++ b/tests/Functional.ecryptfs_manager/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.ecryptfs_manager/spec.json b/tests/Functional.ecryptfs_manager/spec.json
new file mode 100644
index 0000000..88816ec
--- /dev/null
+++ b/tests/Functional.ecryptfs_manager/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.ecryptfs_manager",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.ecryptfs_manager/tests/ecryptfs-manager01.sh b/tests/Functional.ecryptfs_manager/tests/ecryptfs-manager01.sh
new file mode 100644
index 0000000..57bf971
--- /dev/null
+++ b/tests/Functional.ecryptfs_manager/tests/ecryptfs-manager01.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+#  The testscript execute the command ecryptfs-manager and check the passphrase.
+#  option: none
+
+test="ecryptfs-manager01"
+
+expect <<-EOF
+spawn ecryptfs-manager
+expect "Make selection:"
+send "1\r"
+expect "Mount-wide passphrase:"
+send "test123\r"
+expect ".*Confirm passphrase:"
+send "test123\r"
+expect {
+ -re ".*Using the default salt value.*" {
+           send_user " -> $test: TEST-PASS\n"
+          }
+default { send_user " -> $test: TEST-FAIL\n" }  }
+send "4\r"
+expect eof
+EOF
diff --git a/tests/Functional.ecryptfs_manager/tests/ecryptfs-manager02.sh b/tests/Functional.ecryptfs_manager/tests/ecryptfs-manager02.sh
new file mode 100644
index 0000000..b6dd802
--- /dev/null
+++ b/tests/Functional.ecryptfs_manager/tests/ecryptfs-manager02.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+#  The testscript execute the command ecryptfs-manager and check the passphrase.
+#  option: none
+
+test="ecryptfs-manager02"
+
+expect <<-EOF
+spawn ecryptfs-manager
+expect "Make selection:"
+send "1\r"
+expect "Mount-wide passphrase:"
+send "test123\r"
+expect ".*Confirm passphrase:"
+send "test123\r"
+expect {
+ -re "That key was already" {
+           send_user " -> $test: TEST-PASS\n"
+          }
+default { send_user " -> $test: TEST-FAIL\n" }  }
+send "4\r"
+expect eof
+EOF
-- 
1.8.3.1




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

* [Fuego] [PATCH] Add test cases of service crond.
  2019-05-21 11:06 [Fuego] [PATCH v2] Add test cases of command ecryptfs-manager Wang Mingyu
@ 2019-05-21 11:06 ` Wang Mingyu
  2019-05-21 11:06 ` [Fuego] [PATCH v2] Add test cases of service syslog-ng Wang Mingyu
  2019-05-21 11:06 ` [Fuego] [PATCH] Add a general mechanism to check that a module is available and insertable, for test_precheck Wang Mingyu
  2 siblings, 0 replies; 4+ messages in thread
From: Wang Mingyu @ 2019-05-21 11:06 UTC (permalink / raw)
  To: fuego

This test set is used to check the process, pid file of service crond and the command crondtab.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 tests/Functional.vixie_cron/data/cronentry         |  1 +
 tests/Functional.vixie_cron/data/crontab           | 11 ++++
 tests/Functional.vixie_cron/data/crontab.logger    | 12 ++++
 tests/Functional.vixie_cron/fuego_test.sh          | 20 ++++++
 tests/Functional.vixie_cron/parser.py              | 20 ++++++
 tests/Functional.vixie_cron/spec.json              |  6 ++
 .../tests/vixie-cron_crond01.sh                    | 60 ++++++++++++++++++
 .../tests/vixie-cron_crond02.sh                    | 52 +++++++++++++++
 .../tests/vixie-cron_crond03.sh                    | 60 ++++++++++++++++++
 .../tests/vixie-cron_crond04.sh                    | 59 +++++++++++++++++
 .../tests/vixie-cron_crontab01.sh                  | 58 +++++++++++++++++
 .../tests/vixie-cron_crontab02.sh                  | 74 ++++++++++++++++++++++
 tests/Functional.vixie_cron/vixie_cron_test.sh     |  7 ++
 13 files changed, 440 insertions(+)
 create mode 100644 tests/Functional.vixie_cron/data/cronentry
 create mode 100644 tests/Functional.vixie_cron/data/crontab
 create mode 100644 tests/Functional.vixie_cron/data/crontab.logger
 create mode 100644 tests/Functional.vixie_cron/fuego_test.sh
 create mode 100644 tests/Functional.vixie_cron/parser.py
 create mode 100644 tests/Functional.vixie_cron/spec.json
 create mode 100644 tests/Functional.vixie_cron/tests/vixie-cron_crond01.sh
 create mode 100644 tests/Functional.vixie_cron/tests/vixie-cron_crond02.sh
 create mode 100644 tests/Functional.vixie_cron/tests/vixie-cron_crond03.sh
 create mode 100644 tests/Functional.vixie_cron/tests/vixie-cron_crond04.sh
 create mode 100644 tests/Functional.vixie_cron/tests/vixie-cron_crontab01.sh
 create mode 100644 tests/Functional.vixie_cron/tests/vixie-cron_crontab02.sh
 create mode 100644 tests/Functional.vixie_cron/vixie_cron_test.sh

diff --git a/tests/Functional.vixie_cron/data/cronentry b/tests/Functional.vixie_cron/data/cronentry
new file mode 100644
index 0000000..247919e
--- /dev/null
+++ b/tests/Functional.vixie_cron/data/cronentry
@@ -0,0 +1 @@
+0-59/1 * * * * /usr/bin/logger -i -t TEST -p kern.warning "TEST Message2"
diff --git a/tests/Functional.vixie_cron/data/crontab b/tests/Functional.vixie_cron/data/crontab
new file mode 100644
index 0000000..1023aa8
--- /dev/null
+++ b/tests/Functional.vixie_cron/data/crontab
@@ -0,0 +1,11 @@
+SHELL=/bin/bash
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+MAILTO=root
+HOME=/
+
+# run-parts
+01 * * * * root run-parts /etc/cron.hourly
+02 4 * * * root run-parts /etc/cron.daily
+22 4 * * 0 root run-parts /etc/cron.weekly
+42 4 1 * * root run-parts /etc/cron.monthly
+
diff --git a/tests/Functional.vixie_cron/data/crontab.logger b/tests/Functional.vixie_cron/data/crontab.logger
new file mode 100644
index 0000000..4dea00d
--- /dev/null
+++ b/tests/Functional.vixie_cron/data/crontab.logger
@@ -0,0 +1,12 @@
+SHELL=/bin/bash
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+MAILTO=root
+HOME=/
+
+# run-parts
+01 * * * * root run-parts /etc/cron.hourly
+02 4 * * * root run-parts /etc/cron.daily
+22 4 * * 0 root run-parts /etc/cron.weekly
+42 4 1 * * root run-parts /etc/cron.monthly
+0-59/1 * * * * root /usr/bin/logger -i -t TEST -p kern.warning "TEST Message crond"
+
diff --git a/tests/Functional.vixie_cron/fuego_test.sh b/tests/Functional.vixie_cron/fuego_test.sh
new file mode 100644
index 0000000..828398e
--- /dev/null
+++ b/tests/Functional.vixie_cron/fuego_test.sh
@@ -0,0 +1,20 @@
+function test_pre_check {
+    assert_has_program crond
+    assert_has_program crontab
+}
+
+function test_deploy {
+    put $TEST_HOME/vixie_cron_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;\
+    ./vixie_cron_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.vixie_cron/parser.py b/tests/Functional.vixie_cron/parser.py
new file mode 100644
index 0000000..f25a608
--- /dev/null
+++ b/tests/Functional.vixie_cron/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.vixie_cron/spec.json b/tests/Functional.vixie_cron/spec.json
new file mode 100644
index 0000000..0e08a2f
--- /dev/null
+++ b/tests/Functional.vixie_cron/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.vixie_cron",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.vixie_cron/tests/vixie-cron_crond01.sh b/tests/Functional.vixie_cron/tests/vixie-cron_crond01.sh
new file mode 100644
index 0000000..ea00064
--- /dev/null
+++ b/tests/Functional.vixie_cron/tests/vixie-cron_crond01.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+#  In the target start crond, and check process state with ps command.
+
+test="crond01"
+
+service_status=$(get_service_status crond)
+exec_service_on_target crond stop
+
+mv /etc/crontab /etc/crontab_bak
+cp data/crontab /etc/crontab
+
+if exec_service_on_target crond start
+then
+    echo " -> start of crond succeeded."
+else
+    echo " -> start of crond failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+sleep 5
+
+if ps aux | grep "[/]usr/sbin/crond"
+then
+    echo " -> get the pid of crond."
+else
+    echo " -> can't get the pid of crond."
+    echo " -> $test: TEST-FAIL"
+    if [ "$service_status" = "inactive" ]
+    then
+        exec_service_on_target crond stop
+    fi
+    mv /etc/crontab_bak /etc/crontab
+    exit
+fi
+
+if exec_service_on_target crond stop
+then
+    echo " -> stop of crond succeeded."
+else
+    echo " -> stop of crond failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+sleep 5
+
+if ps aux | grep "[/]usr/sbin/crond"
+then
+    echo " -> $test: TEST-FAIL"
+else
+    echo " -> $test: TEST-PASS"
+fi
+
+mv /etc/crontab_bak /etc/crontab
+if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+then
+    exec_service_on_target crond start
+fi
diff --git a/tests/Functional.vixie_cron/tests/vixie-cron_crond02.sh b/tests/Functional.vixie_cron/tests/vixie-cron_crond02.sh
new file mode 100644
index 0000000..89a73c5
--- /dev/null
+++ b/tests/Functional.vixie_cron/tests/vixie-cron_crond02.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+#  In the target to start crond crond, to confirm the acquisition of the log.
+#  check the keyword "crond".
+
+test="crond02"
+
+logger_service=$(detect_logger_service)
+
+syslog_status=$(get_service_status $logger_service )
+crond_status=$(get_service_status crond)
+exec_service_on_target crond stop
+exec_service_on_target $logger_service stop
+
+mv /etc/crontab /etc/crontab_bak
+cp data/crontab /etc/crontab
+
+mv /var/log/cron.log /var/log/cron.log_bak
+
+restore_target() {
+    if [ "$syslog_status" = "inactive" ]
+    then
+        exec_service_on_target $logger_service stop
+    fi
+    if [ "$crond_status" = "inactive" ]
+    then
+        exec_service_on_target crond stop
+    fi
+    mv /etc/crontab_bak /etc/crontab
+    mv /var/log/cron.log_bak /var/log/cron.log
+}
+
+exec_service_on_target $logger_service restart
+if exec_service_on_target crond start
+then
+    echo " -> start of crond succeeded."
+else
+    echo " -> start of crond failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+sleep 5
+
+if tail /var/log/cron.log | grep "cron"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+restore_target
diff --git a/tests/Functional.vixie_cron/tests/vixie-cron_crond03.sh b/tests/Functional.vixie_cron/tests/vixie-cron_crond03.sh
new file mode 100644
index 0000000..ce2b5d5
--- /dev/null
+++ b/tests/Functional.vixie_cron/tests/vixie-cron_crond03.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+#  In the target start crond, and check if the /var/run/crond.pid is exist.
+
+test="crond03"
+
+service_status=$(get_service_status crond)
+exec_service_on_target lighttpd stop
+
+mv /etc/crontab /etc/crontab_bak
+cp data/crontab /etc/crontab
+
+if exec_service_on_target crond start
+then
+    echo " -> start of crond succeeded."
+else
+    echo " -> start of crond failed."
+    echo " -> $test: TEST-FAIL"
+    mv /etc/crontab_bak /etc/crontab
+    exit
+fi
+
+sleep 5
+
+if [ -f /var/run/crond.pid ]
+then
+    echo " -> /var/run/crond.pid is exist."
+else
+    echo " -> /var/run/crond.pid is not exist."
+    echo " -> $test: TEST-FAIL"
+    if [ "$service_status" = "inactive" ]
+    then
+        exec_service_on_target crond stop
+    fi
+    mv /etc/crontab_bak /etc/crontab
+    exit
+fi
+
+if exec_service_on_target crond stop
+then
+    echo " -> stop of crond succeeded."
+else
+    echo " -> stop of crond failed."
+    echo " -> $test: TEST-FAIL"
+    mv /etc/crontab_bak /etc/crontab
+    exit
+fi
+
+if [ -f /var/run/crond.pid ]
+then
+    echo " -> $test: TEST-FAIL"
+else
+    echo " -> $test: TEST-PASS"
+fi
+
+mv /etc/crontab_bak /etc/crontab
+if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+then
+    exec_service_on_target crond start
+fi
diff --git a/tests/Functional.vixie_cron/tests/vixie-cron_crond04.sh b/tests/Functional.vixie_cron/tests/vixie-cron_crond04.sh
new file mode 100644
index 0000000..0892f7e
--- /dev/null
+++ b/tests/Functional.vixie_cron/tests/vixie-cron_crond04.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+#  In the target to start crond crond.
+#  Run the logger command from crontab to check syslog.
+
+test="crond04"
+
+logger_service=$(detect_logger_service)
+
+syslog_status=$(get_service_status $logger_service )
+crond_status=$(get_service_status crond)
+exec_service_on_target crond stop
+exec_service_on_target $logger_service stop
+
+if [ -f /var/log/syslog ]
+then
+    mv /var/log/syslog /var/log/syslog_bak
+fi
+
+exec_service_on_target $logger_service restart
+
+mv /etc/crontab /etc/crontab_bak
+cp data/crontab.logger /etc/crontab
+
+chown root:root /etc/crontab
+
+restore_target() {
+    if [ "$syslog_status" = "inactive" ]
+    then
+        exec_service_on_target $logger_service stop
+    fi
+    if [ "$crond_status" = "inactive" ]
+    then
+        exec_service_on_target crond stop
+    fi
+    mv /etc/crontab_bak /etc/crontab
+    mv /var/log/syslog_bak /var/log/syslog
+}
+
+if exec_service_on_target crond start
+then
+    echo " -> start of crond succeeded."
+else
+    echo " -> start of crond failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+echo "sleep 70s!"
+sleep 70
+
+if cat /var/log/syslog | grep "TEST Message"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+restore_target
diff --git a/tests/Functional.vixie_cron/tests/vixie-cron_crontab01.sh b/tests/Functional.vixie_cron/tests/vixie-cron_crontab01.sh
new file mode 100644
index 0000000..4c62f08
--- /dev/null
+++ b/tests/Functional.vixie_cron/tests/vixie-cron_crontab01.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+#  In the target run crontab to add, list and remove an entry.
+
+test="crontab01"
+
+service_status=$(get_service_status crond)
+exec_service_on_target crond stop
+
+mkdir test_dir
+cp data/cronentry test_dir/
+
+restore_target() {
+    if [ "$service_status" = "inactive" ]
+    then
+        exec_service_on_target crond stop
+    fi
+    rm -fr test_dir
+}
+
+if exec_service_on_target crond start
+then
+    echo " -> start of crond succeeded."
+else
+    echo " -> start of crond failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+if crontab test_dir/cronentry
+then
+    echo " -> add entry succeeded."
+else
+    echo " -> add entry failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+if crontab -l | grep "TEST Message"
+then
+    echo " -> list entry succeeded."
+else
+    echo " -> list entry failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+if crontab -r
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> remove entry failed."
+    echo " -> $test: TEST-FAIL"
+fi
+restore_target
diff --git a/tests/Functional.vixie_cron/tests/vixie-cron_crontab02.sh b/tests/Functional.vixie_cron/tests/vixie-cron_crontab02.sh
new file mode 100644
index 0000000..0ad7b21
--- /dev/null
+++ b/tests/Functional.vixie_cron/tests/vixie-cron_crontab02.sh
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+#  In the target run crontab to add, list and remove an entry.
+
+test="crontab02"
+
+logger_service=$(detect_logger_service)
+
+syslog_status=$(get_service_status $logger_service )
+crond_status=$(get_service_status crond)
+exec_service_on_target crond 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 [ "$syslog_status" = "inactive" ]
+    then
+        exec_service_on_target $logger_service stop
+    fi
+    if [ "$crond_status" = "inactive" ]
+    then
+        exec_service_on_target crond stop
+    fi
+    mv /var/log/syslog_bak /var/log/syslog
+}
+
+sleep 5
+
+exec_service_on_target $logger_service restart
+
+if exec_service_on_target crond start
+then
+    echo " -> start of crond succeeded."
+else
+    echo " -> start of crond failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    exit
+fi
+
+mkdir test_dir
+cp data/cronentry test_dir/
+
+if crontab test_dir/cronentry
+then
+    echo " -> add entry succeeded."
+else
+    echo " -> add entry failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    rm -fr test_dir
+    exit
+fi
+
+echo "sleep 70s!"
+sleep 70
+
+if cat /var/log/syslog | grep "TEST Message"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> service started failed."
+    echo " -> $test: TEST-FAIL"
+    restore_target
+    rm -fr test_dir
+    exit
+fi
+
+crontab -r
+restore_target
diff --git a/tests/Functional.vixie_cron/vixie_cron_test.sh b/tests/Functional.vixie_cron/vixie_cron_test.sh
new file mode 100644
index 0000000..95c34db
--- /dev/null
+++ b/tests/Functional.vixie_cron/vixie_cron_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
-- 
1.8.3.1




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

* [Fuego] [PATCH v2] Add test cases of service syslog-ng.
  2019-05-21 11:06 [Fuego] [PATCH v2] Add test cases of command ecryptfs-manager Wang Mingyu
  2019-05-21 11:06 ` [Fuego] [PATCH] Add test cases of service crond Wang Mingyu
@ 2019-05-21 11:06 ` Wang Mingyu
  2019-05-21 11:06 ` [Fuego] [PATCH] Add a general mechanism to check that a module is available and insertable, for test_precheck Wang Mingyu
  2 siblings, 0 replies; 4+ messages in thread
From: Wang Mingyu @ 2019-05-21 11:06 UTC (permalink / raw)
  To: fuego

This test set is used to check the process, log file of service syslog-ng.

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 tests/Functional.syslog_ng/fuego_test.sh           | 18 ++++++++
 tests/Functional.syslog_ng/parser.py               | 20 +++++++++
 tests/Functional.syslog_ng/spec.json               |  6 +++
 tests/Functional.syslog_ng/syslog_ng_test.sh       |  4 ++
 tests/Functional.syslog_ng/tests/syslog-ng_log.sh  | 15 +++++++
 tests/Functional.syslog_ng/tests/syslog-ng_ps.sh   | 50 ++++++++++++++++++++++
 .../Functional.syslog_ng/tests/syslog-ng_share.sh  | 38 ++++++++++++++++
 .../Functional.syslog_ng/tests/syslog-ng_start.sh  | 18 ++++++++
 8 files changed, 169 insertions(+)
 create mode 100644 tests/Functional.syslog_ng/fuego_test.sh
 create mode 100644 tests/Functional.syslog_ng/parser.py
 create mode 100644 tests/Functional.syslog_ng/spec.json
 create mode 100644 tests/Functional.syslog_ng/syslog_ng_test.sh
 create mode 100644 tests/Functional.syslog_ng/tests/syslog-ng_log.sh
 create mode 100644 tests/Functional.syslog_ng/tests/syslog-ng_ps.sh
 create mode 100644 tests/Functional.syslog_ng/tests/syslog-ng_share.sh
 create mode 100644 tests/Functional.syslog_ng/tests/syslog-ng_start.sh

diff --git a/tests/Functional.syslog_ng/fuego_test.sh b/tests/Functional.syslog_ng/fuego_test.sh
new file mode 100644
index 0000000..45aa953
--- /dev/null
+++ b/tests/Functional.syslog_ng/fuego_test.sh
@@ -0,0 +1,18 @@
+function test_pre_check {
+    assert_has_program syslog-ng
+}
+
+function test_deploy {
+    put $TEST_HOME/syslog_ng_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;\
+    ./syslog_ng_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/tests/Functional.syslog_ng/parser.py b/tests/Functional.syslog_ng/parser.py
new file mode 100644
index 0000000..f25a608
--- /dev/null
+++ b/tests/Functional.syslog_ng/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.syslog_ng/spec.json b/tests/Functional.syslog_ng/spec.json
new file mode 100644
index 0000000..e38e5ca
--- /dev/null
+++ b/tests/Functional.syslog_ng/spec.json
@@ -0,0 +1,6 @@
+{
+    "testName": "Functional.syslog_ng",
+    "specs": {
+        "default": {}
+    }
+}
diff --git a/tests/Functional.syslog_ng/syslog_ng_test.sh b/tests/Functional.syslog_ng/syslog_ng_test.sh
new file mode 100644
index 0000000..dd5ce37
--- /dev/null
+++ b/tests/Functional.syslog_ng/syslog_ng_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/tests/Functional.syslog_ng/tests/syslog-ng_log.sh b/tests/Functional.syslog_ng/tests/syslog-ng_log.sh
new file mode 100644
index 0000000..6407abc
--- /dev/null
+++ b/tests/Functional.syslog_ng/tests/syslog-ng_log.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#  In the target, run syslog-ng and check the message file.
+
+test="log"
+
+mgs="This is a test message $(date)"
+logger "$msg"
+if grep "$msg" /var/log/syslog
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo "  Didn't find test string in log"
+    echo " -> $test: TEST-FAIL"
+fi
diff --git a/tests/Functional.syslog_ng/tests/syslog-ng_ps.sh b/tests/Functional.syslog_ng/tests/syslog-ng_ps.sh
new file mode 100644
index 0000000..1d754ff
--- /dev/null
+++ b/tests/Functional.syslog_ng/tests/syslog-ng_ps.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+#  In the target start syslog-ng, and confirm the process condition by command ps.
+
+test="ps"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+service_status=$(get_service_status syslog-ng)
+
+exec_service_on_target syslog-ng stop
+
+if ps aux | grep "[/]usr/sbin/syslog-ng"
+then
+    echo " -> $test: TEST-FAIL"
+    if [ "$service_status" = "active" -o "$service_status" = "unknown" ]
+    then
+        exec_service_on_target syslog-ng start
+    fi
+    exit
+else
+    echo " -> no progress when service is shutdown"
+fi
+
+if exec_service_on_target syslog-ng start
+then
+    echo " -> start of syslog-ng succeeded."
+else
+    echo " -> start of syslog-ng failed."
+    echo " -> $test: TEST-FAIL"
+    exit
+fi
+
+sleep 5
+
+if ps aux | grep "[/]usr/sbin/syslog-ng"
+then
+    echo " -> get the process of syslog-ng."
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> can't get the process of syslog-ng."
+    echo " -> $test: TEST-FAIL"
+fi
+
+if [ "$service_status" = "inactive" ]
+then
+    exec_service_on_target syslog-ng stop
+fi
diff --git a/tests/Functional.syslog_ng/tests/syslog-ng_share.sh b/tests/Functional.syslog_ng/tests/syslog-ng_share.sh
new file mode 100644
index 0000000..73763e7
--- /dev/null
+++ b/tests/Functional.syslog_ng/tests/syslog-ng_share.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+#  In the target, run syslog-ng
+#  check the process state and keyword "supervising syslog ng".
+
+test="share"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+service_status=$(get_service_status syslog-ng)
+
+exec_service_on_target syslog-ng stop
+
+if [ -f /usr/share/syslog-ng ]
+then
+    mv /usr/share/syslog-ng /usr/share/syslog-ng_bak
+fi
+
+exec_service_on_target syslog-ng restart
+
+if ps aux | grep "[/]usr/sbin/syslog-ng"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+
+if [ -f /usr/share/syslog-ng_orig ]
+then
+    mv /usr/share/syslog-ng_bak /usr/share/syslog-ng
+fi
+
+if [ "$service_status" = "inactive" ]
+then
+    exec_service_on_target syslog-ng stop
+fi
diff --git a/tests/Functional.syslog_ng/tests/syslog-ng_start.sh b/tests/Functional.syslog_ng/tests/syslog-ng_start.sh
new file mode 100644
index 0000000..bab81d2
--- /dev/null
+++ b/tests/Functional.syslog_ng/tests/syslog-ng_start.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+#  In the target, run syslog-ng and check the status of process.
+
+test="start"
+
+. ./fuego_board_function_lib.sh
+
+set_init_manager
+
+exec_service_on_target syslog-ng restart
+
+if ps aux | grep "[/]usr/sbin/syslog-ng"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
-- 
1.8.3.1




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

* [Fuego] [PATCH] Add a general mechanism to check that a module is available and insertable, for test_precheck.
  2019-05-21 11:06 [Fuego] [PATCH v2] Add test cases of command ecryptfs-manager Wang Mingyu
  2019-05-21 11:06 ` [Fuego] [PATCH] Add test cases of service crond Wang Mingyu
  2019-05-21 11:06 ` [Fuego] [PATCH v2] Add test cases of service syslog-ng Wang Mingyu
@ 2019-05-21 11:06 ` Wang Mingyu
  2 siblings, 0 replies; 4+ messages in thread
From: Wang Mingyu @ 2019-05-21 11:06 UTC (permalink / raw)
  To: fuego

eg.
function test_pre_check {
    assert_has_module atmtcp
}

Signed-off-by: Wang Mingyu <wangmy@cn.fujitsu.com>
---
 scripts/functions.sh | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/scripts/functions.sh b/scripts/functions.sh
index 2270f4f..1b7b198 100755
--- a/scripts/functions.sh
+++ b/scripts/functions.sh
@@ -1045,6 +1045,13 @@ function assert_has_program {
    assert_define ${progVar} "Missing '$1' program on target board"
 }
 
+# check for a module on the target, and send message if the module is not available
+# $1 has the module that is required on the target board
+function assert_has_module {
+    moduleName=$1
+    cmd "modprobe $moduleName" || abort_job "$moduleName is not available. Make sure you use the correct module name for this test/benchmark."
+}
+
 # check if the path is an absolute path or a relative path
 # $1 - the path to check
 function is_abs_path {
-- 
1.8.3.1




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

end of thread, other threads:[~2019-05-21 11:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-21 11:06 [Fuego] [PATCH v2] Add test cases of command ecryptfs-manager Wang Mingyu
2019-05-21 11:06 ` [Fuego] [PATCH] Add test cases of service crond Wang Mingyu
2019-05-21 11:06 ` [Fuego] [PATCH v2] Add test cases of service syslog-ng Wang Mingyu
2019-05-21 11:06 ` [Fuego] [PATCH] Add a general mechanism to check that a module is available and insertable, for test_precheck Wang Mingyu

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.