From 7caac4bcc77cc2090186bf9d9eeb831ca1bb773c Mon Sep 17 00:00:00 2001 From: Vladislav Kalugin Date: Mon, 23 Oct 2023 11:03:52 +0300 Subject: [PATCH 1/2] Fix run ubuntu 22.04 --- .../utbot_run_system.sh | 15 ++++++++------- server/src/KleeRunner.cpp | 4 ++-- server/src/printers/NativeMakefilePrinter.cpp | 1 - server/src/tasks/BaseForkTask.cpp | 3 ++- server/test/framework/TestUtils.cpp | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/docker/release_distribution_scripts/utbot_run_system.sh b/docker/release_distribution_scripts/utbot_run_system.sh index 8960b0ed5..843c486c7 100644 --- a/docker/release_distribution_scripts/utbot_run_system.sh +++ b/docker/release_distribution_scripts/utbot_run_system.sh @@ -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 @@ -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'!" diff --git a/server/src/KleeRunner.cpp b/server/src/KleeRunner.cpp index b22e0c061..f2da7d8b7 100644 --- a/server/src/KleeRunner.cpp +++ b/server/src/KleeRunner.cpp @@ -285,7 +285,7 @@ void KleeRunner::processBatchWithoutInteractive(const std::vector cargv, cenvp; std::vector 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); @@ -341,7 +341,7 @@ void KleeRunner::processBatchWithInteractive(const std::vector 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(), diff --git a/server/src/printers/NativeMakefilePrinter.cpp b/server/src/printers/NativeMakefilePrinter.cpp index fc120bebd..fb9011801 100644 --- a/server/src/printers/NativeMakefilePrinter.cpp +++ b/server/src/printers/NativeMakefilePrinter.cpp @@ -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( diff --git a/server/src/tasks/BaseForkTask.cpp b/server/src/tasks/BaseForkTask.cpp index 258ce7994..df475915d 100644 --- a/server/src/tasks/BaseForkTask.cpp +++ b/server/src/tasks/BaseForkTask.cpp @@ -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"; diff --git a/server/test/framework/TestUtils.cpp b/server/test/framework/TestUtils.cpp index 6f1da86f9..931524c50 100644 --- a/server/test/framework/TestUtils.cpp +++ b/server/test/framework/TestUtils.cpp @@ -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( From 22ca3ef99959337337e9f9d20fc5faf931545c0f Mon Sep 17 00:00:00 2001 From: Vladislav Kalugin Date: Tue, 24 Oct 2023 17:02:50 +0300 Subject: [PATCH 2/2] Fix stubs --- server/src/printers/Printer.cpp | 12 ++++++++++++ server/src/printers/Printer.h | 2 ++ server/src/printers/TestsPrinter.cpp | 7 +------ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/server/src/printers/Printer.cpp b/server/src/printers/Printer.cpp index 8c3e151e9..12f7b794a 100644 --- a/server/src/printers/Printer.cpp +++ b/server/src/printers/Printer.cpp @@ -539,6 +539,18 @@ namespace printer { } } + void printer::Printer::writeExternForSymbolicStubs(const Tests::MethodDescription& testMethod) { + std::unordered_map 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 &fInfo, const std::string &methodName, diff --git a/server/src/printers/Printer.h b/server/src/printers/Printer.h index 98caa5808..b9da7a14b 100644 --- a/server/src/printers/Printer.h +++ b/server/src/printers/Printer.h @@ -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); diff --git a/server/src/printers/TestsPrinter.cpp b/server/src/printers/TestsPrinter.cpp index 2ca22a870..a187af0e1 100644 --- a/server/src/printers/TestsPrinter.cpp +++ b/server/src/printers/TestsPrinter.cpp @@ -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"; @@ -177,6 +171,7 @@ void TestsPrinter::genCode(Tests::MethodDescription &methodDescription, int testNum = 0; writeStubsForFunctionParams(typesHandler, methodDescription, false); + writeExternForSymbolicStubs(methodDescription); methodDescription.stubsText = ss.str(); resetStream();