summaryrefslogtreecommitdiffstats
path: root/tests/nettester.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-06-24 10:52:06 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-06-24 10:52:06 +0200
commit8eb10a7105dce1dc3ffc44b291de73d82bd04799 (patch)
treee3c70740599127009b6009a2846d8274e67c8900 /tests/nettester.c
parent675d46f5b59f64e378968baa5e0dec6810090287 (diff)
parentc53ca3a23429e750aeb6ab1c3600ae8ecb3c8ac6 (diff)
downloadrsyslog-8eb10a7105dce1dc3ffc44b291de73d82bd04799.tar.gz
rsyslog-8eb10a7105dce1dc3ffc44b291de73d82bd04799.tar.xz
rsyslog-8eb10a7105dce1dc3ffc44b291de73d82bd04799.zip
Merge branch 'omfile'
Conflicts: ChangeLog
Diffstat (limited to 'tests/nettester.c')
-rw-r--r--tests/nettester.c76
1 files changed, 43 insertions, 33 deletions
diff --git a/tests/nettester.c b/tests/nettester.c
index 566f553b..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
*/
@@ -191,7 +194,7 @@ int openPipe(char *configFile, pid_t *pid, int *pfd)
char *newenviron[] = { NULL };
/* debug aide...
char *newenviron[] = { "RSYSLOG_DEBUG=debug nostdout",
- "RSYSLOG_DEBUGLOG=tmp", NULL };
+ "RSYSLOG_DEBUGLOG=log", NULL };
*/
@@ -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);
@@ -321,8 +330,9 @@ doTests(int fd, char *files)
if(ret == 0) {
if(verbose) printf("successfully completed\n");
} else {
- if(verbose) printf("failed!\n");
- ++iFailed;
+ if(!verbose)
+ printf("test '%s' ", testFile);
+ printf("failed!\n");
}
}
}