Skip to content

Commit 89ede1c

Browse files
authored
Merge pull request #15981 from dcci/validate-moduleimport
2 parents 9f96706 + 5c99c35 commit 89ede1c

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

test/DebugInfo/DumpDeclFromMangledName.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@
77
// RUN: sed -ne '/--->/s/^.*---> *//p' < %S/Inputs/decl-reconstr-names.txt > %t.check
88

99
// RUN: %target-build-swift -emit-executable %s -g -o %t/DeclReconstr -emit-module
10+
11+
// Input validation tests.
12+
// RUN: not %lldb-moduleimport-test patatino 2>&1 | %FileCheck %s \
13+
// RUN: --check-prefix=INVALID-INPUT
14+
// INVALID-INPUT: patatino does not exists, exiting.
15+
16+
// RUN: not %lldb-moduleimport-test %t/DeclReconstr \
17+
// RUN: --decl-from-mangled=patatino 2>&1 | \
18+
// RUN: %FileCheck %s --check-prefix=INVALID-DECL
19+
// INVALID-DECL: patatino does not exists, exiting.
20+
21+
// RUN: not %lldb-moduleimport-test %t/DeclReconstr \
22+
// RUN: --type-from-mangled=patatino 2>&1 | \
23+
// RUN: %FileCheck %s --check-prefix=INVALID-TYPE
24+
// INVALID-TYPE: patatino does not exists, exiting.
25+
1026
// RUN: %lldb-moduleimport-test %t/DeclReconstr \
1127
// RUN: -decl-from-mangled=%t.input > %t.output 2>&1
1228
// RUN: diff %t.check %t.output

tools/lldb-moduleimport-test/lldb-moduleimport-test.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,28 @@ int main(int argc, char **argv) {
199199
DumpTypeFromMangled.removeArgument();
200200
InputNames.removeArgument();
201201

202+
auto validateInputFile = [](std::string Filename) {
203+
if (Filename.empty())
204+
return true;
205+
if (!llvm::sys::fs::exists(llvm::Twine(Filename))) {
206+
llvm::errs() << Filename << " does not exists, exiting.\n";
207+
return false;
208+
}
209+
if (!llvm::sys::fs::is_regular_file(llvm::Twine(Filename))) {
210+
llvm::errs() << Filename << " is not a regular file, exiting.\n";
211+
return false;
212+
}
213+
return true;
214+
};
215+
216+
for (auto &InputFilename : InputNames)
217+
if (!validateInputFile(InputFilename))
218+
return 1;
219+
if (!validateInputFile(DumpTypeFromMangled))
220+
return 1;
221+
if (!validateInputFile(DumpDeclFromMangled))
222+
return 1;
223+
202224
// Fetch the serialized module bitstreams from the Mach-O files and
203225
// register them with the module loader.
204226
llvm::SmallVector<std::pair<char *, uint64_t>, 8> Modules;

0 commit comments

Comments
 (0)