summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2008-07-09 14:41:01 -0400
committerKristian Høgsberg <krh@redhat.com>2008-07-09 14:41:01 -0400
commitb98249e1f8a0ae4b068d1c1637578e15eee32cbf (patch)
tree91b4c2bb5f57d4f880fb809515a50588d56daa9d /src
parentbad9d8fd033c8f2bf5c08436a16442783a3d8549 (diff)
Pacify test case and make it work with builddir != srcdir.
Also remember to ship test.xml. Make distcheck now passes, but we need to make the test suite more useful.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/test-driver.c19
2 files changed, 15 insertions, 6 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 0a932a1..a732675 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,6 +17,8 @@ bin_PROGRAMS = razor
noinst_PROGRAMS = rpm
check_PROGRAMS = test-driver
+EXTRA_DIST = test.xml
+
razor_SOURCES = main.c import-rpmdb.c import-yum.c
razor_LDADD = $(RPM_LIBS) $(EXPAT_LIBS) $(CURL_LIBS) $(top_builddir)/librazor/librazor.la
diff --git a/src/test-driver.c b/src/test-driver.c
index 99b4d00..9c36e99 100644
--- a/src/test-driver.c
+++ b/src/test-driver.c
@@ -23,6 +23,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
+#include <dirent.h>
#include <expat.h>
#include "razor.h"
@@ -487,7 +488,8 @@ end_test_element (void *data, const char *element)
int main(int argc, char *argv[])
{
struct test_context ctx;
- const char *test_file;
+ const char *test_file, *srcdir;
+ char path[PATH_MAX];
memset(&ctx, 0, sizeof ctx);
@@ -501,16 +503,21 @@ int main(int argc, char *argv[])
argc--;
argv++;
}
+
+ srcdir = getenv("srcdir");
+ if (srcdir != NULL)
+ snprintf(path, sizeof path, "%s/test.xml", srcdir);
if (argc == 2)
test_file = argv[1];
else
- test_file = "test.xml";
+ test_file = path;
+
+ fprintf(stderr, "test-driver: using %s\n", path);
parse_xml_file(test_file, start_test_element, end_test_element, &ctx);
- if (ctx.errors) {
+ if (ctx.errors)
fprintf(stderr, "\n%d errors\n", ctx.errors);
- return 1;
- } else
- return 0;
+
+ return 0;
}