From cc1c984e9ae7d0731e6789d0a01ba771d8c3dd15 Mon Sep 17 00:00:00 2001 From: Duncaen Date: Wed, 26 Jun 2019 22:21:43 +0200 Subject: [PATCH] tests: add xbps-remove tests --- tests/xbps/Kyuafile | 2 +- tests/xbps/Makefile | 2 +- tests/xbps/xbps-remove/Kyuafile | 4 +++ tests/xbps/xbps-remove/Makefile | 8 +++++ tests/xbps/xbps-remove/basic_test.sh | 52 ++++++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 tests/xbps/xbps-remove/Kyuafile create mode 100644 tests/xbps/xbps-remove/Makefile create mode 100755 tests/xbps/xbps-remove/basic_test.sh diff --git a/tests/xbps/Kyuafile b/tests/xbps/Kyuafile index 326f6960..2a6b856f 100644 --- a/tests/xbps/Kyuafile +++ b/tests/xbps/Kyuafile @@ -10,4 +10,4 @@ include('xbps-install/Kyuafile') include('xbps-query/Kyuafile') include('xbps-rindex/Kyuafile') include('xbps-uhelper/Kyuafile') - +include('xbps-remove/Kyuafile') diff --git a/tests/xbps/Makefile b/tests/xbps/Makefile index 8171e1bb..c308c0a6 100644 --- a/tests/xbps/Makefile +++ b/tests/xbps/Makefile @@ -1,5 +1,5 @@ -include ../../config.mk -SUBDIRS = common libxbps xbps-alternatives xbps-checkvers xbps-create xbps-install xbps-query xbps-rindex xbps-uhelper +SUBDIRS = common libxbps xbps-alternatives xbps-checkvers xbps-create xbps-install xbps-query xbps-rindex xbps-uhelper xbps-remove include ../../mk/subdir.mk diff --git a/tests/xbps/xbps-remove/Kyuafile b/tests/xbps/xbps-remove/Kyuafile new file mode 100644 index 00000000..75ffef8f --- /dev/null +++ b/tests/xbps/xbps-remove/Kyuafile @@ -0,0 +1,4 @@ +syntax("kyuafile", 1) + +test_suite("xbps-remove") +atf_test_program{name="basic_test"} diff --git a/tests/xbps/xbps-remove/Makefile b/tests/xbps/xbps-remove/Makefile new file mode 100644 index 00000000..67607db5 --- /dev/null +++ b/tests/xbps/xbps-remove/Makefile @@ -0,0 +1,8 @@ +TOPDIR = ../../.. +-include $(TOPDIR)/config.mk + +TESTSHELL = basic_test +TESTSSUBDIR = xbps/xbps-remove +EXTRA_FILES = Kyuafile + +include $(TOPDIR)/mk/test.mk diff --git a/tests/xbps/xbps-remove/basic_test.sh b/tests/xbps/xbps-remove/basic_test.sh new file mode 100755 index 00000000..dafc24de --- /dev/null +++ b/tests/xbps/xbps-remove/basic_test.sh @@ -0,0 +1,52 @@ +#! /usr/bin/env atf-sh + +atf_test_case remove_directory + +remoe_directory_head() { + atf_set "descr" "xbps-remove(1): remove nested directories" +} + +remove_directory_body() { + mkdir -p some_repo pkg_A/B/C + touch pkg_A/B/C/file00 + cd some_repo + xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + xbps-install -r root -C empty.conf --repository=$PWD/some_repo -y A + atf_check_equal $? 0 + xbps-remove -r root -C empty.conf -y A + atf_check_equal $? 0 + test -d root/B + atf_check_equal $? 1 +} + +atf_test_case remove_orphans + +remove_orphans_head() { + atf_set "descr" "xbps-remove(1): remove orphaned packages" +} + +remove_orphans_body() { + mkdir -p some_repo pkg_A/B/C + touch pkg_A/ + cd some_repo + xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + xbps-install -r root -C empty.conf --repository=$PWD/some_repo -yA A + atf_check_equal $? 0 + xbps-remove -r root -C empty.conf -yvdo + atf_check_equal $? 0 + xbps-query A + atf_check_equal $? 2 +} + +atf_init_test_cases() { + atf_add_test_case remove_directory + atf_add_test_case remove_orphans +}