Skip to content

Commit 5ba9426

Browse files
author
Vladislav Kalugin
committed
fixes after rebase
1 parent 5384717 commit 5ba9426

28 files changed

+252
-104
lines changed

server/src/KleeGenerator.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "loguru.h"
1616

1717
using namespace tests;
18-
using namespace ::testsgen;
1918

2019
static const std::string GENERATION_COMPILE_MAKEFILE = "GenerationCompileMakefile.mk";
2120
static const std::string GENERATION_KLEE_MAKEFILE = "GenerationKleeMakefile.mk";

server/src/KleeGenerator.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "streams/tests/TestsWriter.h"
1616
#include "types/Types.h"
1717
#include "utils/ExecUtils.h"
18-
1918
#include "utils/path/FileSystemPath.h"
2019
#include "testgens/BaseTestGen.h"
2120

@@ -25,7 +24,6 @@
2524

2625

2726
using json = nlohmann::json;
28-
using namespace ::testsgen;
2927

3028
/**
3129
* @brief Contains methods for generating files for KLEE and build them.

server/src/KleeRunner.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,15 @@
1010
#include "utils/FileSystemUtils.h"
1111
#include "utils/KleeUtils.h"
1212
#include "utils/LogUtils.h"
13-
#include "TimeExecStatistics.h"
1413
#include "utils/stats/CSVReader.h"
1514
#include "utils/stats/TestsGenerationStats.h"
16-
#include "utils/TraceUtils.h"
1715

1816
#include "loguru.h"
1917

2018
#include <fstream>
2119
#include <utility>
2220

2321
using namespace tests;
24-
using namespace ::testsgen;
2522

2623
namespace {
2724
void clearUnusedData(const fs::path &kleeDir) {
@@ -163,7 +160,6 @@ static void processMethod(MethodKtests &ktestChunk,
163160
std::vector<ConcretizedObject> kTestObjects(
164161
ktestData->objects, ktestData->objects + ktestData->n_objects);
165162

166-
167163
std::vector<UTBotKTestObject> objects = CollectionUtils::transform(
168164
kTestObjects, [](const ConcretizedObject &kTestObject) {
169165
return UTBotKTestObject{ kTestObject };

server/src/Paths.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include <pwd.h>
1010
#include <unistd.h>
11-
#include <utils/ErrorInfo.h>
1211

1312
namespace Paths {
1413
bool testInputFile(const std::string &fileName) {
@@ -130,7 +129,6 @@ namespace Paths {
130129
return fs::exists(errorFile(path, suffix));
131130
}
132131

133-
134132
bool hasInternalError(const fs::path &path) {
135133
static const auto internalErrorSuffixes = {
136134
"exec",

server/src/Paths.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77
#include "utils/CollectionUtils.h"
88
#include "utils/CompilationUtils.h"
99
#include "utils/TimeUtils.h"
10-
#include "utils/JsonUtils.h"
1110

1211
#include "utils/path/FileSystemPath.h"
1312
#include <optional>
1413
#include <vector>
1514
#include <unordered_set>
16-
#include <utils/ErrorInfo.h>
1715

1816
namespace Paths {
1917
extern fs::path logPath;

server/src/Server.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ Status Server::TestsGenServiceImpl::ProcessBaseTestRequest(BaseTestGen &testGen,
272272
std::chrono::duration_cast<std::chrono::milliseconds>(
273273
generationStartTime -
274274
preprocessingStartTime));
275-
auto start_time = std::chrono::steady_clock::now();
276275
kleeRunner.runKlee(testMethods, testGen.tests, generator, testGen.methodNameToReturnTypeMap,
277276
lineInfo, testsWriter, testGen.isBatched(), interactiveMode, generationStatsMap);
278277
LOG_S(INFO) << "KLEE time: " << std::chrono::duration_cast<std::chrono::milliseconds>

server/src/SettingsContext.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "SettingsContext.h"
22

33
#include <protobuf/testgen.grpc.pb.h>
4-
using namespace ::testsgen;
54

65
namespace utbot {
76
SettingsContext::SettingsContext(bool generateForStaticFunctions,
@@ -10,7 +9,7 @@ namespace utbot {
109
int32_t timeoutPerTest,
1110
bool useDeterministicSearcher,
1211
bool useStubs,
13-
ErrorMode errorMode)
12+
testsgen::ErrorMode errorMode)
1413
: generateForStaticFunctions(generateForStaticFunctions),
1514
verbose(verbose),
1615
timeoutPerFunction(timeoutPerFunction > 0

server/src/SettingsContext.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include <chrono>
55
#include <optional>
66
#include <protobuf/testgen.grpc.pb.h>
7-
using namespace ::testsgen;
87

98
namespace testsgen {
109
class SettingsContext;
@@ -21,14 +20,14 @@ namespace utbot {
2120
int32_t timeoutPerTest,
2221
bool useDeterministicSearcher,
2322
bool useStubs,
24-
ErrorMode errorMode);
23+
testsgen::ErrorMode errorMode);
2524

2625
const bool generateForStaticFunctions;
2726
const bool verbose;
2827
const std::optional<std::chrono::seconds> timeoutPerFunction, timeoutPerTest;
2928
const bool useDeterministicSearcher;
3029
const bool useStubs;
31-
ErrorMode errorMode;
30+
testsgen::ErrorMode errorMode;
3231
};
3332
}
3433

server/src/Tests.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include "utils/PrinterUtils.h"
1010
#include "utils/SizeUtils.h"
1111
#include "json.hpp"
12-
#include "utils/ErrorInfo.h"
13-
1412
#include <klee/KTest.h>
1513
#include <klee/TestCase.h>
1614
#include <tsl/ordered_map.h>
@@ -28,6 +26,7 @@
2826
#include <type_traits>
2927
#include <utility>
3028
#include <vector>
29+
#include <utils/ErrorInfo.h>
3130

3231
using json = nlohmann::json;
3332

server/src/coverage/TestRunner.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,16 @@ std::vector<UnitTest> TestRunner::getTestsFromMakefile(const fs::path &makefile,
6464
StringUtils::trim(s);
6565
}
6666
std::string testSuite;
67-
std::vector<std::string> testsList;
68-
for (const std::string &s : gtestListTestsOutput) {
67+
std::vector<UnitTest> testList;
68+
for (const std::string &s: gtestListTestsOutput) {
6969
if (s.back() == '.') {
7070
testSuite = s;
7171
testSuite.pop_back();
7272
} else {
73-
testsList.push_back(s);
73+
testList.push_back({testFilePath, testSuite, s});
7474
}
7575
}
76-
return CollectionUtils::transform(testsList, [&testFilePath, &testSuite](std::string const &name) {
77-
return UnitTest{ testFilePath, testSuite, name };
78-
});
76+
return testList;
7977
}
8078

8179
std::vector<UnitTest> TestRunner::getTestsToLaunch() {

server/src/printers/TestsPrinter.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ void TestsPrinter::genVerboseTestCase(const Tests::MethodDescription &methodDesc
230230
ErrorMode errorMode) {
231231
initializeFiles(methodDescription, testCase);
232232
openFiles(methodDescription, testCase);
233+
233234
TestsPrinter::verboseParameters(methodDescription, testCase);
234235

235236
printLazyVariables(methodDescription, testCase, true);
@@ -250,8 +251,8 @@ void TestsPrinter::genVerboseTestCase(const Tests::MethodDescription &methodDesc
250251
TestsPrinter::verboseFunctionCall(methodDescription, testCase, errorMode);
251252
markTestedFunctionCallIfNeed(methodDescription.name, testCase);
252253

253-
if (testCase.isError() && errorMode == ::testsgen::ErrorMode::FAILING) {
254-
printFailAssertion();
254+
if (testCase.isError()) {
255+
printFailAssertion(errorMode);
255256
} else {
256257
ss << NL;
257258
TestsPrinter::verboseAsserts(methodDescription, testCase, predicateInfo);
@@ -680,7 +681,7 @@ void TestsPrinter::parametrizedAsserts(const Tests::MethodDescription &methodDes
680681
classAsserts(methodDescription, testCase);
681682
changeableParamsAsserts(methodDescription, testCase);
682683
} else {
683-
printFailAssertion();
684+
printFailAssertion(errorMode);
684685
}
685686
}
686687

@@ -791,13 +792,22 @@ void printer::TestsPrinter::parametrizedInitializeSymbolicStubs(const Tests::Met
791792
}
792793
}
793794

794-
void TestsPrinter::printFailAssertion() {
795-
ss << NL;
796-
ss << LINE_INDENT()
797-
<< "FAIL() << \"Unreachable point or the function was supposed to fail, but \"\n"
798-
<< LINE_INDENT() << LINE_INDENT()
799-
<< "\"actually completed successfully. See the SARIF report for details.\"";
800-
ss << SCNL;
795+
void TestsPrinter::printFailAssertion(ErrorMode errorMode) {
796+
switch (errorMode) {
797+
case ErrorMode::FAILING:
798+
ss << NL;
799+
ss << LINE_INDENT()
800+
<< "FAIL() << \"Unreachable point or the function was supposed to fail, but \"\n"
801+
<< LINE_INDENT() << LINE_INDENT()
802+
<< "\"actually completed successfully. See the SARIF report for details.\"";
803+
ss << SCNL;
804+
break;
805+
case ErrorMode::PASSING_IN_TARGET_ONLY:
806+
//TODO add passing scenario
807+
case ErrorMode::PASSING:
808+
default:
809+
break;
810+
}
801811
}
802812

803813
std::string printer::MultiLinePrinter::print(TestsPrinter *printer,

server/src/printers/TestsPrinter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ namespace printer {
167167

168168
std::uint32_t printSuiteAndReturnMethodsCount(const std::string &suiteName, const Tests::MethodsMap &methods);
169169

170-
void printFailAssertion();
170+
void printFailAssertion(ErrorMode errorMode);
171171
};
172172
}
173173
#endif // UNITTESTBOT_TESTSPRINTER_H

server/src/utils/TraceUtils.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
#include <fstream>
33
#include "ErrorInfo.h"
44
#include "utils/path/FileSystemPath.h"
5-
#include "../Paths.h"
5+
#include "Paths.h"
66

7-
static std::string getLineByNumberInFileWithStackTrace(const fs::path& errorFilePath, int lineNumber) {
7+
static std::string getLineByNumberInFileWithStackTrace(const fs::path &errorFilePath, int lineNumber) {
88
std::ifstream input;
99
std::string line;
1010
input.open(errorFilePath.string(), std::ios::in);
@@ -16,26 +16,26 @@ static std::string getLineByNumberInFileWithStackTrace(const fs::path& errorFile
1616
return line;
1717
}
1818

19-
[[nodiscard]]std::string getTypeOfError(const fs::path& errorFilePath) {
19+
[[nodiscard]]std::string getTypeOfError(const fs::path &errorFilePath) {
2020
return getLineByNumberInFileWithStackTrace(errorFilePath, 0);
2121
}
2222

23-
[[nodiscard]]fs::path getFileErrorFound(const fs::path& errorFilePath) {
23+
[[nodiscard]]fs::path getFileErrorFound(const fs::path &errorFilePath) {
2424
std::string lineWithErrorFilePath = getLineByNumberInFileWithStackTrace(errorFilePath, 1);
2525
fs::path fileWithError(lineWithErrorFilePath.substr(6));
2626
return fileWithError;
2727
}
2828

29-
[[nodiscard]]uint64_t getLineErrorFound(const fs::path& errorFilePath) {
29+
[[nodiscard]]uint64_t getLineErrorFound(const fs::path &errorFilePath) {
3030
std::string stringWithLine = getLineByNumberInFileWithStackTrace(errorFilePath, 3);
3131
return std::stoi(stringWithLine.substr(6));
3232
}
3333

34-
bool isPointerOutOfBound(const std::string& typeofError) {
34+
bool isPointerOutOfBound(const std::string &typeofError) {
3535
return typeofError == "Error: memory error: out of bound pointer";
3636
}
3737

38-
bool errorInExceptionHeader(const std::string& fileWhereErrorFound) {
38+
bool errorInExceptionHeader(const std::string &fileWhereErrorFound) {
3939
return fileWhereErrorFound.find("exception.h") != std::string::npos;
4040
}
4141

server/src/visitors/ParametrizedAssertsVisitor.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
#include "AssertsVisitor.h"
55

6-
using namespace ::testsgen;
7-
86
namespace visitor {
97
class ParametrizedAssertsVisitor : public AssertsVisitor {
108
private:

server/test/framework/KleeGen_Tests.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
#include "utils/path/FileSystemPath.h"
88

9-
using namespace ::testsgen;
10-
119
namespace {
1210
using testsgen::TestsResponse;
1311

0 commit comments

Comments
 (0)