Commit 5a505fc4 authored by Mukund Sivaraman's avatar Mukund Sivaraman

Add facility to run system test nameds under Valgrind (#38546)

parent 089d5091
......@@ -15,8 +15,6 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: main.h,v 1.17 2009/09/29 23:48:03 tbox Exp $ */
#ifndef NAMED_MAIN_H
#define NAMED_MAIN_H 1
......@@ -26,6 +24,11 @@
#define main(argc, argv) bindmain(argc, argv)
#endif
/*
* Commandline arguments for named; also referenced in win32/ntservice.c
*/
#define NS_MAIN_ARGS "46c:C:d:D:E:fFgi:lL:M:m:n:N:p:P:sS:t:T:U:u:vVx:X:"
ISC_PLATFORM_NORETURN_PRE void
ns_main_earlyfatal(const char *format, ...)
ISC_FORMAT_PRINTF(1, 2) ISC_PLATFORM_NORETURN_POST;
......
......@@ -387,6 +387,7 @@ static struct flag_def {
const char *name;
unsigned int value;
} mem_debug_flags[] = {
{ "none", 0},
{ "trace", ISC_MEM_DEBUGTRACE },
{ "record", ISC_MEM_DEBUGRECORD },
{ "usage", ISC_MEM_DEBUGUSAGE },
......@@ -397,6 +398,8 @@ static struct flag_def {
static void
set_flags(const char *arg, struct flag_def *defs, unsigned int *ret) {
isc_boolean_t clear = ISC_FALSE;
for (;;) {
const struct flag_def *def;
const char *end = strchr(arg, ',');
......@@ -407,16 +410,21 @@ set_flags(const char *arg, struct flag_def *defs, unsigned int *ret) {
for (def = defs; def->name != NULL; def++) {
if (arglen == (int)strlen(def->name) &&
memcmp(arg, def->name, arglen) == 0) {
if (def->value == 0)
clear = ISC_TRUE;
*ret |= def->value;
goto found;
}
}
ns_main_earlyfatal("unrecognized flag '%.*s'", arglen, arg);
found:
if (*end == '\0')
if (clear || (*end == '\0'))
break;
arg = end + 1;
}
if (clear)
*ret = 0;
}
static void
......@@ -427,10 +435,12 @@ parse_command_line(int argc, char *argv[]) {
save_command_line(argc, argv);
/* PLEASE keep options synchronized when main is hooked! */
#define CMDLINE_FLAGS "46c:C:d:D:E:fFgi:lL:m:n:N:p:P:sS:t:T:U:u:vVx:X:"
/*
* NS_MAIN_ARGS is defined in main.h, so that it can be used
* both by named and by ntservice hooks.
*/
isc_commandline_errprint = ISC_FALSE;
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
while ((ch = isc_commandline_parse(argc, argv, NS_MAIN_ARGS)) != -1) {
switch (ch) {
case '4':
if (ns_g_disable4)
......@@ -488,6 +498,10 @@ parse_command_line(int argc, char *argv[]) {
case 'L':
ns_g_logfile = isc_commandline_argument;
break;
case 'M':
if (strcmp(isc_commandline_argument, "external") == 0)
isc_mem_defaultflags = 0;
break;
case 'm':
set_flags(isc_commandline_argument, mem_debug_flags,
&isc_mem_debugging);
......@@ -665,7 +679,7 @@ parse_command_line(int argc, char *argv[]) {
usage();
if (isc_commandline_option == '?')
exit(0);
p = strchr(CMDLINE_FLAGS, isc_commandline_option);
p = strchr(NS_MAIN_ARGS, isc_commandline_option);
if (p == NULL || *++p != ':')
ns_main_earlyfatal("unknown option '-%c'",
isc_commandline_option);
......
......@@ -67,6 +67,7 @@
<arg><option>-f</option></arg>
<arg><option>-g</option></arg>
<arg><option>-L <replaceable class="parameter">logfile</replaceable></option></arg>
<arg><option>-M <replaceable class="parameter">option</replaceable></option></arg>
<arg><option>-m <replaceable class="parameter">flag</replaceable></option></arg>
<arg><option>-n <replaceable class="parameter">#cpus</replaceable></option></arg>
<arg><option>-p <replaceable class="parameter">port</replaceable></option></arg>
......@@ -212,6 +213,19 @@
</listitem>
</varlistentry>
<varlistentry>
<term>-M <replaceable class="parameter">option</replaceable></term>
<listitem>
<para>
Sets the default memory context options. Currently
the only supported option is
<replaceable class="parameter">external</replaceable>,
which causes the internal memory manager to be bypassed
in favor of system-provided memory allocation functions.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-m <replaceable class="parameter">flag</replaceable></term>
<listitem>
......
......@@ -140,9 +140,7 @@ int main(int argc, char *argv[])
/* Command line users should put -f in the options. */
isc_commandline_errprint = ISC_FALSE;
while ((ch = isc_commandline_parse(argc, argv,
"46c:C:d:D:E:fFgi:lm:n:N:p:P:"
"sS:t:T:U:u:vVx:")) != -1) {
while ((ch = isc_commandline_parse(argc, argv, NS_MAIN_ARGS)) != -1) {
switch (ch) {
case 'f':
case 'g':
......
......@@ -59,4 +59,7 @@ The tests can be run individually like this:
To run all the tests, just type "make test".
$Id: README,v 1.16 2011/01/13 04:59:24 tbox Exp $
When running system tests, named and lwresd can be run under
Valgrind. The output from Valgrind are sent to per-process files that
can be reviewed after the test has completed. To enable this, set the
USE_VALGRIND environment variable.
......@@ -149,7 +149,11 @@ sub start_server {
if ($server =~ /^ns/) {
$cleanup_files = "{*.jnl,*.bk,*.st,named.run}";
$command = "$NAMED ";
if ($ENV{'USE_VALGRIND'}) {
$command = "valgrind -q --gen-suppressions=all --track-origins=yes --num-callers=48 --leak-check=full --fullpath-after= --log-file=named-$server-valgrind-%p.log $NAMED -m none -M external ";
} else {
$command = "$NAMED ";
}
if ($options) {
$command .= "$options";
} elsif (-e $args_file) {
......@@ -195,7 +199,11 @@ sub start_server {
$pid_file = "named.pid";
} elsif ($server =~ /^lwresd/) {
$cleanup_files = "{lwresd.run}";
$command = "$LWRESD ";
if ($ENV{'USE_VALGRIND'}) {
$command = "valgrind -q --gen-suppressions=all --track-origins=yes --num-callers=48 --leak-check=full --fullpath-after= --log-file=lwresd-valgrind-%p.log $LWRESD -m none -M external ";
} else {
$command = "$LWRESD ";
}
if ($options) {
$command .= "$options";
} else {
......
......@@ -15,8 +15,6 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id$ */
#ifndef ISC_MEM_H
#define ISC_MEM_H 1
......@@ -76,6 +74,8 @@ typedef void (*isc_memfree_t)(void *, void *);
#endif
LIBISC_EXTERNAL_DATA extern unsigned int isc_mem_debugging;
LIBISC_EXTERNAL_DATA extern unsigned int isc_mem_defaultflags;
/*@{*/
#define ISC_MEM_DEBUGTRACE 0x00000001U
#define ISC_MEM_DEBUGRECORD 0x00000002U
......
......@@ -15,8 +15,6 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id$ */
/*! \file */
#include <config.h>
......@@ -47,6 +45,7 @@
#define ISC_MEM_DEBUGGING 0
#endif
LIBISC_EXTERNAL_DATA unsigned int isc_mem_debugging = ISC_MEM_DEBUGGING;
LIBISC_EXTERNAL_DATA unsigned int isc_mem_defaultflags = ISC_MEMFLAG_DEFAULT;
/*
* Constants.
......@@ -888,7 +887,7 @@ isc_mem_createx(size_t init_max_size, size_t target_size,
isc_mem_t **ctxp)
{
return (isc_mem_createx2(init_max_size, target_size, memalloc, memfree,
arg, ctxp, ISC_MEMFLAG_DEFAULT));
arg, ctxp, isc_mem_defaultflags));
}
......@@ -2715,12 +2714,12 @@ isc_mem_create(size_t init_max_size, size_t target_size, isc_mem_t **mctxp) {
if (isc_bind9)
return (isc_mem_createx2(init_max_size, target_size,
default_memalloc, default_memfree,
NULL, mctxp, ISC_MEMFLAG_DEFAULT));
NULL, mctxp, isc_mem_defaultflags));
LOCK(&createlock);
REQUIRE(mem_createfunc != NULL);
result = (*mem_createfunc)(init_max_size, target_size, mctxp,
ISC_MEMFLAG_DEFAULT);
isc_mem_defaultflags);
UNLOCK(&createlock);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment