summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-06-19 11:30:57 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-06-19 11:30:57 +0200
commit77c992e2155420702460e835ce2d561cf2d10fcb (patch)
treef8349fbffac3264b8233c55499f285d690637e57 /tests
parentdc603a3dbf0bc0654830e7830a07816c23c85ce5 (diff)
downloadrsyslog-77c992e2155420702460e835ce2d561cf2d10fcb.tar.gz
rsyslog-77c992e2155420702460e835ce2d561cf2d10fcb.tar.xz
rsyslog-77c992e2155420702460e835ce2d561cf2d10fcb.zip
fully optimized datetime module and enhanced test suite
tests for the various timestamp formats have been added
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am22
-rwxr-xr-xtests/diag.sh6
-rw-r--r--tests/nettester.c70
-rw-r--r--tests/testsuites/1.retry.conf2
-rw-r--r--tests/testsuites/Apr.ts31643
-rw-r--r--tests/testsuites/Aug.ts31643
-rw-r--r--tests/testsuites/Dec.ts31643
-rw-r--r--tests/testsuites/Feb.ts31643
-rw-r--r--tests/testsuites/Jan.ts31643
-rw-r--r--tests/testsuites/Jul.ts31643
-rw-r--r--tests/testsuites/Jun.ts31643
-rw-r--r--tests/testsuites/Mar.ts31643
-rw-r--r--tests/testsuites/May.ts31643
-rw-r--r--tests/testsuites/Nov.ts31643
-rw-r--r--tests/testsuites/Oct.ts31643
-rw-r--r--tests/testsuites/Sep.ts31643
-rw-r--r--tests/testsuites/master.subsecond8
-rw-r--r--tests/testsuites/master.ts333922
-rw-r--r--tests/testsuites/master.tsmysql2
-rw-r--r--tests/testsuites/master.tspgsql2
-rw-r--r--tests/testsuites/mon1digit.ts31643
-rw-r--r--tests/testsuites/mon2digit.ts31643
-rw-r--r--tests/testsuites/parse1udp.conf9
-rw-r--r--tests/testsuites/subsecond.conf8
-rw-r--r--tests/testsuites/ts3164.conf8
-rw-r--r--tests/testsuites/ts3339.conf8
-rw-r--r--tests/testsuites/tsmysql.conf8
-rw-r--r--tests/testsuites/tspgsql.conf8
-rwxr-xr-xtests/timestamp.sh13
29 files changed, 206 insertions, 32 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0800f667..955ad405 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -10,7 +10,11 @@ TESTS = $(TESTRUNS) cfg.sh \
queue-persist.sh
if ENABLE_OMSTDOUT
-TESTS += omod-if-array.sh parsertest.sh inputname.sh fieldtest.sh
+TESTS += omod-if-array.sh \
+ parsertest.sh \
+ timestamp.sh \
+ inputname.sh \
+ fieldtest.sh
endif
endif # if ENABLE_TESTBENCH
@@ -37,6 +41,22 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
DevNull.cfgtest \
err1.rstest \
NoExistFile.cfgtest \
+ timestamp.sh \
+ testsuites/ts3164.conf \
+ testsuites/mon1digit.ts3164 \
+ testsuites/mon2digit.ts3164 \
+ testsuites/Jan.ts3164 \
+ testsuites/Feb.ts3164 \
+ testsuites/Mar.ts3164 \
+ testsuites/Apr.ts3164 \
+ testsuites/May.ts3164 \
+ testsuites/Jun.ts3164 \
+ testsuites/Jul.ts3164 \
+ testsuites/Aug.ts3164 \
+ testsuites/Sep.ts3164 \
+ testsuites/Oct.ts3164 \
+ testsuites/Nov.ts3164 \
+ testsuites/Dec.ts3164 \
testsuites/parse1.conf \
testsuites/field1.conf \
testsuites/1.parse1 \
diff --git a/tests/diag.sh b/tests/diag.sh
index 1fa8f62a..2a9d0ee3 100755
--- a/tests/diag.sh
+++ b/tests/diag.sh
@@ -82,5 +82,11 @@ case $1 in
exit 1
fi
;;
+ 'nettester') # perform nettester-based tests
+ ./nettester -t$2 -i$3
+ if [ "$?" -ne "0" ]; then
+ exit 1
+ fi
+ ;;
*) echo "invalid argument" $1
esac
diff --git a/tests/nettester.c b/tests/nettester.c
index e5e6278c..b8816b7c 100644
--- a/tests/nettester.c
+++ b/tests/nettester.c
@@ -61,6 +61,9 @@ static int iPort = 12514; /* port which shall be used for sending data */
static char* pszCustomConf = NULL; /* custom config file, use -c conf to specify */
static int verbose = 0; /* verbose output? -v option */
+/* these two are quick hacks... */
+int iFailed = 0;
+int iTests = 0;
/* provide user-friednly name of input mode
*/
@@ -247,38 +250,47 @@ processTestFile(int fd, char *pszFileName)
/* skip comments at start of file */
- getline(&testdata, &lenLn, fp);
while(!feof(fp)) {
- if(*testdata == '#')
- getline(&testdata, &lenLn, fp);
- else
- break; /* first non-comment */
- }
+ getline(&testdata, &lenLn, fp);
+ while(!feof(fp)) {
+ if(*testdata == '#')
+ getline(&testdata, &lenLn, fp);
+ else
+ break; /* first non-comment */
+ }
+ /* this is not perfect, but works ;) */
+ if(feof(fp))
+ break;
- testdata[strlen(testdata)-1] = '\0'; /* remove \n */
- /* now we have the test data to send (we could use function pointers here...) */
- if(inputMode == inputUDP) {
- if(udpSend(testdata, strlen(testdata)) != 0)
- return(2);
- } else {
- if(tcpSend(testdata, strlen(testdata)) != 0)
- return(2);
- }
+ ++iTests; /* increment test count, we now do one! */
- /* next line is expected output
- * we do not care about EOF here, this will lead to a failure and thus
- * draw enough attention. -- rgerhards, 2009-03-31
- */
- getline(&expected, &lenLn, fp);
- expected[strlen(expected)-1] = '\0'; /* remove \n */
+ testdata[strlen(testdata)-1] = '\0'; /* remove \n */
+ /* now we have the test data to send (we could use function pointers here...) */
+ if(inputMode == inputUDP) {
+ if(udpSend(testdata, strlen(testdata)) != 0)
+ return(2);
+ } else {
+ if(tcpSend(testdata, strlen(testdata)) != 0)
+ return(2);
+ }
+
+ /* next line is expected output
+ * we do not care about EOF here, this will lead to a failure and thus
+ * draw enough attention. -- rgerhards, 2009-03-31
+ */
+ getline(&expected, &lenLn, fp);
+ expected[strlen(expected)-1] = '\0'; /* remove \n */
+
+ /* pull response from server and then check if it meets our expectation */
+ readLine(fd, buf);
+ if(strcmp(expected, buf)) {
+ ++iFailed;
+ printf("\nExpected Response:\n'%s'\nActual Response:\n'%s'\n",
+ expected, buf);
+ ret = 1;
+ }
- /* pull response from server and then check if it meets our expectation */
- readLine(fd, buf);
- if(strcmp(expected, buf)) {
- printf("\nExpected Response:\n'%s'\nActual Response:\n'%s'\n",
- expected, buf);
- ret = 1;
}
free(testdata);
@@ -297,8 +309,6 @@ processTestFile(int fd, char *pszFileName)
int
doTests(int fd, char *files)
{
- int iFailed = 0;
- int iTests = 0;
int ret;
char *testFile;
glob_t testFiles;
@@ -313,7 +323,6 @@ doTests(int fd, char *files)
if(stat((char*) testFile, &fileInfo) != 0)
continue; /* continue with the next file if we can't stat() the file */
- ++iTests;
/* all regular files are run through the test logic. Symlinks don't work. */
if(S_ISREG(fileInfo.st_mode)) { /* config file */
if(verbose) printf("processing test case '%s' ... ", testFile);
@@ -324,7 +333,6 @@ doTests(int fd, char *files)
if(!verbose)
printf("test '%s' ", testFile);
printf("failed!\n");
- ++iFailed;
}
}
}
diff --git a/tests/testsuites/1.retry.conf b/tests/testsuites/1.retry.conf
new file mode 100644
index 00000000..c464b19c
--- /dev/null
+++ b/tests/testsuites/1.retry.conf
@@ -0,0 +1,2 @@
+<167>Mar 6 16:57:54 172.20.245.8 %PIX-7-710005: UDP request discarded from SERVER1/2741 to test_app:255.255.255.255/61601
+167,Mar 6 16:57:54,172.20.245.8,%PIX-7-710005,%PIX-7-710005:,
diff --git a/tests/testsuites/Apr.ts3164 b/tests/testsuites/Apr.ts3164
new file mode 100644
index 00000000..3134f224
--- /dev/null
+++ b/tests/testsuites/Apr.ts3164
@@ -0,0 +1,3 @@
+<167>Apr 6 16:57:54 172.20.245.8 TAG: MSG
+Apr 6 16:57:54
+#Only the first two lines are important, you may place anything behind them!
diff --git a/tests/testsuites/Aug.ts3164 b/tests/testsuites/Aug.ts3164
new file mode 100644
index 00000000..d9a721eb
--- /dev/null
+++ b/tests/testsuites/Aug.ts3164
@@ -0,0 +1,3 @@
+<167>Aug 6 16:57:54 172.20.245.8 TAG: MSG
+Aug 6 16:57:54
+#Only the first two lines are important, you may place anything behind them!
diff --git a/tests/testsuites/Dec.ts3164 b/tests/testsuites/Dec.ts3164
new file mode 100644
index 00000000..080ba401
--- /dev/null
+++ b/tests/testsuites/Dec.ts3164
@@ -0,0 +1,3 @@
+<167>Dec 6 16:57:54 172.20.245.8 TAG: MSG
+Dec 6 16:57:54
+#Only the first two lines are important, you may place anything behind them!
diff --git a/tests/testsuites/Feb.ts3164 b/tests/testsuites/Feb.ts3164
new file mode 100644
index 00000000..d1eaaa33
--- /dev/null
+++ b/tests/testsuites/Feb.ts3164
@@ -0,0 +1,3 @@
+<167>Feb 6 16:57:54 172.20.245.8 TAG: MSG
+Feb 6 16:57:54
+#Only the first two lines are important, you may place anything behind them!
diff --git a/tests/testsuites/Jan.ts3164 b/tests/testsuites/Jan.ts3164
new file mode 100644
index 00000000..0cb1c8e2
--- /dev/null
+++ b/tests/testsuites/Jan.ts3164
@@ -0,0 +1,3 @@
+<167>Jan 6 16:57:54 172.20.245.8 TAG: MSG
+Jan 6 16:57:54
+#Only the first two lines are important, you may place anything behind them!
diff --git a/tests/testsuites/Jul.ts3164 b/tests/testsuites/Jul.ts3164
new file mode 100644
index 00000000..562e1ec4
--- /dev/null
+++ b/tests/testsuites/Jul.ts3164
@@ -0,0 +1,3 @@
+<167>Jul 6 16:57:54 172.20.245.8 TAG: MSG
+Jul 6 16:57:54
+#Only the first two lines are important, you may place anything behind them!
diff --git a/tests/testsuites/Jun.ts3164 b/tests/testsuites/Jun.ts3164
new file mode 100644
index 00000000..ede27e0e
--- /dev/null
+++ b/tests/testsuites/Jun.ts3164
@@ -0,0 +1,3 @@
+<167>Jun 6 16:57:54 172.20.245.8 TAG: MSG
+Jun 6 16:57:54
+#Only the first two lines are important, you may place anything behind them!
diff --git a/tests/testsuites/Mar.ts3164 b/tests/testsuites/Mar.ts3164
new file mode 100644
index 00000000..55dd5bc2
--- /dev/null
+++ b/tests/testsuites/Mar.ts3164
@@ -0,0 +1,3 @@
+<167>Mar 6 16:57:54 172.20.245.8 TAG: MSG
+Mar 6 16:57:54
+#Only the first two lines are important, you may place anything behind them!
diff --git a/tests/testsuites/May.ts3164 b/tests/testsuites/May.ts3164
new file mode 100644
index 00000000..72a5a301
--- /dev/null
+++ b/tests/testsuites/May.ts3164
@@ -0,0 +1,3 @@
+<167>May 6 16:57:54 172.20.245.8 TAG: MSG
+May 6 16:57:54
+#Only the first two lines are important, you may place anything behind them!
diff --git a/tests/testsuites/Nov.ts3164 b/tests/testsuites/Nov.ts3164
new file mode 100644
index 00000000..e8f00e01
--- /dev/null
+++ b/tests/testsuites/Nov.ts3164
@@ -0,0 +1,3 @@
+<167>Nov 6 16:57:54 172.20.245.8 TAG: MSG
+Nov 6 16:57:54
+#Only the first two lines are important, you may place anything behind them!
diff --git a/tests/testsuites/Oct.ts3164 b/tests/testsuites/Oct.ts3164
new file mode 100644
index 00000000..01423fef
--- /dev/null
+++ b/tests/testsuites/Oct.ts3164
@@ -0,0 +1,3 @@
+<167>Oct 6 16:57:54 172.20.245.8 TAG: MSG
+Oct 6 16:57:54
+#Only the first two lines are important, you may place anything behind them!
diff --git a/tests/testsuites/Sep.ts3164 b/tests/testsuites/Sep.ts3164
new file mode 100644
index 00000000..6c9e48e0
--- /dev/null
+++ b/tests/testsuites/Sep.ts3164
@@ -0,0 +1,3 @@
+<167>Sep 6 16:57:54 172.20.245.8 TAG: MSG
+Sep 6 16:57:54
+#Only the first two lines are important, you may place anything behind them!
diff --git a/tests/testsuites/master.subsecond b/tests/testsuites/master.subsecond
new file mode 100644
index 00000000..ee924877
--- /dev/null
+++ b/tests/testsuites/master.subsecond
@@ -0,0 +1,8 @@
+<34>1 2003-01-23T12:34:56.003Z mymachine.example.com su - ID47 - MSG
+003
+# full precision
+<34>1 2003-01-23T12:34:56.123456Z mymachine.example.com su - ID47 - MSG
+123456
+# without
+<34>1 2003-01-23T12:34:56Z mymachine.example.com su - ID47 - MSG
+0
diff --git a/tests/testsuites/master.ts3339 b/tests/testsuites/master.ts3339
new file mode 100644
index 00000000..b4dd5f39
--- /dev/null
+++ b/tests/testsuites/master.ts3339
@@ -0,0 +1,22 @@
+<34>1 2003-11-11T22:14:15.003Z mymachine.example.com su - ID47 - MSG
+2003-11-11T22:14:15.003Z
+# next test
+<34>1 2003-01-11T22:14:15.003Z mymachine.example.com su - ID47 - MSG
+2003-01-11T22:14:15.003Z
+# next test
+<34>1 2003-11-01T22:04:15.003Z mymachine.example.com su - ID47 - MSG
+2003-11-01T22:04:15.003Z
+# next test
+<34>1 2003-11-11T02:14:15.003Z mymachine.example.com su - ID47 - MSG
+2003-11-11T02:14:15.003Z
+# next test
+<34>1 2003-11-11T22:04:05.003Z mymachine.example.com su - ID47 - MSG
+2003-11-11T22:04:05.003Z
+# next test
+<34>1 2003-11-11T22:04:05.003+02:00 mymachine.example.com su - ID47 - MSG
+2003-11-11T22:04:05.003+02:00
+# next test
+<34>1 2003-11-11T22:04:05.003+01:30 mymachine.example.com su - ID47 - MSG
+2003-11-11T22:04:05.003+01:30
+<34>1 2003-11-11T22:04:05.123456+01:30 mymachine.example.com su - ID47 - MSG
+2003-11-11T22:04:05.123456+01:30
diff --git a/tests/testsuites/master.tsmysql b/tests/testsuites/master.tsmysql
new file mode 100644
index 00000000..dc6d85be
--- /dev/null
+++ b/tests/testsuites/master.tsmysql
@@ -0,0 +1,2 @@
+<34>1 2003-01-23T12:34:56.003Z mymachine.example.com su - ID47 - MSG
+20030123123456
diff --git a/tests/testsuites/master.tspgsql b/tests/testsuites/master.tspgsql
new file mode 100644
index 00000000..d7ac19ff
--- /dev/null
+++ b/tests/testsuites/master.tspgsql
@@ -0,0 +1,2 @@
+<34>1 2003-01-23T12:34:56.003Z mymachine.example.com su - ID47 - MSG
+2003-01-23 12:34:56
diff --git a/tests/testsuites/mon1digit.ts3164 b/tests/testsuites/mon1digit.ts3164
new file mode 100644
index 00000000..0cb1c8e2
--- /dev/null
+++ b/tests/testsuites/mon1digit.ts3164
@@ -0,0 +1,3 @@
+<167>Jan 6 16:57:54 172.20.245.8 TAG: MSG
+Jan 6 16:57:54
+#Only the first two lines are important, you may place anything behind them!
diff --git a/tests/testsuites/mon2digit.ts3164 b/tests/testsuites/mon2digit.ts3164
new file mode 100644
index 00000000..9606961c
--- /dev/null
+++ b/tests/testsuites/mon2digit.ts3164
@@ -0,0 +1,3 @@
+<167>Jan 16 16:57:54 172.20.245.8 TAG: MSG
+Jan 16 16:57:54
+#Only the first two lines are important, you may place anything behind them!
diff --git a/tests/testsuites/parse1udp.conf b/tests/testsuites/parse1udp.conf
new file mode 100644
index 00000000..0fb7d16d
--- /dev/null
+++ b/tests/testsuites/parse1udp.conf
@@ -0,0 +1,9 @@
+$ModLoad ../plugins/omstdout/.libs/omstdout
+$ModLoad ../plugins/imudp/.libs/imudp
+$UDPServerRun 12514
+
+$ErrorMessagesToStderr off
+
+# use a special format that we can easily parse in expect
+$template expect,"%PRI%,%syslogfacility-text%,%syslogseverity-text%,%timestamp%,%hostname%,%programname%,%syslogtag%,%msg%\n"
+*.* :omstdout:;expect
diff --git a/tests/testsuites/subsecond.conf b/tests/testsuites/subsecond.conf
new file mode 100644
index 00000000..58c26cc7
--- /dev/null
+++ b/tests/testsuites/subsecond.conf
@@ -0,0 +1,8 @@
+$ModLoad ../plugins/omstdout/.libs/omstdout
+$IncludeConfig nettest.input.conf # This picks the to be tested input from the test driver!
+
+$ErrorMessagesToStderr off
+
+# use a special format
+$template fmt,"%timestamp:::date-subseconds%\n"
+*.* :omstdout:;fmt
diff --git a/tests/testsuites/ts3164.conf b/tests/testsuites/ts3164.conf
new file mode 100644
index 00000000..7aa6a8ef
--- /dev/null
+++ b/tests/testsuites/ts3164.conf
@@ -0,0 +1,8 @@
+$ModLoad ../plugins/omstdout/.libs/omstdout
+$IncludeConfig nettest.input.conf # This picks the to be tested input from the test driver!
+
+$ErrorMessagesToStderr off
+
+# use a special format
+$template fmt,"%timestamp:::date-rfc3164%\n"
+*.* :omstdout:;fmt
diff --git a/tests/testsuites/ts3339.conf b/tests/testsuites/ts3339.conf
new file mode 100644
index 00000000..df8f23ac
--- /dev/null
+++ b/tests/testsuites/ts3339.conf
@@ -0,0 +1,8 @@
+$ModLoad ../plugins/omstdout/.libs/omstdout
+$IncludeConfig nettest.input.conf # This picks the to be tested input from the test driver!
+
+$ErrorMessagesToStderr off
+
+# use a special format
+$template fmt,"%timestamp:::date-rfc3339%\n"
+*.* :omstdout:;fmt
diff --git a/tests/testsuites/tsmysql.conf b/tests/testsuites/tsmysql.conf
new file mode 100644
index 00000000..f97d4b0a
--- /dev/null
+++ b/tests/testsuites/tsmysql.conf
@@ -0,0 +1,8 @@
+$ModLoad ../plugins/omstdout/.libs/omstdout
+$IncludeConfig nettest.input.conf # This picks the to be tested input from the test driver!
+
+$ErrorMessagesToStderr off
+
+# use a special format
+$template fmt,"%timestamp:::date-mysql%\n"
+*.* :omstdout:;fmt
diff --git a/tests/testsuites/tspgsql.conf b/tests/testsuites/tspgsql.conf
new file mode 100644
index 00000000..eb18c091
--- /dev/null
+++ b/tests/testsuites/tspgsql.conf
@@ -0,0 +1,8 @@
+$ModLoad ../plugins/omstdout/.libs/omstdout
+$IncludeConfig nettest.input.conf # This picks the to be tested input from the test driver!
+
+$ErrorMessagesToStderr off
+
+# use a special format
+$template fmt,"%timestamp:::date-pgsql%\n"
+*.* :omstdout:;fmt
diff --git a/tests/timestamp.sh b/tests/timestamp.sh
new file mode 100755
index 00000000..7699a4af
--- /dev/null
+++ b/tests/timestamp.sh
@@ -0,0 +1,13 @@
+echo various timestamp tests
+source $srcdir/diag.sh init
+source $srcdir/diag.sh nettester ts3164 udp
+source $srcdir/diag.sh nettester ts3164 tcp
+source $srcdir/diag.sh nettester ts3339 udp
+source $srcdir/diag.sh nettester ts3339 tcp
+source $srcdir/diag.sh nettester tsmysql udp
+source $srcdir/diag.sh nettester tsmysql tcp
+source $srcdir/diag.sh nettester tspgsql udp
+source $srcdir/diag.sh nettester tspgsql tcp
+source $srcdir/diag.sh nettester subsecond udp
+source $srcdir/diag.sh nettester subsecond tcp
+source $srcdir/diag.sh init