Opened 10 years ago

Closed 10 years ago

#122 closed defect (fixed)

location of testdata files

Reported by: jreed Owned by: jreed
Priority: low Milestone:
Component: Unclassified Version:
Keywords: Cc:
CVSS Scoring: Parent Tickets:
Sensitive: no Defect Severity:
Sub-Project: Feature Depending on Ticket:
Estimated Difficulty: Add Hours to Ticket:
Total Hours: Internal?:

Description

See
http://bind10.isc.org/~tester/builder/BIND10-distcheck/20100327010000-FreeBSD7-amd64/logs/distcheck.out

The files exist like at:

ls -l src/lib/dns/tests/testdata/message_fromWire1

-r--r--r-- 1 jreed jreed 637 Mar 26 18:00 src/lib/dns/tests/testdata/message_fromWire1

But not in the build directory, for example:

ls -l _build/src/lib/dns/tests/testdata/

total 16
-rwxr-xr-x 1 jreed jreed 15192 Mar 26 18:00 gen-wiredata.py

Maybe MessageTest::factoryFromFile should use the @srcdir@ and not the @builddir@ to open the testdata file. Could be passed in as a macro.

Subtickets

Change History (7)

comment:1 Changed 10 years ago by jreed

Something like this. But not tested using distcheck yet.

Index: src/lib/dns/tests/unittest_util.cc
===================================================================
--- src/lib/dns/tests/unittest_util.cc	(revision 1705)
+++ src/lib/dns/tests/unittest_util.cc	(working copy)
@@ -38,7 +38,14 @@
                            vector<unsigned char>& data)
 {
     ifstream ifs;
- 
+    string datafile_with_path;
+
+#ifndef SRCDIR
+#define SRCDIR .
+#endif
+    datafile_with_path.append("SRCDIR/"); 
+    datafile_with_path.append(datafile); 
+
     ifs.open(datafile, ios_base::in);
     if ((ifs.rdstate() & istream::failbit) != 0) {
         throw runtime_error("failed to open data file: " +
Index: src/lib/dns/tests/Makefile.am
===================================================================
--- src/lib/dns/tests/Makefile.am	(revision 1705)
+++ src/lib/dns/tests/Makefile.am	(working copy)
@@ -1,5 +1,6 @@
 AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
 AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
+AM_CPPFLAGS +=	-DSRCDIR=${srcdir}
 
 CLEANFILES = *.gcno *.gcda
 

comment:2 Changed 10 years ago by jreed

patch was incomplete. Forgot to use the new string!

comment:3 Changed 10 years ago by jreed

When I use ifs.open(datafile_with_path, ios_base::in); I now get

unittest_util.cc: In static member function 'static void isc::UnitTestUtil::readWireData(const char*, std::vector<unsigned char, std::allocator<unsigned char> >&)':
unittest_util.cc:49: error: no matching function for call to 'std::basic_ifstream<char, std::char_traits<char> >::open(std::string&, const std::_Ios_Openmode&)'
/usr/pkg/gcc44/lib/gcc/x86_64-unknown-netbsd4.99.62/4.4.1/../../../../include/c++/4.4.1/fstream:525: note: candidates are: void std::basic_ifstream<_CharT, _Traits>::open(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]
*** Error code 1

comment:4 Changed 10 years ago by jinmei

  • Owner set to jreed
  • Status changed from new to assigned

I believe r1709 solved this ticket.

I expect unittest_util will be shared with other modules than the dns library, so I didn't want to hardcode the path to unittest_util. Also, as commented in the commit log I guess we'll need to specify multiple paths. r1709 allowed that.

Please someone review r1709. The only substantial changes are for unittest_util.* and run_unittests.cc. Other changes are minor cleanup: removing "testdata/".

comment:5 Changed 10 years ago by jinmei

...and r1710. in fact, dns/tests/unittest_util.* were already used in another module (but I forgot that:-)

comment:6 Changed 10 years ago by jreed

Error changed to:

[----------] 10 tests from MessageRendererTest
[ RUN      ] MessageRendererTest.writeIntger
...
[ RUN      ] MessageRendererTest.writeNameCaseSensitiveCompress
terminate called after throwing an instance of 'std::runtime_error'
  what():  failed to open data file in data paths: name_toWire5
Abort trap (core dumped)
FAIL: run_unittests

Previously it was like:

  what():  failed to open data file: testdata/message_fromWire1

Your fix works. The new problem was caused by additional test data added but not included in tarball. I will commit that.

My next problem is in the auth tests:

[----------] 43 tests from Sqlite3DataSourceTest
[ RUN      ] Sqlite3DataSourceTest.close
terminate called after throwing an instance of 'isc::auth::Sqlite3Error'
  what():  Cannot open Sqlite3 database file: testdata/test.sqlite3
[1]   Abort trap (core dumped) ${dir}${tst}
FAIL: run_unittests

I don't know if "Open" means it can't find it or if it means that it can't open for writing. It is read-only for make distcheck.

comment:7 Changed 10 years ago by jreed

  • Resolution set to fixed
  • Status changed from assigned to closed

This was fixed. (I think in r1713.)

Note: See TracTickets for help on using tickets.