diff options
author | Matthew Wilcox <willy@infradead.org> | 2018-05-19 16:30:54 -0400 |
---|---|---|
committer | Matthew Wilcox <willy@infradead.org> | 2018-08-21 23:31:20 -0400 |
commit | d1c0d5e3c63d61226a75f24d5c35fe20755f0180 (patch) | |
tree | e29ecd34507fc26355626633e4d433955a67643b | |
parent | c9b933521aa5795f5b9b6f9809325d6b21710d78 (diff) |
radix tree test suite: Enable ubsan
Add support for the undefined behaviour sanitizer and fix the bugs
that ubsan pointed out. Nothing major, and all in the test suite,
not the code.
Signed-off-by: Matthew Wilcox <willy@infradead.org>
-rw-r--r-- | tools/testing/radix-tree/Makefile | 5 | ||||
-rw-r--r-- | tools/testing/radix-tree/main.c | 20 |
2 files changed, 14 insertions, 11 deletions
diff --git a/tools/testing/radix-tree/Makefile b/tools/testing/radix-tree/Makefile index db66f8a0d4be..da030a65d6d6 100644 --- a/tools/testing/radix-tree/Makefile +++ b/tools/testing/radix-tree/Makefile | |||
@@ -1,7 +1,8 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
2 | 2 | ||
3 | CFLAGS += -I. -I../../include -g -O2 -Wall -D_LGPL_SOURCE -fsanitize=address | 3 | CFLAGS += -I. -I../../include -g -Og -Wall -D_LGPL_SOURCE -fsanitize=address \ |
4 | LDFLAGS += -fsanitize=address | 4 | -fsanitize=undefined |
5 | LDFLAGS += -fsanitize=address -fsanitize=undefined | ||
5 | LDLIBS+= -lpthread -lurcu | 6 | LDLIBS+= -lpthread -lurcu |
6 | TARGETS = main idr-test multiorder | 7 | TARGETS = main idr-test multiorder |
7 | CORE_OFILES := radix-tree.o idr.o linux.o test.o find_bit.o | 8 | CORE_OFILES := radix-tree.o idr.o linux.o test.o find_bit.o |
diff --git a/tools/testing/radix-tree/main.c b/tools/testing/radix-tree/main.c index 257f3f8aacaa..584a8732f5ce 100644 --- a/tools/testing/radix-tree/main.c +++ b/tools/testing/radix-tree/main.c | |||
@@ -27,20 +27,22 @@ void __gang_check(unsigned long middle, long down, long up, int chunk, int hop) | |||
27 | item_check_present(&tree, middle + idx); | 27 | item_check_present(&tree, middle + idx); |
28 | item_check_absent(&tree, middle + up); | 28 | item_check_absent(&tree, middle + up); |
29 | 29 | ||
30 | item_gang_check_present(&tree, middle - down, | 30 | if (chunk > 0) { |
31 | up + down, chunk, hop); | 31 | item_gang_check_present(&tree, middle - down, up + down, |
32 | item_full_scan(&tree, middle - down, down + up, chunk); | 32 | chunk, hop); |
33 | item_full_scan(&tree, middle - down, down + up, chunk); | ||
34 | } | ||
33 | item_kill_tree(&tree); | 35 | item_kill_tree(&tree); |
34 | } | 36 | } |
35 | 37 | ||
36 | void gang_check(void) | 38 | void gang_check(void) |
37 | { | 39 | { |
38 | __gang_check(1 << 30, 128, 128, 35, 2); | 40 | __gang_check(1UL << 30, 128, 128, 35, 2); |
39 | __gang_check(1 << 31, 128, 128, 32, 32); | 41 | __gang_check(1UL << 31, 128, 128, 32, 32); |
40 | __gang_check(1 << 31, 128, 128, 32, 100); | 42 | __gang_check(1UL << 31, 128, 128, 32, 100); |
41 | __gang_check(1 << 31, 128, 128, 17, 7); | 43 | __gang_check(1UL << 31, 128, 128, 17, 7); |
42 | __gang_check(0xffff0000, 0, 65536, 17, 7); | 44 | __gang_check(0xffff0000UL, 0, 65536, 17, 7); |
43 | __gang_check(0xfffffffe, 1, 1, 17, 7); | 45 | __gang_check(0xfffffffeUL, 1, 1, 17, 7); |
44 | } | 46 | } |
45 | 47 | ||
46 | void __big_gang_check(void) | 48 | void __big_gang_check(void) |