Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/rump/rumpkern In case of LOCKDEBUG, expect certain tex...
details: https://anonhg.NetBSD.org/src/rev/7279a4ccf839
branches: trunk
changeset: 760513:7279a4ccf839
user: pooka <pooka%NetBSD.org@localhost>
date: Thu Jan 06 13:42:45 2011 +0000
description:
In case of LOCKDEBUG, expect certain text in the kernel output.
diffstat:
tests/rump/rumpkern/t_kern.c | 43 +++++++++++++++++++++++++++++++------------
1 files changed, 31 insertions(+), 12 deletions(-)
diffs (87 lines):
diff -r 15ba55c27040 -r 7279a4ccf839 tests/rump/rumpkern/t_kern.c
--- a/tests/rump/rumpkern/t_kern.c Thu Jan 06 13:36:48 2011 +0000
+++ b/tests/rump/rumpkern/t_kern.c Thu Jan 06 13:42:45 2011 +0000
@@ -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)
{
Home |
Main Index |
Thread Index |
Old Index