@@ -2826,7 +2826,6 @@ def test_ctu_path_builddir(tmp_path): # #11883
28262826 ]
28272827
28282828 exitcode_1 , stdout_1 , stderr_1 = cppcheck (args )
2829- print (stderr_1 )
28302829 assert exitcode_1 == 0 , stdout_1
28312830 assert stdout_1 == ''
28322831 assert stderr_1 .splitlines () == stderr_exp
@@ -2835,3 +2834,38 @@ def test_ctu_path_builddir(tmp_path): # #11883
28352834 assert exitcode_2 == 0 , stdout_2
28362835 assert stdout_2 == ''
28372836 assert stderr_2 .splitlines () == stderr_exp
2837+
2838+
2839+ @pytest .mark .xfail (strict = True )
2840+ def test_ctu_builddir (tmp_path ): # #11883
2841+ build_dir = tmp_path / 'b1'
2842+ os .mkdir (build_dir )
2843+
2844+ test_file = tmp_path / 'test.c'
2845+ with open (test_file , 'wt' ) as f :
2846+ f .write ("""
2847+ void f(int *p) { *p = 3; }
2848+ int main() {
2849+ int *p = 0;
2850+ f(p);
2851+ }
2852+ """ )
2853+
2854+ args = [
2855+ '-q' ,
2856+ '--template=simple' ,
2857+ '--enable=style' ,
2858+ '--suppress=nullPointer' , # we only care about the CTU findings
2859+ '--cppcheck-build-dir={}' .format (build_dir ),
2860+ '-j1' ,
2861+ '--emit-duplicates' ,
2862+ str (test_file )
2863+ ]
2864+
2865+ # the CTU was run and then evaluated again from the builddir leading to duplicated findings
2866+ exitcode , stdout , stderr = cppcheck (args )
2867+ assert exitcode == 0 , stdout
2868+ assert stdout == ''
2869+ assert stderr .splitlines () == [
2870+ '{}:2:19: error: Null pointer dereference: p [ctunullpointer]' .format (test_file )
2871+ ]
0 commit comments