Skip to content

Integrate new version of klee #579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions integration-tests/c-example/lib/linked-list/hard-linked-list.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "hard-linked-list.h"
#include <stddef.h>

int hard_list_and_pointers(struct Node *node) {
if (node == NULL) {
return 0;
}
if (node->x == NULL || node->data == NULL) {
return -1;
}
if (node->x == &(node->data->x) && *node->x == node->data->x) {
return 1;
}
if (node->next == NULL) {
return -2;
}
if (node->next->x == NULL || node->next->data == NULL) {
return -3;
}
if (node->next->data == node->data && &(node->next->data->y) == node->x && node->next->data->y == *node->x) {
return 2;
}
return 3;
}
15 changes: 15 additions & 0 deletions integration-tests/c-example/lib/linked-list/hard-linked-list.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef HARD_LINKED_LIST_H
#define HARD_LINKED_LIST_H

struct Data {
int x;
int y;
};

struct Node {
int *x;
struct Data *data;
struct Node *next;
};

#endif
71 changes: 37 additions & 34 deletions server/src/KleeRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,35 +138,35 @@ static void processMethod(MethodKtests &ktestChunk,
bool hasError = false;
for (auto const &entry : fs::directory_iterator(kleeOut)) {
auto const &path = entry.path();
if (Paths::isKtestJson(path)) {
if (Paths::isKtest(path)) {
if (Paths::hasEarly(path)) {
hasTimeout = true;
} else if (Paths::hasInternalError(path)) {
hasError = true;
} else {
std::unique_ptr<TestCase, decltype(&TestCase_free)> ktestData{
TC_fromFile(path.c_str()), TestCase_free
std::unique_ptr<KTest, decltype(&kTest_free)> ktestData{
kTest_fromFile(path.c_str()), kTest_free
};
if (ktestData == nullptr) {
LOG_S(WARNING) << "Unable to open .ktestjson file";
LOG_S(WARNING) << "Unable to open .ktest file";
continue;
}
const std::vector<fs::path> &errorDescriptorFiles =
Paths::getErrorDescriptors(path);
Paths::getErrorDescriptors(path);

UTBotKTest::Status status = errorDescriptorFiles.empty()
? UTBotKTest::Status::SUCCESS
: UTBotKTest::Status::FAILED;
std::vector<ConcretizedObject> kTestObjects(
ktestData->objects, ktestData->objects + ktestData->n_objects);
? UTBotKTest::Status::SUCCESS
: UTBotKTest::Status::FAILED;
std::vector<KTestObject> kTestObjects(ktestData->objects,
ktestData->objects + ktestData->numObjects);

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

std::vector<std::string> errorDescriptors = CollectionUtils::transform(
errorDescriptorFiles, [](const fs::path &errorFile) {
std::vector<std::string> errorDescriptors =
CollectionUtils::transform(errorDescriptorFiles, [](const fs::path &errorFile) {
std::ifstream fileWithError(errorFile.c_str(), std::ios_base::in);
std::string content((std::istreambuf_iterator<char>(fileWithError)),
std::istreambuf_iterator<char>());
Expand Down Expand Up @@ -209,29 +209,32 @@ std::pair<std::vector<std::string>, fs::path>
KleeRunner::createKleeParams(const tests::TestMethod &testMethod,
const tests::Tests &tests,
const std::string &methodNameOrEmptyForFolder) {
fs::path kleeOut = Paths::kleeOutDirForEntrypoints(projectContext,
tests.sourceFilePath,
fs::path kleeOut = Paths::kleeOutDirForEntrypoints(projectContext, tests.sourceFilePath,
methodNameOrEmptyForFolder);
fs::create_directories(kleeOut.parent_path());

std::vector<std::string> argvData = { "klee",
"--entry-point=" + KleeUtils::entryPointFunction(tests, testMethod.methodName, true),
"--libc=klee",
"--utbot",
"--posix-runtime",
"--type-system=CXX",
"--fp-runtime",
"--only-output-states-covering-new",
"--allocate-determ",
"--external-calls=all",
"--timer-interval=1000ms",
"--bcov-check-interval=8s",
"-istats-write-interval=5s",
"--disable-verify",
"--check-div-zero=false",
"--check-overshift=false",
"--skip-not-lazy-and-symbolic-pointers",
"--output-dir=" + kleeOut.string()};
std::vector<std::string> argvData = {
"klee",
"--entry-point=" + KleeUtils::entryPointFunction(tests, testMethod.methodName, true),
"--libc=klee",
"--utbot",
"--posix-runtime",
"--skip-not-lazy-initialized",
"--type-system=CXX",
"--fp-runtime",
"--only-output-states-covering-new",
"--allocate-determ",
"--external-calls=all",
"--timer-interval=1000ms",
"--use-cov-check=instruction-based",
"-istats-write-interval=5s",
"--disable-verify",
"--check-div-zero=false",
"--check-overshift=false",
"--skip-not-symbolic-objects",
"--use-tbaa",
"--output-dir=" + kleeOut.string()
};
if (settingsContext.useDeterministicSearcher) {
argvData.emplace_back("--search=dfs");
}
Expand All @@ -240,7 +243,7 @@ KleeRunner::createKleeParams(const tests::TestMethod &testMethod,
argvData.emplace_back("--allocate-determ-size=" + std::to_string(1));
argvData.emplace_back("--allocate-determ-start-address=" + std::to_string(0x10000));
}
return {argvData, kleeOut};
return { argvData, kleeOut };
}

void KleeRunner::addTailKleeInitParams(std::vector<std::string> &argvData, const std::string &bitcodeFilePath)
Expand Down
Loading