Skip to content
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

Fix run ubuntu 22.04 #649

Merged
merged 2 commits into from
Oct 24, 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
15 changes: 8 additions & 7 deletions docker/release_distribution_scripts/utbot_run_system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,19 @@ export UTBOT_LOGS_FOLDER=$UTBOT_ALL
export UTBOT_INSTALL_DIR=$UTBOT_ALL/install
export CC=$UTBOT_ALL/install/bin/clang
export CXX=$UTBOT_ALL/install/bin/clang++
export CPATH=$UTBOT_ALL/klee/include:$CPATH # Path for C and C++ includes
export PATH=$UTBOT_ALL/bear/bin:$UTBOT_ALL/klee/bin:$UTBOT_INSTALL_DIR/bin:$PATH
export CPATH=$UTBOT_ALL/klee/include${CPATH:+:${CPATH}} # Path for C and C++ includes
export PATH=$UTBOT_ALL/bear/bin:$UTBOT_ALL/klee/bin:$UTBOT_INSTALL_DIR/bin${PATH:+:${PATH}}
export KLEE_RUNTIME_LIBRARY_PATH=$UTBOT_ALL/klee/lib/klee/runtime/

# If the system is opensuse, variable is not empty. It is empty otherwise.
IS_SUSE="$(grep '^NAME=' /etc/os-release | tr '[:upper:]' '[:lower:]' | grep suse)"

# Setting environment variables for debian packages
export PATH=$UTBOT_ALL/debs-install/usr/bin:$PATH
export LD_LIBRARY_PATH=$UTBOT_ALL/install/lib:$UTBOT_ALL/debs-install/lib/x86_64-linux-gnu:$UTBOT_ALL/debs-install/usr/lib/x86_64-linux-gnu:$UTBOT_ALL/debs-install/usr/local/lib:$UTBOT_ALL/debs-install/lib:$UTBOT_ALL/debs-install/usr/lib:$LD_LIBRARY_PATH
export CPATH=$UTBOT_ALL/debs-install/usr/lib/gcc/x86_64-linux-gnu/9/include:$UTBOT_ALL/debs-install/usr/local/include:$UTBOT_ALL/debs-install/usr/include/x86_64-linux-gnu:$UTBOT_ALL/debs-install/usr/include:$CPATH
export CPLUS_INCLUDE_PATH=$UTBOT_ALL/debs-install/usr/include/c++/9:$UTBOT_ALL/debs-install/usr/include/x86_64-linux-gnu/c++/9:$UTBOT_ALL/debs-install/usr/include/c++/9/backward:$CPLUS_INCLUDE_PATH
export PATH=$UTBOT_ALL/debs-install/usr/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=$UTBOT_ALL/install/lib:$UTBOT_ALL/debs-install/lib/x86_64-linux-gnu:$UTBOT_ALL/debs-install/usr/lib/x86_64-linux-gnu:$UTBOT_ALL/debs-install/usr/local/lib:$UTBOT_ALL/debs-install/lib:$UTBOT_ALL/debs-install/usr/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export GENERAL_INCLUDES=$UTBOT_ALL/debs-install/usr/lib/gcc/x86_64-linux-gnu/9/include:$UTBOT_ALL/debs-install/usr/local/include:$UTBOT_ALL/debs-install/usr/include/x86_64-linux-gnu:$UTBOT_ALL/debs-install/usr/include
export C_INCLUDE_PATH=GENERAL_INCLUDES${C_INCLUDE_PATH:+:${C_INCLUDE_PATH}}
export CPLUS_INCLUDE_PATH=$UTBOT_ALL/debs-install/usr/include/c++/9:$UTBOT_ALL/debs-install/usr/include/x86_64-linux-gnu/c++/9:$UTBOT_ALL/debs-install/usr/include/c++/9/backward:GENERAL_INCLUDES${CPLUS_INCLUDE_PATH:+:${CPLUS_INCLUDE_PATH}}
export LDFLAGS="-fuse-ld=gold $LDFLAGS"

# This function moves dev version of libc into $UTBOT_ALL/debs-install directory
Expand Down Expand Up @@ -133,7 +134,7 @@ then
PROJECT_PATH=$4
mkdir -p $PROJECT_PATH/build
cd $PROJECT_PATH/build || exit

if [ -f "../$UTBOT_BUILD_SCRIPT" ]
then
echo "Trying to run '$UTBOT_BUILD_SCRIPT'!"
Expand Down
4 changes: 2 additions & 2 deletions server/src/KleeRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ void KleeRunner::processBatchWithoutInteractive(const std::vector<tests::TestMet
std::vector<char *> cargv, cenvp;
std::vector<std::string> tmp;
ExecUtils::toCArgumentsPtr(argvData, tmp, cargv, cenvp, false);
LOG_S(DEBUG) << "Klee command :: " + StringUtils::joinWith(argvData, " ");
LOG_S(DEBUG) << "Klee command: " + StringUtils::joinWith(argvData, " ");
MEASURE_FUNCTION_EXECUTION_TIME

RunKleeTask task(cargv.size(), cargv.data(), settingsContext.timeoutPerFunction);
Expand Down Expand Up @@ -341,7 +341,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(DEBUG) << "Klee command: " + StringUtils::joinWith(argvData, " ");
MEASURE_FUNCTION_EXECUTION_TIME

RunKleeTask task(cargv.size(),
Expand Down
1 change: 0 additions & 1 deletion server/src/printers/NativeMakefilePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ namespace printer {
}

compileCommand.setOptimizationLevel(OPTIMIZATION_FLAG);
compileCommand.addEnvironmentVariable("C_INCLUDE_PATH", "$UTBOT_LAUNCH_INCLUDE_PATH");
compileCommand.addFlagToBegin(FPIC_FLAG);
compileCommand.addFlagsToBegin(SANITIZER_NEEDED_FLAGS);
compileCommand.addFlagsToBegin(
Expand Down
12 changes: 12 additions & 0 deletions server/src/printers/Printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,18 @@ namespace printer {
}
}

void printer::Printer::writeExternForSymbolicStubs(const Tests::MethodDescription& testMethod) {
std::unordered_map<std::string, std::string> symbolicNamesToTypesMap;
for (const auto& testCase: testMethod.testCases) {
for (size_t i = 0; i < testCase.stubValues.size(); i++) {
symbolicNamesToTypesMap[testCase.stubValues[i].name] = testCase.stubValuesTypes[i].type.usedType();
}
}
for (const auto& [name, type]: symbolicNamesToTypesMap) {
strDeclareVar("extern \"C\" " + type, name);
}
}

void printer::Printer::writeStubForParam(const types::TypesHandler *typesHandler,
const std::shared_ptr<types::FunctionInfo> &fInfo,
const std::string &methodName,
Expand Down
2 changes: 2 additions & 0 deletions server/src/printers/Printer.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ namespace printer {
const Tests::MethodDescription& testMethod,
bool forKlee);

void writeExternForSymbolicStubs(const Tests::MethodDescription& testMethod);

void writeStubsForStructureFields(const Tests &tests);

void writeStubsForParameters(const Tests &tests);
Expand Down
7 changes: 1 addition & 6 deletions server/src/printers/TestsPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ void TestsPrinter::joinToFinalCode(Tests &tests, const fs::path& generatedHeader
genHeaders(tests, generatedHeaderPath);
ss << NL;

if (!tests.methods.empty()) {
for (const auto &stubsHeader: tests.methods.begin()->second.stubsStorage->getStubsHeaders()) {
strInclude(stubsHeader) << NL;
}
}

strDeclareSetOfVars(tests.externVariables);

ss << "namespace " << PrinterUtils::TEST_NAMESPACE << " {\n";
Expand Down Expand Up @@ -177,6 +171,7 @@ void TestsPrinter::genCode(Tests::MethodDescription &methodDescription,
int testNum = 0;

writeStubsForFunctionParams(typesHandler, methodDescription, false);
writeExternForSymbolicStubs(methodDescription);

methodDescription.stubsText = ss.str();
resetStream();
Expand Down
3 changes: 2 additions & 1 deletion server/src/tasks/BaseForkTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ ExecUtils::ExecutionResult BaseForkTask::run() {
status = TIMEOUT_CODE;
}
if (!ignoreErrors && status && status != TIMEOUT_CODE) {
LOG_S(ERROR) << "Exit status: " << status;
LOG_S(ERROR) << "Exit status '" << processName << "': " << status;
LOG_S(ERROR) << "Output: " << output;
LOG_S(ERROR) << "See details in " << logFilePath;
}
LOG_IF_S(DEBUG, status == 0) << "Exit status: 0";
Expand Down
2 changes: 1 addition & 1 deletion server/test/framework/TestUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ namespace testUtils {
case CompilationUtils::CompilerName::GCC:
return StringUtils::stringFormat(
"rm -rf build_gcc && mkdir -p build_gcc && cd build_gcc && "
"export CC=%s && export CXX=%s && export C_INCLUDE_PATH=$UTBOT_LAUNCH_INCLUDE_PATH",
"export CC=%s && export CXX=%s",
Paths::getGcc(), Paths::getGpp());
case CompilationUtils::CompilerName::CLANG:
return StringUtils::stringFormat(
Expand Down