diff options
-rw-r--r-- | tests/README.md | 10 | ||||
-rwxr-xr-x | tests/setup_devd_test | 22 | ||||
-rwxr-xr-x | tests/setup_hostname_test | 22 | ||||
-rwxr-xr-x | tests/setup_interfaces_test | 10 | ||||
-rwxr-xr-x | tests/setup_keymap_test | 22 | ||||
-rwxr-xr-x | tests/setup_sshd_test | 35 |
6 files changed, 40 insertions, 81 deletions
diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..b20c5d7 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,10 @@ +# alpine-conf testsuite + +This testsuite uses kyua and atf-sh + +For documentation: + +- https://github.com/jmmv/kyua/wiki/Quickstart-atf-sh-test +- https://manned.org/atf-sh-api + + diff --git a/tests/setup_devd_test b/tests/setup_devd_test index d911314..60e84b3 100755 --- a/tests/setup_devd_test +++ b/tests/setup_devd_test @@ -1,24 +1,10 @@ #!/usr/bin/env atf-sh -init_env() { - PATH=$(atf_get_srcdir)/..:$PATH - export ROOT=$PWD LIBDIR=$(atf_get_srcdir)/.. MOCK=echo -} - -# docs: -# - https://github.com/jmmv/kyua/wiki/Quickstart-atf-sh-test -# - https://manned.org/atf-sh-api - -atf_init_test_cases() { - atf_add_test_case setup_devd_usage -} +. $(atf_get_srcdir)/test_env.sh +init_tests \ + setup_devd_usage -atf_test_case setup_devd_usage setup_devd_usage_body() { - init_env - atf_check -s exit:0 \ - -o match:'^usage: setup-devd' \ - -e empty \ - setup-devd -h + test_usage setup-devd } diff --git a/tests/setup_hostname_test b/tests/setup_hostname_test index 2a5943f..a4c1809 100755 --- a/tests/setup_hostname_test +++ b/tests/setup_hostname_test @@ -1,24 +1,10 @@ #!/usr/bin/env atf-sh -init_env() { - PATH=$(atf_get_srcdir)/..:$PATH - export ROOT=$PWD LIBDIR=$(atf_get_srcdir)/.. MOCK=echo -} - -# docs: -# - https://github.com/jmmv/kyua/wiki/Quickstart-atf-sh-test -# - https://manned.org/atf-sh-api - -atf_init_test_cases() { - atf_add_test_case setup_hostname_usage -} +. $(atf_get_srcdir)/test_env.sh +init_tests \ + setup_hostname_usage -atf_test_case setup_hostname_usage setup_hostname_usage_body() { - init_env - atf_check -s exit:0 \ - -o match:'^usage: setup-hostname' \ - -e empty \ - setup-hostname -h + test_usage setup-hostname } diff --git a/tests/setup_interfaces_test b/tests/setup_interfaces_test new file mode 100755 index 0000000..e486083 --- /dev/null +++ b/tests/setup_interfaces_test @@ -0,0 +1,10 @@ +#!/usr/bin/env atf-sh + +. $(atf_get_srcdir)/test_env.sh +init_tests \ + setup_interfaces_usage + +setup_interfaces_usage_body() { + test_usage setup-interfaces +} + diff --git a/tests/setup_keymap_test b/tests/setup_keymap_test index 44c1643..30efbed 100755 --- a/tests/setup_keymap_test +++ b/tests/setup_keymap_test @@ -1,24 +1,10 @@ #!/usr/bin/env atf-sh -init_env() { - PATH=$(atf_get_srcdir)/..:$PATH - export ROOT=$PWD LIBDIR=$(atf_get_srcdir)/.. MOCK=echo -} - -# docs: -# - https://github.com/jmmv/kyua/wiki/Quickstart-atf-sh-test -# - https://manned.org/atf-sh-api - -atf_init_test_cases() { - atf_add_test_case setup_keymap_usage -} +. $(atf_get_srcdir)/test_env.sh +init_tests \ + setup_keymap_usage -atf_test_case setup_keymap_usage setup_keymap_usage_body() { - init_env - atf_check -s exit:0 \ - -o match:'^usage: setup-keymap' \ - -e empty \ - setup-keymap -h + test_usage setup-keymap } diff --git a/tests/setup_sshd_test b/tests/setup_sshd_test index c8e9dc7..b47f05e 100755 --- a/tests/setup_sshd_test +++ b/tests/setup_sshd_test @@ -1,33 +1,17 @@ #!/usr/bin/env atf-sh +. $(atf_get_srcdir)/test_env.sh +init_tests \ + setup_sshd_usage \ + setup_sshd_empty \ + setup_sshd_dropbear \ + setup_sshd_openssh \ + setup_sshd_interactive -init_env() { - PATH=$(atf_get_srcdir)/..:$PATH - export ROOT=$PWD LIBDIR=$(atf_get_srcdir)/.. MOCK=echo -} - -# docs: -# - https://github.com/jmmv/kyua/wiki/Quickstart-atf-sh-test -# - https://manned.org/atf-sh-api - -atf_init_test_cases() { - atf_add_test_case setup_sshd_usage - atf_add_test_case setup_sshd_empty - atf_add_test_case setup_sshd_dropbear - atf_add_test_case setup_sshd_openssh - atf_add_test_case setup_sshd_interactive -} - -atf_test_case setup_sshd_usage setup_sshd_usage_body() { - init_env - atf_check -s exit:0 \ - -o match:'^usage:' \ - -e empty \ - setup-sshd -h + test_usage setup-sshd } -atf_test_case setup_sshd_empty setup_sshd_empty_body() { init_env atf_check -s exit:0 \ @@ -36,7 +20,6 @@ setup_sshd_empty_body() { setup-sshd none } -atf_test_case setup_sshd_dropbear setup_sshd_dropbear_body() { init_env atf_check -s exit:0 \ @@ -47,7 +30,6 @@ setup_sshd_dropbear_body() { setup-sshd dropbear } -atf_test_case setup_sshd_openssh setup_sshd_openssh_body() { init_env atf_check -s exit:0 \ @@ -59,7 +41,6 @@ setup_sshd_openssh_body() { grep '^wget .*https://example.com/user.keys$' root/.ssh/authorized_keys || atf_fail "failed to wget ssh key" } -atf_test_case setup_sshd_interactive setup_sshd_interactive_body() { init_env mkdir -p etc/ssh |