Skip to content

fetcher & tests minor fixes #454

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

Merged
merged 1 commit into from
Sep 16, 2022
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
2 changes: 1 addition & 1 deletion server/src/ReturnTypesFetcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void ReturnTypesFetcher::fetch(ProgressWriter *const progressWriter,
testsMap[filePath];
}
Fetcher(Fetcher::Options::Value::RETURN_TYPE_NAMES_ONLY,
testGen->getTargetBuildDatabase()->compilationDatabase, testsMap, nullptr, nullptr, nullptr,
testGen->getTargetBuildDatabase()->compilationDatabase, testsMap, nullptr, nullptr,
testGen->compileCommandsJsonPath, false)
.fetchWithProgress(progressWriter, "Fetching return types for functions", true);
for (auto const &[sourceFilePath, test] : testsMap) {
Expand Down
4 changes: 2 additions & 2 deletions server/src/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Status Server::TestsGenServiceImpl::ProcessBaseTestRequest(BaseTestGen &testGen,
LOG_S(DEBUG) << logMessage;
Fetcher fetcher(Fetcher::Options::Value::ALL,
testGen.getTargetBuildDatabase()->compilationDatabase, testGen.tests, &testGen.types,
&sizeContext.pointerSize, &sizeContext.maximumAlignment,
&sizeContext.maximumAlignment,
testGen.compileCommandsJsonPath, false);
fetcher.fetchWithProgress(testGen.progressWriter, logMessage);
SourceToHeaderRewriter(testGen.projectContext, testGen.getTargetBuildDatabase()->compilationDatabase,
Expand Down Expand Up @@ -552,7 +552,7 @@ Status Server::TestsGenServiceImpl::ProcessProjectStubsRequest(BaseTestGen *test
LOG_S(DEBUG) << logMessage;
Fetcher fetcher(Fetcher::Options::Value::TYPE | Fetcher::Options::Value::FUNCTION,
testGen->getTargetBuildDatabase()->compilationDatabase, testGen->tests, &testGen->types,
&sizeContext.pointerSize, &sizeContext.maximumAlignment,
&sizeContext.maximumAlignment,
testGen->compileCommandsJsonPath, false);

fetcher.fetchWithProgress(testGen->progressWriter, logMessage);
Expand Down
8 changes: 4 additions & 4 deletions server/src/Synchronizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ void Synchronizer::synchronizeStubs(StubSet &outdatedStubs,
auto filesInFolder = Paths::findFilesInFolder(stubDirPath);
auto presentStubs = CollectionUtils::transformTo<StubSet>(
dropHeaders(filesInFolder), [this](const fs::path &stubPath) {
return StubOperator(Paths::stubPathToSourcePath(this->testGen->projectContext, stubPath), Paths::isHeaderFile(stubPath));
return StubOperator(Paths::stubPathToSourcePath(this->testGen->projectContext, stubPath),
Paths::isHeaderFile(stubPath));
});
StubSet stubFiles = CollectionUtils::unionSet(allStubs, presentStubs);
tests::TestsMap stubFilesMap, sourceFilesMap;
Expand All @@ -153,11 +154,10 @@ void Synchronizer::synchronizeStubs(StubSet &outdatedStubs,

auto stubFetcher =
Fetcher(options, testGen->getProjectBuildDatabase()->compilationDatabase, sourceFilesMap, &testGen->types,
&sizeContext->pointerSize, &sizeContext->maximumAlignment,
&sizeContext->maximumAlignment,
testGen->compileCommandsJsonPath, false);

stubFetcher.fetchWithProgress(testGen->progressWriter, "Finding source files required for stubs",
true);
stubFetcher.fetchWithProgress(testGen->progressWriter, "Finding source files required for stubs", true);

fs::path ccJsonStubDirPath =
Paths::getUtbotBuildDir(testGen->projectContext) / "stubs_build_files";
Expand Down
8 changes: 4 additions & 4 deletions server/src/fetchers/Fetcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ Fetcher::Fetcher(Options options,
const std::shared_ptr<CompilationDatabase> &compilationDatabase,
tests::TestsMap &tests,
types::TypeMaps *types,
size_t *pointerSize,
size_t *maximumAlignment,
const fs::path &compileCommandsJsonPath,
bool fetchFunctionBodies)
: options(options), projectTests(&tests), projectTypes(types),
pointerSize(pointerSize), maximumAlignment(maximumAlignment),
fetchFunctionBodies(fetchFunctionBodies), clangToolRunner(compilationDatabase) {
: options(options), projectTests(&tests), projectTypes(types),
maximumAlignment(maximumAlignment), fetchFunctionBodies(fetchFunctionBodies),
clangToolRunner(compilationDatabase) {
buildRootPath = Paths::subtractPath(compileCommandsJsonPath.string(), CompilationUtils::UTBOT_BUILD_DIR_NAME);
if (options.has(Options::Value::TYPE)) {
addMatcher<TypeDeclsMatchCallback>(anyTypeDeclarationMatcher);
Expand Down Expand Up @@ -83,6 +82,7 @@ void Fetcher::fetchWithProgress(const ProgressWriter *progressWriter,

void Fetcher::postProcess() const {
if (options.has(Options::Value::FUNCTION) && maximumAlignment != nullptr) {
// TODO maybe this is useless?
for (auto projectTestsIterator = projectTests->begin();
projectTestsIterator != projectTests->end(); projectTestsIterator++) {
tests::Tests &tests = projectTestsIterator.value();
Expand Down
2 changes: 0 additions & 2 deletions server/src/fetchers/Fetcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ class Fetcher {
const std::shared_ptr<CompilationDatabase> &compilationDatabase,
tests::TestsMap &tests,
types::TypeMaps *types,
size_t *pointerSize,
size_t *maximumAlignment,
const fs::path &compileCommandsJsonPath,
bool fetchFunctionBodies);
Expand All @@ -76,7 +75,6 @@ class Fetcher {

tests::TestsMap *const projectTests;
types::TypeMaps *const projectTypes;
size_t *const pointerSize;
size_t *const maximumAlignment;
fs::path buildRootPath;

Expand Down
1 change: 0 additions & 1 deletion server/src/fetchers/TypeDeclsMatchCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ TypeDeclsMatchCallback::TypeDeclsMatchCallback(const Fetcher *parent)
void TypeDeclsMatchCallback::run(const MatchFinder::MatchResult &Result) {
QualType pointerType = Result.Context->getPointerType(Result.Context->getWideCharType());
uint64_t pointerSize = Result.Context->getTypeSize(pointerType) / 8;
*parent->pointerSize = pointerSize;

ExecUtils::throwIfCancelled();
checkStructDecl(Result);
Expand Down
3 changes: 1 addition & 2 deletions server/src/stubs/StubGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ StubGen::findStubFilesBySignatures(const std::vector<tests::Tests::MethodDescrip
stubFilesMap[file].sourceFilePath = file;
}
Fetcher::Options::Value options = Fetcher::Options::Value::FUNCTION_NAMES_ONLY;
Fetcher fetcher(options, stubsCdb, stubFilesMap, nullptr,
nullptr, nullptr, ccJsonDirPath, true);
Fetcher fetcher(options, stubsCdb, stubFilesMap, nullptr, nullptr, ccJsonDirPath, true);
fetcher.fetchWithProgress(testGen.progressWriter, "Finding stub files", true);
CollectionUtils::FileSet stubFilesSet;
auto signatureNamesSet = CollectionUtils::transformTo<std::unordered_set<std::string>>(
Expand Down
15 changes: 0 additions & 15 deletions server/test/framework/Regression_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,21 +197,6 @@ namespace {
"ret");
}

TEST_F(Regression_Test, Unnamed_Bit_Field) {
fs::path source = getTestFilePath("PR124.c");
auto [testGen, status] = createTestForFunction(source, 8);

ASSERT_TRUE(status.ok()) << status.error_message();

checkTestCasePredicates(
testGen.tests.at(source).methods.begin().value().testCases,
std::vector<TestCasePredicate>(
{ [](const tests::Tests::MethodTestCase &testCase) {
return !testCase.isError();
} }),
"bpf_xdp_attach");
}

TEST_F(Regression_Test, VaList_In_Function_Pointer_Type) {
fs::path source = getTestFilePath("PR123.c");
auto [testGen, status] = createTestForFunction(source, 7);
Expand Down
Loading