Skip to content

Commit 9bbad1b

Browse files
committed
TestNullPointer: Moved posix.cfg tests
1 parent 80feb86 commit 9bbad1b

File tree

2 files changed

+4
-37
lines changed

2 files changed

+4
-37
lines changed

test/cfg/runtests.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ else # assume we are in repo root
99
DIR=./test/cfg/
1010
fi
1111

12+
# posix.c
13+
gcc -fsyntax-only ${DIR}posix.c
14+
${CPPCHECK} --check-library --library=posix --enable=information --error-exitcode=1 --inline-suppr ${DIR}posix.c
15+
1216
# std.c
1317
gcc -fsyntax-only ${DIR}std.c
1418
${CPPCHECK} --check-library --enable=information --error-exitcode=1 --inline-suppr ${DIR}std.c

test/testnullpointer.cpp

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@ class TestNullPointer : public TestFixture {
9595
TEST_CASE(nullpointer_internal_error); // #5080
9696
TEST_CASE(nullpointerFputc); // #5645 FP: Null pointer dereference in fputc argument
9797
TEST_CASE(nullpointerPutchar);
98-
99-
// Load posix library file
100-
LOAD_LIB_2(settings.library, "posix.cfg");
101-
// Test that posix.cfg is configured correctly
102-
TEST_CASE(posixcfg);
10398
}
10499

105100
void check(const char code[], bool inconclusive = false, const char filename[] = "test.cpp", bool verify=true) {
@@ -2470,38 +2465,6 @@ class TestNullPointer : public TestFixture {
24702465
"}\n");
24712466
ASSERT_EQUALS("[test.cpp:2]: (error) Null pointer dereference\n", errout.str());
24722467
}
2473-
2474-
void posixcfg() {
2475-
const char errp[] = "[test.cpp:1] -> [test.cpp:1]: (warning) Possible null pointer dereference: p - otherwise it is redundant to check it against null.\n";
2476-
2477-
check("void f(FILE *p){ isatty (*p);if(!p){}}");
2478-
ASSERT_EQUALS(errp,errout.str());
2479-
2480-
check("void f(){ isatty (0);}");
2481-
ASSERT_EQUALS("",errout.str());
2482-
2483-
check("void f(char *p){ mkdir (p, 0);}");
2484-
ASSERT_EQUALS("",errout.str());
2485-
2486-
check("void f(char *p){ int i = 0; mkdir (p, i);}");
2487-
ASSERT_EQUALS("",errout.str());
2488-
2489-
check("void f(){ getcwd (0, 0);}");
2490-
ASSERT_EQUALS("",errout.str());
2491-
2492-
check("void f(char *p){ mkdir (p, *0);}");
2493-
ASSERT_EQUALS("[test.cpp:1]: (error) Null pointer dereference\n",errout.str());
2494-
2495-
check("void foo()\n"
2496-
"{\n"
2497-
" char const * x = 0;\n"
2498-
" strdup(x);\n"
2499-
"}");
2500-
ASSERT_EQUALS("[test.cpp:4]: (error) Possible null pointer dereference: x\n", errout.str());
2501-
2502-
check("DIR* f(){ DIR *dirp = 0; return readdir (dirp);}");
2503-
ASSERT_EQUALS("[test.cpp:1]: (error) Possible null pointer dereference: dirp\n",errout.str());
2504-
}
25052468
};
25062469

25072470
REGISTER_TEST(TestNullPointer)

0 commit comments

Comments
 (0)