Improved speed of testrunner: Avoid repeated loading of the same library
This commit is contained in:
parent
3fade4d28c
commit
0a416910c4
|
@ -165,6 +165,13 @@ public:
|
||||||
*/
|
*/
|
||||||
std::string addEnabled(const std::string &str);
|
std::string addEnabled(const std::string &str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disables all severities, except from error.
|
||||||
|
*/
|
||||||
|
void clearEnabled() {
|
||||||
|
_enabled.clear();
|
||||||
|
}
|
||||||
|
|
||||||
enum Language {
|
enum Language {
|
||||||
None, C, CPP
|
None, C, CPP
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,8 +29,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Settings settings;
|
||||||
|
|
||||||
void run() {
|
void run() {
|
||||||
|
LOAD_LIB_2(settings.library, "std.cfg");
|
||||||
|
|
||||||
TEST_CASE(coutCerrMisusage);
|
TEST_CASE(coutCerrMisusage);
|
||||||
|
|
||||||
TEST_CASE(wrongMode_simple);
|
TEST_CASE(wrongMode_simple);
|
||||||
|
@ -49,6 +52,8 @@ private:
|
||||||
TEST_CASE(testPrintfArgument);
|
TEST_CASE(testPrintfArgument);
|
||||||
TEST_CASE(testPosixPrintfScanfParameterPosition); // #4900
|
TEST_CASE(testPosixPrintfScanfParameterPosition); // #4900
|
||||||
|
|
||||||
|
LOAD_LIB_2(settings.library, "windows.cfg");
|
||||||
|
|
||||||
TEST_CASE(testMicrosoftPrintfArgument); // ticket #4902
|
TEST_CASE(testMicrosoftPrintfArgument); // ticket #4902
|
||||||
TEST_CASE(testMicrosoftScanfArgument);
|
TEST_CASE(testMicrosoftScanfArgument);
|
||||||
TEST_CASE(testMicrosoftCStringFormatArguments); // ticket #4920
|
TEST_CASE(testMicrosoftCStringFormatArguments); // ticket #4920
|
||||||
|
@ -60,7 +65,7 @@ private:
|
||||||
// Clear the error buffer..
|
// Clear the error buffer..
|
||||||
errout.str("");
|
errout.str("");
|
||||||
|
|
||||||
Settings settings;
|
settings.clearEnabled();
|
||||||
settings.addEnabled("warning");
|
settings.addEnabled("warning");
|
||||||
settings.addEnabled("style");
|
settings.addEnabled("style");
|
||||||
if (portability)
|
if (portability)
|
||||||
|
@ -68,8 +73,6 @@ private:
|
||||||
settings.inconclusive = inconclusive;
|
settings.inconclusive = inconclusive;
|
||||||
settings.platform(platform);
|
settings.platform(platform);
|
||||||
|
|
||||||
settings.library = _lib;
|
|
||||||
|
|
||||||
// Tokenize..
|
// Tokenize..
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
|
@ -612,8 +615,6 @@ private:
|
||||||
|
|
||||||
|
|
||||||
void testScanf1() {
|
void testScanf1() {
|
||||||
LOAD_LIB("std.cfg");
|
|
||||||
|
|
||||||
check("void foo() {\n"
|
check("void foo() {\n"
|
||||||
" int a, b;\n"
|
" int a, b;\n"
|
||||||
" FILE *file = fopen(\"test\", \"r\");\n"
|
" FILE *file = fopen(\"test\", \"r\");\n"
|
||||||
|
@ -632,8 +633,6 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void testScanf2() {
|
void testScanf2() {
|
||||||
LOAD_LIB("std.cfg");
|
|
||||||
|
|
||||||
check("void foo() {\n"
|
check("void foo() {\n"
|
||||||
" scanf(\"%5s\", bar);\n" // Width specifier given
|
" scanf(\"%5s\", bar);\n" // Width specifier given
|
||||||
" scanf(\"%5[^~]\", bar);\n" // Width specifier given
|
" scanf(\"%5[^~]\", bar);\n" // Width specifier given
|
||||||
|
@ -660,8 +659,6 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void testScanf4() { // ticket #2553
|
void testScanf4() { // ticket #2553
|
||||||
LOAD_LIB("std.cfg");
|
|
||||||
|
|
||||||
check("void f()\n"
|
check("void f()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" char str [8];\n"
|
" char str [8];\n"
|
||||||
|
@ -674,8 +671,6 @@ private:
|
||||||
|
|
||||||
|
|
||||||
void testScanfArgument() {
|
void testScanfArgument() {
|
||||||
LOAD_LIB("std.cfg");
|
|
||||||
|
|
||||||
check("void foo() {\n"
|
check("void foo() {\n"
|
||||||
" scanf(\"%1d\", &foo);\n"
|
" scanf(\"%1d\", &foo);\n"
|
||||||
" sscanf(bar, \"%1d\", &foo);\n"
|
" sscanf(bar, \"%1d\", &foo);\n"
|
||||||
|
@ -2276,7 +2271,6 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void testPrintfArgument() {
|
void testPrintfArgument() {
|
||||||
LOAD_LIB("std.cfg");
|
|
||||||
check("void foo() {\n"
|
check("void foo() {\n"
|
||||||
" printf(\"%u\");\n"
|
" printf(\"%u\");\n"
|
||||||
" printf(\"%u%s\", 123);\n"
|
" printf(\"%u%s\", 123);\n"
|
||||||
|
@ -3108,8 +3102,6 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void testPosixPrintfScanfParameterPosition() { // #4900 - No support for parameters in format strings
|
void testPosixPrintfScanfParameterPosition() { // #4900 - No support for parameters in format strings
|
||||||
LOAD_LIB("std.cfg");
|
|
||||||
|
|
||||||
check("void foo() {"
|
check("void foo() {"
|
||||||
" int bar;"
|
" int bar;"
|
||||||
" printf(\"%1$d\", 1);"
|
" printf(\"%1$d\", 1);"
|
||||||
|
@ -3134,9 +3126,6 @@ private:
|
||||||
|
|
||||||
|
|
||||||
void testMicrosoftPrintfArgument() {
|
void testMicrosoftPrintfArgument() {
|
||||||
LOAD_LIB("std.cfg");
|
|
||||||
LOAD_LIB("windows.cfg");
|
|
||||||
|
|
||||||
check("void foo() {\n"
|
check("void foo() {\n"
|
||||||
" size_t s;\n"
|
" size_t s;\n"
|
||||||
" ptrdiff_t p;\n"
|
" ptrdiff_t p;\n"
|
||||||
|
@ -3226,9 +3215,6 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void testMicrosoftScanfArgument() {
|
void testMicrosoftScanfArgument() {
|
||||||
LOAD_LIB("std.cfg");
|
|
||||||
LOAD_LIB("windows.cfg");
|
|
||||||
|
|
||||||
check("void foo() {\n"
|
check("void foo() {\n"
|
||||||
" size_t s;\n"
|
" size_t s;\n"
|
||||||
" ptrdiff_t p;\n"
|
" ptrdiff_t p;\n"
|
||||||
|
@ -3333,9 +3319,6 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void testMicrosoftSecurePrintfArgument() {
|
void testMicrosoftSecurePrintfArgument() {
|
||||||
LOAD_LIB("std.cfg");
|
|
||||||
LOAD_LIB("windows.cfg");
|
|
||||||
|
|
||||||
check("void foo() {\n"
|
check("void foo() {\n"
|
||||||
" int i;\n"
|
" int i;\n"
|
||||||
" unsigned int u;\n"
|
" unsigned int u;\n"
|
||||||
|
@ -3526,8 +3509,6 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void testMicrosoftSecureScanfArgument() {
|
void testMicrosoftSecureScanfArgument() {
|
||||||
LOAD_LIB("windows.cfg");
|
|
||||||
|
|
||||||
check("void foo() {\n"
|
check("void foo() {\n"
|
||||||
" int i;\n"
|
" int i;\n"
|
||||||
" unsigned int u;\n"
|
" unsigned int u;\n"
|
||||||
|
|
|
@ -126,6 +126,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Settings settings1;
|
Settings settings1;
|
||||||
|
Settings settings2;
|
||||||
|
|
||||||
void check(const char code[], const Settings *settings = nullptr) {
|
void check(const char code[], const Settings *settings = nullptr) {
|
||||||
// Clear the error buffer..
|
// Clear the error buffer..
|
||||||
|
@ -150,6 +151,7 @@ private:
|
||||||
void run() {
|
void run() {
|
||||||
LOAD_LIB_2(settings1.library, "std.cfg");
|
LOAD_LIB_2(settings1.library, "std.cfg");
|
||||||
LOAD_LIB_2(settings1.library, "gtk.cfg");
|
LOAD_LIB_2(settings1.library, "gtk.cfg");
|
||||||
|
LOAD_LIB_2(settings2.library, "std.cfg");
|
||||||
|
|
||||||
// Check that getcode works correctly..
|
// Check that getcode works correctly..
|
||||||
TEST_CASE(testgetcode);
|
TEST_CASE(testgetcode);
|
||||||
|
@ -367,20 +369,14 @@ private:
|
||||||
TEST_CASE(posixcfg);
|
TEST_CASE(posixcfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadlib(Library& library) {
|
|
||||||
LOAD_LIB_2(library, "std.cfg");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getcode(const char code[], const char varname[], bool classfunc=false) {
|
std::string getcode(const char code[], const char varname[], bool classfunc=false) {
|
||||||
// Clear the error buffer..
|
// Clear the error buffer..
|
||||||
errout.str("");
|
errout.str("");
|
||||||
|
|
||||||
Settings settings;
|
settings2.standards.posix = true;
|
||||||
settings.standards.posix = true;
|
|
||||||
loadlib(settings.library);
|
|
||||||
|
|
||||||
// Tokenize..
|
// Tokenize..
|
||||||
Tokenizer tokenizer(&settings, this);
|
Tokenizer tokenizer(&settings2, this);
|
||||||
std::istringstream istr(code);
|
std::istringstream istr(code);
|
||||||
if (!tokenizer.tokenize(istr, "test.cpp"))
|
if (!tokenizer.tokenize(istr, "test.cpp"))
|
||||||
return "";
|
return "";
|
||||||
|
@ -389,7 +385,7 @@ private:
|
||||||
const unsigned int varId(Token::findmatch(tokenizer.tokens(), varname)->varId());
|
const unsigned int varId(Token::findmatch(tokenizer.tokens(), varname)->varId());
|
||||||
|
|
||||||
// getcode..
|
// getcode..
|
||||||
CheckMemoryLeakInFunction checkMemoryLeak(&tokenizer, &settings, nullptr);
|
CheckMemoryLeakInFunction checkMemoryLeak(&tokenizer, &settings2, nullptr);
|
||||||
std::list<const Token *> callstack;
|
std::list<const Token *> callstack;
|
||||||
callstack.push_back(0);
|
callstack.push_back(0);
|
||||||
CheckMemoryLeak::AllocType allocType, deallocType;
|
CheckMemoryLeak::AllocType allocType, deallocType;
|
||||||
|
|
Loading…
Reference in New Issue