[Fuego] [PATCH v2] sysvinit: Add test cases for commands of sysvinit.
Wang Mingyu <[email protected]>
| Newsgroups | dev.linux.lists.fuego |
|---|---|
| Message-ID | <[email protected]> |
The sysvinit is the default init program used by some system. This test set is used to check the programs for controlling the startup, running, and shutdown of the system. Signed-off-by: Wang Mingyu <[email protected]> --- tests/Functional.sysvinit/fuego_test.sh | 26 +++++++++++++++++++ tests/Functional.sysvinit/spec.json | 6 +++++ tests/Functional.sysvinit/sysvinit_test.sh | 4 +++ tests/Functional.sysvinit/test.yaml | 21 +++++++++++++++ .../tests/sysvinit_halt.sh | 12 +++++++++ .../tests/sysvinit_last.sh | 13 ++++++++++ .../tests/sysvinit_mesg.sh | 21 +++++++++++++++ .../tests/sysvinit_shutdown.sh | 12 +++++++++ .../tests/sysvinit_sulogin.sh | 18 +++++++++++++ .../tests/sysvinit_utmpdump.sh | 12 +++++++++ .../tests/sysvinit_wall.sh | 12 +++++++++ 11 files changed, 157 insertions(+) create mode 100644 tests/Functional.sysvinit/fuego_test.sh create mode 100644 tests/Functional.sysvinit/spec.json create mode 100755 tests/Functional.sysvinit/sysvinit_test.sh create mode 100644 tests/Functional.sysvinit/test.yaml create mode 100644 tests/Functional.sysvinit/tests/sysvinit_halt.sh create mode 100644 tests/Functional.sysvinit/tests/sysvinit_last.sh create mode 100644 tests/Functional.sysvinit/tests/sysvinit_mesg.sh create mode 100644 tests/Functional.sysvinit/tests/sysvinit_shutdown.sh create mode 100644 tests/Functional.sysvinit/tests/sysvinit_sulogin.sh create mode 100644 tests/Functional.sysvinit/tests/sysvinit_utmpdump.sh create mode 100644 tests/Functional.sysvinit/tests/sysvinit_wall.sh diff --git a/tests/Functional.sysvinit/fuego_test.sh b/tests/Functional.sysvinit/fuego_test.sh new file mode 100644 index 0000000..fcb5aa7 --- /dev/null +++ b/tests/Functional.sysvinit/fuego_test.sh @@ -0,0 +1,26 @@ +function test_pre_check { + assert_has_program halt + assert_has_program last + assert_has_program mesg + assert_has_program runlevel + assert_has_program shutdown + assert_has_program sulogin + assert_has_program utmpdump + assert_has_program wall + assert_has_program expect +} + +function test_deploy { + put $TEST_HOME/sysvinit_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/ + put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/ +} + +function test_run { + report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\ + export test_passwd=$PASSWORD;\ + ./sysvinit_test.sh" +} + +function test_processing { + log_compare "$TESTDIR" "0" "TEST-FAIL" "n" +} diff --git a/tests/Functional.sysvinit/spec.json b/tests/Functional.sysvinit/spec.json new file mode 100644 index 0000000..70d367e --- /dev/null +++ b/tests/Functional.sysvinit/spec.json @@ -0,0 +1,6 @@ +{ + "testName": "Functional.sysvinit", + "specs": { + "default": {} + } +} diff --git a/tests/Functional.sysvinit/sysvinit_test.sh b/tests/Functional.sysvinit/sysvinit_test.sh new file mode 100755 index 0000000..dd5ce37 --- /dev/null +++ b/tests/Functional.sysvinit/sysvinit_test.sh @@ -0,0 +1,4 @@ +#!/bin/sh +for i in tests/*.sh; do + sh $i +done diff --git a/tests/Functional.sysvinit/test.yaml b/tests/Functional.sysvinit/test.yaml new file mode 100644 index 0000000..2383443 --- /dev/null +++ b/tests/Functional.sysvinit/test.yaml @@ -0,0 +1,21 @@ +fuego_package_version: 1 +name: Functional.sysvinit +description: | + Sysvinit is a collection of System init programs originally. + This is a simple test to check the program of sysvinit. +license: BSD-3-Clause +author: Wang Mingyu <[email protected]> +maintainer: Wang Mingyu <[email protected]> +version: 1.00 +fuego_release: 1 +type: Functional +tags: ['sysvinit'] +params: + PASSWORD: + description: the password to login to your host - Defined in board file +data_files: + - sysvinit_test.sh + - fuego_test.sh + - spec.json + - test.yaml + - tests diff --git a/tests/Functional.sysvinit/tests/sysvinit_halt.sh b/tests/Functional.sysvinit/tests/sysvinit_halt.sh new file mode 100644 index 0000000..a8aeb76 --- /dev/null +++ b/tests/Functional.sysvinit/tests/sysvinit_halt.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# In target, run command halt. + +test="halt" + +if halt -w +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi diff --git a/tests/Functional.sysvinit/tests/sysvinit_last.sh b/tests/Functional.sysvinit/tests/sysvinit_last.sh new file mode 100644 index 0000000..d8a11b0 --- /dev/null +++ b/tests/Functional.sysvinit/tests/sysvinit_last.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# In target, run command last. + +test="last" + +USER_NAME=$(id -u -n) +if last | grep "$USER_NAME.*still logged in" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi diff --git a/tests/Functional.sysvinit/tests/sysvinit_mesg.sh b/tests/Functional.sysvinit/tests/sysvinit_mesg.sh new file mode 100644 index 0000000..72dc1b1 --- /dev/null +++ b/tests/Functional.sysvinit/tests/sysvinit_mesg.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# In target, run command mesg. + +test="mesg" + +mesg +mesg_status=$(echo $?) + +mesg n +if echo $? = 1 +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi + +if [ $mesg_status = 0 ] +then + mesg y +fi diff --git a/tests/Functional.sysvinit/tests/sysvinit_shutdown.sh b/tests/Functional.sysvinit/tests/sysvinit_shutdown.sh new file mode 100644 index 0000000..293957b --- /dev/null +++ b/tests/Functional.sysvinit/tests/sysvinit_shutdown.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# In target, run command shutdown. + +test="shutdown" + +if shutdown -k now +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi diff --git a/tests/Functional.sysvinit/tests/sysvinit_sulogin.sh b/tests/Functional.sysvinit/tests/sysvinit_sulogin.sh new file mode 100644 index 0000000..aa769ef --- /dev/null +++ b/tests/Functional.sysvinit/tests/sysvinit_sulogin.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# In target, run command sulogin. + +test="sulogin" + +expect <<-EOF +spawn sulogin +expect ":" +send "$test_passwd\r" +expect { +"#" { + send_user " -> $test: TEST-PASS\n" + } +default { send_user " -> $test: TEST-FAIL\n" } } +send "exit\r" +expect eof +EOF diff --git a/tests/Functional.sysvinit/tests/sysvinit_utmpdump.sh b/tests/Functional.sysvinit/tests/sysvinit_utmpdump.sh new file mode 100644 index 0000000..a5947a8 --- /dev/null +++ b/tests/Functional.sysvinit/tests/sysvinit_utmpdump.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# In target, run command utmpdump. + +test="utmpdump" + +if utmpdump /var/log/wtmp +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi diff --git a/tests/Functional.sysvinit/tests/sysvinit_wall.sh b/tests/Functional.sysvinit/tests/sysvinit_wall.sh new file mode 100644 index 0000000..967cf7e --- /dev/null +++ b/tests/Functional.sysvinit/tests/sysvinit_wall.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# In target, run command wall. + +test="wall" + +if wall "Testing wall command" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi -- 2.17.1