Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CPPFLAGS to dmake Makefile generation #449

Closed
wants to merge 2 commits into from

Conversation

LocutusOfBorg
Copy link
Contributor

This is a follow up after the bad #424 pull request

@LocutusOfBorg
Copy link
Contributor Author

The reason for #424 was that debian is not able to run testsuite (version 1.66) because the cfg files are not found

Tests failed: 18

Assertion failed in test/testsamples.cpp at line 76
Expected:
[samples\AssignmentAddressToInteger\bad.c:3]: (portability) Assigning a pointer to an integer is not portable.\n

Actual:
(information) Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled with CFGDIR set to \"\usr\share\cppcheck\cfg\" and will therefore search for std.cfg in that path.\n

Hint:
samples/AssignmentAddressToInteger/bad.c
_____
Assertion failed in test/testsamples.cpp at line 64
Expected:

Actual:
(information) Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled with CFGDIR set to \"/usr/share/cppcheck/cfg\" and will therefore search for std.cfg in that path.\n

Hint:
samples/AssignmentAddressToInteger/good.c
_____
Assertion failed in test/testsamples.cpp at line 76
Expected:
[samples\arrayIndexOutOfBounds\bad.c:6]: (error) Array 'a[2]' accessed at index 2, which is out of bounds.\n

Actual:
(information) Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled with CFGDIR set to \"\usr\share\cppcheck\cfg\" and will therefore search for std.cfg in that path.\n

Hint:
samples/arrayIndexOutOfBounds/bad.c
_____
Assertion failed in test/testsamples.cpp at line 64
Expected:

Actual:
(information) Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled with CFGDIR set to \"/usr/share/cppcheck/cfg\" and will therefore search for std.cfg in that path.\n

Hint:
samples/arrayIndexOutOfBounds/good.c
_____
Assertion failed in test/testsamples.cpp at line 76
Expected:
[samples\autoVariables\bad.c:4]: (error) Address of local auto-variable assigned to a function parameter.\n

Actual:
(information) Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled with CFGDIR set to \"\usr\share\cppcheck\cfg\" and will therefore search for std.cfg in that path.\n

Hint:
samples/autoVariables/bad.c
_____
Assertion failed in test/testsamples.cpp at line 64
Expected:

Actual:
(information) Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled with CFGDIR set to \"/usr/share/cppcheck/cfg\" and will therefore search for std.cfg in that path.\n

Hint:
samples/autoVariables/good.c
_____
Assertion failed in test/testsamples.cpp at line 76
Expected:
[samples\bufferAccessOutOfBounds\bad.c:6]: (error) Array 'a[2]' accessed at index 2, which is out of bounds.\n

Actual:
(information) Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled with CFGDIR set to \"\usr\share\cppcheck\cfg\" and will therefore search for std.cfg in that path.\n

Hint:
samples/bufferAccessOutOfBounds/bad.c
_____
Assertion failed in test/testsamples.cpp at line 64
Expected:

Actual:
(information) Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled with CFGDIR set to \"/usr/share/cppcheck/cfg\" and will therefore search for std.cfg in that path.\n

Hint:
samples/bufferAccessOutOfBounds/good.c
_____
Assertion failed in test/testsamples.cpp at line 76
Expected:
[samples\erase\bad.cpp:9] -> [samples\erase\bad.cpp:11]: (error) Iterator 'iter' used after element has been erased.\n

Actual:
(information) Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled with CFGDIR set to \"\usr\share\cppcheck\cfg\" and will therefore search for std.cfg in that path.\n

Hint:
samples/erase/bad.cpp
_____
Assertion failed in test/testsamples.cpp at line 64
Expected:

Actual:
(information) Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled with CFGDIR set to \"/usr/share/cppcheck/cfg\" and will therefore search for std.cfg in that path.\n

Hint:
samples/erase/good.cpp
_____
Assertion failed in test/testsamples.cpp at line 76
Expected:
[samples\memleak\bad.c:8]: (error) Memory leak: a\n

Actual:
(information) Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled with CFGDIR set to \"\usr\share\cppcheck\cfg\" and will therefore search for std.cfg in that path.\n

Hint:
samples/memleak/bad.c
_____
Assertion failed in test/testsamples.cpp at line 64
Expected:

Actual:
(information) Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled with CFGDIR set to \"/usr/share/cppcheck/cfg\" and will therefore search for std.cfg in that path.\n

Hint:
samples/memleak/good.c
_____
Assertion failed in test/testsamples.cpp at line 76
Expected:
[samples\outOfBounds\bad.c:5]: (error) snprintf size is out of bounds: Supplied size 10 is larger than actual size 5.\n

Actual:
(information) Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled with CFGDIR set to \"\usr\share\cppcheck\cfg\" and will therefore search for std.cfg in that path.\n

Hint:
samples/outOfBounds/bad.c
_____
Assertion failed in test/testsamples.cpp at line 64
Expected:

Actual:
(information) Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled with CFGDIR set to \"/usr/share/cppcheck/cfg\" and will therefore search for std.cfg in that path.\n

Hint:
samples/outOfBounds/good.c
_____
Assertion failed in test/testsamples.cpp at line 76
Expected:
[samples\resourceLeak\bad.c:8]: (error) Resource leak: a\n

Actual:
(information) Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled with CFGDIR set to \"\usr\share\cppcheck\cfg\" and will therefore search for std.cfg in that path.\n

Hint:
samples/resourceLeak/bad.c
_____
Assertion failed in test/testsamples.cpp at line 64
Expected:

Actual:
(information) Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled with CFGDIR set to \"/usr/share/cppcheck/cfg\" and will therefore search for std.cfg in that path.\n

Hint:
samples/resourceLeak/good.c
_____
Assertion failed in test/testsamples.cpp at line 76
Expected:
[samples\syntaxError\bad.c:2]: (error) Invalid number of character ({) when these macros are defined: 'A'.\n

Actual:
(information) Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled with CFGDIR set to \"\usr\share\cppcheck\cfg\" and will therefore search for std.cfg in that path.\n

Hint:
samples/syntaxError/bad.c
_____
Assertion failed in test/testsamples.cpp at line 64
Expected:

Actual:
(information) Failed to load std.cfg. Your Cppcheck installation is broken, please re-install. The Cppcheck binary was compiled with CFGDIR set to \"/usr/share/cppcheck/cfg\" and will therefore search for std.cfg in that path.\n

Hint:
samples/syntaxError/good.c
_____
make[2]: *** [test] Error 1
dh_auto_test: make -j1 test HAVE_RULES=yes TINYXML=-ltinyxml2 INCLUDE_FOR_LIB=-Ilib INCLUDE_FOR_CLI=-Ilib INCLUDE_FOR_TEST=-Ilib -Icli returned exit code 2

the patch to make them run successfully is this one:

--- cppcheck-1.66.orig/cli/cppcheckexecutor.cpp
+++ cppcheck-1.66/cli/cppcheckexecutor.cpp
@@ -696,10 +696,10 @@ int CppCheckExecutor::check_internal(Cpp
 {
     Settings& settings = cppcheck.settings();
     _settings = &settings;
-    bool std = (settings.library.load(argv[0], "std.cfg").errorcode == Library::OK);
+    bool std = (settings.library.load(argv[0], "std.cfg").errorcode == Library::OK || settings.library.load(argv[0], "cfg/std.cfg").errorcode == Lib$
     bool posix = true;
     if (settings.standards.posix)
-        posix = (settings.library.load(argv[0], "posix.cfg").errorcode == Library::OK);
+        posix = (settings.library.load(argv[0], "posix.cfg").errorcode == Library::OK || settings.library.load(argv[0], "cfg/posix.cfg").errorcode =$

     if (!std || !posix) {
         const std::list<ErrorLogger::ErrorMessage::FileLocation> callstack;

however this file seems to have been removed on latest master, I'm investigating right now

@LocutusOfBorg
Copy link
Contributor Author

12ed4e6 should fix the testsuite failure

@danmar
Copy link
Owner

danmar commented Sep 26, 2014

how do I reproduce? what are you doing?

I use debian and the "make test" works fine here. No matter if I use CFGDIR or not.

@danmar
Copy link
Owner

danmar commented Sep 26, 2014

For me.. this works:

make  clean
make test

This also works:

make clean
make CFGDIR=/home/daniel/cppcheck/cfg test

@LocutusOfBorg
Copy link
Contributor Author

Steps to reproduce:
remove the installed cppcheck configuration file (yes, tests needs to be run prior to install a package, not after)

CFGDIR=/usr/share/cppcheck/cfg make test -j4 HAVE_RULES=yes TINYXML=-ltinyxml2 INCLUDE_FOR_LIB=-Ilib INCLUDE_FOR_CLI=-Ilib "INCLUDE_FOR_TEST=-Ilib -Icli"

enjoy your crash.
(yes, debian testing has the correct tinyxml2 library available)

the tests in "samples" expects that the configuration file is available system-wide, and my commit adds the local conf file as fallback if the first one isn't available.

Again, build machines forbids installation of stuff outside the build directory, and installs something only if testsuite pass (obviously). Now debian has the testsuite disabled because samples cannot be run if the conf file is not installed.
My commit is not the best one, but it is the easiest one I could think of ;)

@danmar
Copy link
Owner

danmar commented Sep 30, 2014

I am not sure about this. I like that testrunner fails if something bad happens.

why don't you run a normal 'make test' without the bad configuration first?

@LocutusOfBorg
Copy link
Contributor Author

can you please define "bad" configuration? it isn't "bad", since it it where it is supposed to be installed.
The whole point is that tests should be able to run locally without any "make install" prior.
this isn't "bad", since in the final configuration (after the make install) everything will be good

@danmar
Copy link
Owner

danmar commented Sep 30, 2014

You can run the tests locally without any prior "make install".

make test
make clean
... build cppcheck, copy files, etc ...

I'd expect that if CFGDIR is specified then testrunner will use that path. If that path doesn't work then I expect a failure. What if I want to run the testrunner on nonlocal cfg files (/home/daniel/cfg). but I mistype the path or something and then the testrunner silently uses my local cfg files instead.

@LocutusOfBorg
Copy link
Contributor Author

What if I want to run the testrunner on nonlocal cfg files (/home/daniel/cfg). but I mistype the path or something and then the testrunner silently uses my local cfg files instead.

is that a problem?
we can add a warning about this

@PKEuS
Copy link
Contributor

PKEuS commented Jul 31, 2016

Closing this as there are no updates.

@PKEuS PKEuS closed this Jul 31, 2016
@LocutusOfBorg
Copy link
Contributor Author

@PKEuS I'm not sure why it has been closed, what should I do to have a testsuite working during build?

@danmar
Copy link
Owner

danmar commented Aug 1, 2016

I made a fix with 095b2f7

Now the tests will execute with this command even though "/a/b" does not exist (yet)..

make CFGDIR=/a/b test

@LocutusOfBorg
Copy link
Contributor Author

thanks!

@LocutusOfBorg LocutusOfBorg deleted the patch-1 branch August 1, 2016 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants