summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/dbgserver_build_id_find.c10
-rwxr-xr-xtests/run-dbgserver-find.sh30
2 files changed, 21 insertions, 19 deletions
diff --git a/tests/dbgserver_build_id_find.c b/tests/dbgserver_build_id_find.c
index 30b55e3a..8e302c8e 100644
--- a/tests/dbgserver_build_id_find.c
+++ b/tests/dbgserver_build_id_find.c
@@ -25,6 +25,7 @@
#include <dwarf.h>
#include <argp.h>
#include <assert.h>
+#include <string.h>
static const char *debuginfo_path = "";
static const Dwfl_Callbacks cb =
@@ -38,6 +39,7 @@ static const Dwfl_Callbacks cb =
int
main (int argc __attribute__ ((unused)), char **argv)
{
+ int expect_pass = strcmp(argv[3], "0");
Dwarf_Addr bias = 0;
Dwfl *dwfl = dwfl_begin(&cb);
dwfl_report_begin(dwfl);
@@ -47,6 +49,12 @@ main (int argc __attribute__ ((unused)), char **argv)
/* The corresponding debuginfo will not be found in debuginfo_path
(since it's empty), causing the server to be queried. */
- assert(dwfl_module_getdwarf(mod, &bias));
+
+ Dwarf *res = dwfl_module_getdwarf(mod, &bias);
+ if (expect_pass)
+ assert(res);
+ else
+ assert(!res);
+
return 0;
}
diff --git a/tests/run-dbgserver-find.sh b/tests/run-dbgserver-find.sh
index e39fdd29..cf547dfe 100755
--- a/tests/run-dbgserver-find.sh
+++ b/tests/run-dbgserver-find.sh
@@ -16,8 +16,7 @@
. $srcdir/test-subr.sh
-
-if [ -z $DBGSERVER_URLS ]; then
+if [ -z "$DBGSERVER_URLS" ]; then
echo "unknown server url"
exit 77
fi
@@ -25,34 +24,29 @@ fi
testfiles testfile-dbgserver.exec
testfiles testfile-dbgserver.debug
-DB="$PWD/.dbgserver_tmp.sqlite"
-
-if [ -z $HOME ]; then
- CACHE_DIR="/.dbgserver_client_cache"
-else
- CACHE_DIR="$HOME/.dbgserver_client_cache"
-fi
-
-# Clear the cache
-if [ -d $CACHE_DIR ]; then
- echo "t"
- rm -rf $CACHE_DIR
-fi
+EXPECT_FAIL=0
+EXPECT_PASS=1
+DB=${PWD}/.dbgserver_tmp.sqlite
+export DBGSERVER_CACHE_PATH=${PWD}/.client_cache
+export DBGSERVER_CACHE_CLEAN_INTERVAL_S=100
../../src/dbgserver -vvv -d $DB -F $PWD &
PID=$!
sleep 5
# Test whether the server is able to fetch the file from the local dbgserver.
-testrun ${abs_builddir}/dbgserver_build_id_find -e testfile-dbgserver.exec
+testrun ${abs_builddir}/dbgserver_build_id_find -e testfile-dbgserver.exec $EXPECT_PASS
kill $PID
rm $DB
# Run the test again without the server running. The target file should
# be found in the cache.
-testrun ${abs_builddir}/dbgserver_build_id_find -e testfile-dbgserver.exec
+testrun ${abs_builddir}/dbgserver_build_id_find -e testfile-dbgserver.exec $EXPECT_PASS
-rm -rf $CACHE_DIR
+# Trigger a cache clean and run the test again. The client should be unable to
+# find the target.
+export DBGSERVER_CACHE_CLEAN_INTERVAL_S=0
+testrun ${abs_builddir}/dbgserver_build_id_find -e testfile-dbgserver.exec $EXPECT_FAIL
exit 0