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

Add ld to isArchiveCommand #642

Merged
merged 4 commits into from
Sep 14, 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
6 changes: 4 additions & 2 deletions server/src/building/LinkCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ namespace utbot {
}

bool LinkCommand::isArchiveCommand() const {
return StringUtils::contains(getBuildTool().filename().c_str(), "ar");
return StringUtils::contains(getBuildTool().filename().c_str(), "ld") ||
StringUtils::contains(getBuildTool().filename().c_str(), "ar");
}

bool LinkCommand::isSharedLibraryCommand() const {
return CollectionUtils::contains(commandLine, "-shared");
return StringUtils::contains(getBuildTool().filename().c_str(), "ld") ||
CollectionUtils::contains(commandLine, "-shared");
}

void LinkCommand::initOutput() {
Expand Down
4 changes: 2 additions & 2 deletions server/src/printers/NativeMakefilePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ namespace printer {
using StringUtils::stringFormat;

static const std::string STUB_OBJECT_FILES_NAME = "STUB_OBJECT_FILES";
static const std::string STUB_OBJECT_FILES = "$(STUB_OBJECT_FILES)";
static const std::string STUB_OBJECT_FILES = "$(" + STUB_OBJECT_FILES_NAME + ")";

static const std::string FPIC_FLAG = "-fPIC";
static const std::vector<std::string> SANITIZER_NEEDED_FLAGS = {
"-g", "-fno-omit-frame-pointer", "-fno-optimize-sibling-calls"
"-g", "-fno-omit-frame-pointer", "-fno-optimize-sibling-calls"
};
static const std::string STATIC_FLAG = "-static";
static const std::string SHARED_FLAG = "-shared";
Expand Down
1 change: 0 additions & 1 deletion server/test/framework/Regression_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,5 +400,4 @@ namespace {
"isCorrectPointerStruct"
);
}

}
37 changes: 37 additions & 0 deletions server/test/framework/Server_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1574,6 +1574,43 @@ namespace {
testUtils::checkStatusesCount(resultMap, tests, expectedStatusCountMap);
}

TEST_F(Server_Test, Linkage_LD) {
std::string suite = "linkage-ld";
setSuite(suite);
static const std::string issue_c = getTestFilePath("issue-638.c");
auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths,
GrpcUtils::UTBOT_AUTO_TARGET_PATH, false, false, 30, ErrorMode::FAILING);
auto request = GrpcUtils::createFileRequest(std::move(projectRequest), issue_c);
auto testGen = FileTestGen(*request, writer.get(), TESTMODE);

Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get());
ASSERT_TRUE(status.ok()) << status.error_message();

testUtils::checkMinNumberOfTests(testGen.tests, 2);

auto testFilter = GrpcUtils::createTestFilterForProject();
auto runRequest = createCoverageAndResultsRequest(
projectName, suitePath, suitePath / "tests",
buildDirRelativePath, std::move(testFilter));
auto coverageAndResultsWriter = std::make_unique<ServerCoverageAndResultsWriter>(nullptr);
CoverageAndResultsGenerator coverageGenerator{ runRequest.get(), coverageAndResultsWriter.get() };
utbot::SettingsContext settingsContext{ true, true, 45, 0, true, false, ErrorMode::FAILING, false};
coverageGenerator.generate(false, settingsContext);

ASSERT_TRUE(coverageGenerator.getCoverageMap().empty());

auto resultMap = coverageGenerator.getTestResultMap();
auto tests = coverageGenerator.getTestsToLaunch();

ASSERT_FALSE(resultMap.empty());
EXPECT_EQ(resultMap.getNumberOfTests(), 2);

testUtils::checkStatuses(resultMap, tests);

StatusCountMap expectedStatusCountMap{{testsgen::TEST_PASSED, 2}};
testUtils::checkStatusesCount(resultMap, tests, expectedStatusCountMap);
}

TEST_F(Server_Test, Assert_Fail) {
std::string suite = "error";
setSuite(suite);
Expand Down
6 changes: 5 additions & 1 deletion server/test/framework/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ int main(int argc, char **argv) {

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

testUtils::tryExecGetBuildCommands(testUtils::getRelativeTestSuitePath("object-file"), clang, testUtils::MAKE_BUILD_COMMANDS_TOOL);
testUtils::tryExecGetBuildCommands(testUtils::getRelativeTestSuitePath("object-file"), clang,
testUtils::MAKE_BUILD_COMMANDS_TOOL);

testUtils::tryExecGetBuildCommands(testUtils::getRelativeTestSuitePath("linkage-ld"), clang,
testUtils::MAKE_BUILD_COMMANDS_TOOL);

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

Expand Down
12 changes: 12 additions & 0 deletions server/test/suites/linkage-ld/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.PHONY: all clean

all: issue-638.so

clean:
rm issue-638.o issue-638.so

issue-638.o: issue-638.c
clang -c -o issue-638.o issue-638.c

issue-638.so: issue-638.o
ld --shared -o issue-638.so issue-638.o
6 changes: 6 additions & 0 deletions server/test/suites/linkage-ld/issue-638.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
int abs(int i) {
if (i < 0) {
return -1 * i;
}
return i;
}
2 changes: 1 addition & 1 deletion submodules/Bear
Submodule Bear updated 1 files
+6 −0 bear/bear.py