socsvn commit: r239709 - in soc2012/gmiller/locking-head: .
tools/regression/lib/libwitness
gmiller at FreeBSD.org
gmiller at FreeBSD.org
Mon Jul 23 20:20:45 UTC 2012
Author: gmiller
Date: Mon Jul 23 20:20:43 2012
New Revision: 239709
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239709
Log:
r239743 at FreeBSD-dev: root | 2012-07-23 12:57:15 -0500
Add tests for pthread_lockorder_set_np().
Added:
soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setorder.c
soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setorder.t
- copied unchanged from r239444, soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.t
Modified:
soc2012/gmiller/locking-head/ (props changed)
soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile
soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.c
Modified: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile
==============================================================================
--- soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile Mon Jul 23 20:20:25 2012 (r239708)
+++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/Makefile Mon Jul 23 20:20:43 2012 (r239709)
@@ -1,6 +1,6 @@
# $FreeBSD$
-TESTS= lor-basic
+TESTS= lor-basic setorder
CFLAGS+= -g -Wall -Wextra -Werror -lwitness
.PHONY: tests
@@ -13,3 +13,6 @@
lor-basic: lor-basic.c check.c
${CC} -o lor-basic lor-basic.c check.c ${CFLAGS}
+
+setorder: setorder.c check.c
+ ${CC} -o setorder setorder.c check.c ${CFLAGS}
Modified: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.c
==============================================================================
--- soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.c Mon Jul 23 20:20:25 2012 (r239708)
+++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.c Mon Jul 23 20:20:43 2012 (r239709)
@@ -1,3 +1,29 @@
+/*-
+ * Copyright (c) 2012 Greg Miller <gmiller at freebsd.org>..
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
#include <pthread.h>
#include <pthread_np.h>
Added: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setorder.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setorder.c Mon Jul 23 20:20:43 2012 (r239709)
@@ -0,0 +1,104 @@
+/*-
+ * Copyright (c) 2012 Greg Miller <gmiller at freebsd.org>..
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include <pthread.h>
+#include <pthread_np.h>
+
+#include "check.h"
+
+void
+unset_test(void)
+{
+ pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER;
+ pthread_rwlock_t rwlock2 = PTHREAD_RWLOCK_INITIALIZER;
+
+ pthread_rwlock_rdlock(&rwlock1);
+ pthread_rwlock_rdlock(&rwlock2);
+
+ pthread_rwlock_unlock(&rwlock2);
+ pthread_rwlock_unlock(&rwlock1);
+}
+
+void
+set_test(void)
+{
+ pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER;
+ pthread_rwlock_t rwlock2 = PTHREAD_RWLOCK_INITIALIZER;
+
+ pthread_lockorder_reset_np();
+ pthread_lockorder_set_np(&rwlock2, &rwlock1);
+
+ pthread_rwlock_rdlock(&rwlock1);
+ pthread_rwlock_rdlock(&rwlock2);
+
+ pthread_rwlock_unlock(&rwlock2);
+ pthread_rwlock_unlock(&rwlock1);
+}
+
+void
+check_unset(void)
+{
+ int record_count = 0;
+ struct pthread_lor_np lor;
+
+ pthread_lor_begin_np(&lor);
+ while (pthread_lor_next_np(&lor)) {
+ record_count++;
+ }
+ pthread_lor_end_np(&lor);
+
+ check(record_count == 0);
+}
+
+void
+check_set(void)
+{
+ int record_count = 0;
+ struct pthread_lor_np lor;
+
+ pthread_lor_begin_np(&lor);
+ while (pthread_lor_next_np(&lor)) {
+ record_count++;
+ }
+ pthread_lor_end_np(&lor);
+
+ check(record_count == 1);
+}
+
+int
+main(void)
+{
+ unset_test();
+ check_unset();
+
+ set_test();
+ check_set();
+
+ show_test_results();
+
+ return 0;
+}
Copied: soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setorder.t (from r239444, soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.t)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ soc2012/gmiller/locking-head/tools/regression/lib/libwitness/setorder.t Mon Jul 23 20:20:43 2012 (r239709, copy of r239444, soc2012/gmiller/locking-head/tools/regression/lib/libwitness/lor-basic.t)
@@ -0,0 +1,10 @@
+#!/bin/sh
+# $FreeBSD$
+
+cd `dirname $0`
+
+executable=`basename $0 .t`
+
+make $executable 2>&1 > /dev/null
+
+exec ./$executable
More information about the svn-soc-all
mailing list