Skip to content

Commit 5b25d20

Browse files
committed
Added regression test for pointers. Updated KLEE.
1 parent d1ead3c commit 5b25d20

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed

server/test/framework/Regression_Tests.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,34 @@ namespace {
340340
"f4");
341341
}
342342

343+
static bool checkAlignmentInNode(const tests::Tests::TestCaseParamValue &param) {
344+
static const size_t HEX = 16;
345+
static const size_t NODE_ALIGNMENT = 8;
346+
347+
const auto stringPointer = param.view->getSubViews().at(1)->getEntryValue(nullptr);
348+
const size_t address = strtoull(stringPointer.c_str(), nullptr, HEX);
349+
bool result = (address % NODE_ALIGNMENT == 0);
350+
351+
for (const auto &innerLazyValueParam : param.lazyValues) {
352+
result &= checkAlignmentInNode(innerLazyValueParam);
353+
}
354+
return result;
355+
}
356+
357+
TEST_F(Regression_Test, Pointers_Alignment) {
358+
fs::path source = getTestFilePath("issue-195.c");
359+
auto [testGen, status] = createTestForFunction(source, 8);
360+
361+
ASSERT_TRUE(status.ok()) << status.error_message();
362+
363+
for (const tests::Tests::MethodTestCase &testCase :
364+
testGen.tests.at(source).methods.begin().value().testCases) {
365+
for (const auto &paramValue : testCase.paramValues) {
366+
EXPECT_TRUE(checkAlignmentInNode(paramValue));
367+
}
368+
}
369+
}
370+
343371
TEST_F(Regression_Test, Generate_Folder) {
344372
fs::path folderPath = getTestFilePath("ISSUE-140");
345373
auto [testGen, status] = createTestForFolder(folderPath, true, true);

server/test/suites/regression/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,6 @@ target_compile_definitions(issue-276 PUBLIC EXPORT2="")
4949
target_compile_definitions(issue-276 PUBLIC EXPORT3=4)
5050
target_compile_definitions(issue-276 PUBLIC EXPORT4="4")
5151

52+
add_library(issue-195 issue-195.c)
53+
5254
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+
#include <stdlib.h>
2+
3+
typedef struct Node {
4+
int value;
5+
struct Node *next;
6+
} Node;
7+
8+
int list_sum(Node *head) {
9+
int sum = 0;
10+
while (head != NULL) {
11+
sum += head->value;
12+
head = head->next;
13+
}
14+
return sum;
15+
}

0 commit comments

Comments
 (0)