-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #756 from guwirth/enhancement/CxxProjectBuilder
add an integration test example with absolute paths
- Loading branch information
Showing
8 changed files
with
126 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
integration-tests/testdata/cppcheck_with_absolute_paths_project/reports/cppcheck-v2.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<results version="2"> | ||
<cppcheck version="1.61"/> | ||
<errors> | ||
<error id="unusedVariable" severity="style" msg="Unused variable: x" verbose="Unused variable: x"> | ||
<location file="/home/travis/build/SonarOpenCommunity/sonar-cxx/integration-tests/testdata/cppcheck_with_absolute_paths_project/src/sample/component1.cc" line="15"/> | ||
</error> | ||
<error id="unreadVariable" severity="style" msg="Variable 'i' is assigned a value that is never used." verbose="Variable 'i' is assigned a value that is never used."> | ||
<location file="/home/travis/build/SonarOpenCommunity/sonar-cxx/integration-tests/testdata/cppcheck_with_absolute_paths_project/src/sample/component1.cc" line="35"/> | ||
</error> | ||
<error id="deallocDealloc" severity="error" msg="Deallocating a deallocated pointer: ip" verbose="Deallocating a deallocated pointer: ip"> | ||
<location file="/home/travis/build/SonarOpenCommunity/sonar-cxx/integration-tests/testdata/cppcheck_with_absolute_paths_project/src/sample/component1.cc" line="45"/> | ||
</error> | ||
<error id="doubleFree" severity="error" msg="Memory pointed to by 'ip' is freed twice." verbose="Memory pointed to by 'ip' is freed twice."> | ||
<location file="/home/travis/build/SonarOpenCommunity/sonar-cxx/integration-tests/testdata/cppcheck_with_absolute_paths_project/src/sample/component1.cc" line="45"/> | ||
</error> | ||
<error id="uninitvar" severity="error" msg="Uninitialized variable: a" verbose="Uninitialized variable: a"> | ||
<location file="/home/travis/build/SonarOpenCommunity/sonar-cxx/integration-tests/testdata/cppcheck_with_absolute_paths_project/src/sample/component1.cc" line="30"/> | ||
</error> | ||
<error id="unusedFunction" severity="style" msg="The function 'do_valgrind_errors' is never used." verbose="The function 'do_valgrind_errors' is never used."> | ||
<location file="/home/travis/build/SonarOpenCommunity/sonar-cxx/integration-tests/testdata/cppcheck_with_absolute_paths_project/src/sample/component1.cc" line="22"/> | ||
</error> | ||
</errors> | ||
</results> |
15 changes: 15 additions & 0 deletions
15
integration-tests/testdata/cppcheck_with_absolute_paths_project/sonar-project.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# required metadata | ||
sonar.projectKey=cppcheck_with_absolute_paths_project | ||
sonar.projectName=cppcheck_with_absolute_paths_project | ||
sonar.projectVersion=1.0.0 | ||
sonar.language=c++ | ||
|
||
# disable SCM support | ||
sonar.scm.disabled=true | ||
|
||
# path to source directories | ||
sonar.sources=. | ||
sonar.cxx.includeDirectories=. | ||
|
||
# paths to the reports | ||
sonar.cxx.cppcheck.reportPath=${TestDataFolder}/cppcheck_with_absolute_paths_project/reports/cppcheck-*.xml |
50 changes: 50 additions & 0 deletions
50
integration-tests/testdata/cppcheck_with_absolute_paths_project/src/sample/component1.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include \ | ||
"component1.hh" | ||
|
||
/** | ||
* Does something | ||
* | ||
* @return: an int indicating something | ||
*/ | ||
int Bar::foo(){ | ||
// single line comment | ||
|
||
/* | ||
* multi-line comment | ||
*/ | ||
int \ | ||
x; //unused variable | ||
|
||
return 111; | ||
} | ||
|
||
|
||
void Bar::do_valgrind_errors(){ | ||
///// lets provoke some valgrind errors ///// | ||
|
||
// Memory leak (definitely lost) | ||
new float(); | ||
|
||
// Condition depends on undefined value | ||
int a; | ||
if(a) a = a*a; | ||
|
||
// Invalid read | ||
int* ip = new int(0); | ||
delete ip; | ||
int i = *ip; | ||
|
||
// Invalid write | ||
ip = new int(0); | ||
delete ip; | ||
*ip = 1; | ||
|
||
// Invalid free | ||
ip = new int(0); | ||
delete ip; | ||
delete ip; | ||
|
||
// Mismatched free() / delete / delete [] | ||
ip = new int(0); | ||
delete [] ip; | ||
} |
9 changes: 9 additions & 0 deletions
9
integration-tests/testdata/cppcheck_with_absolute_paths_project/src/sample/component1.hh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef COMPONENT1_HH | ||
#define COMPONENT1_HH | ||
|
||
class Bar { | ||
public: | ||
int foo(); | ||
void do_valgrind_errors(); | ||
}; | ||
#endif |
6 changes: 6 additions & 0 deletions
6
integration-tests/testdata/cppcheck_with_absolute_paths_project/src/sample/main.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <component1.hh> | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
return Bar().foo(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters