tests/xbps/xbps-digest: create tests.

This commit is contained in:
Érico Rolim 2020-08-30 01:30:09 -03:00 committed by Duncan Overbruck
parent 19f3e519fd
commit 9e812c2d7e
5 changed files with 58 additions and 1 deletions

View File

@ -11,3 +11,4 @@ include('xbps-query/Kyuafile')
include('xbps-rindex/Kyuafile') include('xbps-rindex/Kyuafile')
include('xbps-uhelper/Kyuafile') include('xbps-uhelper/Kyuafile')
include('xbps-remove/Kyuafile') include('xbps-remove/Kyuafile')
include('xbps-digest/Kyuafile')

View File

@ -1,5 +1,5 @@
-include ../../config.mk -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 include ../../mk/subdir.mk

View File

@ -0,0 +1,4 @@
syntax("kyuafile", 1)
test_suite("xbps-digest")
atf_test_program{name="basic_test"}

View File

@ -0,0 +1,8 @@
TOPDIR = ../../..
-include $(TOPDIR)/config.mk
TESTSHELL = basic_test
TESTSSUBDIR = xbps/xbps-digest
EXTRA_FILES = Kyuafile
include $(TOPDIR)/mk/test.mk

View File

@ -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
}