Skip to content

Commit 56bbd54

Browse files
authored
Add ld to isArchiveCommand (#642)
* Add ld to linker
1 parent a857fa0 commit 56bbd54

File tree

8 files changed

+67
-7
lines changed

8 files changed

+67
-7
lines changed

server/src/building/LinkCommand.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ namespace utbot {
6262
}
6363

6464
bool LinkCommand::isArchiveCommand() const {
65-
return StringUtils::contains(getBuildTool().filename().c_str(), "ar");
65+
return StringUtils::contains(getBuildTool().filename().c_str(), "ld") ||
66+
StringUtils::contains(getBuildTool().filename().c_str(), "ar");
6667
}
6768

6869
bool LinkCommand::isSharedLibraryCommand() const {
69-
return CollectionUtils::contains(commandLine, "-shared");
70+
return StringUtils::contains(getBuildTool().filename().c_str(), "ld") ||
71+
CollectionUtils::contains(commandLine, "-shared");
7072
}
7173

7274
void LinkCommand::initOutput() {

server/src/printers/NativeMakefilePrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ namespace printer {
2020
using StringUtils::stringFormat;
2121

2222
static const std::string STUB_OBJECT_FILES_NAME = "STUB_OBJECT_FILES";
23-
static const std::string STUB_OBJECT_FILES = "$(STUB_OBJECT_FILES)";
23+
static const std::string STUB_OBJECT_FILES = "$(" + STUB_OBJECT_FILES_NAME + ")";
2424

2525
static const std::string FPIC_FLAG = "-fPIC";
2626
static const std::vector<std::string> SANITIZER_NEEDED_FLAGS = {
27-
"-g", "-fno-omit-frame-pointer", "-fno-optimize-sibling-calls"
27+
"-g", "-fno-omit-frame-pointer", "-fno-optimize-sibling-calls"
2828
};
2929
static const std::string STATIC_FLAG = "-static";
3030
static const std::string SHARED_FLAG = "-shared";

server/test/framework/Regression_Tests.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,5 +400,4 @@ namespace {
400400
"isCorrectPointerStruct"
401401
);
402402
}
403-
404403
}

server/test/framework/Server_Tests.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,6 +1574,43 @@ namespace {
15741574
testUtils::checkStatusesCount(resultMap, tests, expectedStatusCountMap);
15751575
}
15761576

1577+
TEST_F(Server_Test, Linkage_LD) {
1578+
std::string suite = "linkage-ld";
1579+
setSuite(suite);
1580+
static const std::string issue_c = getTestFilePath("issue-638.c");
1581+
auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths,
1582+
GrpcUtils::UTBOT_AUTO_TARGET_PATH, false, false, 30, ErrorMode::FAILING);
1583+
auto request = GrpcUtils::createFileRequest(std::move(projectRequest), issue_c);
1584+
auto testGen = FileTestGen(*request, writer.get(), TESTMODE);
1585+
1586+
Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get());
1587+
ASSERT_TRUE(status.ok()) << status.error_message();
1588+
1589+
testUtils::checkMinNumberOfTests(testGen.tests, 2);
1590+
1591+
auto testFilter = GrpcUtils::createTestFilterForProject();
1592+
auto runRequest = createCoverageAndResultsRequest(
1593+
projectName, suitePath, suitePath / "tests",
1594+
buildDirRelativePath, std::move(testFilter));
1595+
auto coverageAndResultsWriter = std::make_unique<ServerCoverageAndResultsWriter>(nullptr);
1596+
CoverageAndResultsGenerator coverageGenerator{ runRequest.get(), coverageAndResultsWriter.get() };
1597+
utbot::SettingsContext settingsContext{ true, true, 45, 0, true, false, ErrorMode::FAILING, false};
1598+
coverageGenerator.generate(false, settingsContext);
1599+
1600+
ASSERT_TRUE(coverageGenerator.getCoverageMap().empty());
1601+
1602+
auto resultMap = coverageGenerator.getTestResultMap();
1603+
auto tests = coverageGenerator.getTestsToLaunch();
1604+
1605+
ASSERT_FALSE(resultMap.empty());
1606+
EXPECT_EQ(resultMap.getNumberOfTests(), 2);
1607+
1608+
testUtils::checkStatuses(resultMap, tests);
1609+
1610+
StatusCountMap expectedStatusCountMap{{testsgen::TEST_PASSED, 2}};
1611+
testUtils::checkStatusesCount(resultMap, tests, expectedStatusCountMap);
1612+
}
1613+
15771614
TEST_F(Server_Test, Assert_Fail) {
15781615
std::string suite = "error";
15791616
setSuite(suite);

server/test/framework/main.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ int main(int argc, char **argv) {
6868

6969
testUtils::tryExecGetBuildCommands(testUtils::getRelativeTestSuitePath("targets"), clang);
7070

71-
testUtils::tryExecGetBuildCommands(testUtils::getRelativeTestSuitePath("object-file"), clang, testUtils::MAKE_BUILD_COMMANDS_TOOL);
71+
testUtils::tryExecGetBuildCommands(testUtils::getRelativeTestSuitePath("object-file"), clang,
72+
testUtils::MAKE_BUILD_COMMANDS_TOOL);
73+
74+
testUtils::tryExecGetBuildCommands(testUtils::getRelativeTestSuitePath("linkage-ld"), clang,
75+
testUtils::MAKE_BUILD_COMMANDS_TOOL);
7276

7377
testUtils::tryExecGetBuildCommands(testUtils::getRelativeTestSuitePath("small-project"), gcc);
7478

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.PHONY: all clean
2+
3+
all: issue-638.so
4+
5+
clean:
6+
rm issue-638.o issue-638.so
7+
8+
issue-638.o: issue-638.c
9+
clang -c -o issue-638.o issue-638.c
10+
11+
issue-638.so: issue-638.o
12+
ld --shared -o issue-638.so issue-638.o
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
int abs(int i) {
2+
if (i < 0) {
3+
return -1 * i;
4+
}
5+
return i;
6+
}

submodules/Bear

Submodule Bear updated 1 file

0 commit comments

Comments
 (0)