From 98344faf58c6ae59c9df9b46e4f0b0e49013846b Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Mon, 19 Sep 2016 02:58:29 +0000 Subject: [PATCH] fixup tests --- Makefile | 6 ++-- t/addfile.t | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100755 t/addfile.t diff --git a/Makefile b/Makefile index 1899152..ff9f4c9 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CFLAGS=-Wall -std=c99 -I. -Ilzma/api -Ilzma/tuklib -Ilzma/lzma -Ilzma/common -Ilzma/check -Ilzma/lz -Ilzma/rangecoder -Ilzma/simple -Ilzma/delta -DHAVE_CHECK_CRC64 -DHAVE_CHECK_CRC32 -DHAVE_ENCODER_LZMA2 -DHAVE_DECODER_LZMA2 -DHAVE_MF_BT4 +CFLAGS=-Wall -std=c99 -I. -Ilzma/api -Ilzma/tuklib -Ilzma/lzma -Ilzma/common -Ilzma/check -Ilzma/lz -Ilzma/rangecoder -Ilzma/simple -Ilzma/delta -DHAVE_CHECK_CRC64 -DHAVE_CHECK_CRC32 -DHAVE_ENCODER_LZMA2 -DHAVE_DECODER_LZMA2 -DHAVE_MF_BT4 -D_POSIX_C_SOURCE=1 LDFLAGS=-L. LZMACHECKSRC=lzma/check/check.c lzma/check/crc32_fast.c lzma/check/crc64_fast.c lzma/check/crc32_table.c lzma/check/crc64_table.c @@ -9,6 +9,8 @@ def: libzpm.a d: printf '%s\n' $(LZMAOBJ) +test: zpm-addfile + prove -e'' t/*.t programs: elftype soname zpm-addfile zpm-extract @@ -53,4 +55,4 @@ install: elftype #SPOOL=$(DESTDIR)/var/lib/admin/notes ./zpm-sequence -c notes clean: - rm -f *.o lib/*.o $(LZMAOBJ) liblzma.a + rm -f *.o lib/*.o $(LZMAOBJ) liblzma.a zpm-addfile diff --git a/t/addfile.t b/t/addfile.t new file mode 100755 index 0000000..fbfa70e --- /dev/null +++ b/t/addfile.t @@ -0,0 +1,84 @@ +#!/bin/sh + +# test addfile + +tn=0 +planned=0 + +shownote() { + if [ "$note" != "" ]; then + printf '# %s\n' "$note" + fi +} + +okexit() { + exitwith 0 "$*" +} + +failsok() { + note= + if [ $? -eq 0 ]; then + printf 'not '; + note=$(printf '# got "%d" expected "%d"' "$1" "0") + fi + tn=$((tn + 1)) + printf 'ok %d - %s\n' $tn "$*" + shownote +} + +exitwith() { + note= + if [ $? -ne $1 ]; then + printf 'not '; + note=$(printf '# got "%d" expected "%d"' "$1" "$2") + fi + shift + tn=$((tn + 1)) + printf 'ok %d - %s\n' $tn "$*" + shownote +} + +okstreq() { + note= + if [ "$1" != "$2" ]; then + printf 'not '; + note=$(printf 'got "%s" expected "%s"' "$1" "$2") + fi + + shift;shift; + tn=$((tn + 1)) + printf 'ok %d - %s\n' $tn "$*" + shownote +} + +plan() { + planned=$1 + printf '1..%d\n' $planned +} + +finish() { + if [ $planned -eq 0 ]; then + printf '1..%d\n' $tn + fi +} + +plan 4 + +PF=test.db + +rm -f $PF test.empty +touch test.empty + +hash=$(./zpm-addfile $PF test.empty 2>> test.out) +okexit add empty file content +okstreq $hash e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 hash contents + +appid=$(sqlite3 test.db 'pragma application_id') +okstreq $appid 1515209794 application id set + +userv=$(sqlite3 test.db 'pragma user_version') +okstreq $userv 1 db version set + +finish + +#rm -f $PF test.empty -- 2.40.0