+#!/bin/sh
+
+# test addfile
+
+tn=0
+planned=0
+
+okexit() {
+ if [ $? -ne 0 ]; then
+ printf 'not ';
+ fi
+ tn=$((tn + 1))
+ printf 'ok %d - %s\n' $tn "$*"
+}
+
+failsok() {
+ if [ $? -eq 0 ]; then
+ printf 'not ';
+ fi
+ tn=$((tn + 1))
+ printf 'ok %d - %s\n' $tn "$*"
+}
+
+exitwith() {
+ if [ $? -ne $1 ]; then
+ printf 'not ';
+ fi
+ shift
+ tn=$((tn + 1))
+ printf 'ok %d - %s\n' $tn "$*"
+}
+
+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 "$*"
+ if [ "$note" != "" ]; then
+ printf '%s\n' "$note"
+ fi
+}
+
+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) >> test.out 2>&1
+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