/*
* Copyright (C) 1999-2001, 2004, 2007, 2011, 2014-2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* $Id: log_test.c,v 1.29 2011/08/28 23:46:51 marka Exp $ */
/* Principal Authors: DCL */
#include <config.h>
#include <stdlib.h>
#include <unistd.h>
#include <isc/commandline.h>
if (result != ISC_R_SUCCESS) { \
}
int
progname++;
else
switch (ch) {
case 'm':
break;
case 's':
break;
case 'r':
if (file_versions < 0 &&
"%d (ISC_LOG_ROLLNEVER),\n\t"
"%d (ISC_LOG_ROLLINFINITE) "
"or > 0\n", progname,
exit(1);
}
break;
case '?':
exit(1);
}
}
if (argc > 0) {
exit(1);
}
"8 lines to stderr (first 4 numbered, #3 repeated)\n",
"2 lines to syslog\n",
"lines ending with exclamation marks are errors\n\n");
/*
* Test isc_log_categorybyname and isc_log_modulebyname.
*/
else
else
/*
* Create a file channel to test file opening, size limiting and
* version rolling.
*/
/*
* Create a dynamic debugging channel to a file descriptor.
*/
/*
* Test the usability of the four predefined logging channels.
*/
NULL));
/*
* Use the custom channels.
*/
/*
* Write to the internal default by testing both a category for which
* no channel has been specified and a category which was specified
* but not with the named module.
*/
stderr_line = 1;
ISC_LOG_CRITICAL, "%s (%d)",
"Unspecified category and unspecified module to stderr",
stderr_line++);
ISC_LOG_CRITICAL, "%s (%d)",
"Specified category and unspecified module to stderr",
stderr_line++);
/*
* Write to default_syslog, default_stderr and default_debug.
*/
ISC_LOG_WARNING, "%s (%d twice)",
"Using the predefined channels to syslog+stderr",
stderr_line++);
/*
* Write to predefined null channel.
*/
ISC_LOG_INFO, "This is to null and should not appear!");
/*
* Reset the internal default to use syslog instead of stderr,
* and test it.
*/
ISC_LOG_ERROR, "%s%s",
"This message to the redefined default category should ",
"be second in syslog");
/*
* Write to the file channel.
*/
/*
* If file_versions is 0 or ISC_LOG_ROLLINFINITE, write
* the "should not appear" and "should be in file" messages
* to ensure they get rolled.
*/
if (file_versions <= 0)
else
"This should be rolled over "
"and not appear!");
for (i = file_versions - 1; i >= 0; i--)
"should be in file %d/%d", i,
file_versions - 1);
"should be in base file");
} else {
for (i = 1; i <= file_versions; i++)
"This is message %d in the log file", i);
}
/*
* Write a debugging message to a category that has no
* debugging channels for the named module.
*/
ISC_LOG_DEBUG(1),
"This debug message should not appear!");
/*
* Write debugging messages to a dynamic debugging channel.
*/
ISC_LOG_CRITICAL, "This critical message should "
"not appear because the debug level is 0!");
"Dynamic debugging to stderr", stderr_line++);
ISC_LOG_DEBUG(5),
"This debug level is too high and should not appear!");
/*
* Test out the duplicate filtering using the debug_test channel.
*/
message = "This message should appear only once on stderr";
message = "This message should appear twice on stderr";
sleep(2);
/*
* Review where everything went.
* XXXDCL NT
*/
TEST_FILE "*\") failed\n");
goto cleanup;
}
/* This is highly system specific. */
goto cleanup;
}
if (system("tail -2") != 0) {
goto cleanup;
}
if (show_final_mem)
return (0);
}