Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Jan 2004 13:28:29 -0800 (PST)
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 46081 for review
Message-ID:  <200401282128.i0SLSTC4079755@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=46081

Change 46081 by jhb@jhb_slimer on 2004/01/28 13:27:45

	Reverse integrate extra witness test from jhb_lock.

Affected files ...

.. //depot/projects/smpng/sys/modules/crash/crash.c#10 integrate

Differences ...

==== //depot/projects/smpng/sys/modules/crash/crash.c#10 (text+ko) ====

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001
+ * Copyright (c) 2001-2004
  *	John Baldwin <jhb@FreeBSD.org>.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,7 @@
 
 #define	INVARIANTS
 #define	INVARIANT_SUPPORT
+#define	WITNESS
 
 #include <sys/param.h>
 #include <sys/condvar.h>
@@ -51,7 +52,7 @@
 #include <sys/sysctl.h>
 #include <sys/systm.h>
 
-#define	MAX_EVENT	18
+#define	MAX_EVENT	19
 
 static struct sx foo, bar, bar2;
 static struct cv event_cv;
@@ -77,7 +78,8 @@
 	"assert that foo is slocked while it is xlocked",
 	"lock test, slock foo, sunlock foo, unlock test",
 	"use test1 and test2 mutexes to test witness removal",
-	"try lock tests including recursion test"
+	"try lock tests including recursion test",
+	"test witness_defineorder and witness_checkorder",
 };
 
 static int	mod_event(struct module *module, int cmd, void *arg);
@@ -257,6 +259,39 @@
 			mtx_destroy(&test1_mtx);
 			mtx_destroy(&test2_mtx);
 			break;
+		case 19:
+			bzero(&test1_mtx, sizeof(test1_mtx));
+			bzero(&test2_mtx, sizeof(test2_mtx));
+			mtx_init(&test1_mtx, "test1", NULL, MTX_DEF);
+			mtx_init(&test2_mtx, "test2", NULL, MTX_DEF);
+			Debugger("no order yet");
+			status = WITNESS_DEFINEORDER(&test1_mtx, &test2_mtx);
+			printf("Status of test1 -> test2 set order should be 0: %d\n",
+			    status);
+			Debugger("order should be test1 then test2");
+			printf("Check order of test1 -> test2 should succeed.\n");
+			mtx_lock(&test1_mtx);
+			witness_check_mutex(&test2_mtx);
+			mtx_unlock(&test1_mtx);
+			status = WITNESS_DEFINEORDER(&test2_mtx, &test1_mtx);
+			printf("Status of test2 -> test1 set order should be EDOOFUS: %d\n",
+			    status);
+			printf("Clearing test order.\n");
+			mtx_destroy(&test1_mtx);
+			mtx_destroy(&test2_mtx);
+			mtx_init(&test1_mtx, "test1", NULL, MTX_DEF);
+			mtx_init(&test2_mtx, "test2", NULL, MTX_DEF);
+			status = WITNESS_DEFINEORDER(&test1_mtx, &test2_mtx);
+			printf("Status of test1 -> test2 set order should be 0: %d\n",
+			    status);
+			printf("Should get a reversal:\n");
+			mtx_lock(&test2_mtx);
+			mtx_lock(&test1_mtx);
+			mtx_unlock(&test1_mtx);
+			mtx_unlock(&test2_mtx);
+			mtx_destroy(&test1_mtx);
+			mtx_destroy(&test2_mtx);
+			break;
 		default:
 			panic("event %d is bogus\n", event);
 		}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200401282128.i0SLSTC4079755>