Skip to content

Commit 4881f03

Browse files
committed
Add test
1 parent 3f1eeaa commit 4881f03

File tree

9 files changed

+58
-9
lines changed

9 files changed

+58
-9
lines changed

server/test/framework/Server_Tests.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,22 @@ namespace {
15641564
testUtils::checkStatusesCount(resultMap, tests, expectedStatusCountMap);
15651565
}
15661566

1567+
TEST_F(Server_Test, precompiled_obj) {
1568+
std::string suite = "precompiled";
1569+
setSuite(suite);
1570+
static const std::string source2_c = getTestFilePath("source2.c");
1571+
auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths,
1572+
GrpcUtils::UTBOT_AUTO_TARGET_PATH, false, false, 30,
1573+
ErrorMode::FAILING, false, true);
1574+
auto request = GrpcUtils::createFileRequest(std::move(projectRequest), source2_c);
1575+
auto testGen = FileTestGen(*request, writer.get(), TESTMODE);
1576+
1577+
Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get());
1578+
ASSERT_TRUE(status.ok()) << status.error_message();
1579+
1580+
testUtils::checkMinNumberOfTests(testGen.tests, 1);
1581+
}
1582+
15671583
TEST_F(Server_Test, Linkage_LD) {
15681584
std::string suite = "linkage-ld";
15691585
setSuite(suite);
@@ -1584,7 +1600,7 @@ namespace {
15841600
buildDirRelativePath, std::move(testFilter));
15851601
auto coverageAndResultsWriter = std::make_unique<ServerCoverageAndResultsWriter>(nullptr);
15861602
CoverageAndResultsGenerator coverageGenerator{ runRequest.get(), coverageAndResultsWriter.get() };
1587-
utbot::SettingsContext settingsContext{ true, true, 45, 0, true, false, ErrorMode::FAILING, false};
1603+
utbot::SettingsContext settingsContext{ true, true, 45, 0, true, false, ErrorMode::FAILING, false, false};
15881604
coverageGenerator.generate(false, settingsContext);
15891605

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

server/test/framework/Stub_Tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ namespace {
197197
static auto coverageAndResultsWriter =
198198
std::make_unique<ServerCoverageAndResultsWriter>(nullptr);
199199
CoverageAndResultsGenerator coverageGenerator{runRequest.get(), coverageAndResultsWriter.get()};
200-
utbot::SettingsContext settingsContext{true, true, 15, 0, true, true, ErrorMode::FAILING, false};
200+
utbot::SettingsContext settingsContext{true, true, 15, 0, true, true, ErrorMode::FAILING, false, false};
201201
coverageGenerator.generate(true, settingsContext);
202202
EXPECT_FALSE(coverageGenerator.hasExceptions());
203203
}

server/test/framework/TestUtils.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,13 @@ namespace testUtils {
229229
bool verbose,
230230
int kleeTimeout,
231231
ErrorMode errorMode,
232-
bool differentVariables) {
232+
bool differentVariables,
233+
bool skipPrecompiled) {
233234
auto projectContext = GrpcUtils::createProjectContext(
234235
projectName, projectPath, projectPath / "tests", buildDirRelativePath);
235236
auto settingsContext =
236237
GrpcUtils::createSettingsContext(true, verbose, kleeTimeout, 0, false, useStubs, errorMode,
237-
differentVariables, false);
238+
differentVariables, skipPrecompiled);
238239
return GrpcUtils::createProjectRequest(std::move(projectContext),
239240
std::move(settingsContext),
240241
srcPaths,

server/test/framework/TestUtils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ namespace testUtils {
7878
bool verbose = true,
7979
int kleeTimeout = 60,
8080
ErrorMode errorMode = ErrorMode::FAILING,
81-
bool differentVariables = false);
81+
bool differentVariables = false,
82+
bool skipPrecompiled = false);
8283

8384
std::unique_ptr<FileRequest> createFileRequest(const std::string &projectName,
8485
const fs::path &projectPath,

server/test/framework/main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ int main(int argc, char **argv) {
7171
testUtils::tryExecGetBuildCommands(testUtils::getRelativeTestSuitePath("object-file"), clang,
7272
testUtils::MAKE_BUILD_COMMANDS_TOOL);
7373

74+
testUtils::tryExecGetBuildCommands(testUtils::getRelativeTestSuitePath("precompiled"), clang,
75+
testUtils::MAKE_BUILD_COMMANDS_TOOL);
76+
7477
testUtils::tryExecGetBuildCommands(testUtils::getRelativeTestSuitePath("linkage-ld"), clang,
7578
testUtils::MAKE_BUILD_COMMANDS_TOOL);
7679

server/test/suites/object-file/Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
all: exe
44

55
clean:
6-
rm exe lib.a lib1.o lib2.o
6+
rm exe lib.a lib1.o lib2.o source1.o
77

88
lib1.o: lib1.c
99
clang -c -o lib1.o lib1.c
@@ -14,5 +14,8 @@ lib2.o: lib2.c
1414
lib.a: lib1.o lib2.o
1515
ar crs -o lib.a lib1.o lib2.o
1616

17-
exe: source1.c source2.c lib.a
18-
clang -o exe source1.c source2.c lib.a
17+
source1.o: source1.c
18+
clang -c -o source1.o source1.c
19+
20+
exe: source1.o source2.c lib.a
21+
clang -o exe source1.o source2.c lib.a

server/test/suites/object-file/source2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <stdlib.h>
22

3-
int main(int argc, char* argv[]) {
3+
int main(int argc, char *argv[]) {
44
if (f(argc) < 5) {
55
return 0;
66
} else {
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: exe
4+
5+
clean:
6+
rm source2.o exe
7+
8+
source2.o: source2.c
9+
clang -c -o source2.o source2.c
10+
11+
exe: source2.o
12+
clang -o exe ../object-file/source1.o source2.o
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <stdlib.h>
2+
3+
int g() {
4+
return 15;
5+
}
6+
7+
int main(int argc, char *argv[]) {
8+
if (f(argc) < 5) {
9+
return 0;
10+
} else {
11+
return atoi(argv[0]);
12+
}
13+
}

0 commit comments

Comments
 (0)