summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-04-19 15:13:33 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2010-04-19 15:13:33 +0200
commitada87cbaefecff9d32f3d008876f2eec59335ded (patch)
treec52339b2e2c2cbfc7a7152bf1cc65912b46932c2 /tests
parent11ab3c800043b036132b0fc96d20bcba637a72b6 (diff)
parent9039fad4019cb9a0f96eb296835476841b453dd3 (diff)
downloadrsyslog-ada87cbaefecff9d32f3d008876f2eec59335ded.tar.gz
rsyslog-ada87cbaefecff9d32f3d008876f2eec59335ded.tar.xz
rsyslog-ada87cbaefecff9d32f3d008876f2eec59335ded.zip
Merge branch 'v4-devel' into master
Conflicts: ChangeLog Makefile.am configure.ac doc/manual.html runtime/debug.c runtime/rsyslog.h tests/Makefile.am tests/diag.sh tests/nettester.c tools/syslogd.c
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am5
-rwxr-xr-xtests/diag.sh1
-rw-r--r--tests/msleep.c1
-rw-r--r--tests/nettester.c70
-rwxr-xr-xtests/random.sh2
5 files changed, 56 insertions, 23 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b4d8f5af..b161d1bc 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -32,7 +32,6 @@ TESTS = $(TESTRUNS) cfg.sh \
dynfile_invld_sync.sh \
dynfile_invalid2.sh \
complex1.sh \
- random.sh \
queue-persist.sh \
pipeaction.sh \
execonlyonce.sh \
@@ -65,6 +64,10 @@ TESTS += omruleset.sh \
omruleset-queue.sh
endif
+if ENABLE_EXTENDED_TESTS
+TESTS += random.sh
+endif
+
check_JAVA = DiagTalker.java
endif # if ENABLE_TESTBENCH
diff --git a/tests/diag.sh b/tests/diag.sh
index 86551155..06512d4a 100755
--- a/tests/diag.sh
+++ b/tests/diag.sh
@@ -22,6 +22,7 @@ case $1 in
rm -f work rsyslog.out.log rsyslog.out.log.save # common work files
rm -rf test-spool test-logdir
rm -f rsyslog.out.*.log work-presort
+ rm -f rsyslog.out.*.log work-presort
rm -f core.* vgcore.*
mkdir test-spool
;;
diff --git a/tests/msleep.c b/tests/msleep.c
index 6fa57b79..36fa01b5 100644
--- a/tests/msleep.c
+++ b/tests/msleep.c
@@ -26,6 +26,7 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
int main(int argc, char *argv[])
{
diff --git a/tests/nettester.c b/tests/nettester.c
index e12758a8..7c8c413a 100644
--- a/tests/nettester.c
+++ b/tests/nettester.c
@@ -125,6 +125,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)
@@ -132,30 +136,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); /* ms = 1000 us! */
}
@@ -164,20 +172,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;
}
@@ -253,6 +273,7 @@ int openPipe(char *configFile, pid_t *pid, int *pfd)
fclose(stdin);
execve("../tools/rsyslogd", newargv, ourEnvp);
} else {
+ usleep(10000);
close(pipefd[1]);
*pid = cpid;
*pfd = pipefd[0];
@@ -372,6 +393,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(strlen(buf) == 0) {
printf("something went wrong - read a zero-length string from rsyslogd\n");
@@ -438,7 +460,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);
@@ -549,6 +572,11 @@ int main(int argc, char *argv[], char *envp[])
/* arm died-child handler */
signal(SIGCHLD, childDied);
+ /* 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/random.sh b/tests/random.sh
index 79f704c7..d1f392d3 100755
--- a/tests/random.sh
+++ b/tests/random.sh
@@ -17,4 +17,4 @@ source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done proces
source $srcdir/diag.sh wait-shutdown # and wait for it to terminate
# we do not check anything yet, the point is if rsyslog survived ;)
# TODO: check for exit message, but we'll notice an abort anyhow, so not that important
-#source $srcdir/diag.sh exit
+source $srcdir/diag.sh exit