Skip to content

Commit 18f1f66

Browse files
author
Vladislav Kalugin
committed
Build ByteCode by make instead of shellExec
1 parent 9354128 commit 18f1f66

File tree

4 files changed

+93
-1
lines changed

4 files changed

+93
-1
lines changed

server/src/KleeGenerator.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,18 @@ Result<fs::path> KleeGenerator::defaultBuild(const fs::path &hintPath,
177177
auto &command = optionalCommand.value();
178178
command.setSourcePath(sourceFilePath);
179179
command.setOutput(bitcodeFilePath);
180-
auto [out, status, _] = ShellExecTask::executeUtbotCommand(command, buildDirPath, projectContext.projectName);
180+
181+
printer::DefaultMakefilePrinter makefilePrinter;
182+
std::vector<fs::path> outfilePaths;
183+
184+
fs::path output = command.getOutput();
185+
makefilePrinter.declareTarget("build", { command.getSourcePath() },
186+
{ command.toStringWithChangingDirectory() });
187+
fs::path makefile = projectTmpPath / "BCForKLEE.mk";
188+
FileSystemUtils::writeToFile(makefile, makefilePrinter.ss.str());
189+
190+
auto makefileCommand = MakefileUtils::makefileCommand(projectContext, makefile, "build");
191+
auto [out, status, _] = makefileCommand.run();
181192
if (status != 0) {
182193
LOG_S(ERROR) << "Compilation for " << sourceFilePath << " failed.\n"
183194
<< "Command: \"" << command.toString() << "\"\n"

server/test/framework/Regression_Tests.cpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,4 +268,64 @@ namespace {
268268
} }),
269269
"hash");
270270
}
271+
272+
TEST_F(Regression_Test, Export_Empty) {
273+
fs::path source = getTestFilePath("issue-276.c");
274+
auto [testGen, status] = createTestForFunction(source, 2);
275+
276+
ASSERT_TRUE(status.ok()) << status.error_message();
277+
278+
checkTestCasePredicates(
279+
testGen.tests.at(source).methods.begin().value().testCases,
280+
std::vector<TestCasePredicate>(
281+
{ [](const tests::Tests::MethodTestCase &testCase) {
282+
return testCase.returnValue.view->getEntryValue(nullptr) == "0";
283+
} }),
284+
"f1");
285+
}
286+
287+
TEST_F(Regression_Test, Export_Empty_String) {
288+
fs::path source = getTestFilePath("issue-276.c");
289+
auto [testGen, status] = createTestForFunction(source, 6);
290+
291+
ASSERT_TRUE(status.ok()) << status.error_message();
292+
293+
checkTestCasePredicates(
294+
testGen.tests.at(source).methods.begin().value().testCases,
295+
std::vector<TestCasePredicate>(
296+
{ [](const tests::Tests::MethodTestCase &testCase) {
297+
return testCase.returnValue.view->getEntryValue(nullptr) == "'\\0'";
298+
} }),
299+
"f2");
300+
}
301+
302+
TEST_F(Regression_Test, Export_Int) {
303+
fs::path source = getTestFilePath("issue-276.c");
304+
auto [testGen, status] = createTestForFunction(source, 10);
305+
306+
ASSERT_TRUE(status.ok()) << status.error_message();
307+
308+
checkTestCasePredicates(
309+
testGen.tests.at(source).methods.begin().value().testCases,
310+
std::vector<TestCasePredicate>(
311+
{ [](const tests::Tests::MethodTestCase &testCase) {
312+
return testCase.returnValue.view->getEntryValue(nullptr) == "4";
313+
} }),
314+
"f3");
315+
}
316+
317+
TEST_F(Regression_Test, Export_String_Int) {
318+
fs::path source = getTestFilePath("issue-276.c");
319+
auto [testGen, status] = createTestForFunction(source, 14);
320+
321+
ASSERT_TRUE(status.ok()) << status.error_message();
322+
323+
checkTestCasePredicates(
324+
testGen.tests.at(source).methods.begin().value().testCases,
325+
std::vector<TestCasePredicate>(
326+
{ [](const tests::Tests::MethodTestCase &testCase) {
327+
return testCase.returnValue.view->getEntryValue(nullptr) == "'4'";
328+
} }),
329+
"f4");
330+
}
271331
}

server/test/suites/regression/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,10 @@ add_library(PR153 PR153.c)
4040

4141
add_library(GH215 GH215.c)
4242

43+
add_library(issue-276 issue-276.c)
44+
target_compile_definitions(issue-276 PUBLIC EXPORT1=)
45+
target_compile_definitions(issue-276 PUBLIC EXPORT2="")
46+
target_compile_definitions(issue-276 PUBLIC EXPORT3=4)
47+
target_compile_definitions(issue-276 PUBLIC EXPORT4="4")
48+
4349
set_target_properties(regression PROPERTIES LINK_WHAT_YOU_USE TRUE)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
int EXPORT1 f1() {
2+
return 0;
3+
}
4+
5+
char* f2() {
6+
return EXPORT2;
7+
}
8+
9+
int f3() {
10+
return EXPORT3;
11+
}
12+
13+
char* f4() {
14+
return EXPORT4;
15+
}

0 commit comments

Comments
 (0)