changeset 945:d83ac58d2500

synch: add rwlock tests Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Sun, 11 Aug 2019 12:18:09 -0400
parents bc8880710efd
children ec30705b2104
files tests/.hgignore tests/CMakeLists.txt tests/test_rwlock-destroy-memcpy.c tests/test_rwlock-destroy-null.c tests/test_rwlock-destroy-rheld.c tests/test_rwlock-destroy-wheld.c tests/test_rwlock-init-null-both.c tests/test_rwlock-init-null-class.c tests/test_rwlock-init-null-lock.c tests/test_rwlock-lock-held-multi-common.c tests/test_rwlock-rlock-destroyed.c tests/test_rwlock-rlock-held-class.c tests/test_rwlock-rlock-held-multi-first.c tests/test_rwlock-rlock-held-multi-second.c tests/test_rwlock-rlock-held-multi-third.c tests/test_rwlock-rlock-held-nesting.c tests/test_rwlock-rlock-memcpy.c tests/test_rwlock-rlock-null.c tests/test_rwlock-rlock-rheld.c tests/test_rwlock-rlock-wheld.c tests/test_rwlock-unlock-destroyed.c tests/test_rwlock-unlock-memcpy.c tests/test_rwlock-unlock-null.c tests/test_rwlock-unlock-unheld.c tests/test_rwlock-wlock-destroyed.c tests/test_rwlock-wlock-held-class.c tests/test_rwlock-wlock-held-multi-first.c tests/test_rwlock-wlock-held-multi-second.c tests/test_rwlock-wlock-held-multi-third.c tests/test_rwlock-wlock-held-nesting.c tests/test_rwlock-wlock-memcpy.c tests/test_rwlock-wlock-null.c tests/test_rwlock-wlock-rheld.c tests/test_rwlock-wlock-wheld.c
diffstat 34 files changed, 1247 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/.hgignore	Sun Aug 11 12:06:42 2019 -0400
+++ b/tests/.hgignore	Sun Aug 11 12:18:09 2019 -0400
@@ -38,6 +38,39 @@
 test_nvl_pack
 test_padding
 test_qstring
+test_rwlock-destroy-memcpy
+test_rwlock-destroy-null
+test_rwlock-destroy-rheld
+test_rwlock-destroy-wheld
+test_rwlock-destroy.core
+test_rwlock-init-null-both
+test_rwlock-init-null-class
+test_rwlock-init-null-lock
+test_rwlock-rlock-destroyed
+test_rwlock-rlock-held-class
+test_rwlock-rlock-held-multi-first
+test_rwlock-rlock-held-multi-second
+test_rwlock-rlock-held-multi-third
+test_rwlock-rlock-held-nesting
+test_rwlock-rlock-memcpy
+test_rwlock-rlock-null
+test_rwlock-rlock-rheld
+test_rwlock-rlock-wheld
+test_rwlock-unlock-.core
+test_rwlock-unlock-destroyed
+test_rwlock-unlock-memcpy
+test_rwlock-unlock-null
+test_rwlock-unlock-unheld
+test_rwlock-wlock-destroyed
+test_rwlock-wlock-held-class
+test_rwlock-wlock-held-multi-first
+test_rwlock-wlock-held-multi-second
+test_rwlock-wlock-held-multi-third
+test_rwlock-wlock-held-nesting
+test_rwlock-wlock-memcpy
+test_rwlock-wlock-null
+test_rwlock-wlock-rheld
+test_rwlock-wlock-wheld
 test_sexpr_parser
 test_sexpr_compact
 test_sexpr_eval
--- a/tests/CMakeLists.txt	Sun Aug 11 12:06:42 2019 -0400
+++ b/tests/CMakeLists.txt	Sun Aug 11 12:18:09 2019 -0400
@@ -66,6 +66,41 @@
 endif()
 build_test_bin_and_run(nvl)
 build_test_bin_and_run(padding)
+build_test_bin_and_run(rwlock-destroy-memcpy)
+build_test_bin_and_run(rwlock-destroy-null)
+build_test_bin_and_run(rwlock-init-null-both)
+build_test_bin_and_run(rwlock-init-null-class)
+build_test_bin_and_run(rwlock-init-null-lock)
+build_test_bin_and_run(rwlock-rlock-destroyed)
+build_test_bin_and_run(rwlock-rlock-held-class)
+build_test_bin_and_run(rwlock-rlock-held-nesting)
+build_test_bin_and_run(rwlock-rlock-memcpy)
+build_test_bin_and_run(rwlock-rlock-null)
+build_test_bin_and_run(rwlock-unlock-destroyed)
+build_test_bin_and_run(rwlock-unlock-memcpy)
+build_test_bin_and_run(rwlock-unlock-null)
+build_test_bin_and_run(rwlock-wlock-destroyed)
+build_test_bin_and_run(rwlock-wlock-held-class)
+build_test_bin_and_run(rwlock-wlock-held-nesting)
+build_test_bin_and_run(rwlock-wlock-memcpy)
+build_test_bin_and_run(rwlock-wlock-null)
+if(JEFFPC_LOCK_TRACKING)
+# NOTE: These tests rely on checks that are not performed when lock tracking
+# is disabled.
+build_test_bin_and_run(rwlock-destroy-rheld)
+build_test_bin_and_run(rwlock-destroy-wheld)
+build_test_bin_and_run(rwlock-rlock-rheld)
+build_test_bin_and_run(rwlock-rlock-wheld)
+build_test_bin_and_run(rwlock-rlock-held-multi-first)
+build_test_bin_and_run(rwlock-rlock-held-multi-second)
+build_test_bin_and_run(rwlock-rlock-held-multi-third)
+build_test_bin_and_run(rwlock-unlock-unheld)
+build_test_bin_and_run(rwlock-wlock-rheld)
+build_test_bin_and_run(rwlock-wlock-wheld)
+build_test_bin_and_run(rwlock-wlock-held-multi-first)
+build_test_bin_and_run(rwlock-wlock-held-multi-second)
+build_test_bin_and_run(rwlock-wlock-held-multi-third)
+endif()
 build_test_bin_and_run(sexpr_compact)
 build_test_bin_and_run(sexpr_eval)
 build_test_bin_and_run(sexpr_iter)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-destroy-memcpy.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	LOCK_CLASS(lc);
+	struct rwlock a;
+	struct rwlock b;
+
+	RWINIT(&a, &lc);
+
+	b = a;
+
+	test_set_panic_string("lockdep: Aborting - bad rwlock magic");
+
+	RWDESTROY(&b);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-destroy-null.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	test_set_panic_string("lockdep: invalid call to RWDESTROY");
+
+	RWDESTROY(NULL);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-destroy-rheld.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	LOCK_CLASS(lc);
+	struct rwlock a;
+
+	RWINIT(&a, &lc);
+	RWLOCK(&a, false);
+
+	test_set_panic_string("lockdep: Aborting - destroying held rwlock");
+
+	RWDESTROY(&a);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-destroy-wheld.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	LOCK_CLASS(lc);
+	struct rwlock a;
+
+	RWINIT(&a, &lc);
+	RWLOCK(&a, true);
+
+	test_set_panic_string("lockdep: Aborting - destroying held rwlock");
+
+	RWDESTROY(&a);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-init-null-both.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	test_set_panic_string("lockdep: invalid call to RWINIT");
+
+	RWINIT(NULL, NULL);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-init-null-class.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	struct rwlock a;
+
+	test_set_panic_string("lockdep: invalid call to RWINIT");
+
+	RWINIT(&a, NULL);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-init-null-lock.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	LOCK_CLASS(c1);
+
+	test_set_panic_string("lockdep: invalid call to RWINIT");
+
+	RWINIT(NULL, &c1);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-lock-held-multi-common.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+static LOCK_CLASS(lc1);
+static LOCK_CLASS(lc2);
+static LOCK_CLASS(lc3);
+static struct rwlock a;
+static struct rwlock b;
+static struct rwlock c;
+
+static void test_setup(bool wr)
+{
+	RWINIT(&a, &lc1);
+	RWINIT(&b, &lc2);
+	RWINIT(&c, &lc3);
+	RWLOCK(&a, wr);
+	RWLOCK(&b, wr);
+	RWLOCK(&c, wr);
+
+	test_set_panic_string("lockdep: Aborting - deadlock");
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-rlock-destroyed.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	LOCK_CLASS(lc);
+	struct rwlock a;
+
+	RWINIT(&a, &lc);
+	RWDESTROY(&a);
+
+	test_set_panic_string("lockdep: Aborting - bad rwlock magic");
+
+	RWLOCK(&a, false);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-rlock-held-class.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	LOCK_CLASS(lc);
+	struct rwlock a;
+	struct rwlock b;
+
+	RWINIT(&a, &lc);
+	RWINIT(&b, &lc);
+	RWLOCK(&a, false);
+	RWLOCK(&b, false);
+
+	/* TODO: check lockdep state */
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-rlock-held-multi-first.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "test_rwlock-lock-held-multi-common.c"
+
+void test(void)
+{
+	test_setup(false);
+
+	RWLOCK(&a, false);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-rlock-held-multi-second.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "test_rwlock-lock-held-multi-common.c"
+
+void test(void)
+{
+	test_setup(false);
+
+	RWLOCK(&b, false);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-rlock-held-multi-third.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "test_rwlock-lock-held-multi-common.c"
+
+void test(void)
+{
+	test_setup(false);
+
+	RWLOCK(&c, false);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-rlock-held-nesting.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+#define NLOCKS	(JEFFPC_LOCK_STACK_DEPTH + 1)
+
+void test(void)
+{
+	struct lock_class lc[NLOCKS];
+	struct rwlock lock[NLOCKS];
+	size_t i;
+
+	for (i = 0; i < NLOCKS; i++) {
+		char *name;
+
+		/* initialize the lock class */
+		asprintf(&name, "class %zu", i);
+		memset(&lc[i], 0, sizeof(struct lock_class));
+		lc[i].name = name;
+
+		/* initialize the lock */
+		RWINIT(&lock[i], &lc[i]);
+	}
+
+	/* lock enough to fill up the stack */
+	for (i = 0; i < (NLOCKS - 1); i++)
+		RWLOCK(&lock[i], false);
+
+	/* lock another lock to overflow the stack */
+	RWLOCK(&lock[NLOCKS - 1], false);
+
+	/* TODO: check lockdep state */
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-rlock-memcpy.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	LOCK_CLASS(lc);
+	struct rwlock a;
+	struct rwlock b;
+
+	RWINIT(&a, &lc);
+
+	b = a;
+
+	test_set_panic_string("lockdep: Aborting - bad rwlock magic");
+
+	RWLOCK(&b, false);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-rlock-null.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	test_set_panic_string("lockdep: invalid call to RWLOCK");
+
+	RWLOCK(NULL, false);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-rlock-rheld.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	LOCK_CLASS(lc);
+	struct rwlock a;
+
+	RWINIT(&a, &lc);
+	RWLOCK(&a, false);
+
+	test_set_panic_string("lockdep: Aborting - deadlock");
+
+	RWLOCK(&a, false);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-rlock-wheld.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	LOCK_CLASS(lc);
+	struct rwlock a;
+
+	RWINIT(&a, &lc);
+	RWLOCK(&a, true);
+
+	test_set_panic_string("lockdep: Aborting - deadlock");
+
+	RWLOCK(&a, false);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-unlock-destroyed.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	LOCK_CLASS(lc);
+	struct rwlock a;
+
+	RWINIT(&a, &lc);
+	RWDESTROY(&a);
+
+	test_set_panic_string("lockdep: Aborting - bad rwlock magic");
+
+	RWUNLOCK(&a);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-unlock-memcpy.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2018 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	LOCK_CLASS(lc);
+	struct rwlock a;
+	struct rwlock b;
+
+	RWINIT(&a, &lc);
+
+	b = a;
+
+	test_set_panic_string("lockdep: Aborting - bad rwlock magic");
+
+	RWUNLOCK(&b);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-unlock-null.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	test_set_panic_string("lockdep: invalid call to RWUNLOCK");
+
+	RWUNLOCK(NULL);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-unlock-unheld.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	LOCK_CLASS(lc);
+	struct rwlock a;
+
+	RWINIT(&a, &lc);
+
+	test_set_panic_string("lockdep: Aborting - releasing unheld rwlock");
+
+	RWUNLOCK(&a);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-wlock-destroyed.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	LOCK_CLASS(lc);
+	struct rwlock a;
+
+	RWINIT(&a, &lc);
+	RWDESTROY(&a);
+
+	test_set_panic_string("lockdep: Aborting - bad rwlock magic");
+
+	RWLOCK(&a, true);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-wlock-held-class.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	LOCK_CLASS(lc);
+	struct rwlock a;
+	struct rwlock b;
+
+	RWINIT(&a, &lc);
+	RWINIT(&b, &lc);
+	RWLOCK(&a, true);
+	RWLOCK(&b, true);
+
+	/* TODO: check lockdep state */
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-wlock-held-multi-first.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "test_rwlock-lock-held-multi-common.c"
+
+void test(void)
+{
+	test_setup(true);
+
+	RWLOCK(&a, true);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-wlock-held-multi-second.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "test_rwlock-lock-held-multi-common.c"
+
+void test(void)
+{
+	test_setup(true);
+
+	RWLOCK(&b, true);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-wlock-held-multi-third.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "test_rwlock-lock-held-multi-common.c"
+
+void test(void)
+{
+	test_setup(true);
+
+	RWLOCK(&c, true);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-wlock-held-nesting.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+#define NLOCKS	(JEFFPC_LOCK_STACK_DEPTH + 1)
+
+void test(void)
+{
+	struct lock_class lc[NLOCKS];
+	struct rwlock lock[NLOCKS];
+	size_t i;
+
+	for (i = 0; i < NLOCKS; i++) {
+		char *name;
+
+		/* initialize the lock class */
+		asprintf(&name, "class %zu", i);
+		memset(&lc[i], 0, sizeof(struct lock_class));
+		lc[i].name = name;
+
+		/* initialize the lock */
+		RWINIT(&lock[i], &lc[i]);
+	}
+
+	/* lock enough to fill up the stack */
+	for (i = 0; i < (NLOCKS - 1); i++)
+		RWLOCK(&lock[i], true);
+
+	/* lock another lock to overflow the stack */
+	RWLOCK(&lock[NLOCKS - 1], true);
+
+	/* TODO: check lockdep state */
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-wlock-memcpy.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	LOCK_CLASS(lc);
+	struct rwlock a;
+	struct rwlock b;
+
+	RWINIT(&a, &lc);
+
+	b = a;
+
+	test_set_panic_string("lockdep: Aborting - bad rwlock magic");
+
+	RWLOCK(&b, true);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-wlock-null.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	test_set_panic_string("lockdep: invalid call to RWLOCK");
+
+	RWLOCK(NULL, true);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-wlock-rheld.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	LOCK_CLASS(lc);
+	struct rwlock a;
+
+	RWINIT(&a, &lc);
+	RWLOCK(&a, false);
+
+	test_set_panic_string("lockdep: Aborting - deadlock");
+
+	RWLOCK(&a, true);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_rwlock-wlock-wheld.c	Sun Aug 11 12:18:09 2019 -0400
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2018-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/synch.h>
+
+#include "test.c"
+
+void test(void)
+{
+	LOCK_CLASS(lc);
+	struct rwlock a;
+
+	RWINIT(&a, &lc);
+	RWLOCK(&a, true);
+
+	test_set_panic_string("lockdep: Aborting - deadlock");
+
+	RWLOCK(&a, true);
+}