From f852b15718e4800cbda7b33dd7ec0b5cbd6f35cb Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 1 Oct 2019 12:24:04 +0000 Subject: [PATCH] test: Generate database dynamically Signed-off-by: Michael Tremer --- .gitignore | 1 + Makefile.am | 11 ++++++----- examples/python/create-database.py | 4 +++- src/perl/t/Location.t | 2 +- testdata/Readme.txt | 12 ------------ testdata/test.db | Bin 16459 -> 0 bytes 6 files changed, 11 insertions(+), 19 deletions(-) delete mode 100644 testdata/Readme.txt delete mode 100644 testdata/test.db diff --git a/.gitignore b/.gitignore index 6d9114d..a2dc6b1 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ Makefile.in /stamp-h1 /src/python/location-query /test.db +/testdata.db diff --git a/Makefile.am b/Makefile.am index 3d00324..f31a918 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/examples/python/create-database.py b/examples/python/create-database.py index 651709c..d2c3b61 100644 --- a/examples/python/create-database.py +++ b/examples/python/create-database.py @@ -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) diff --git a/src/perl/t/Location.t b/src/perl/t/Location.t index 75cd92f..b583af4 100644 --- a/src/perl/t/Location.t +++ b/src/perl/t/Location.t @@ -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 index 25e7f59..0000000 --- a/testdata/Readme.txt +++ /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 index 5840aca7fa48bed4459803c6005a3e7ac2eea146..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc-jL100001 literal 16459 zc-rmSIZnes6oBCu!V=bmeJ8`74n#|XaM(m7QXr9r!VZ>W1hJI3=MJ2WV{iws#UMS+ z4G8}y$MffDJcVmF?!5YWt0lR|_tOvgQOUrm!1=WkHmuxSq{VS?hopaV~udDfn>P=_=mhGyV8`ay+{vF%9&U{bx zzU>3G=TLRcc@_Ww008jM)i31t8vp