Add unit test for --diffhitlist option

Signed-off-by: Labidurie Jerome <jerome.labidurie@orange.com>
This commit is contained in:
Labidurie Jerome 2019-05-17 10:08:33 +02:00
parent 280dc4a295
commit 8f8353df07
2 changed files with 29 additions and 1 deletions

17
correct-results-008.txt Normal file
View File

@ -0,0 +1,17 @@
Flawfinder version 2.0.9, (C) 2001-2017 David A. Wheeler.
Showing hits not in test-saved-hitlist-008.txt
Number of rules (primarily dangerous function names) in C/C++ ruleset: 223
ANALYSIS SUMMARY:
No hits found.
Lines analyzed = 121
Physical Source Lines of Code (SLOC) = 84
Hits@level = [0] 0 [1] 0 [2] 0 [3] 0 [4] 0 [5] 0
Hits@level+ = [0+] 0 [1+] 0 [2+] 0 [3+] 0 [4+] 0 [5+] 0
Hits/KSLOC@level+ = [0+] 0 [1+] 0 [2+] 0 [3+] 0 [4+] 0 [5+] 0
Suppressed hits = 2 (use --neverignore to show them)
Minimum risk level = 1
There may be other security vulnerabilities; review your code!
See 'Secure Programming HOWTO'
(https://dwheeler.com/secure-programs) for more information.

View File

@ -181,11 +181,21 @@ test_007: setup.py
@test "`$(PYTHON) setup.py --license`" = 'GPL-2.0+'
@test "`$(PYTHON) setup.py --author`" = 'David A. Wheeler'
test_008: flawfinder test.c
@echo 'test_008 (diff hitlist)'
@$(PYTHON) ./flawfinder -S -DC --quiet \
--savehitlist test-saved-hitlist-008.txt \
test.c > test-junk-008.txt
@$(PYTHON) ./flawfinder -S -C --quiet --omittime \
--diffhitlist test-saved-hitlist-008.txt test.c > \
test-results-008.txt
@diff -u correct-results-008.txt test-results-008.txt
# Run all tests on *one* version of Python;
# output shows differences from expected results.
# If everything works as expected, it just prints test numbers.
# Set PYTHON as needed, including to ""
test: test_001 test_002 test_003 test_004 test_005 test_006 test_007
test: test_001 test_002 test_003 test_004 test_005 test_006 test_007 test_008
@echo 'All tests pass!'
# Usual check routine. Run all tests using *both* python2 and python3.
@ -204,6 +214,7 @@ test-is-correct: test-results.txt
cp -p test-results-004.txt correct-results-004.txt
cp -p test-results-005.txt correct-results-005.txt
cp -p test-results-006.txt correct-results-006.txt
cp -p test-results-008.txt correct-results-008.txt
profile:
/usr/lib/python1.5/profile.py ./flawfinder > profile-results $(SAMPLE_DIR)/*/*.[ch] > profile-results