Module Name: src
Committed By: pgoyette
Date: Wed May 3 12:09:41 UTC 2017
Modified Files:
src/tests/rump/rumpkern: t_kern.c
Log Message:
Fix detection of expected results. The rump kernel code apparently
includes source-code line numbers in the messages, so rather than
hard-coding them in the test, just use a reg-ex to match the text.
Fixes PR bin/52207
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 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.4 src/tests/rump/rumpkern/t_kern.c:1.5
--- src/tests/rump/rumpkern/t_kern.c:1.4 Fri Jan 13 21:30:43 2017
+++ src/tests/rump/rumpkern/t_kern.c Wed May 3 12:09:41 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_kern.c,v 1.4 2017/01/13 21:30:43 christos Exp $ */
+/* $NetBSD: t_kern.c,v 1.5 2017/05/03 12:09:41 pgoyette Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -37,6 +37,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <regex.h>
#include "h_macros.h"
#include "../kernspace/kernspace.h"
@@ -56,6 +57,8 @@ locktest(const atf_tc_t *tc, enum lockte
extern const int rump_lockdebug;
int pipetti[2];
int status;
+ ssize_t len;
+ regex_t preg;
if (needld && !rump_lockdebug)
atf_tc_skip("test requires LOCKDEBUG kernel");
@@ -76,9 +79,27 @@ locktest(const atf_tc_t *tc, enum lockte
if (rump_lockdebug) {
char buf[8192];
- ATF_REQUIRE(read(pipetti[0], buf, sizeof(buf)) > 0);
- if (strncmp(buf, expect, strlen(expect)) != 0)
+ len = read(pipetti[0], buf, sizeof(buf) - 1);
+ ATF_REQUIRE(len > 0);
+ buf[len] = '\0';
+ /*
+ * We use regex matching here, since the rump
+ * kernel messages include routine names and line
+ * numbers which may not remain constant.
+ */
+ if ((status = regcomp(&preg, expect, REG_BASIC)) != 0) {
+ regerror(status, &preg, buf, sizeof(buf));
+ printf("regcomp error: %s\n", buf);
+ atf_tc_fail("regcomp failed");
+ }
+ if ((status = regexec(&preg, buf, 0, NULL, 0)) != 0) {
+ printf("expected: \"%s\"\n", expect);
+ printf("received: \"%s\"\n", buf);
+ regerror(status, &preg, buf, sizeof(buf));
+ printf("regexec error: %s\n", buf);
atf_tc_fail("unexpected output");
+ }
+ regfree(&preg);
}
break;
case -1:
@@ -87,21 +108,21 @@ locktest(const atf_tc_t *tc, enum lockte
}
LOCKFUN(DESTROYHELD, "destroy lock while held", 0,
- "mutex error: lockdebug_free: is locked or in use");
+ "mutex error: mutex_destroy,.*: is locked or in use");
LOCKFUN(DOUBLEFREE, "free lock twice", 0,
- "panic: lockdebug_lookup: uninitialized lock");
+ "panic: mutex_destroy,.*: uninitialized lock");
LOCKFUN(DOUBLEINIT, "init lock twice", 1,
- "mutex error: lockdebug_alloc: already initialized");
+ "mutex error: mutex_init,.*: already initialized");
LOCKFUN(MEMFREE, "free memory active lock is in", 1,
- "mutex error: kmem_intr_free: allocation contains active lock");
+ "mutex error: kmem_intr_free,.*: allocation contains active lock");
LOCKFUN(MTX, "locking-against-self mutex", 0,
- "mutex error: lockdebug_wantlock: locking against myself");
+ "mutex error: mutex_enter,.*: locking against myself");
LOCKFUN(RWDOUBLEX, "locking-against-self exclusive rwlock", 0,
- "rwlock error: lockdebug_wantlock: locking against myself");
+ "rwlock error: rw_enter,.*: locking against myself");
LOCKFUN(RWRX, "rw: first shared, then exclusive", 1,
- "rwlock error: lockdebug_wantlock: locking against myself");
+ "rwlock error: rw_enter,.*: locking against myself");
LOCKFUN(RWXR, "rw: first execusive, then shared", 0,
- "rwlock error: lockdebug_wantlock: locking against myself");
+ "rwlock error: rw_enter,.*: locking against myself");
ATF_TP_ADD_TCS(tp)
{