See comments inline below.
> -----Original Message-----
> From: [email protected] [mailto:fuego-
> [email protected]] On Behalf Of Wang Mingyu
> Sent: Wednesday, September 18, 2019 9:21 PM
> To: [email protected]
> Subject: [Fuego] [PATCH v3] initscripts: Add test cases for commands of
> initscripts.
>
> This test set is used to check che inittab command halt, ifdown-ifup and
che-> the
> sendsigs.
>
> Signed-off-by: Wang Mingyu <[email protected]>
> ---
> tests/Functional.initscripts/fuego_test.sh | 18 ++++++++++++
> .../initscripts_test.sh | 4 +++
> tests/Functional.initscripts/spec.json | 6 ++++
> .../tests/initscripts_halt.sh | 13 +++++++++
> .../tests/initscripts_ifdown-ifup.sh | 29 +++++++++++++++++++
> .../tests/initscripts_sendsigs.sh | 13 +++++++++
> 6 files changed, 83 insertions(+)
> create mode 100644 tests/Functional.initscripts/fuego_test.sh
> create mode 100755 tests/Functional.initscripts/initscripts_test.sh
> create mode 100644 tests/Functional.initscripts/spec.json
> create mode 100644 tests/Functional.initscripts/tests/initscripts_halt.sh
> create mode 100644 tests/Functional.initscripts/tests/initscripts_ifdown-
> ifup.sh
> create mode 100644 tests/Functional.initscripts/tests/initscripts_sendsigs.sh
>
> diff --git a/tests/Functional.initscripts/fuego_test.sh
> b/tests/Functional.initscripts/fuego_test.sh
> new file mode 100644
> index 0000000..b3fb94a
> --- /dev/null
> +++ b/tests/Functional.initscripts/fuego_test.sh
> @@ -0,0 +1,18 @@
> +function test_pre_check {
> + assert_has_program ifup
> + assert_has_program ifdown
> +}
> +
> +function test_deploy {
> + put $TEST_HOME/initscripts_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
> + put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
> +}
> +
> +function test_run {
> + report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
> + ./initscripts_test.sh"
> +}
> +
> +function test_processing {
> + log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
> +}
> diff --git a/tests/Functional.initscripts/initscripts_test.sh
> b/tests/Functional.initscripts/initscripts_test.sh
> new file mode 100755
> index 0000000..dd5ce37
> --- /dev/null
> +++ b/tests/Functional.initscripts/initscripts_test.sh
> @@ -0,0 +1,4 @@
> +#!/bin/sh
> +for i in tests/*.sh; do
> + sh $i
> +done
> diff --git a/tests/Functional.initscripts/spec.json
> b/tests/Functional.initscripts/spec.json
> new file mode 100644
> index 0000000..6560900
> --- /dev/null
> +++ b/tests/Functional.initscripts/spec.json
> @@ -0,0 +1,6 @@
> +{
> + "testName": "Functional.initscripts",
> + "specs": {
> + "default": {}
> + }
> +}
> diff --git a/tests/Functional.initscripts/tests/initscripts_halt.sh
> b/tests/Functional.initscripts/tests/initscripts_halt.sh
> new file mode 100644
> index 0000000..5fadd19
> --- /dev/null
> +++ b/tests/Functional.initscripts/tests/initscripts_halt.sh
> @@ -0,0 +1,13 @@
> +#!/bin/sh
> +
> +# In target, verify that the file is executable.
> +# option: none
> +
> +test="halt"
> +
> +if [ -x /etc/init.d/halt ]
> +then
> + echo " -> $test: TEST-PASS"
> +else
> + echo " -> $test: TEST-FAIL"
> +fi
Would be nice to actually test if the program can halt the machine here.
But that could be an enhancement for the future.
> diff --git a/tests/Functional.initscripts/tests/initscripts_ifdown-ifup.sh
> b/tests/Functional.initscripts/tests/initscripts_ifdown-ifup.sh
> new file mode 100644
> index 0000000..ed1d2eb
> --- /dev/null
> +++ b/tests/Functional.initscripts/tests/initscripts_ifdown-ifup.sh
> @@ -0,0 +1,29 @@
> +#!/bin/sh
> +
> +# In target, run command ifdown/ifup.
> +# option: none
> +
> +test="ifdown/ifup"
> +
> +if [ ! -f /etc/sysconfig/network-scripts/ifcfg-lo ]
> +then
> + echo " -> $test: ifcfg file is not exist."
is not exist -> was not found
> + echo " -> $test: TEST-SKIP"
> + exit 0
> +fi
> +
> +if ifdown lo
> +then
> + echo " -> $test: ifdown lo succeeded."
> +else
> + echo " -> $test: ifdown lo failed."
> + echo " -> $test: TEST-FAIL"
> + exit 0
> +fi
Should check here that the 'lo' interface (loopback)
is no longer present in the output of 'ifconfig'
I added some lines to do this.
> +
> +if ifup lo
> +then
> + echo " -> $test: TEST-PASS"
> +else
> + echo " -> $test: TEST-FAIL"
> +fi
> diff --git a/tests/Functional.initscripts/tests/initscripts_sendsigs.sh
> b/tests/Functional.initscripts/tests/initscripts_sendsigs.sh
> new file mode 100644
> index 0000000..633acad
> --- /dev/null
> +++ b/tests/Functional.initscripts/tests/initscripts_sendsigs.sh
> @@ -0,0 +1,13 @@
> +#!/bin/sh
> +
> +# In target, verify that the file is executable.
> +# option: none
> +
> +test="sendsigs"
> +
> +if [ -x /etc/init.d/sendsigs ]
> +then
> + echo " -> $test: TEST-PASS"
> +else
> + echo " -> $test: TEST-FAIL"
> +fi
> --
> 2.17.1
OK - just checking that the program is present and executable
is not very deep testing.
However, I'll accept this as a starting point for this test.
I'm applying this, but will re-word a few items, and I have added some
extra checking for the correct status of the loopback device,
as described above.
-- Tim
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.