Skip to content
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
8 changes: 2 additions & 6 deletions server/src/building/Linker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@ Result<Linker::LinkResult> Linker::linkWholeTarget(const fs::path &target) {
CollectionUtils::FileSet siblingObjectsToBuild;
for (const fs::path &objectFile : siblings) {
auto objectInfo = testGen.buildDatabase->getClientCompilationUnitInfo(objectFile);
if (CollectionUtils::contains(stubSources, objectInfo->getSourcePath())) {
continue;
}
bool insideFolder = true;
if (auto folderTestGen = dynamic_cast<FolderTestGen *>(&testGen)) {
fs::path folderGen = folderTestGen->folderPath;
Expand All @@ -154,12 +151,11 @@ Result<Linker::LinkResult> Linker::linkWholeTarget(const fs::path &target) {
if (testGen.buildDatabase->isFirstObjectFileForSource(objectFile) &&
!CollectionUtils::contains(testedFiles, objectInfo->getSourcePath()) &&
insideFolder) {
filesToLink.insert(
{ objectFile, objectInfo->kleeFilesInfo->getKleeBitcodeFile() });
filesToLink.emplace(objectFile, objectInfo->kleeFilesInfo->getKleeBitcodeFile());
} else {
siblingObjectsToBuild.insert(objectInfo->getOutputFile());
fs::path bitcodeFile =
testGen.buildDatabase->getBitcodeForSource(objectInfo->getSourcePath());
testGen.buildDatabase->getBitcodeForSource(objectInfo->getSourcePath());
filesToLink.emplace(objectFile, bitcodeFile);
}
}
Expand Down
21 changes: 20 additions & 1 deletion server/test/framework/Regression_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace {

std::pair<FunctionTestGen, Status>
createTestForFunction(const fs::path &pathToFile, int lineNum, bool verbose = true) {
auto lineRequest = createLineRequest(projectName, suitePath, buildDirRelativePath,
auto lineRequest = testUtils::createLineRequest(projectName, suitePath, buildDirRelativePath,
srcPaths, pathToFile, lineNum, false, verbose, 0);
auto request = GrpcUtils::createFunctionRequest(std::move(lineRequest));
auto testGen = FunctionTestGen(*request, writer.get(), TESTMODE);
Expand All @@ -36,6 +36,18 @@ namespace {
Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get());
return { testGen, status };
}

std::pair<FolderTestGen, Status>
createTestForFolder(const fs::path &pathToFolder, bool useStubs = true, bool verbose = true) {
auto folderRequest = testUtils::createProjectRequest(projectName, suitePath, buildDirRelativePath,
srcPaths, useStubs, verbose, 0);
auto request = GrpcUtils::createFolderRequest(std::move(folderRequest), pathToFolder);
auto testGen = FolderTestGen(*request, writer.get(), TESTMODE);
testGen.setTargetPath(GrpcUtils::UTBOT_AUTO_TARGET_PATH);

Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get());
return {testGen, status};
}
};

// uint_32t parameters/return values and call external printf
Expand Down Expand Up @@ -328,4 +340,11 @@ namespace {
} }),
"f4");
}

TEST_F(Regression_Test, Generate_Folder) {
fs::path folderPath = getTestFilePath("ISSUE-140");
auto [testGen, status] = createTestForFolder(folderPath, true, true);
ASSERT_TRUE(status.ok()) << status.error_message();
testUtils::checkMinNumberOfTests(testGen.tests, 1);
}
}
3 changes: 3 additions & 0 deletions server/test/suites/regression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ add_executable(
SAT-777.c
main.c)

add_subdirectory(ISSUE-140)
target_link_libraries(regression issue-140)

add_library(
SAT-760
SAT-760/SAT-760_1.c
Expand Down
4 changes: 4 additions & 0 deletions server/test/suites/regression/ISSUE-140/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
add_library(issue-140)
target_include_directories(issue-140 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
file(GLOB_RECURSE ALL_SOURCES "*.c" "*.h")
target_sources(issue-140 PRIVATE ${ALL_SOURCES})
5 changes: 5 additions & 0 deletions server/test/suites/regression/ISSUE-140/module/libfunc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "libfunc.h"

int libfunc(int a) {
return 10;
}
6 changes: 6 additions & 0 deletions server/test/suites/regression/ISSUE-140/module/libfunc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef SIMPLE_TEST_PROJECT_LIBFUNC_H
#define SIMPLE_TEST_PROJECT_LIBFUNC_H

int libfunc(int a);

#endif //SIMPLE_TEST_PROJECT_LIBFUNC_H