libubox/tests/cram/test_list.t
Petr Štetiar bf680707ac tests: add unit tests covered with Clang sanitizers
Currently we run all tests via Valgrind. This patch adds 2nd batch of
tests which are compiled with Clang AddressSanitizer[1],
LeakSanitizer[2] and UndefinedBehaviorSanitizer[3] in order to catch
more issues during QA on CI.

AddressSanitizer is a fast memory error detector.  The tool can detect
the following types of bugs:

 * Out-of-bounds accesses to heap, stack and globals
 * Use-after-free, use-after-return, use-after-scope
 * Double-free, invalid free

LeakSanitizer is a run-time memory leak detector. It can be combined
with AddressSanitizer to get both memory error and leak detection, or
used in a stand-alone mode.

UndefinedBehaviorSanitizer (UBSan) is a fast undefined behavior
detector. UBSan modifies the program at compile-time to catch various
kinds of undefined behavior during program execution, for example:

 * Using misaligned or null pointer
 * Signed integer overflow
 * Conversion to, from, or between floating-point types which would
   overflow the destination

1. http://clang.llvm.org/docs/AddressSanitizer.html
2. http://http://clang.llvm.org/docs/LeakSanitizer.html
3. http://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html

Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-12-25 10:31:58 +01:00

42 lines
1.8 KiB
Perl

check that list is producing expected results:
$ [ -n "$TEST_BIN_DIR" ] && export PATH="$TEST_BIN_DIR:$PATH"
$ valgrind --quiet --leak-check=full test-list
test_basics: list_empty: yes
test_basics: list_add_tail: zero one two three four five six seven eight nine ten eleven twelve
test_basics: list_empty: no
test_basics: first=zero last=twelve
test_basics: 'zero' is first, yes
test_basics: 'twelve' is last, yes
test_basics: removing 'twelve' and 'zero'
test_basics: first=one last=eleven
test_basics: 'one' is first, yes
test_basics: 'eleven' is last, yes
test_basics: moving 'one' to the tail
test_basics: first=two last=one
test_basics: 'two' is first, yes
test_basics: 'one' is last, yes
test_basics: list_for_each_entry: two three four five six seven eight nine ten eleven one
test_basics: list_for_each_entry_reverse: one eleven ten nine eight seven six five four three two
test_basics: delete all entries
test_basics: list_empty: yes
$ test-list-san
test_basics: list_empty: yes
test_basics: list_add_tail: zero one two three four five six seven eight nine ten eleven twelve
test_basics: list_empty: no
test_basics: first=zero last=twelve
test_basics: 'zero' is first, yes
test_basics: 'twelve' is last, yes
test_basics: removing 'twelve' and 'zero'
test_basics: first=one last=eleven
test_basics: 'one' is first, yes
test_basics: 'eleven' is last, yes
test_basics: moving 'one' to the tail
test_basics: first=two last=one
test_basics: 'two' is first, yes
test_basics: 'one' is last, yes
test_basics: list_for_each_entry: two three four five six seven eight nine ten eleven one
test_basics: list_for_each_entry_reverse: one eleven ten nine eight seven six five four three two
test_basics: delete all entries
test_basics: list_empty: yes