Skip to content

Commit 1cb07a6

Browse files
committed
Update klee
Fix test after update klee Update z3 in Dockerfile_base
1 parent 88fa5f3 commit 1cb07a6

22 files changed

+425
-284
lines changed

.github/workflows/matrix.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"include": [
33
{
4-
"DOCKER_TAG": "2022.10.0",
4+
"DOCKER_TAG": "2023.10.0",
55
"OPERATING_SYSTEM_TAG": "18.04",
66
"LLVM_VERSION_MAJOR": "10"
77
}

build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33
set -o pipefail
44
pwd=$PWD
5-
chmod +x $pwd/submodules/klee/build.sh $pwd/submodules/Bear/build.sh $pwd/server/build.sh
6-
cd $pwd/submodules/klee && ./build.sh
5+
chmod +x $pwd/submodules/build-klee.sh $pwd/submodules/Bear/build.sh $pwd/server/build.sh
6+
cd $pwd/submodules && ./build-klee.sh
77
cd $pwd/submodules/Bear && ./build.sh
88
cd $pwd/server && ./build.sh

docker/Dockerfile_base

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ RUN git clone --single-branch --branch "release/${LLVM_VERSION_MAJOR}.x" --depth
7474
WORKDIR $UTBOT_ALL/llvm-project
7575
RUN mkdir build && cd build \
7676
&& $UTBOT_CMAKE_BINARY \
77-
-DCMAKE_BUILD_TYPE="Release" \
77+
-DCMAKE_BUILD_TYPE=MinSizeRel \
7878
-DCMAKE_INSTALL_PREFIX=$UTBOT_INSTALL_DIR \
7979
-DLLVM_INCLUDE_TESTS=OFF \
8080
-DLLVM_BINUTILS_INCDIR=$UTBOT_ALL/llvm_gold_plugin \
@@ -125,7 +125,7 @@ RUN cd $UTBOT_ALL/grpc && git submodule update --init
125125
RUN cd $UTBOT_ALL/grpc \
126126
&& mkdir -p cmake/build \
127127
&& cd cmake/build \
128-
&& $UTBOT_CMAKE_BINARY -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=$UTBOT_INSTALL_DIR ../.. \
128+
&& $UTBOT_CMAKE_BINARY -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_INSTALL_PREFIX=$UTBOT_INSTALL_DIR ../.. \
129129
&& make -j`nproc` \
130130
&& make install \
131131
&& cd $UTBOT_ALL \
@@ -142,9 +142,9 @@ USER utbot
142142

143143
# Install z3
144144
USER root
145-
RUN git clone --single-branch -b z3-4.8.7 --depth=1 https://github.com/Z3Prover/z3.git $UTBOT_ALL/z3-src
145+
RUN git clone --single-branch -b z3-4.8.17 --depth=1 https://github.com/Z3Prover/z3.git $UTBOT_ALL/z3-src
146146
RUN cd $UTBOT_ALL/z3-src && mkdir build && cd build && \
147-
$UTBOT_CMAKE_BINARY -G "Ninja" -DCMAKE_INSTALL_PREFIX=$UTBOT_INSTALL_DIR .. && \
147+
$UTBOT_CMAKE_BINARY -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$UTBOT_INSTALL_DIR .. && \
148148
$UTBOT_CMAKE_BINARY --build . --target install && \
149149
cd $UTBOT_ALL && \
150150
rm -rf $UTBOT_ALL/z3-src
@@ -171,7 +171,7 @@ RUN npm config set strict-ssl false
171171
RUN npm cache clean -f
172172
RUN sudo -E npm install -g n
173173
RUN echo insecure > ~/.curlrc
174-
RUN sudo -E n stable
174+
RUN sudo -E n 16
175175
RUN sudo -E apt remove -y --purge nodejs npm
176176

177177
# Install cmake which can generate link_commands.json. Installing cmake the second time in order to build base image faster since this cmake may be changed frequently.

docs/contributor-guides/advanced/symbolic-stdin.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ TEST(regression, check_password_test_10)
249249
In the previous version, UnitTestBot didn't preprocess functions that were using `stdin` before sending the bitcode to
250250
KLEE. Having added the interactive mode, we faced difficulties: KLEE couldn't work with multiple entry points
251251
that used `stdin` in one launch. The fact is that KLEE substitutes the original entry point to POSIX wrapper, which
252-
initializes environment and adds the `stdin`, `stdin-stat`, `stdin-read`, and `model-version` symbolic variables.
252+
initializes environment and adds the `stdin`, `stdin_stat`, `stdin_read`, and `model_version` symbolic variables.
253253
Then KLEE launches this wrapper as if the wrapper was the initial entry point.
254254
255255
UnitTestBot doesn't use these KLEE wrappers now. Instead, UnitTestBot creates the POSIX wrapper for every
@@ -304,4 +304,4 @@ TEST(regression, file_fgetc_test_1)
304304
int actual = file_fgetc(fA, fB, fC);
305305
EXPECT_EQ(4, actual);
306306
}
307-
```
307+
```

server/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
mkdir -p build
44
cd build
55

6-
$UTBOT_CMAKE_BINARY -G "Ninja" -DCMAKE_INSTALL_PREFIX=$UTBOT_ALL/server-install ..
6+
$UTBOT_CMAKE_BINARY -G "Ninja" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=$UTBOT_ALL/server-install ..
77
$UTBOT_CMAKE_BINARY --build .
88
$UTBOT_CMAKE_BINARY --install .

server/src/KleeRunner.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ KleeRunner::createKleeParams(const tests::TestMethod &testMethod,
222222
"--utbot",
223223
"--posix-runtime",
224224
"--skip-not-lazy-initialized",
225-
"--type-system=CXX",
225+
"--min-number-elements-li=1",
226226
"--fp-runtime",
227227
"--only-output-states-covering-new",
228228
"--allocate-determ",
@@ -235,10 +235,12 @@ KleeRunner::createKleeParams(const tests::TestMethod &testMethod,
235235
"--check-overshift=false",
236236
"--skip-not-symbolic-objects",
237237
"--use-tbaa",
238+
"--ubsan-runtime",
238239
"--output-dir=" + kleeOut.string()
239240
};
240241
if (Paths::isCXXFile(testMethod.sourceFilePath)) {
241-
argvData.emplace_back("--libcxx=true");
242+
argvData.emplace_back("--use-advanced-type-system=true");
243+
// argvData.emplace_back("--libcxx=true");
242244
}
243245
if (settingsContext.useDeterministicSearcher) {
244246
argvData.emplace_back("--search=dfs");

server/src/SARIFGenerator.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ namespace sarif {
6666
if (lineInDescriptor.empty() || lineInDescriptor[0] == '#')
6767
continue;
6868
if (isspace(lineInDescriptor[0])) {
69-
if (key == "Stack") {
69+
if (key == "ExecutionStack") {
7070
const std::regex stack_regex(
71-
R"regex(\s+#(.*) in ([^ ]*) [(][^)]*[)] at ([^:]*):(\d+))regex");
71+
R"regex(\s+#(.*) in ([^ ]*)[(][^)]*[)] at ([^:]*):(\d+))regex");
7272
std::smatch stack_match;
7373
if (!std::regex_match(lineInDescriptor, stack_match, stack_regex)) {
7474
LOG_S(ERROR) << "wrong `Stack` line: " << lineInDescriptor;
@@ -129,10 +129,10 @@ namespace sarif {
129129
if (pos == std::string::npos) {
130130
LOG_S(ERROR) << "no key:" << lineInDescriptor;
131131
} else {
132-
if (key == "Stack") {
132+
if (key == "ExecutionStack") {
133133
// Check stack validity
134134
if (firstCallInStack) {
135-
LOG_S(ERROR) << "no visible stack in descriptor:" << descriptor;
135+
LOG_S(ERROR) << "no visible ExecutionStack in descriptor:" << descriptor;
136136
} else {
137137
canAddThisTestToSARIF = true;
138138
}
@@ -147,7 +147,7 @@ namespace sarif {
147147
result["kind"] = "fail";
148148
} else if (key == ERROR_ID_KEY) {
149149
result["ruleId"] = value;
150-
} else if (key == "Stack") {
150+
} else if (key == "ExecutionStack") {
151151
stackLocations = json();
152152
codeFlowsLocations = json();
153153
} else if (key == TEST_FILE_KEY) {

server/src/Tests.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ void KTestObjectParser::assignTypeUnnamedVar(
675675
curType.paramValue.lazyValues.emplace_back(name, std::nullopt, testParamView);
676676
}
677677

678-
for (auto const &[offset, indObj, indexOffset] : testCase.objects[curType.jsonInd].pointers) {
678+
for (auto const &[offset, indObj, indexOffset]: testCase.objects[curType.jsonInd].pointers) {
679679
if (indexOffset != 0) {
680680
continue;
681681
}
@@ -1065,12 +1065,12 @@ void KTestObjectParser::processGlobalParamPreValue(Tests::TestCaseDescription &t
10651065

10661066
void KTestObjectParser::processSymbolicStdin(Tests::TestCaseDescription &testCaseDescription,
10671067
const std::vector<RawKleeParam> &rawKleeParams) {
1068-
auto &&read = getKleeParamOrThrow(rawKleeParams, "stdin-read");
1068+
auto &&read = getKleeParamOrThrow(rawKleeParams, KleeUtils::STDIN_READ_NAME);
10691069
std::string &&view =
1070-
testParameterView(read, { types::Type::longlongType(), "stdin-read" },
1071-
types::PointerUsage::PARAMETER, testCaseDescription.objects,
1072-
testCaseDescription.lazyReferences)
1073-
->getEntryValue(nullptr);
1070+
testParameterView(read, {types::Type::longlongType(), KleeUtils::STDIN_READ_NAME},
1071+
types::PointerUsage::PARAMETER, testCaseDescription.objects,
1072+
testCaseDescription.lazyReferences)
1073+
->getEntryValue(nullptr);
10741074
if (view == "0LL") {
10751075
return;
10761076
} else {
@@ -1080,7 +1080,7 @@ void KTestObjectParser::processSymbolicStdin(Tests::TestCaseDescription &testCas
10801080
LOG_S(ERROR) << message;
10811081
throw UnImplementedException(message);
10821082
}
1083-
auto &&stdinBuffer = getKleeParamOrThrow(rawKleeParams, "stdin");
1083+
auto &&stdinBuffer = getKleeParamOrThrow(rawKleeParams, KleeUtils::STDIN_NAME);
10841084
auto &&testParamView = stringLiteralView(stdinBuffer.rawData, usedStdinBytesCount);
10851085
testCaseDescription.stdinValue = Tests::TestCaseParamValue(types::Type::getStdinParamName(),
10861086
std::nullopt, testParamView);

server/src/Tests.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -888,8 +888,7 @@ namespace tests {
888888
std::enable_if_t<std::is_floating_point<T>::value, std::string>
889889
primitiveValueToString(T value) {
890890
std::stringstream ss;
891-
ss << std::scientific;
892-
ss << value;
891+
ss << std::scientific << value;
893892
return ss.str();
894893
}
895894

server/src/fetchers/FunctionDeclsMatchCallback.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ FunctionDeclsMatchCallback::FunctionDeclsMatchCallback(const Fetcher *parent,
2222
void FunctionDeclsMatchCallback::run(const MatchFinder::MatchResult &Result) {
2323
ExecUtils::throwIfCancelled();
2424
if (const FunctionDecl *FS = ClangUtils::getFunctionOrConstructor(Result)) {
25+
if (FS->isTemplated()) {
26+
return;
27+
}
2528
ExecUtils::throwIfCancelled();
2629
SourceManager &sourceManager = Result.Context->getSourceManager();
2730
fs::path sourceFilePath = ClangUtils::getSourceFilePath(sourceManager);

server/src/types/Types.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ types::Type types::Type::baseTypeObj(size_t depth) const {
114114
type.mKinds.erase(type.mKinds.begin(), type.mKinds.begin() + depth);
115115
type.dimension = type.getDimension();
116116
type.mTypeId = mBaseTypeId;
117-
type.mBaseTypeId = {};
117+
type.mBaseTypeId = mBaseTypeId;
118118
return type;
119119
}
120120

server/src/utils/KleeUtils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ namespace KleeUtils {
1212
static inline const std::string RESULT_VARIABLE_NAME = "utbot_result";
1313
static inline const std::string NOT_NULL_VARIABLE_NAME = "utbot_return_not_null";
1414

15+
static inline const std::string STDIN_READ_NAME = "stdin_read";
16+
static inline const std::string STDIN_NAME = "stdin";
17+
1518
std::string getRenamedOperator(std::string_view methodName);
1619

1720
std::string entryPointFunction(const tests::Tests &tests,

server/src/utils/PrinterUtils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,15 @@ namespace PrinterUtils {
161161
}
162162

163163
std::string getFileParamKTestJSON(char fileName) {
164-
return StringUtils::stringFormat("%c-data", fileName);
164+
return StringUtils::stringFormat("%c_data", fileName);
165165
}
166166

167167
std::string getFileReadBytesParamKTestJSON(char fileName) {
168-
return StringUtils::stringFormat("%c-data-read", fileName);
168+
return StringUtils::stringFormat("%c_data_read", fileName);
169169
}
170170

171171
std::string getFileWriteBytesParamKTestJSON(char fileName) {
172-
return StringUtils::stringFormat("%c-data-write", fileName);
172+
return StringUtils::stringFormat("%c_data_write", fileName);
173173
}
174174

175175
void removeThreadLocalQualifiers(std::string &decl) {

0 commit comments

Comments
 (0)