-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
d:
printf '%s\n' $(LZMAOBJ)
+test: zpm-addfile
+ prove -e'' t/*.t
programs: elftype soname zpm-addfile zpm-extract
#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
--- /dev/null
+#!/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