From bc15f3016f10206e0a4236fc14b881b22651c402 Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Fri, 9 Nov 2018 22:04:29 +0000 Subject: [PATCH] use tmp directory for test script --- t/schema.t | 79 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 64 insertions(+), 15 deletions(-) diff --git a/t/schema.t b/t/schema.t index 27bbc11..838158d 100755 --- a/t/schema.t +++ b/t/schema.t @@ -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 -- 2.40.0