diff --git a/tests/xbps/Kyuafile b/tests/xbps/Kyuafile index 2a6b856f..a71995e2 100644 --- a/tests/xbps/Kyuafile +++ b/tests/xbps/Kyuafile @@ -11,3 +11,4 @@ include('xbps-query/Kyuafile') include('xbps-rindex/Kyuafile') include('xbps-uhelper/Kyuafile') include('xbps-remove/Kyuafile') +include('xbps-digest/Kyuafile') diff --git a/tests/xbps/Makefile b/tests/xbps/Makefile index c308c0a6..a0fc3f95 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 xbps-remove +SUBDIRS = common libxbps xbps-alternatives xbps-checkvers xbps-create xbps-install xbps-query xbps-rindex xbps-uhelper xbps-remove xbps-digest include ../../mk/subdir.mk diff --git a/tests/xbps/xbps-digest/Kyuafile b/tests/xbps/xbps-digest/Kyuafile new file mode 100644 index 00000000..47023ef5 --- /dev/null +++ b/tests/xbps/xbps-digest/Kyuafile @@ -0,0 +1,4 @@ +syntax("kyuafile", 1) + +test_suite("xbps-digest") +atf_test_program{name="basic_test"} diff --git a/tests/xbps/xbps-digest/Makefile b/tests/xbps/xbps-digest/Makefile new file mode 100644 index 00000000..5f6e371c --- /dev/null +++ b/tests/xbps/xbps-digest/Makefile @@ -0,0 +1,8 @@ +TOPDIR = ../../.. +-include $(TOPDIR)/config.mk + +TESTSHELL = basic_test +TESTSSUBDIR = xbps/xbps-digest +EXTRA_FILES = Kyuafile + +include $(TOPDIR)/mk/test.mk diff --git a/tests/xbps/xbps-digest/basic_test.sh b/tests/xbps/xbps-digest/basic_test.sh new file mode 100644 index 00000000..83050562 --- /dev/null +++ b/tests/xbps/xbps-digest/basic_test.sh @@ -0,0 +1,44 @@ +#! /usr/bin/env atf-sh +# Test that xbps-digest(1) works as expected. + +atf_test_case empty_string + +empty_string_head() { + atf_set "descr" "xbps-digest(1): check empty string hash" +} + +empty_string_body() { + result="$(printf "" | xbps-digest)" + expected=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + rv=0 + if [ "$result" != "$expected" ]; then + echo "result: $result" + echo "expected: $expected" + rv=1 + fi + atf_check_equal $rv 0 +} + +atf_test_case small_file + +small_file_head() { + atf_set "descr" "xbps-digest(1): check small file hash" +} + +small_file_body() { + printf "abc\nbca" > file + result="$(xbps-digest file)" + expected="36749ea1445c9fcb405767cbf67ebb4679dd4f7560a3b5fa977bc288fe15f999" + rv=0 + if [ "$result" != "$expected" ]; then + echo "result: $result" + echo "expected: $expected" + rv=1 + fi + atf_check_equal $rv 0 +} + +atf_init_test_cases() { + atf_add_test_case empty_string + atf_add_test_case small_file +}