Skip to content

Commit 036108f

Browse files
committed
csdiff: implement --filter-file option
1 parent 38aec91 commit 036108f

18 files changed

+239
-2
lines changed

src/csdiff.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ int main(int argc, char *argv[])
5050
("json-output,j", "write the result in JSON format")
5151
("html-output", "write the result in HTML format")
5252
("file-rename,s", po::value<TStringList>(),
53-
"account the file base-name change, [OLD,NEW] (*testing*)");
53+
"account the file base-name change, [OLD,NEW] (*testing*)")
54+
("filter-file,f", po::value<TStringList>(),
55+
"read custom filtering rules from a file in JSON format");
5456

5557
addColorOptions(&desc);
5658

@@ -151,6 +153,13 @@ int main(int argc, char *argv[])
151153
const bool showInternal = vm.count("show-internal");
152154
const bool silent = vm.count("quiet");
153155

156+
if (vm.count("filter-file")) {
157+
const TStringList &filterFiles = vm["filter-file"].as<TStringList>();
158+
if (!MsgFilter::inst()->setFilterFiles(filterFiles, silent))
159+
// an error message already printed out
160+
return 1;
161+
}
162+
154163
try {
155164
// open streams
156165
InStream strOld(fnOld, silent);

tests/csdiff/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2011 - 2020 Red Hat, Inc.
1+
# Copyright (C) 2011 - 2021 Red Hat, Inc.
22
#
33
# This file is part of csdiff.
44
#
@@ -77,3 +77,5 @@ test_csdiff(diff-misc 09-shellcheck-raw)
7777
test_csdiff(diff-misc 10-pylint-copr)
7878
test_csdiff(diff-misc 11-pylint-copr-json)
7979
test_csdiff(diff-misc 12-shellcheck-sc222x)
80+
81+
add_subdirectory(filter-file)

tests/csdiff/filter-file/01-basic-add-z.err

Whitespace-only changes.

tests/csdiff/filter-file/01-basic-add.err

Whitespace-only changes.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"msg-filter" : [
3+
{
4+
"checker" : "DIVINE|SYMBIOTIC",
5+
"regexp" : "memory"
6+
},
7+
{
8+
"checker" : "COMPILER_WARNING",
9+
"regexp" : "called on unallocated object",
10+
"replace" : "called correctly, no UB here"
11+
}
12+
]
13+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Error: COMPILER_WARNING:
2+
/home/lukas/aufover-benchmark/tests/single-c/mem-basic-calloc/0004-calloc-plain-leak/0004-test.c: scope_hint: In function 'main'
3+
/home/lukas/aufover-benchmark/tests/single-c/mem-basic-calloc/0004-calloc-plain-leak/0004-test.c:5:5: warning[-Wunused-result]: ignoring return value of 'calloc' declared with attribute 'warn_unused_result'
4+
# 5 | calloc(1, sizeof(char)); /* leak */
5+
# | ^~~~~~~~~~~~~~~~~~~~~~~
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Error: COMPILER_WARNING:
2+
/home/lukas/aufover-benchmark/tests/single-c/mem-basic-calloc/0004-calloc-plain-leak/0004-test.c: scope_hint: In function 'main'
3+
/home/lukas/aufover-benchmark/tests/single-c/mem-basic-calloc/0004-calloc-plain-leak/0004-test.c:5:5: warning[-Wunused-result]: ignoring return value of 'calloc' declared with attribute 'warn_unused_result'
4+
# 5 | calloc(1, sizeof(char)); /* leak */
5+
# | ^~~~~~~~~~~~~~~~~~~~~~~
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Error: COMPILER_WARNING:
2+
/home/lukas/aufover-benchmark/tests/single-c/mem-basic-free/0006-free-stack/0006-test.c: scope_hint: In function 'main'
3+
/home/lukas/aufover-benchmark/tests/single-c/mem-basic-free/0006-free-stack/0006-test.c:6:5: warning[-Wfree-nonheap-object]: 'free' called correctly, no UB here 'a'
4+
# 6 | free(&a); /* invalid free */
5+
# | ^~~~~~~~
6+
/home/lukas/aufover-benchmark/tests/single-c/mem-basic-free/0006-free-stack/0006-test.c:5:9: note: declared here
7+
# 5 | int a;
8+
# | ^
9+
10+
Error: SYMBIOTIC_WARNING:
11+
/home/lukas/aufover-benchmark/tests/single-c/mem-basic-malloc/0009-malloc-zerosize-leak/0009-test.c:10: error: memory error: memory not cleaned up
12+
/home/lukas/aufover-benchmark/tests/single-c/mem-basic-malloc/0009-malloc-zerosize-leak/0009-test.c:10: note: call stack: main ()
13+
14+
Error: DIVINE_WARNING:
15+
/home/lukas/tmp/assert-bounds.c: scope_hint: In function 'main':
16+
/home/lukas/tmp/assert-bounds.c:8: error: access of size 1 at [alloca*] is 1 bytes out of bounds
17+
/home/lukas/tmp/assert-bounds.c:8: note: memory error in userspace
18+
/opt/divine/include/dios/sys/fault.hpp:119: note: void __dios::FaultBase::handler<__dios::Context>(_VM_Fault, _VM_Frame*, void (*)())
19+
/home/lukas/tmp/assert-bounds.c:8: note: main
20+
/opt/divine/include/dios/libc/sys/start.cpp:91: note: __dios_start
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Error: COMPILER_WARNING:
2+
/home/lukas/aufover-benchmark/tests/single-c/mem-basic-free/0006-free-stack/0006-test.c: scope_hint: In function 'main'
3+
/home/lukas/aufover-benchmark/tests/single-c/mem-basic-free/0006-free-stack/0006-test.c:6:5: warning[-Wfree-nonheap-object]: 'free' called on unallocated object 'a'
4+
# 6 | free(&a); /* invalid free */
5+
# | ^~~~~~~~
6+
/home/lukas/aufover-benchmark/tests/single-c/mem-basic-free/0006-free-stack/0006-test.c:5:9: note: declared here
7+
# 5 | int a;
8+
# | ^
9+
10+
Error: COMPILER_WARNING:
11+
/home/lukas/aufover-benchmark/tests/single-c/mem-basic-calloc/0004-calloc-plain-leak/0004-test.c: scope_hint: In function 'main'
12+
/home/lukas/aufover-benchmark/tests/single-c/mem-basic-calloc/0004-calloc-plain-leak/0004-test.c:5:5: warning[-Wunused-result]: ignoring return value of 'calloc' declared with attribute 'warn_unused_result'
13+
# 5 | calloc(1, sizeof(char)); /* leak */
14+
# | ^~~~~~~~~~~~~~~~~~~~~~~
15+
16+
Error: SYMBIOTIC_WARNING:
17+
/home/lukas/aufover-benchmark/tests/single-c/mem-basic-malloc/0009-malloc-zerosize-leak/0009-test.c:10: error: memory error: memory not cleaned up
18+
/home/lukas/aufover-benchmark/tests/single-c/mem-basic-malloc/0009-malloc-zerosize-leak/0009-test.c:10: note: call stack: main ()
19+
20+
Error: DIVINE_WARNING:
21+
/home/lukas/tmp/assert-bounds.c: scope_hint: In function 'main':
22+
/home/lukas/tmp/assert-bounds.c:8: error: access of size 1 at [alloca*] is 1 bytes out of bounds
23+
/home/lukas/tmp/assert-bounds.c:8: note: memory error in userspace
24+
/opt/divine/include/dios/sys/fault.hpp:119: note: void __dios::FaultBase::handler<__dios::Context>(_VM_Fault, _VM_Frame*, void (*)())
25+
/home/lukas/tmp/assert-bounds.c:8: note: main
26+
/opt/divine/include/dios/libc/sys/start.cpp:91: note: __dios_start
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Error: COMPILER_WARNING:
2+
/home/lukas/aufover-benchmark/tests/single-c/mem-basic-free/0006-free-stack/0006-test.c: scope_hint: In function 'main'
3+
/home/lukas/aufover-benchmark/tests/single-c/mem-basic-free/0006-free-stack/0006-test.c:6:5: warning[-Wfree-nonheap-object]: 'free' called correctly, no UB here 'a'
4+
# 6 | free(&a); /* invalid free */
5+
# | ^~~~~~~~
6+
/home/lukas/aufover-benchmark/tests/single-c/mem-basic-free/0006-free-stack/0006-test.c:5:9: note: declared here
7+
# 5 | int a;
8+
# | ^

0 commit comments

Comments
 (0)