# HG changeset patch # User Josef 'Jeff' Sipek # Date 1565540289 14400 # Node ID d83ac58d25009c9728bac736aa0b151fd4c9ee85 # Parent bc8880710efd7ed00c821bd848a542bd7c43fa82 synch: add rwlock tests Signed-off-by: Josef 'Jeff' Sipek diff -r bc8880710efd -r d83ac58d2500 tests/.hgignore --- 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 diff -r bc8880710efd -r d83ac58d2500 tests/CMakeLists.txt --- 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) diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-destroy-memcpy.c --- /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 + * + * 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 + +#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); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-destroy-null.c --- /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 + * + * 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 + +#include "test.c" + +void test(void) +{ + test_set_panic_string("lockdep: invalid call to RWDESTROY"); + + RWDESTROY(NULL); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-destroy-rheld.c --- /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 + * + * 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 + +#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); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-destroy-wheld.c --- /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 + * + * 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 + +#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); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-init-null-both.c --- /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 + * + * 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 + +#include "test.c" + +void test(void) +{ + test_set_panic_string("lockdep: invalid call to RWINIT"); + + RWINIT(NULL, NULL); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-init-null-class.c --- /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 + * + * 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 + +#include "test.c" + +void test(void) +{ + struct rwlock a; + + test_set_panic_string("lockdep: invalid call to RWINIT"); + + RWINIT(&a, NULL); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-init-null-lock.c --- /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 + * + * 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 + +#include "test.c" + +void test(void) +{ + LOCK_CLASS(c1); + + test_set_panic_string("lockdep: invalid call to RWINIT"); + + RWINIT(NULL, &c1); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-lock-held-multi-common.c --- /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 + * + * 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 + +#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"); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-rlock-destroyed.c --- /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 + * + * 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 + +#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); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-rlock-held-class.c --- /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 + * + * 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 + +#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 */ +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-rlock-held-multi-first.c --- /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 + * + * 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); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-rlock-held-multi-second.c --- /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 + * + * 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); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-rlock-held-multi-third.c --- /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 + * + * 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); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-rlock-held-nesting.c --- /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 + * + * 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 + +#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 */ +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-rlock-memcpy.c --- /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 + * + * 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 + +#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); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-rlock-null.c --- /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 + * + * 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 + +#include "test.c" + +void test(void) +{ + test_set_panic_string("lockdep: invalid call to RWLOCK"); + + RWLOCK(NULL, false); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-rlock-rheld.c --- /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 + * + * 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 + +#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); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-rlock-wheld.c --- /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 + * + * 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 + +#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); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-unlock-destroyed.c --- /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 + * + * 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 + +#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); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-unlock-memcpy.c --- /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 + * + * 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 + +#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); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-unlock-null.c --- /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 + * + * 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 + +#include "test.c" + +void test(void) +{ + test_set_panic_string("lockdep: invalid call to RWUNLOCK"); + + RWUNLOCK(NULL); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-unlock-unheld.c --- /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 + * + * 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 + +#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); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-wlock-destroyed.c --- /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 + * + * 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 + +#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); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-wlock-held-class.c --- /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 + * + * 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 + +#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 */ +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-wlock-held-multi-first.c --- /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 + * + * 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); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-wlock-held-multi-second.c --- /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 + * + * 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); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-wlock-held-multi-third.c --- /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 + * + * 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); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-wlock-held-nesting.c --- /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 + * + * 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 + +#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 */ +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-wlock-memcpy.c --- /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 + * + * 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 + +#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); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-wlock-null.c --- /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 + * + * 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 + +#include "test.c" + +void test(void) +{ + test_set_panic_string("lockdep: invalid call to RWLOCK"); + + RWLOCK(NULL, true); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-wlock-rheld.c --- /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 + * + * 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 + +#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); +} diff -r bc8880710efd -r d83ac58d2500 tests/test_rwlock-wlock-wheld.c --- /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 + * + * 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 + +#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); +}