summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-02-11 09:18:32 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-02-12 20:00:42 -0500
commitfff85dbe15475c35fed2af66fabef3bdfb94f389 (patch)
tree237e33d1ecbc5c9d732a4aac142c48d7445d2667
parent6d99904f5a263cc119ac79718d83d7136dde349d (diff)
test-dns-packet: allow running without arguments
-rw-r--r--Makefile.am4
-rw-r--r--src/resolve/test-dns-packet.c27
2 files changed, 25 insertions, 6 deletions
diff --git a/Makefile.am b/Makefile.am
index 4e6a27a77d..754772156c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5309,6 +5309,10 @@ test_dns_packet_SOURCES = \
src/resolve/test-dns-packet.c \
$(basic_dns_sources)
+test_dns_packet_CPPFLAGS = \
+ $(AM_CPPFLAGS) \
+ -DRESOLVE_TEST_DIR=\"$(abs_top_srcdir)/src/resolve/test-data\"
+
test_dns_packet_LDADD = \
libshared.la
diff --git a/src/resolve/test-dns-packet.c b/src/resolve/test-dns-packet.c
index d8a5d9bbef..1abbd3fa2e 100644
--- a/src/resolve/test-dns-packet.c
+++ b/src/resolve/test-dns-packet.c
@@ -18,14 +18,17 @@
***/
#include <net/if.h>
+#include <glob.h>
#include "alloc-util.h"
#include "fileio.h"
-#include "macro.h"
+#include "glob-util.h"
#include "log.h"
+#include "macro.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-rr.h"
#include "string-util.h"
+#include "strv.h"
#define HASH_KEY SD_ID128_MAKE(d3,1e,48,90,4b,fa,4c,fe,af,9d,d5,a1,d7,2e,8a,b1)
@@ -84,15 +87,27 @@ static void test_packet_from_file(const char* filename, bool canonical) {
}
int main(int argc, char **argv) {
- int i;
+ int i, N;
+ _cleanup_globfree_ glob_t g = {};
+ _cleanup_strv_free_ char **globs = NULL;
+ char **fnames;
log_parse_environment();
- for (i = 1; i < argc; i++) {
- test_packet_from_file(argv[i], false);
+ if (argc >= 2) {
+ N = argc - 1;
+ fnames = argv + 1;
+ } else {
+ assert_se(glob(RESOLVE_TEST_DIR "/*.pkts", GLOB_NOSORT, NULL, &g) == 0);
+ N = g.gl_pathc;
+ fnames = g.gl_pathv;
+ }
+
+ for (i = 0; i < N; i++) {
+ test_packet_from_file(fnames[i], false);
puts("");
- test_packet_from_file(argv[i], true);
- if (i + 1 < argc)
+ test_packet_from_file(fnames[i], true);
+ if (i + 1 < N)
puts("");
}