From 1adfe4072438b0f3954c6ef1fba87d7f37022409 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 11 May 2022 21:18:53 +0200 Subject: tests: add testing with kyua Use kyua to do testing. --- Kyuafile | 5 +++++ Makefile | 5 ++++- tests/Kyuafile | 5 +++++ tests/setup_sshd_test | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 Kyuafile create mode 100644 tests/Kyuafile create mode 100755 tests/setup_sshd_test diff --git a/Kyuafile b/Kyuafile new file mode 100644 index 0000000..bb1c24a --- /dev/null +++ b/Kyuafile @@ -0,0 +1,5 @@ +syntax(2) + +test_suite('alpine-conf') + +include('tests/Kyuafile') diff --git a/Makefile b/Makefile index 2224067..9fdec11 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ SED_REPLACE := -e 's:@VERSION@:$(FULL_VERSION):g' \ ${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@ %: %.in - ${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@ + ${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@ && chmod +x $@ .PHONY: all apk clean install uninstall iso all: $(SCRIPTS) $(BIN_FILES) @@ -101,3 +101,6 @@ alpine-conf.iso: $(SCRIPTS) $(BIN_FILES) xorriso -as mkisofs -r -V 'ALPINECONF' -J -o $@ tmp/ && rm -rf tmp iso: alpine-conf.iso + +test: $(SCRIPTS) $(BIN_FILES) + kyua test || (kyua report --verbose && exit 1) diff --git a/tests/Kyuafile b/tests/Kyuafile new file mode 100644 index 0000000..77fd0bd --- /dev/null +++ b/tests/Kyuafile @@ -0,0 +1,5 @@ +syntax(2) + +test_suite('alpine-conf') + +atf_test_program{name='setup_sshd_test'} diff --git a/tests/setup_sshd_test b/tests/setup_sshd_test new file mode 100755 index 0000000..a373d8c --- /dev/null +++ b/tests/setup_sshd_test @@ -0,0 +1,42 @@ +#!/usr/bin/env atf-sh + +PATH=$(atf_get_srcdir)/..:$PATH + +init_env() { + export ROOT=$PWD LIBDIR=$(atf_get_srcdir)/.. MOCK=echo +} + +atf_test_case setup_sshd_help +setup_sshd_help_body() { + init_env + atf_check -s exit:0 \ + -o match:'^usage:' \ + -e empty \ + setup-sshd -h +} + +atf_test_case setup_sshd_empty +setup_sshd_empty_body() { + init_env + atf_check -s exit:0 \ + -e empty \ + -o empty \ + setup-sshd none +} + +atf_test_case setup_sshd_dropbear +setup_sshd_dropbear_body() { + init_env + atf_check -s exit:0 \ + -e empty \ + -o match:"^apk add .* dropbear" \ + -o match:"^rc-update add dropbear" \ + -o match:"^rc-service dropbear start" \ + setup-sshd dropbear +} + +atf_init_test_cases() { + atf_add_test_case setup_sshd_help + atf_add_test_case setup_sshd_empty + atf_add_test_case setup_sshd_dropbear +} -- cgit v1.2.3