diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-10-11 14:04:32 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-10-11 14:38:21 +0300 |
commit | 791cdf412f5fb66a056aa28b27507fdc9af86507 (patch) | |
tree | 9e6c4af696424ea72b51d0b8d9c8cf85c8b43856 | |
parent | df83b714395d41b096f7ad8cc3a090c9341f7598 (diff) | |
download | vmod-binlog-791cdf412f5fb66a056aa28b27507fdc9af86507.tar.gz vmod-binlog-791cdf412f5fb66a056aa28b27507fdc9af86507.tar.bz2 |
Add testsuite.
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | configure.ac | 8 | ||||
-rw-r--r-- | src/binlog.c | 0 | ||||
-rw-r--r-- | src/binlogcat.c | 16 | ||||
-rw-r--r-- | tests/.gitignore | 6 | ||||
-rw-r--r-- | tests/Makefile.am | 71 | ||||
-rw-r--r-- | tests/atlocal.in | 8 | ||||
-rw-r--r-- | tests/test01.at | 83 | ||||
-rw-r--r-- | tests/test02.at | 83 | ||||
-rw-r--r-- | tests/testsuite.at | 25 |
10 files changed, 298 insertions, 6 deletions
diff --git a/Makefile.am b/Makefile.am index 221d1c0..d11b042 100644 --- a/Makefile.am +++ b/Makefile.am | |||
@@ -12,10 +12,10 @@ | |||
12 | # GNU General Public License for more details. | 12 | # GNU General Public License for more details. |
13 | # | 13 | # |
14 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
15 | # along with vmod-sql. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with vmod-binlog. If not, see <http://www.gnu.org/licenses/>. |
16 | ACLOCAL_AMFLAGS = -I m4 | 16 | ACLOCAL_AMFLAGS = -I m4 |
17 | 17 | ||
18 | SUBDIRS = src #doc tests | 18 | SUBDIRS = src tests #doc |
19 | 19 | ||
20 | EXTRA_DIST=git2chg.awk | 20 | EXTRA_DIST=git2chg.awk |
21 | 21 | ||
diff --git a/configure.ac b/configure.ac index 2924eae..ea7c061 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -12,7 +12,7 @@ | |||
12 | # GNU General Public License for more details. | 12 | # GNU General Public License for more details. |
13 | # | 13 | # |
14 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
15 | # along with vmod-sql. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with vmod-binlog. If not, see <http://www.gnu.org/licenses/>. |
16 | AC_PREREQ(2.69) | 16 | AC_PREREQ(2.69) |
17 | AC_INIT([vmod-binlog], 1.0, [gray@gnu.org]) | 17 | AC_INIT([vmod-binlog], 1.0, [gray@gnu.org]) |
18 | AC_CONFIG_AUX_DIR([build-aux]) | 18 | AC_CONFIG_AUX_DIR([build-aux]) |
@@ -96,7 +96,11 @@ if test -z "$VMODDIR"; then | |||
96 | VMODDIR='$(libdir)/varnish/mods' | 96 | VMODDIR='$(libdir)/varnish/mods' |
97 | fi | 97 | fi |
98 | 98 | ||
99 | dnl FIXME: tests/Makefile | 99 | # Initialize the test suite. |
100 | AC_CONFIG_TESTDIR(tests) | ||
101 | AC_CONFIG_FILES([tests/Makefile tests/atlocal]) | ||
102 | AM_MISSING_PROG([AUTOM4TE], [autom4te]) | ||
103 | |||
100 | dnl FIXME: doc/Makefile | 104 | dnl FIXME: doc/Makefile |
101 | AC_CONFIG_FILES([ | 105 | AC_CONFIG_FILES([ |
102 | Makefile | 106 | Makefile |
diff --git a/src/binlog.c b/src/binlog.c index f896803..be32e10 100644 --- a/src/binlog.c +++ b/src/binlog.c | |||
diff --git a/src/binlogcat.c b/src/binlogcat.c index c51125b..219f78c 100644 --- a/src/binlogcat.c +++ b/src/binlogcat.c | |||
@@ -28,6 +28,7 @@ char *progname; | |||
28 | char *timefmt = "%c"; | 28 | char *timefmt = "%c"; |
29 | int number_option; | 29 | int number_option; |
30 | int verbose_option; | 30 | int verbose_option; |
31 | int timediff_option; | ||
31 | 32 | ||
32 | void | 33 | void |
33 | catlog(const char *fname) | 34 | catlog(const char *fname) |
@@ -37,6 +38,7 @@ catlog(const char *fname) | |||
37 | struct binlog_record rec; | 38 | struct binlog_record rec; |
38 | char timebuf[128]; | 39 | char timebuf[128]; |
39 | size_t i; | 40 | size_t i; |
41 | time_t start_ts; | ||
40 | 42 | ||
41 | if (strcmp(fname, "-") == 0) | 43 | if (strcmp(fname, "-") == 0) |
42 | fp = stdin; | 44 | fp = stdin; |
@@ -83,6 +85,12 @@ catlog(const char *fname) | |||
83 | break; | 85 | break; |
84 | } | 86 | } |
85 | 87 | ||
88 | if (timediff_option) { | ||
89 | if (i == 0) | ||
90 | start_ts = rec.ts; | ||
91 | rec.ts -= start_ts; | ||
92 | } | ||
93 | |||
86 | strftime(timebuf, sizeof timebuf, timefmt, localtime(&rec.ts)); | 94 | strftime(timebuf, sizeof timebuf, timefmt, localtime(&rec.ts)); |
87 | if (number_option) | 95 | if (number_option) |
88 | printf("%lu ", (unsigned long) i); | 96 | printf("%lu ", (unsigned long) i); |
@@ -95,7 +103,7 @@ catlog(const char *fname) | |||
95 | void | 103 | void |
96 | help() | 104 | help() |
97 | { | 105 | { |
98 | printf("usage: %s [-hnv] [t FORMAT] [FILE...]\n"); | 106 | printf("usage: %s [-dhnv] [t FORMAT] [FILE...]\n"); |
99 | } | 107 | } |
100 | 108 | ||
101 | int | 109 | int |
@@ -104,8 +112,12 @@ main(int argc, char **argv) | |||
104 | progname = argv[0]; | 112 | progname = argv[0]; |
105 | int c; | 113 | int c; |
106 | 114 | ||
107 | while ((c = getopt(argc, argv, "ht:nv")) != EOF) | 115 | while ((c = getopt(argc, argv, "dht:nv")) != EOF) |
108 | switch (c) { | 116 | switch (c) { |
117 | case 'd': | ||
118 | timediff_option = 1; | ||
119 | timefmt = "%s"; | ||
120 | break; | ||
109 | case 'h': | 121 | case 'h': |
110 | help(); | 122 | help(); |
111 | return 0; | 123 | return 0; |
diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..93f8f46 --- /dev/null +++ b/tests/.gitignore | |||
@@ -0,0 +1,6 @@ | |||
1 | atconfig | ||
2 | atlocal | ||
3 | package.m4 | ||
4 | testsuite | ||
5 | testsuite.dir | ||
6 | testsuite.log | ||
diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..7f24aeb --- /dev/null +++ b/tests/Makefile.am | |||
@@ -0,0 +1,71 @@ | |||
1 | # This file is part of vmod-binlog | ||
2 | # Copyright (C) 2013 Sergey Poznyakoff | ||
3 | # | ||
4 | # Vmod-binlog is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # Vmod-binlog is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with vmod-binlog. If not, see <http://www.gnu.org/licenses/>. | ||
16 | |||
17 | EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 | ||
18 | DISTCLEANFILES = atconfig $(check_SCRIPTS) | ||
19 | MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE) | ||
20 | |||
21 | |||
22 | ## ------------ ## | ||
23 | ## package.m4. ## | ||
24 | ## ------------ ## | ||
25 | |||
26 | $(srcdir)/package.m4: $(top_srcdir)/configure.ac | ||
27 | $(AM_V_GEN){ \ | ||
28 | echo '# Signature of the current package.'; \ | ||
29 | echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \ | ||
30 | echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \ | ||
31 | echo 'm4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])'; \ | ||
32 | echo 'm4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])'; \ | ||
33 | echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \ | ||
34 | } >$(srcdir)/package.m4 | ||
35 | |||
36 | # | ||
37 | |||
38 | ## ------------ ## | ||
39 | ## Test suite. ## | ||
40 | ## ------------ ## | ||
41 | |||
42 | TESTSUITE_AT = \ | ||
43 | test01.at\ | ||
44 | test02.at\ | ||
45 | testsuite.at | ||
46 | |||
47 | TESTSUITE = $(srcdir)/testsuite | ||
48 | M4=m4 | ||
49 | |||
50 | AUTOTEST = $(AUTOM4TE) --language=autotest | ||
51 | $(TESTSUITE): package.m4 $(TESTSUITE_AT) | ||
52 | $(AUTOTEST) -I $(srcdir) testsuite.at -o $@.tmp | ||
53 | mv $@.tmp $@ | ||
54 | |||
55 | atconfig: $(top_builddir)/config.status | ||
56 | cd $(top_builddir) && ./config.status tests/$@ | ||
57 | |||
58 | clean-local: | ||
59 | test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean | ||
60 | |||
61 | check-local: atconfig atlocal $(TESTSUITE) | ||
62 | $(SHELL) $(TESTSUITE) | ||
63 | |||
64 | # Run the test suite on the *installed* tree. | ||
65 | #installcheck-local: | ||
66 | # $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin | ||
67 | |||
68 | |||
69 | |||
70 | |||
71 | |||
diff --git a/tests/atlocal.in b/tests/atlocal.in new file mode 100644 index 0000000..24a523c --- /dev/null +++ b/tests/atlocal.in | |||
@@ -0,0 +1,8 @@ | |||
1 | # @configure_input@ -*- shell-script -*- | ||
2 | # Configurable variable values for vmod-binlog test suite. | ||
3 | # Copyright (C) 2013 Sergey Poznyakoff | ||
4 | |||
5 | PATH=@abs_builddir@:@abs_top_builddir@/src:@abs_top_srcdir@/build-aux:$top_srcdir:$srcdir:$PATH | ||
6 | VARNISHTEST="@VARNISHSRC@/bin/varnishtest/varnishtest -Dvarnishd=@VARNISHSRC@/bin/varnishd/varnishd" | ||
7 | |||
8 | |||
diff --git a/tests/test01.at b/tests/test01.at new file mode 100644 index 0000000..116c8f1 --- /dev/null +++ b/tests/test01.at | |||
@@ -0,0 +1,83 @@ | |||
1 | # This file is part of vmod-binlog testsuite -*- autotest -*- | ||
2 | # Copyright (C) 2013 Sergey Poznyakoff | ||
3 | # | ||
4 | # Vmod-binlog is free software; you can redistribute it and/or modify | ||
5 | # it under the terms of the GNU General Public License as published by | ||
6 | # the Free Software Foundation; either version 3, or (at your option) | ||
7 | # any later version. | ||
8 | # | ||
9 | # Vmod-binlog is distributed in the hope that it will be useful, | ||
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | # GNU General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||