]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
test: Generate database dynamically
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Oct 2019 12:24:04 +0000 (12:24 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Oct 2019 12:24:20 +0000 (12:24 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
.gitignore
Makefile.am
examples/python/create-database.py
src/perl/t/Location.t
testdata/Readme.txt [deleted file]
testdata/test.db [deleted file]

index 6d9114d288ccc7a63446066135d3e08487ee8b35..a2dc6b14335f63fab2babdcdad0306171786bab4 100644 (file)
@@ -14,3 +14,4 @@ Makefile.in
 /stamp-h1
 /src/python/location-query
 /test.db
+/testdata.db
index 3d003246c30ef0053aed9f1282acbb01c012e621..f31a9187847bca1156672e6b49ba098ba2e43ed8 100644 (file)
@@ -159,8 +159,8 @@ build-perl:
        cd $(builddir)/src/perl && $(MAKE)
 
 .PHONY: check-perl
-check-perl:
-       cd $(builddir)/src/perl && $(MAKE) test srcdir=$(abs_srcdir)
+check-perl: testdata.db
+       cd $(builddir)/src/perl && $(MAKE) test database="../../$<"
 
 .PHONY: install-perl
 install-perl:
@@ -199,10 +199,11 @@ TESTS = \
        src/test-network
 
 CLEANFILES += \
-       test.db
+       test.db \
+       testdata.db
 
-EXTRA_DIST += \
-       testdata/test.db
+testdata.db: examples/python/create-database.py
+       PYTHONPATH=$(abs_builddir)/src/python/.libs $(PYTHON) $< $@
 
 check_PROGRAMS = \
        src/test-libloc \
index 651709c3495956986385391238c14c71ef78f7c1..d2c3b61a9922bde8b18a1daa7a5cec84f92aa508 100644 (file)
@@ -1,6 +1,7 @@
 #!/usr/bin/python3
 
 import location
+import sys
 
 w = location.Writer()
 
@@ -27,4 +28,5 @@ n.asn = a.number
 print(n)
 
 # Write the database to disk
-w.write("test.db")
+for f in sys.argv[1:]:
+    w.write(f)
index 75cd92f039ada44680e05d9b44bafec0ed3d7a4a..b583af451dfde363df351027b2af105fd727b660 100644 (file)
@@ -9,7 +9,7 @@ use strict;
 use warnings;
 
 # Where to find the test database.
-my $testdb = "$ENV{'srcdir'}/testdata/test.db";
+my $testdb = $ENV{'database'};
 
 use Test::More tests => 5;
 BEGIN { use_ok('Location') };
diff --git a/testdata/Readme.txt b/testdata/Readme.txt
deleted file mode 100644 (file)
index 25e7f59..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-The database in this folder can be used to run various tests against it and
-has been created by using the "create-database.py" script in the examples directory.
-
-It contains the following content:
-
-Vendor: "IPFire Project"
-Description: "This is a geo location database"
-License: "CC"
-
-AS: "AS204867 (Lightning Wire Labs GmbH)"
-Subnet: "2a07:1c44:5800::/40"
-Country Code: "DE"
diff --git a/testdata/test.db b/testdata/test.db
deleted file mode 100644 (file)
index 5840aca..0000000
Binary files a/testdata/test.db and /dev/null differ