Skip to content

Commit c6a5f55

Browse files
committed
Check cbmc-library regressions for completeness
This will make sure that newly added library functions are also covered by tests.
1 parent 4367e6e commit c6a5f55

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

src/ansi-c/library_check.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,65 @@ for f in "$@"; do
1919
rm __libcheck.s __libcheck.i __libcheck.c
2020
[ "${ec}" -eq 0 ] || exit "${ec}"
2121
done
22+
23+
# Make sure all internal library functions have tests exercising them:
24+
grep '^/\* FUNCTION:' ../*/library/* | cut -f3 -d" " | sort -u > __functions
25+
26+
# Some functions are not expected to have tests:
27+
perl -p -i -e 's/^__CPROVER_jsa_synthesise\n//' __functions
28+
perl -p -i -e 's/^java::java.io.InputStream.read:\(\)I\n//' __functions
29+
perl -p -i -e 's/^__CPROVER_contracts_library\n//' __functions
30+
31+
# Some functions are implicitly covered by running on different operating
32+
# systems:
33+
perl -p -i -e 's/^_fopen\n//' __functions # fopen, macOS
34+
perl -p -i -e 's/^_mmap\n//' __functions # mmap, macOS
35+
perl -p -i -e 's/^_munmap\n//' __functions # mumap, macOS
36+
perl -p -i -e 's/^_pipe\n//' __functions # pipe, macOS
37+
perl -p -i -e 's/^_setjmp\n//' __functions # pipe, macOS
38+
perl -p -i -e 's/^_time(32|64)\n//' __functions # time, Windows
39+
perl -p -i -e 's/^__isoc99_v?fscanf\n//' __functions # fscanf, Linux
40+
perl -p -i -e 's/^__isoc99_v?scanf\n//' __functions # scanf, Linux
41+
perl -p -i -e 's/^__isoc99_v?sscanf\n//' __functions # sscanf, Linux
42+
perl -p -i -e 's/^__sigsetjmp\n//' __functions # sigsetjmp, Linux
43+
perl -p -i -e 's/^__stdio_common_vfscanf\n//' __functions # fscanf, Windows
44+
perl -p -i -e 's/^__stdio_common_vsscanf\n//' __functions # sscanf, Windows
45+
46+
# Some functions are covered by existing tests:
47+
perl -p -i -e 's/^__CPROVER_deallocate\n//' __functions # free-01
48+
perl -p -i -e 's/^__builtin_alloca\n//' __functions # alloca-01
49+
perl -p -i -e 's/^fclose_cleanup\n//' __functions # fopen
50+
perl -p -i -e 's/^munmap\n//' __functions # mmap-01
51+
52+
# Some functions are covered by tests in other folders:
53+
perl -p -i -e 's/^__spawned_thread\n//' __functions # any pthread_create tests
54+
perl -p -i -e 's/^__builtin_ffsl?l?\n//' __functions # cbmc/__builtin_ffs-01
55+
perl -p -i -e 's/^__builtin_[su]addl?l?_overflow\n//' __functions # cbmc/gcc_builtin_add_overflow
56+
perl -p -i -e 's/^__builtin_[su]mull?l?_overflow\n//' __functions # cbmc/gcc_builtin_mul_overflow
57+
perl -p -i -e 's/^__builtin_[su]subl?l?_overflow\n//' __functions # cbmc/gcc_builtin_sub_overflow
58+
perl -p -i -e 's/^__builtin_ia32_p(add|sub)sw\n//' __functions # cbmc/SIMD1
59+
perl -p -i -e 's/^__builtin_ia32_psubu?sw128\n//' __functions # cbmc/SIMD1
60+
perl -p -i -e 's/^__builtin_ia32_vec_ext_v16qi\n//' __functions # cbmc/SIMD1
61+
perl -p -i -e 's/^__builtin_ia32_vec_ext_v2di\n//' __functions # cbmc/SIMD1
62+
perl -p -i -e 's/^__builtin_ia32_vec_ext_v4s[fi]\n//' __functions # cbmc/SIMD1
63+
perl -p -i -e 's/^__builtin_ia32_vec_ext_v[48]hi\n//' __functions # cbmc/SIMD1
64+
perl -p -i -e 's/^__builtin_ia32_vec_init_v4hi\n//' __functions # cbmc/SIMD1
65+
perl -p -i -e 's/^_mm_adds_ep[iu]16\n//' __functions # cbmc/SIMD1
66+
perl -p -i -e 's/^_mm_extract_epi(16|32)\n//' __functions # cbmc/SIMD1
67+
perl -p -i -e 's/^_mm_extract_pi16\n//' __functions # cbmc/SIMD1
68+
perl -p -i -e 's/^_mm_set_epi(16|32)\n//' __functions # cbmc/SIMD1
69+
perl -p -i -e 's/^_mm_set_pi16\n//' __functions # cbmc/SIMD1
70+
perl -p -i -e 's/^_mm_setr_epi(16|32)\n//' __functions # cbmc/SIMD1
71+
perl -p -i -e 's/^_mm_setr_pi16\n//' __functions # cbmc/SIMD1
72+
perl -p -i -e 's/^_mm_subs_ep[iu]16\n//' __functions # cbmc/SIMD1
73+
74+
ls ../../regression/cbmc-library/ | grep -- - | cut -f1 -d- | sort -u > __tests
75+
diff -u __tests __functions
76+
ec="${?}"
77+
rm __functions __tests
78+
if [ $ec != 0 ]; then
79+
echo "Tests and library functions don't match."
80+
echo "Lines prefixed with - are tests not matching any library function."
81+
echo "Lines prefixed with + are functions lacking a test."
82+
fi
83+
exit "${ec}"

0 commit comments

Comments
 (0)