]> pd.if.org Git - zpackage/commitdiff
use tmp directory for test script
authorNathan Wagner <nw@hydaspes.if.org>
Fri, 9 Nov 2018 22:04:29 +0000 (22:04 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Fri, 9 Nov 2018 22:04:29 +0000 (22:04 +0000)
t/schema.t

index 27bbc11a40f841b76c2912eb725239fe22610eb2..838158dd8d9be4a92820192c705005d15edf0943 100755 (executable)
@@ -2,15 +2,18 @@
 
 . tap.sh
 
-plan 5
+plan 7
+
+require rm -rf tmp
+require mkdir tmp
 
 PF=test.db
 
-rm -f $PF
+zpm-shell tmp/$PF < db.sql
 
-zpm-shell $PF < db.sql
+okexit direct schema load || bailout 'cannot load schema'
 
-okexit direct schema load
+cd tmp
 
 { cat<<-EOS
 pragma foreign_keys = off;
@@ -45,6 +48,8 @@ EOS
 
 failsok null groupname rejected
 
+#zpm-shell $PF '.tables'
+
 { cat<<-EOS
 pragma foreign_keys = off;
 insert into packagefiles
@@ -56,16 +61,60 @@ EOS
 
 failsok null username rejected
 
-finish
-rm -f $PF
-exit 0
-
-zpm-test test.empty 2>/dev/null
-failsok zpm-test of empty file
-
-zpm-init $PF
- zpm-init new file
+# check the library logic
+
+fakepkg() {
+zpm-shell $PF "insert into packages (package,version,release,status)
+ values ('$1','$2',1,NULL)"
+}
+
+fakelib() {
+       hash="hv.$3.so.$4"
+       soname="lib$3.so.$4"
+       path="/lib/$soname"
+       hash="$path"
+zpm-shell $PF "insert into packagefiles (package,version,release,path,hash)
+ values ('$1','$2',1,'$path','$hash');"
+zpm-shell $PF "insert into elflibraries (file,soname)
+ values ('$hash','$soname');"
+       if [ -n "$5" ]; then
+               dep="lib$5.so.$6"
+               zpm-shell $PF "insert into elfneeded (file,needed)
+               values ('$hash','$dep');"
+       fi
+}
+
+fakeprg() {
+       hash="hv.$2.$3"
+       path="/bin/$3 ($2)"
+       hash="$path"
+zpm-shell $PF "insert into packagefiles (package,version,release,path,hash)
+ values ('$1','$2',1,'$path','$hash');"
+       if [ -n "$4" ]; then
+               dep="lib$4.so.$5"
+               zpm-shell $PF "insert into elfneeded (file,needed)
+               values ('$hash','$dep');"
+       fi
+}
 
-finish
+exit 0
+fakepkg foo 1.0 libfoo 1
+fakepkg foo 2.0 libfoo 2
+fakepkg hw 1.0
+fakepkg hw 2.0
+fakepkg bar 1.0
+fakepkg bar 2.0
+fakelib foo 1.0 foo 1 bar 1
+fakelib foo 2.0 foo 2 bar 1
+fakelib bar 1.0 bar 1
+fakelib bar 2.0 bar 2
+fakeprg hw 1.0 hw foo 1
+fakeprg hw 2.0 hw foo 1
+
+echo needed
+zpm-shell $PF 'select * from elfneeded'
+echo libs
+zpm-shell $PF 'select * from elflibraries'
 
-rm -f $PF test.empty
+rm -f $PF
+exit 0