[netfilter-cvslog] r3578 - in trunk: nfsim/core nfsim-testsuite

rusty at netfilter.org rusty at netfilter.org
Thu Jan 6 06:35:29 CET 2005


Author: rusty at netfilter.org
Date: 2005-01-06 06:35:28 +0100 (Thu, 06 Jan 2005)
New Revision: 3578

Modified:
   trunk/nfsim-testsuite/.gdbinit
   trunk/nfsim-testsuite/test-kernel-source
   trunk/nfsim-testsuite/test.sh
   trunk/nfsim/core/core.c
   trunk/nfsim/core/core.h
   trunk/nfsim/core/failtest.c
   trunk/nfsim/core/tui.c
Log:
Better debugging with --valgrind and --failtest together.
Better nfsim caching checksum including .config and env vars.



Modified: trunk/nfsim/core/core.c
===================================================================
--- trunk/nfsim/core/core.c	2005-01-05 21:40:48 UTC (rev 3577)
+++ trunk/nfsim/core/core.c	2005-01-06 05:35:28 UTC (rev 3578)
@@ -31,6 +31,7 @@
 #include <unistd.h>
 #include <signal.h>
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <fcntl.h>
 #include <getopt.h>
 
@@ -139,6 +140,7 @@
 	char *hookname = talloc_asprintf(NULL, "%s:%i", __func__, hooknum);
 
 	nfsim_check_packet(*skb);
+	check_for_valgrind_errors();
 
 	if (should_i_fail(hookname)) {
 		talloc_free(hookname);
@@ -272,6 +274,29 @@
 }
 cmdline_opt("help", 0, 'h', cmdline_help);
 
+static char *valgrind_file = NULL;
+
+static void cmdline_valgrind_file(struct option *opt)
+{
+	valgrind_file = optarg;
+}
+
+/* Hack for valgrind: if only it just aborted on error... */
+void check_for_valgrind_errors(void)
+{
+	struct stat st;
+
+	if (!valgrind_file)
+		return;
+
+	if (stat(valgrind_file, &st) != 0)
+		barf_perror("statting valgrind file %s", valgrind_file);
+
+	if (st.st_size != 0)
+		abort();
+}
+cmdline_opt("valgrind-file", 1, 0, cmdline_valgrind_file);
+
 extern struct cmdline_option __start_cmdline[], __stop_cmdline[];
 
 static struct cmdline_option *get_cmdline_option(int opt)
@@ -355,6 +380,8 @@
 		talloc_report_full(nfsim_tallocs, stderr);
 		barf("Resource leak");
 	}
+
+	check_for_valgrind_errors();
 }
 
 int main(int argc, char **argv)

Modified: trunk/nfsim/core/core.h
===================================================================
--- trunk/nfsim/core/core.h	2005-01-05 21:40:48 UTC (rev 3577)
+++ trunk/nfsim/core/core.h	2005-01-06 05:35:28 UTC (rev 3578)
@@ -299,6 +299,9 @@
 /* If the test has a name, this is it. */
 extern const char *nfsim_testname;
 
+/* Hack for valgrind */
+extern void check_for_valgrind_errors(void);
+
 enum exitcodes
 {
 	/* EXIT_SUCCESS, EXIT_FAILURE is in stdlib.h */

Modified: trunk/nfsim/core/failtest.c
===================================================================
--- trunk/nfsim/core/failtest.c	2005-01-05 21:40:48 UTC (rev 3577)
+++ trunk/nfsim/core/failtest.c	2005-01-06 05:35:28 UTC (rev 3578)
@@ -98,7 +98,7 @@
 /* Separate function to make .gdbinit easier */
 static bool failpath_fail(void)
 {
-	return false;
+	return true;
 }
 
 static bool do_failpath(const char *func)

Modified: trunk/nfsim/core/tui.c
===================================================================
--- trunk/nfsim/core/tui.c	2005-01-05 21:40:48 UTC (rev 3577)
+++ trunk/nfsim/core/tui.c	2005-01-06 05:35:28 UTC (rev 3578)
@@ -209,6 +209,7 @@
 		}
 		if (!do_post_commands(cmd->name))
 			ret = false;
+		check_for_valgrind_errors();
 		return ret;
 	}
 

Modified: trunk/nfsim-testsuite/.gdbinit
===================================================================
--- trunk/nfsim-testsuite/.gdbinit	2005-01-05 21:40:48 UTC (rev 3577)
+++ trunk/nfsim-testsuite/.gdbinit	2005-01-06 05:35:28 UTC (rev 3578)
@@ -1,5 +1,6 @@
 # Break on FATAL
 break barf
 break barf_perror
+break script_fail
 # Break on failure return from failpath.
 break failpath_fail

Modified: trunk/nfsim-testsuite/test-kernel-source
===================================================================
--- trunk/nfsim-testsuite/test-kernel-source	2005-01-05 21:40:48 UTC (rev 3577)
+++ trunk/nfsim-testsuite/test-kernel-source	2005-01-06 05:35:28 UTC (rev 3578)
@@ -25,6 +25,13 @@
     return 0
 }
 
+# Simple signature of relevent kernel source & env vars.
+kernel_signature()
+{
+    # $CC and $GCOV effect compilation, as does .config
+    (echo $CC; echo $GCOV; cat $1/.config 2>/dev/null; find $1/include/linux/netfilter_ipv4 $1/net/ipv4/netfilter -name '*.[ch]' -exec cat {} \;) | md5sum | cut -c1-32    
+}
+
 usage()
 {
     echo "Usage: $0 <test.sh args> <kerneldir> [test]" >&2
@@ -64,7 +71,7 @@
 # Clean cached nfsims which are more than one month old.
 find . -name '.nfsim*' -mtime +30 -exec rm {} \;
 
-NFSIM=$(pwd)/.nfsim-$(find $KERNELDIR/include/linux/netfilter_ipv4 $KERNELDIR/net/ipv4/netfilter -name '*.[ch]' -exec cat {} \; | md5sum | cut -c1-32)
+NFSIM=$(pwd)/.nfsim-$(kernel_signature $KERNELDIR)
 if [ -f $NFSIM ] && recent $NFSIM; then
     echo Using cached nfsim...
     (cd ../nfsim && make --quiet gcov-clean)

Modified: trunk/nfsim-testsuite/test.sh
===================================================================
--- trunk/nfsim-testsuite/test.sh	2005-01-05 21:40:48 UTC (rev 3577)
+++ trunk/nfsim-testsuite/test.sh	2005-01-06 05:35:28 UTC (rev 3578)
@@ -27,7 +27,7 @@
 done
 
 NFSIM_ARGS="$NFSIM_QUIET_ARGS $NFSIM_ARGS"
-KVERSION=`echo version kernel | $NFSIM -q`
+KVERSION=`echo version kernel | $NFSIM -q | sed 's/-.*//'`
 
 # Creates a temporary file and exports the name of the file to
 # the provided argument.  Exits on error.
@@ -81,7 +81,7 @@
 {
     VG_NFSIM=$1
     shift
-    valgrind -q --suppressions=valgrind-suppressions --num-callers=8 --logfile-fd=3 $VG_NFSIM "$@" 3>/tmp/valgrind
+    valgrind -q --suppressions=valgrind-suppressions --num-callers=8 --logfile-fd=3 $VG_NFSIM --valgrind-file=/tmp/valgrind "$@" 3>/tmp/valgrind
     VG_RESULT=$?
 
     if [ -s /tmp/valgrind ]; then




More information about the netfilter-cvslog mailing list