summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am20
-rwxr-xr-xtests/complex1.sh5
-rwxr-xr-xtests/diag.sh22
-rw-r--r--tests/diagtalker.c157
-rw-r--r--tests/historical/DiagTalker.java (renamed from tests/DiagTalker.java)1
-rw-r--r--tests/historical/README2
-rw-r--r--tests/msleep.c51
-rw-r--r--tests/nettester.c83
-rwxr-xr-xtests/rsf_getenv.sh17
-rw-r--r--tests/rt-init.c2
-rw-r--r--tests/tcpflood.c15
-rw-r--r--tests/testsuites/rsf_getenv.conf17
-rw-r--r--tests/testsuites/uxsock_simple.conf10
-rwxr-xr-xtests/threadingmqaq.sh3
-rwxr-xr-xtests/uxsock_simple.sh31
-rw-r--r--tests/uxsockrcvr.c157
16 files changed, 547 insertions, 46 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8b75a9f2..5914f94b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,12 +1,13 @@
if ENABLE_TESTBENCH
TESTRUNS = rt_init rscript
-check_PROGRAMS = $(TESTRUNS) ourtail nettester tcpflood chkseq randomgen
+check_PROGRAMS = $(TESTRUNS) ourtail nettester tcpflood chkseq msleep randomgen diagtalker uxsockrcvr
TESTS = $(TESTRUNS) cfg.sh \
validation-run.sh \
imtcp-multiport.sh \
diskqueue.sh \
diskqueue-fsync.sh \
manytcp.sh \
+ rsf_getenv.sh \
manyptcp.sh \
imptcp_large.sh \
imptcp_addtlframedelim.sh \
@@ -31,7 +32,8 @@ TESTS = $(TESTRUNS) cfg.sh \
dynfile_invalid2.sh \
complex1.sh \
queue-persist.sh \
- pipeaction.sh
+ pipeaction.sh \
+ uxsock_simple.sh \
execonlyonce.sh \
queue-persist.sh
@@ -50,12 +52,10 @@ if ENABLE_EXTENDED_TESTS
TESTS += random.sh
endif
-check_JAVA = DiagTalker.java
-
endif # if ENABLE_TESTBENCH
TESTS_ENVIRONMENT = RSYSLOG_MODDIR='$(abs_top_builddir)'/runtime/.libs/
-DISTCLEANFILES=rsyslog.pid '$(abs_top_builddir)'/DiagTalker.class
+DISTCLEANFILES=rsyslog.pid
test_files = testbench.h runtime-dummy.c
EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
@@ -134,6 +134,8 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
killrsyslog.sh \
parsertest.sh \
fieldtest.sh \
+ rsf_getenv.sh \
+ testsuites/rsf_getenv.conf \
diskqueue.sh \
testsuites/diskqueue.conf \
diskqueue-fsync.sh \
@@ -179,6 +181,8 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
testsuites/sndrcv_gzip_rcvr.conf \
pipeaction.sh \
testsuites/pipeaction.conf \
+ uxsock_simple.sh \
+ testsuites/uxsock_simple.conf \
asynwr_simple.sh \
testsuites/asynwr_simple.conf \
asynwr_timeout.sh \
@@ -219,15 +223,19 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
execonlyonce.sh \
testsuites/execonlyonce.conf \
testsuites/execonlyonce.data \
- DiagTalker.java \
cfg.sh
+uxsockrcvr_SOURCES = uxsockrcvr.c
ourtail_SOURCES = ourtail.c
+msleep_SOURCES = msleep.c
chkseq_SOURCES = chkseq.c
tcpflood_SOURCES = tcpflood.c
tcpflood_LDADD = $(SOL_LIBS)
+diagtalker_SOURCES = diagtalker.c
+diagtalker_LDADD = $(SOL_LIBS)
+
randomgen_SOURCES = randomgen.c
randomgen_LDADD = $(SOL_LIBS)
diff --git a/tests/complex1.sh b/tests/complex1.sh
index 954ddf6c..e138bff5 100755
--- a/tests/complex1.sh
+++ b/tests/complex1.sh
@@ -10,12 +10,13 @@ source $srcdir/diag.sh init
#export RSYSLOG_DEBUG="debug nostdout"
#export RSYSLOG_DEBUGLOG="log"
source $srcdir/diag.sh startup complex1.conf
-# send 30,000 messages of 400 bytes plus header max, via three dest ports
+# send 40,000 messages of 400 bytes plus header max, via three dest ports
source $srcdir/diag.sh tcpflood -m40000 -rd400 -P129 -f5 -n3 -c15 -i1
sleep 4 # due to large messages, we need this time for the tcp receiver to settle...
source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
source $srcdir/diag.sh wait-shutdown # and wait for it to terminate
ls rsyslog.out.*.log
-zcat rsyslog.out.*.log > rsyslog.out.log
+source $srcdir/diag.sh setzcat # find out which zcat to use
+$ZCAT rsyslog.out.*.log > rsyslog.out.log
source $srcdir/diag.sh seq-check 1 40000 -E
source $srcdir/diag.sh exit
diff --git a/tests/diag.sh b/tests/diag.sh
index 8659aa17..1caf529f 100755
--- a/tests/diag.sh
+++ b/tests/diag.sh
@@ -37,25 +37,26 @@ case $1 in
$srcdir/diag.sh wait-startup $3
;;
'wait-startup') # wait for rsyslogd startup ($2 is the instance)
+ while test ! -f rsyslog$2.pid; do
+ ./msleep 100 # wait 100 milliseconds
+ done
while test ! -f rsyslogd$2.started; do
- #true
- sleep 0.1 # if this is not supported by all platforms, use above!
+ ./msleep 100 # wait 100 milliseconds
done
echo "rsyslogd$2 started with pid " `cat rsyslog$2.pid`
;;
'wait-shutdown') # actually, we wait for rsyslog.pid to be deleted. $2 is the
# instance
while test -f rsyslog$2.pid; do
- #true
- sleep 0.1 # if this is not supported by all platforms, use above!
+ ./msleep 100 # wait 100 milliseconds
done
;;
'wait-queueempty') # wait for main message queue to be empty. $2 is the instance.
if [ "$2" == "2" ]
then
- echo WaitMainQueueEmpty | java -classpath $abs_top_builddir DiagTalker
+ echo WaitMainQueueEmpty | ./diagtalker
else
- echo WaitMainQueueEmpty | java -classpath $abs_top_builddir DiagTalker 13501
+ echo WaitMainQueueEmpty | ./diagtalker
fi
;;
'shutdown-when-empty') # shut rsyslogd down when main queue is empty. $2 is the instance.
@@ -77,7 +78,7 @@ case $1 in
;;
'injectmsg') # inject messages via our inject interface (imdiag)
echo injecting $3 messages
- echo injectmsg $2 $3 $4 $5 | java -classpath $abs_top_builddir DiagTalker
+ echo injectmsg $2 $3 $4 $5 | ./diagtalker
# TODO: some return state checking? (does it really make sense here?)
;;
'check-mainq-spool') # check if mainqueue spool files exist, if not abort (we just check .qi).
@@ -131,5 +132,12 @@ case $1 in
exit 1
fi
;;
+ 'setzcat') # find out name of zcat tool
+ if [ `uname` == SunOS ]; then
+ ZCAT=gzcat
+ else
+ ZCAT=zcat
+ fi
+ ;;
*) echo "invalid argument" $1
esac
diff --git a/tests/diagtalker.c b/tests/diagtalker.c
new file mode 100644
index 00000000..6a721e47
--- /dev/null
+++ b/tests/diagtalker.c
@@ -0,0 +1,157 @@
+/* A yet very simple tool to talk to imdiag (this replaces the
+ * previous Java implementation in order to get fewer dependencies).
+ *
+ * Copyright 2010 Rainer Gerhards and Adiscon GmbH.
+ *
+ * This file is part of rsyslog.
+ *
+ * Rsyslog is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Rsyslog is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this distribution.
+ */
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+
+static char *targetIP = "127.0.0.1";
+static int targetPort = 13500;
+
+
+/* open a single tcp connection
+ */
+int openConn(int *fd)
+{
+ int sock;
+ struct sockaddr_in addr;
+ int port;
+ int retries = 0;
+
+ if((sock=socket(AF_INET, SOCK_STREAM, 0))==-1) {
+ perror("socket()");
+ exit(1);
+ }
+
+ port = targetPort;
+ memset((char *) &addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons(port);
+ if(inet_aton(targetIP, &addr.sin_addr)==0) {
+ fprintf(stderr, "inet_aton() failed\n");
+ exit(1);
+ }
+ while(1) { /* loop broken inside */
+ if(connect(sock, (struct sockaddr*)&addr, sizeof(addr)) == 0) {
+ break;
+ } else {
+ if(retries++ == 50) {
+ perror("connect()");
+ fprintf(stderr, "connect() failed\n");
+ exit(1);
+ } else {
+ fprintf(stderr, "connect failed, retrying...\n");
+ usleep(100000); /* ms = 1000 us! */
+ }
+ }
+ }
+
+ *fd = sock;
+ return 0;
+}
+
+
+/* send a string
+ */
+static void
+sendCmd(int fd, char *buf, int len)
+{
+ int lenSend;
+
+ lenSend = send(fd, buf, len, 0);
+ if(lenSend != len) {
+ perror("sending string");
+ exit(1);
+ }
+}
+
+
+/* wait for a response from remote system
+ */
+static void
+waitRsp(int fd, char *buf, int len)
+{
+ int ret;
+
+ ret = recv(fd, buf, len - 1, 0);
+ if(ret < 0) {
+ perror("receiving response");
+ exit(1);
+ }
+ /* we assume the message was complete, it may be better to wait
+ * for a LF...
+ */
+ buf[ret] = '\0';
+}
+
+
+/* do the actual processing
+ */
+static void
+doProcessing()
+{
+ int fd;
+ int len;
+ char line[2048];
+
+ openConn(&fd);
+ while(!feof(stdin)) {
+ if(fgets(line, sizeof(line) - 1, stdin) == NULL)
+ break;
+ len = strlen(line);
+ sendCmd(fd, line, len);
+ waitRsp(fd, line, sizeof(line));
+ printf("imdiag: %s", line);
+ }
+}
+
+
+/* Run the test.
+ * rgerhards, 2009-04-03
+ */
+int main(int argc, char *argv[])
+{
+ int ret = 0;
+ int opt;
+
+ while((opt = getopt(argc, argv, "f:t:p:c:C:m:i:I:P:d:n:M:rB")) != -1) {
+ switch (opt) {
+ case 't': targetIP = optarg;
+ break;
+ case 'p': targetPort = atoi(optarg);
+ break;
+ default: printf("invalid option '%c' or value missing - terminating...\n", opt);
+ exit (1);
+ break;
+ }
+ }
+
+ doProcessing();
+
+ exit(ret);
+}
diff --git a/tests/DiagTalker.java b/tests/historical/DiagTalker.java
index 5a6f7dd5..147cec34 100644
--- a/tests/DiagTalker.java
+++ b/tests/historical/DiagTalker.java
@@ -1,3 +1,4 @@
+This tool has been replaced by ./tests/diagtalker.c in release 4.7.1
/* A yet very simple tool to talk to imdiag.
*
* Copyright 2009 Rainer Gerhards and Adiscon GmbH.
diff --git a/tests/historical/README b/tests/historical/README
new file mode 100644
index 00000000..5f10ecef
--- /dev/null
+++ b/tests/historical/README
@@ -0,0 +1,2 @@
+This directory contains tools that are currently not being used, but are
+kept because they may be used again in the future.
diff --git a/tests/msleep.c b/tests/msleep.c
new file mode 100644
index 00000000..36fa01b5
--- /dev/null
+++ b/tests/msleep.c
@@ -0,0 +1,51 @@
+/* sleeps for the specified number of MILLIseconds.
+ * Primarily meant as a portable tool available everywhere for the
+ * testbench (sleep 0.1 does not work on all platforms).
+ *
+ * Part of the testbench for rsyslog.
+ *
+ * Copyright 2010 Rainer Gerhards and Adiscon GmbH.
+ *
+ * This file is part of rsyslog.
+ *
+ * Rsyslog is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Rsyslog is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this distribution.
+ */
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+int main(int argc, char *argv[])
+{
+ struct timeval tvSelectTimeout;
+ long sleepTime;
+
+ if(argc != 2) {
+ fprintf(stderr, "usage: msleep <milliseconds>\n");
+ exit(1);
+ }
+
+ sleepTime = atoi(argv[1]);
+ tvSelectTimeout.tv_sec = sleepTime / 1000;
+ tvSelectTimeout.tv_usec = (sleepTime % 1000) * 1000; /* micro seconds */
+ if(select(0, NULL, NULL, NULL, &tvSelectTimeout) == -1) {
+ perror("select");
+ exit(1);
+ }
+
+ return 0;
+}
+
diff --git a/tests/nettester.c b/tests/nettester.c
index e1ecbcb5..24e20422 100644
--- a/tests/nettester.c
+++ b/tests/nettester.c
@@ -62,7 +62,7 @@ static char *testSuite = NULL; /* name of current test suite */
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 */
-static int useDebugEnv = 0; /* activate debugging environment (for rsyslog debug log)? */
+static char **ourEnvp;
/* these two are quick hacks... */
int iFailed = 0;
@@ -117,6 +117,10 @@ void readLine(int fd, char *ln)
* We use traditional framing '\n' at EOR for this tester. It may be
* worth considering additional framing modes.
* rgerhards, 2009-04-08
+ * Note: we re-create the socket within the retry loop, because this
+ * seems to be needed under Solaris. If we do not do that, we run
+ * into troubles (maybe something wrongly initialized then?)
+ * -- rgerhards, 2010-04-12
*/
int
tcpSend(char *buf, int lenBuf)
@@ -124,30 +128,34 @@ tcpSend(char *buf, int lenBuf)
static int sock = INVALID_SOCKET;
struct sockaddr_in addr;
int retries;
+ int ret;
+ int iRet = 0; /* 0 OK, anything else error */
if(sock == INVALID_SOCKET) {
/* first time, need to connect to target */
- if((sock=socket(AF_INET, SOCK_STREAM, 0))==-1) {
- perror("socket()");
- return(1);
- }
-
- memset((char *) &addr, 0, sizeof(addr));
- addr.sin_family = AF_INET;
- addr.sin_port = htons(iPort);
- if(inet_aton("127.0.0.1", &addr.sin_addr)==0) {
- fprintf(stderr, "inet_aton() failed\n");
- return(1);
- }
retries = 0;
while(1) { /* loop broken inside */
- if(connect(sock, (struct sockaddr*)&addr, sizeof(addr)) == 0) {
+ /* first time, need to connect to target */
+ if((sock=socket(AF_INET, SOCK_STREAM, 0))==-1) {
+ perror("socket()");
+ iRet = 1;
+ goto finalize_it;
+ }
+ memset((char *) &addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons(iPort);
+ if(inet_aton("127.0.0.1", &addr.sin_addr)==0) {
+ fprintf(stderr, "inet_aton() failed\n");
+ iRet = 1;
+ goto finalize_it;
+ }
+ if((ret = connect(sock, (struct sockaddr*)&addr, sizeof(addr))) == 0) {
break;
} else {
if(retries++ == 50) {
- ++iFailed;
fprintf(stderr, "connect() failed\n");
- return(1);
+ iRet = 1;
+ goto finalize_it;
} else {
usleep(100000); /* 0.1 sec, these are us! */
}
@@ -156,20 +164,32 @@ tcpSend(char *buf, int lenBuf)
}
/* send test data */
- if(send(sock, buf, lenBuf, 0) != lenBuf) {
+ if((ret = send(sock, buf, lenBuf, 0)) != lenBuf) {
perror("send test data");
- fprintf(stderr, "send() failed\n");
- return(1);
+ fprintf(stderr, "send() failed, sock=%d, ret=%d\n", sock, ret);
+ iRet = 1;
+ goto finalize_it;
}
/* send record terminator */
if(send(sock, "\n", 1, 0) != 1) {
perror("send record terminator");
fprintf(stderr, "send() failed\n");
- return(1);
+ iRet = 1;
+ goto finalize_it;
}
- return 0;
+finalize_it:
+ if(iRet != 0) {
+ /* need to do some (common) cleanup */
+ if(sock != INVALID_SOCKET) {
+ close(sock);
+ sock = INVALID_SOCKET;
+ }
+ ++iFailed;
+ }
+
+ return iRet;
}
@@ -218,9 +238,6 @@ int openPipe(char *configFile, pid_t *pid, int *pfd)
char *newargv[] = {"../tools/rsyslogd", "dummy", "-c4", "-u2", "-n", "-irsyslog.pid",
"-M../runtime/.libs:../.libs", NULL };
char confFile[1024];
- char *newenviron[] = { NULL };
- char *newenvironDeb[] = { "RSYSLOG_DEBUG=debug nostdout",
- "RSYSLOG_DEBUGLOG=log", NULL };
sprintf(confFile, "-f%s/testsuites/%s.conf", srcdir,
(pszCustomConf == NULL) ? configFile : pszCustomConf);
@@ -243,8 +260,9 @@ int openPipe(char *configFile, pid_t *pid, int *pfd)
close(pipefd[1]);
close(pipefd[0]);
fclose(stdin);
- execve("../tools/rsyslogd", newargv, (useDebugEnv) ? newenvironDeb : newenviron);
+ execve("../tools/rsyslogd", newargv, ourEnvp);
} else {
+ usleep(10000);
close(pipefd[1]);
*pid = cpid;
*pfd = pipefd[0];
@@ -364,6 +382,7 @@ processTestFile(int fd, char *pszFileName)
expected[strlen(expected)-1] = '\0'; /* remove \n */
/* pull response from server and then check if it meets our expectation */
+//printf("try pull pipe...\n");
readLine(fd, buf);
if(strcmp(expected, buf)) {
++iFailed;
@@ -426,7 +445,8 @@ doTests(int fd, char *files)
printf("Error: no test cases found, no tests executed.\n");
iFailed = 1;
} else {
- printf("Number of tests run: %d, number of failures: %d\n", iTests, iFailed);
+ printf("Number of tests run: %3d, number of failures: %d, test: %s/%s\n",
+ iTests, iFailed, testSuite, inputMode2Str(inputMode));
}
return(iFailed);
@@ -450,7 +470,7 @@ void doAtExit(void)
* of this file.
* rgerhards, 2009-04-03
*/
-int main(int argc, char *argv[])
+int main(int argc, char *argv[], char *envp[])
{
int fd;
int opt;
@@ -459,14 +479,12 @@ int main(int argc, char *argv[])
char buf[4096];
char testcases[4096];
+ ourEnvp = envp;
while((opt = getopt(argc, argv, "dc:i:p:t:v")) != EOF) {
switch((char)opt) {
case 'c':
pszCustomConf = optarg;
break;
- case 'd':
- useDebugEnv = 1;
- break;
case 'i':
if(!strcmp(optarg, "udp"))
inputMode = inputUDP;
@@ -520,6 +538,11 @@ int main(int argc, char *argv[])
}
fclose(fp);
+ /* make sure we do not abort if there is an issue with pipes.
+ * our code does the necessary error handling.
+ */
+ sigset(SIGPIPE, SIG_IGN);
+
/* start to be tested rsyslogd */
openPipe(testSuite, &rsyslogdPid, &fd);
readLine(fd, buf);
diff --git a/tests/rsf_getenv.sh b/tests/rsf_getenv.sh
new file mode 100755
index 00000000..fd083bce
--- /dev/null
+++ b/tests/rsf_getenv.sh
@@ -0,0 +1,17 @@
+# Test for the getenv() rainerscript function
+# this is a quick test, but it gurantees that the code path is
+# at least progressed (but we do not check for unset envvars!)
+# added 2009-11-03 by Rgerhards
+# This file is part of the rsyslog project, released under GPLv3
+# uncomment for debugging support:
+echo ===============================================================================
+echo \[rsf_getenv.sh\]: testing RainerScript getenv\(\) function
+export MSGNUM="msgnum:"
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup rsf_getenv.conf
+source $srcdir/diag.sh tcpflood -m10000
+source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
+source $srcdir/diag.sh wait-shutdown
+source $srcdir/diag.sh seq-check 0 9999
+unset MSGNUM
+source $srcdir/diag.sh exit
diff --git a/tests/rt-init.c b/tests/rt-init.c
index 66a9ad32..dbe94b4a 100644
--- a/tests/rt-init.c
+++ b/tests/rt-init.c
@@ -39,6 +39,6 @@ ENDExit
BEGINTest
CODESTARTTest
-finalize_it:
+/*finalize_it:*/
/* room for custom error reporter, leave blank if not needed */
ENDTest
diff --git a/tests/tcpflood.c b/tests/tcpflood.c
index f3aa4e7f..3020f389 100644
--- a/tests/tcpflood.c
+++ b/tests/tcpflood.c
@@ -65,6 +65,7 @@
#include <unistd.h>
#include <string.h>
#include <netinet/in.h>
+#include <sys/resource.h>
#define EXIT_FAILURE 1
#define INVALID_SOCKET -1
@@ -419,6 +420,20 @@ int main(int argc, char *argv[])
}
}
+ if(numConnections > 20) {
+ /* if we use many (whatever this means, 20 is randomly picked)
+ * connections, we need to make sure we have a high enough
+ * limit. -- rgerhards, 2010-03-25
+ */
+ struct rlimit maxFiles;
+ maxFiles.rlim_cur = numConnections + 20;
+ maxFiles.rlim_max = numConnections + 20;
+ if(setrlimit(RLIMIT_NOFILE, &maxFiles) < 0) {
+ perror("setrlimit to increase file handles failed");
+ exit(1);
+ }
+ }
+
if(dataFile != NULL) {
if((dataFP = fopen(dataFile, "r")) == NULL) {
perror(dataFile);
diff --git a/tests/testsuites/rsf_getenv.conf b/tests/testsuites/rsf_getenv.conf
new file mode 100644
index 00000000..2f2eb58c
--- /dev/null
+++ b/tests/testsuites/rsf_getenv.conf
@@ -0,0 +1,17 @@
+# Test for RainerScript getenv() function (see .sh file for details)
+# Note envvar MSGNUM must be set to "msgnum:"
+# rgerhards, 2009-11-03
+$IncludeConfig diag-common.conf
+
+$ModLoad ../plugins/imtcp/.libs/imtcp
+$MainMsgQueueTimeoutShutdown 10000
+$InputTCPServerRun 13514
+
+# set spool locations and switch queue to disk-only mode
+$WorkDirectory test-spool
+$MainMsgQueueFilename mainq
+$MainMsgQueueType disk
+
+$template outfmt,"%msg:F,58:2%\n"
+$template dynfile,"rsyslog.out.log" # trick to use relative path names!
+if $msg contains getenv('MSGNUM') then ?dynfile;outfmt
diff --git a/tests/testsuites/uxsock_simple.conf b/tests/testsuites/uxsock_simple.conf
new file mode 100644
index 00000000..efffdd90
--- /dev/null
+++ b/tests/testsuites/uxsock_simple.conf
@@ -0,0 +1,10 @@
+# Test for pipe output action (see .sh file for details)
+# rgerhards, 2009-11-05
+$IncludeConfig diag-common.conf
+
+$MainMsgQueueTimeoutShutdown 10000
+
+$ModLoad ../plugins/omuxsock/.libs/omuxsock
+$template outfmt,"%msg:F,58:2%\n"
+$OMUXSockSocket rsyslog-testbench-dgram-uxsock
+:msg, contains, "msgnum:" :omuxsock:;outfmt
diff --git a/tests/threadingmqaq.sh b/tests/threadingmqaq.sh
index b7764821..0104be00 100755
--- a/tests/threadingmqaq.sh
+++ b/tests/threadingmqaq.sh
@@ -12,6 +12,9 @@ source $srcdir/diag.sh startup threadingmqaq.conf
#source $srcdir/diag.sh tcpflood -c2 -m100000
#source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
source $srcdir/diag.sh injectmsg 0 100000
+# we need to sleep a bit on some environments, as imdiag can not correctly
+# diagnose when the action queues are empty...
+sleep 3
source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
source $srcdir/diag.sh wait-shutdown
source $srcdir/diag.sh seq-check 0 99999
diff --git a/tests/uxsock_simple.sh b/tests/uxsock_simple.sh
new file mode 100755
index 00000000..7f00f4bc
--- /dev/null
+++ b/tests/uxsock_simple.sh
@@ -0,0 +1,31 @@
+# This tests basic omuxsock functionality. A socket receiver is started which sends
+# all data to an output file, then a rsyslog instance is started which generates
+# messages and sends them to the unix socket. Datagram sockets are being used.
+# added 2010-08-06 by Rgerhards
+echo ===============================================================================
+echo \[uxsock_simple.sh\]: simple tests for omuxsock functionality
+
+# create the pipe and start a background process that copies data from
+# it to the "regular" work file
+source $srcdir/diag.sh init
+./uxsockrcvr -srsyslog-testbench-dgram-uxsock -orsyslog.out.log &
+BGPROCESS=$!
+echo background uxsockrcvr process id is $BGPROCESS
+
+# now do the usual run
+source $srcdir/diag.sh startup uxsock_simple.conf
+# 10000 messages should be enough
+source $srcdir/diag.sh injectmsg 0 10000
+source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
+source $srcdir/diag.sh wait-shutdown
+
+# wait for the cp process to finish, do pipe-specific cleanup
+echo shutting down uxsockrcvr...
+# TODO: we should do this more reliable in the long run! (message counter? timeout?)
+kill $BGPROCESS
+wait $BGPROCESS
+echo background process has terminated, continue test...
+
+# and continue the usual checks
+source $srcdir/diag.sh seq-check 0 9999
+source $srcdir/diag.sh exit
diff --git a/tests/uxsockrcvr.c b/tests/uxsockrcvr.c
new file mode 100644
index 00000000..551f0ef3
--- /dev/null
+++ b/tests/uxsockrcvr.c
@@ -0,0 +1,157 @@
+/* receives messages from a specified unix sockets and writes
+ * output to specfied file.
+ *
+ * Command line options:
+ * -s name of socket (required)
+ * -o name of output file (stdout if not given)
+ * -l add newline after each message received (default: do not add anything)
+ *
+ * Part of the testbench for rsyslog.
+ *
+ * Copyright 2010 Rainer Gerhards and Adiscon GmbH.
+ *
+ * This file is part of rsyslog.
+ *
+ * Rsyslog is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Rsyslog is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this distribution.
+ */
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <signal.h>
+#include <getopt.h>
+#include <sys/un.h>
+#include <netdb.h>
+
+char *sockName = NULL;
+int sock;
+int addNL = 0;
+
+
+/* called to clean up on exit
+ */
+void
+cleanup(void)
+{
+ unlink(sockName);
+ close(sock);
+}
+
+
+void
+doTerm(int __attribute__((unused)) signum)
+{
+ exit(1);
+}
+
+
+void
+usage(void)
+{
+ fprintf(stderr, "usage: uxsockrcvr -s /socket/name -o /output/file -l\n"
+ "-l adds newline after each message received\n"
+ "-s MUST be specified\n"
+ "if -o ist not specified, stdout is used\n");
+ exit(1);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ int opt;
+ int rlen;
+ FILE *fp = stdout;
+ unsigned char data[128*1024];
+ struct sockaddr_un addr; /* address of server */
+ struct sockaddr from;
+ socklen_t fromlen;
+
+ if(argc < 2) {
+ fprintf(stderr, "error: too few arguments!\n");
+ usage();
+ }
+
+ while((opt = getopt(argc, argv, "s:o:l")) != EOF) {
+ switch((char)opt) {
+ case 'l':
+ addNL = 1;
+ break;
+ case 's':
+ sockName = optarg;
+ break;
+ case 'o':
+ if((fp = fopen(optarg, "w")) == NULL) {
+ perror(optarg);
+ exit(1);
+ }
+ break;
+ default:usage();
+ }
+ }
+
+ if(sockName == NULL) {
+ fprintf(stderr, "error: -s /socket/name must be specified!\n");
+ exit(1);
+ }
+
+ if(signal(SIGTERM, doTerm) == SIG_ERR) {
+ perror("signal(SIGTERM, ...)");
+ exit(1);
+ }
+ if(signal(SIGINT, doTerm) == SIG_ERR) {
+ perror("signal(SIGINT, ...)");
+ exit(1);
+ }
+
+ /* Create a UNIX datagram socket for server */
+ if ((sock = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0) {
+ perror("server: socket");
+ exit(1);
+ }
+
+ atexit(cleanup);
+
+ /* Set up address structure for server socket */
+ memset(&addr, 0, sizeof(addr));
+ addr.sun_family = AF_UNIX;
+ strcpy(addr.sun_path, sockName);
+
+ if (bind(sock, (struct sockaddr*) &addr, sizeof(addr)) < 0) {
+ close(sock);
+ perror("server: bind");
+ exit(1);
+ }
+
+ /* we now run in an endless loop. We do not check who sends us
+ * data. This should be no problem for our testbench use.
+ */
+ while(1) {
+ fromlen = sizeof(from);
+ rlen = recvfrom(sock, data, 2000, 0, &from, &fromlen);
+ if(rlen == -1) {
+ perror("uxsockrcvr : recv\n");
+ exit(1);
+ } else {
+ fwrite(data, 1, rlen, fp);
+ if(addNL)
+ fputc('\n', fp);
+ }
+ }
+
+ return 0;
+}