Skip to content

Commit 065aa10

Browse files
Vladislav Kaluginladisgin
authored andcommitted
Fix generate for folder
1 parent 2171673 commit 065aa10

File tree

6 files changed

+40
-7
lines changed

6 files changed

+40
-7
lines changed

server/src/building/Linker.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,6 @@ Result<Linker::LinkResult> Linker::linkWholeTarget(const fs::path &target) {
141141
CollectionUtils::FileSet siblingObjectsToBuild;
142142
for (const fs::path &objectFile : siblings) {
143143
auto objectInfo = testGen.buildDatabase->getClientCompilationUnitInfo(objectFile);
144-
if (CollectionUtils::contains(stubSources, objectInfo->getSourcePath())) {
145-
continue;
146-
}
147144
bool insideFolder = true;
148145
if (auto folderTestGen = dynamic_cast<FolderTestGen *>(&testGen)) {
149146
fs::path folderGen = folderTestGen->folderPath;
@@ -154,12 +151,11 @@ Result<Linker::LinkResult> Linker::linkWholeTarget(const fs::path &target) {
154151
if (testGen.buildDatabase->isFirstObjectFileForSource(objectFile) &&
155152
!CollectionUtils::contains(testedFiles, objectInfo->getSourcePath()) &&
156153
insideFolder) {
157-
filesToLink.insert(
158-
{ objectFile, objectInfo->kleeFilesInfo->getKleeBitcodeFile() });
154+
filesToLink.emplace(objectFile, objectInfo->kleeFilesInfo->getKleeBitcodeFile());
159155
} else {
160156
siblingObjectsToBuild.insert(objectInfo->getOutputFile());
161157
fs::path bitcodeFile =
162-
testGen.buildDatabase->getBitcodeForSource(objectInfo->getSourcePath());
158+
testGen.buildDatabase->getBitcodeForSource(objectInfo->getSourcePath());
163159
filesToLink.emplace(objectFile, bitcodeFile);
164160
}
165161
}

server/test/framework/Regression_Tests.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace {
2727

2828
std::pair<FunctionTestGen, Status>
2929
createTestForFunction(const fs::path &pathToFile, int lineNum, bool verbose = true) {
30-
auto lineRequest = createLineRequest(projectName, suitePath, buildDirRelativePath,
30+
auto lineRequest = testUtils::createLineRequest(projectName, suitePath, buildDirRelativePath,
3131
srcPaths, pathToFile, lineNum, false, verbose, 0);
3232
auto request = GrpcUtils::createFunctionRequest(std::move(lineRequest));
3333
auto testGen = FunctionTestGen(*request, writer.get(), TESTMODE);
@@ -36,6 +36,18 @@ namespace {
3636
Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get());
3737
return { testGen, status };
3838
}
39+
40+
std::pair<FolderTestGen, Status>
41+
createTestForFolder(const fs::path &pathToFolder, bool useStubs = true, bool verbose = true) {
42+
auto folderRequest = testUtils::createProjectRequest(projectName, suitePath, buildDirRelativePath,
43+
srcPaths, useStubs, verbose, 0);
44+
auto request = GrpcUtils::createFolderRequest(std::move(folderRequest), pathToFolder);
45+
auto testGen = FolderTestGen(*request, writer.get(), TESTMODE);
46+
testGen.setTargetPath(GrpcUtils::UTBOT_AUTO_TARGET_PATH);
47+
48+
Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get());
49+
return {testGen, status};
50+
}
3951
};
4052

4153
// uint_32t parameters/return values and call external printf
@@ -328,4 +340,11 @@ namespace {
328340
} }),
329341
"f4");
330342
}
343+
344+
TEST_F(Regression_Test, Generate_Folder) {
345+
fs::path folderPath = getTestFilePath("ISSUE-140");
346+
auto [testGen, status] = createTestForFolder(folderPath, true, true);
347+
ASSERT_TRUE(status.ok()) << status.error_message();
348+
testUtils::checkMinNumberOfTests(testGen.tests, 1);
349+
}
331350
}

server/test/suites/regression/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ add_executable(
1717
SAT-777.c
1818
main.c)
1919

20+
add_subdirectory(ISSUE-140)
21+
target_link_libraries(regression issue-140)
22+
2023
add_library(
2124
SAT-760
2225
SAT-760/SAT-760_1.c
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
add_library(issue-140)
2+
target_include_directories(issue-140 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
3+
file(GLOB_RECURSE ALL_SOURCES "*.c" "*.h")
4+
target_sources(issue-140 PRIVATE ${ALL_SOURCES})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "libfunc.h"
2+
3+
int libfunc(int a) {
4+
return 10;
5+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef SIMPLE_TEST_PROJECT_LIBFUNC_H
2+
#define SIMPLE_TEST_PROJECT_LIBFUNC_H
3+
4+
int libfunc(int a);
5+
6+
#endif //SIMPLE_TEST_PROJECT_LIBFUNC_H

0 commit comments

Comments
 (0)