Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ladisgin committed Oct 10, 2023
1 parent 8997979 commit dac36ff
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 108 deletions.
2 changes: 1 addition & 1 deletion server/src/KleeRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ void KleeRunner::processBatchWithInteractive(const std::vector<tests::TestMethod
std::vector<std::string> tmp;
ExecUtils::toCArgumentsPtr(argvData, tmp, cargv, cenvp, false);

LOG_S(DEBUG) << "Klee command :: " + StringUtils::joinWith(argvData, " ");
LOG_S(ERROR) << "Klee command :: " + StringUtils::joinWith(argvData, " ");
MEASURE_FUNCTION_EXECUTION_TIME

RunKleeTask task(cargv.size(),
Expand Down
101 changes: 45 additions & 56 deletions server/test/framework/Server_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,66 +142,55 @@ namespace {
}

void checkDifferentVariables_C(BaseTestGen &testGen, bool differentVariables) {
for (const auto &[methodName, methodDescription] :
testGen.tests.at(different_variables_c).methods) {
for (const auto &[methodName, methodDescription]:
testGen.tests.at(different_variables_c).methods) {
if (methodName == "swap_two_int_pointers") {
checkTestCasePredicates(
methodDescription.testCases,
std::vector<TestCasePredicate>(
{ [differentVariables](tests::Tests::MethodTestCase const &testCase) {
return (differentVariables ^
checkEquals(testCase.paramValues[0],
testCase.paramValues[1])) &&
checkEquals(testCase.paramPostValues[0],
testCase.paramValues[1]) &&
checkEquals(testCase.paramPostValues[1],
testCase.paramValues[0]) &&
testCase.stdinValue == std::nullopt;
} }),
methodName);
methodDescription.testCases,
std::vector<TestCasePredicate>(
{[differentVariables](tests::Tests::MethodTestCase const &testCase) {
return (differentVariables ^
checkEquals(testCase.paramValues[0],
testCase.paramValues[1])) &&
checkEquals(testCase.paramPostValues[0],
testCase.paramValues[1]) &&
checkEquals(testCase.paramPostValues[1],
testCase.paramValues[0]) &&
testCase.stdinValue == std::nullopt;
}}),
methodName);
} else if (methodName == "max_of_two_float") {
checkTestCasePredicates(
methodDescription.testCases,
std::vector<TestCasePredicate>(
{ [differentVariables](tests::Tests::MethodTestCase const &testCase) {
return ((stod(testCase.paramValues[0].view->getEntryValue(
nullptr)) ==
stod(testCase.paramValues[1].view->getEntryValue(
nullptr))) ^
differentVariables) &&
stod(testCase.returnValue.view->getEntryValue(nullptr)) ==
std::max(
stod(testCase.paramValues[0].view->getEntryValue(
nullptr)),
stod(testCase.paramValues[1].view->getEntryValue(
nullptr))) &&
testCase.stdinValue == std::nullopt;
},
[](tests::Tests::MethodTestCase const &testCase) {
return stod(testCase.paramValues[0].view->getEntryValue(
nullptr)) !=
stod(testCase.paramValues[1].view->getEntryValue(
nullptr)) &&
stod(testCase.returnValue.view->getEntryValue(nullptr)) ==
std::max(
stod(testCase.paramValues[0].view->getEntryValue(
nullptr)),
stod(testCase.paramValues[1].view->getEntryValue(
nullptr))) &&
testCase.stdinValue == std::nullopt;
} }),
methodName);
methodDescription.testCases,
std::vector<TestCasePredicate>(
{[differentVariables](tests::Tests::MethodTestCase const &testCase) {
double param0 = stod(testCase.paramValues[0].view->getEntryValue(nullptr));
double param1 = stod(testCase.paramValues[1].view->getEntryValue(nullptr));
double ret = stod(testCase.returnValue.view->getEntryValue(nullptr));
return (param0 != param1 || differentVariables) &&
ret == std::max(param0, param1) &&
testCase.stdinValue == std::nullopt;
},
[](tests::Tests::MethodTestCase const &testCase) {
double param0 = stod(testCase.paramValues[0].view->getEntryValue(nullptr));
double param1 = stod(testCase.paramValues[1].view->getEntryValue(nullptr));
double ret = stod(testCase.returnValue.view->getEntryValue(nullptr));
return param0 != param1 &&
ret == std::max(param0, param1) &&
testCase.stdinValue == std::nullopt;
}}),
methodName);
} else if (methodName == "struct_test") {
checkTestCasePredicates(
methodDescription.testCases,
std::vector<TestCasePredicate>(
{ [](tests::Tests::MethodTestCase const &testCase) {
return testCase.returnValue.view->getEntryValue(nullptr) == "-1";
},
[](tests::Tests::MethodTestCase const &testCase) {
return testCase.returnValue.view->getEntryValue(nullptr) == "1";
} }),
methodName);
methodDescription.testCases,
std::vector<TestCasePredicate>(
{[](tests::Tests::MethodTestCase const &testCase) {
return testCase.returnValue.view->getEntryValue(nullptr) == "-1";
},
[](tests::Tests::MethodTestCase const &testCase) {
return testCase.returnValue.view->getEntryValue(nullptr) == "1";
}}),
methodName);
}
}
}
Expand Down Expand Up @@ -1549,7 +1538,7 @@ namespace {
Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get());
ASSERT_TRUE(status.ok()) << status.error_message();

testUtils::checkMinNumberOfTests(testGen.tests, 2);
testUtils::checkMinNumberOfTests(testGen.tests, 7);

auto testFilter = GrpcUtils::createTestFilterForProject();
auto runRequest = createCoverageAndResultsRequest(
Expand All @@ -1566,7 +1555,7 @@ namespace {
auto tests = coverageGenerator.getTestsToLaunch();

ASSERT_FALSE(resultMap.empty());
EXPECT_GT(resultMap.getNumberOfTests(), 2);
EXPECT_GE(resultMap.getNumberOfTests(), 7);

testUtils::checkStatuses(resultMap, tests);

Expand Down
107 changes: 59 additions & 48 deletions server/test/framework/Syntax_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,15 @@ namespace {
{[](const tests::Tests::MethodTestCase& testCase) {
std::cout << testCase.paramValues[0].view->getEntryValue(nullptr) << std::endl;
return stoi(testCase.returnValue.view->getEntryValue(nullptr)) == 1
&& testCase.paramValues[0].view->getEntryValue(nullptr).find("{{'\\0', ") == 0;
&& testCase.paramValues[0].view->getEntryValue(nullptr).find(", 'a'") != std::string::npos;
},
[](const tests::Tests::MethodTestCase& testCase) {
return stoi(testCase.returnValue.view->getEntryValue(nullptr)) == 0
&& testCase.paramValues[0].view->getEntryValue(nullptr).find("{{'\\0', ") == std::string::npos;
&& testCase.paramValues[0].view->getEntryValue(nullptr).find("{{'a', ") == 0;
},
[](const tests::Tests::MethodTestCase& testCase) {
return stoi(testCase.returnValue.view->getEntryValue(nullptr)) == -1
&& testCase.paramValues[0].view->getEntryValue(nullptr).find("{{'\\0', ") == 0;
&& testCase.paramValues[0].view->getEntryValue(nullptr).find("'a'") == std::string::npos;
}
}),
"extract_bit");
Expand Down Expand Up @@ -512,17 +512,19 @@ namespace {
ASSERT_TRUE(status.ok()) << status.error_message();

checkTestCasePredicates(
testGen.tests.at(complex_structs_c).methods.begin().value().testCases,
std::vector<TestCasePredicate>(
{[] (const tests::Tests::MethodTestCase& testCase) {
std::string expectedString = StringUtils::stringFormat("{%s, {%s, %s}, 0}",
PrinterUtils::C_NULL, PrinterUtils::C_NULL, PrinterUtils::C_NULL);
return testCase.returnValue.view->getEntryValue(nullptr) == expectedString &&
testCase.paramValues[0].view->getEntryValue(nullptr) == expectedString &&
testCase.globalPostValues[0].view->getEntryValue(nullptr) == expectedString;
}
}),
"check_double_pointer");
testGen.tests.at(complex_structs_c).methods.begin().value().testCases,
std::vector<TestCasePredicate>(
{[](const tests::Tests::MethodTestCase &testCase) {
std::string expectedString = StringUtils::stringFormat("{%s, {%s, %s}",
PrinterUtils::C_NULL,
PrinterUtils::C_NULL,
PrinterUtils::C_NULL);
return testCase.paramValues[0].view->getEntryValue(nullptr).find(expectedString) == 0 &&
testCase.globalPostValues[0].view->getEntryValue(nullptr) ==
testCase.returnValue.view->getEntryValue(nullptr);
}
}),
"check_double_pointer");
}

TEST_F(Syntax_Test, Booleans_as_Parameters_Test) {
Expand Down Expand Up @@ -599,13 +601,14 @@ namespace {
ASSERT_TRUE(status.ok()) << status.error_message();

checkTestCasePredicates(
testGen.tests.at(pointer_parameters_c).methods.begin().value().testCases,
std::vector<TestCasePredicate>(
{[] (const tests::Tests::MethodTestCase& testCase) {
return testCase.paramValues[0].view->getEntryValue(nullptr) == "0" && stoll(testCase.returnValue.view->getEntryValue(nullptr)) == 0;
}
}),
"void_pointer_int_usage");
testGen.tests.at(pointer_parameters_c).methods.begin().value().testCases,
std::vector<TestCasePredicate>(
{[](const tests::Tests::MethodTestCase &testCase) {
return testCase.paramValues[0].view->getEntryValue(nullptr) == "0" &&
stoll(testCase.returnValue.view->getEntryValue(nullptr)) == 0;
}
}),
"void_pointer_int_usage");
}

TEST_F(Syntax_Test, Enum_Pointer_as_Parameter_Test) {
Expand Down Expand Up @@ -1112,15 +1115,17 @@ namespace {
ASSERT_TRUE(status.ok()) << status.error_message();

checkTestCasePredicates(
testGen.tests.at(pointer_return_c).methods.begin().value().testCases,
std::vector<TestCasePredicate>(
{[] (const tests::Tests::MethodTestCase& testCase) {
return stoi(testCase.paramValues[0].view->getEntryValue(nullptr)) == 0 && testUtils::cmpChars(testCase.returnValue.view->getEntryValue(nullptr), 'a');
},
[] (const tests::Tests::MethodTestCase& testCase) {
return stoi(testCase.paramValues[0].view->getEntryValue(nullptr)) != 0 && testUtils::cmpChars(testCase.returnValue.view->getEntryValue(nullptr), 'b');
}
})
testGen.tests.at(pointer_return_c).methods.begin().value().testCases,
std::vector<TestCasePredicate>(
{[](const tests::Tests::MethodTestCase &testCase) {
return stoi(testCase.paramValues[0].view->getEntryValue(nullptr)) == 0 &&
testUtils::cmpChars(testCase.returnValue.view->getEntryValue(nullptr), 'a');
},
[](const tests::Tests::MethodTestCase &testCase) {
return stoi(testCase.paramValues[0].view->getEntryValue(nullptr)) != 0 &&
testUtils::cmpChars(testCase.returnValue.view->getEntryValue(nullptr), 'b');
}
})
);
}

Expand All @@ -1130,17 +1135,21 @@ namespace {
ASSERT_TRUE(status.ok()) << status.error_message();

checkTestCasePredicates(
testGen.tests.at(pointer_return_c).methods.begin().value().testCases,
std::vector<TestCasePredicate>(
{[] (const tests::Tests::MethodTestCase& testCase) {
return stoi(testCase.paramValues[0].view->getEntryValue(nullptr)) < stoi(testCase.paramValues[1].view->getEntryValue(nullptr)) &&
stoi(testCase.returnValue.view->getSubViews()[0]->getEntryValue(nullptr)) < stoi(testCase.returnValue.view->getSubViews()[1]->getEntryValue(nullptr));
},
[] (const tests::Tests::MethodTestCase& testCase) {
return stoi(testCase.paramValues[0].view->getEntryValue(nullptr)) >= stoi(testCase.paramValues[1].view->getEntryValue(nullptr)) &&
stoi(testCase.returnValue.view->getSubViews()[0]->getEntryValue(nullptr)) >= stoi(testCase.returnValue.view->getSubViews()[1]->getEntryValue(nullptr));
}
})
testGen.tests.at(pointer_return_c).methods.begin().value().testCases,
std::vector<TestCasePredicate>(
{[](const tests::Tests::MethodTestCase &testCase) {
return stoi(testCase.paramValues[0].view->getEntryValue(nullptr)) <
stoi(testCase.paramValues[1].view->getEntryValue(nullptr)) &&
stoi(testCase.returnValue.view->getSubViews()[0]->getEntryValue(nullptr)) <
stoi(testCase.returnValue.view->getSubViews()[1]->getEntryValue(nullptr));
},
[](const tests::Tests::MethodTestCase &testCase) {
return stoi(testCase.paramValues[0].view->getEntryValue(nullptr)) >=
stoi(testCase.paramValues[1].view->getEntryValue(nullptr)) &&
stoi(testCase.returnValue.view->getSubViews()[0]->getEntryValue(nullptr)) <
stoi(testCase.returnValue.view->getSubViews()[1]->getEntryValue(nullptr));
}
})
);
}

Expand Down Expand Up @@ -1740,7 +1749,8 @@ namespace {
testGen.tests.at(floats_special_c).methods.begin().value().testCases,
std::vector<TestCasePredicate>(
{[](const tests::Tests::MethodTestCase &testCase) {
return testCase.paramValues[0].view->getEntryValue(nullptr) == "NAN";
return testCase.paramValues[0].view->getEntryValue(nullptr).find("NAN") !=
std::string::npos;
}}));
}

Expand All @@ -1752,15 +1762,16 @@ namespace {

printer::TestsPrinter testsPrinter(testGen.projectContext, nullptr, utbot::Language::C);
const auto &tests = testGen.tests.at(floats_special_c)
.methods.begin().value().testCases;
.methods.begin().value().testCases;
checkTestCasePredicates(
tests, std::vector<TestCasePredicate>(
{ [](const tests::Tests::MethodTestCase &testCase) {
return testCase.paramValues[0].view->getEntryValue(nullptr) == "NAN";
},
tests, std::vector<TestCasePredicate>(
{[](const tests::Tests::MethodTestCase &testCase) {
return testCase.paramValues[0].view->getEntryValue(nullptr).find("NAN") !=
std::string::npos;
},
[](const tests::Tests::MethodTestCase &testCase) {
return testCase.paramValues[0].view->getEntryValue(nullptr) == "0.000000e+00L";
} }));
}}));
}

TEST_F(Syntax_Test, Floats_Special_Values_Inf) {
Expand Down
4 changes: 2 additions & 2 deletions server/test/suites/syntax/simple_unions.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ int get_sign_union(union IntBytesUnion st) {
}

int extract_bit(union ShortBytesUnion x) {
if (x.bytes[0] > 0) {
if (x.bytes[0] == 'a') {
return 0;
}
if (x.bytes[1] > 0) {
if (x.bytes[1] == 'a') {
return 1;
}
return -1;
Expand Down
2 changes: 1 addition & 1 deletion submodules/build-klee.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $UTBOT_CMAKE_BINARY -G Ninja \
-DKLEE_LIBCXX_INCLUDE_DIR=$UTBOT_ALL/libcxx/install/include/c++/v1 \
-DENABLE_KLEE_EH_CXX=TRUE \
-DKLEE_LIBCXXABI_SRC_DIR=$UTBOT_ALL/libcxx/libcxxabi \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
..

$UTBOT_CMAKE_BINARY --build .
Expand Down

0 comments on commit dac36ff

Please sign in to comment.