Module Name:    src
Committed By:   pooka
Date:           Thu Jan  6 13:42:45 UTC 2011

Modified Files:
        src/tests/rump/rumpkern: t_kern.c

Log Message:
In case of LOCKDEBUG, expect certain text in the kernel output.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/rump/rumpkern/t_kern.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/rump/rumpkern/t_kern.c
diff -u src/tests/rump/rumpkern/t_kern.c:1.1 src/tests/rump/rumpkern/t_kern.c:1.2
--- src/tests/rump/rumpkern/t_kern.c:1.1	Thu Jan  6 13:12:52 2011
+++ src/tests/rump/rumpkern/t_kern.c	Thu Jan  6 13:42:45 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_kern.c,v 1.1 2011/01/06 13:12:52 pooka Exp $	*/
+/*	$NetBSD: t_kern.c,v 1.2 2011/01/06 13:42:45 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -41,26 +41,30 @@
 #include "../../h_macros.h"
 #include "../kernspace/kernspace.h"
 
-#define LOCKFUN(_name_, _descr_,_needld_)				\
+#define LOCKFUN(_name_, _descr_,_needld_, _expect_)			\
 	ATF_TC(lockme_##_name_);					\
 	ATF_TC_HEAD(lockme_##_name_, tc) {				\
 		atf_tc_set_md_var(tc, "descr", _descr_);		\
 	}								\
 	ATF_TC_BODY(lockme_##_name_, tc) {				\
-		locktest(tc, LOCKME_##_name_, _needld_);		\
+		locktest(tc, LOCKME_##_name_, _needld_, _expect_);	\
 	}
 
 static void
-locktest(const atf_tc_t *tc, enum locktest lt, int needld)
+locktest(const atf_tc_t *tc, enum locktest lt, int needld, const char *expect)
 {
 	extern const int rump_lockdebug;
+	int pipetti[2];
 	int status;
 
 	if (needld && !rump_lockdebug)
 		atf_tc_skip("test requires LOCKDEBUG kernel");
+	RL(pipe(pipetti));
 
 	switch (fork()) {
 	case 0:
+		RL(dup2(pipetti[1], STDOUT_FILENO));
+		RL(dup2(pipetti[1], STDOUT_FILENO));
 		rump_init();
 		rump_schedule();
 		rumptest_lockme(lt);
@@ -69,20 +73,35 @@
 	default:
 		RL(wait(&status));
 		ATF_REQUIRE(WIFSIGNALED(status) && WTERMSIG(status) == SIGABRT);
+		if (rump_lockdebug) {
+			char buf[8192];
+
+			ATF_REQUIRE(read(pipetti[0], buf, sizeof(buf)) > 0);
+			if (strncmp(buf, expect, strlen(expect)) != 0)
+				atf_tc_fail("unexpected output");
+		}
 		break;
 	case -1:
 		atf_tc_fail("fork");
 	}
 }
 
-LOCKFUN(DESTROYHELD, "destroy lock while held", 0);
-LOCKFUN(DOUBLEFREE, "free lock twice", 0);
-LOCKFUN(DOUBLEINIT, "init lock twice", 1);
-LOCKFUN(MEMFREE, "free memory active lock is in", 1);
-LOCKFUN(MTX, "locking-against-self mutex", 0);
-LOCKFUN(RWDOUBLEX, "locking-against-self exclusive rwlock", 0);
-LOCKFUN(RWRX, "rw: first shared, then exclusive", 1);
-LOCKFUN(RWXR, "rw: first execusive, then shared", 0);
+LOCKFUN(DESTROYHELD, "destroy lock while held", 0,
+    "mutex error: lockdebug_free: is locked or in use");
+LOCKFUN(DOUBLEFREE, "free lock twice", 0,
+    "panic: lockdebug_lookup: uninitialized lock");
+LOCKFUN(DOUBLEINIT, "init lock twice", 1,
+    "mutex error: lockdebug_alloc: already initialized");
+LOCKFUN(MEMFREE, "free memory active lock is in", 1,
+    "mutex error: kmem_free: allocation contains active lock");
+LOCKFUN(MTX, "locking-against-self mutex", 0,
+    "mutex error: lockdebug_wantlock: locking against myself");
+LOCKFUN(RWDOUBLEX, "locking-against-self exclusive rwlock", 0,
+    "rwlock error: lockdebug_wantlock: locking against myself");
+LOCKFUN(RWRX, "rw: first shared, then exclusive", 1,
+    "rwlock error: lockdebug_wantlock: locking against myself");
+LOCKFUN(RWXR, "rw: first execusive, then shared", 0,
+    "rwlock error: lockdebug_wantlock: locking against myself");
 
 ATF_TP_ADD_TCS(tp)
 {

Reply via email to