diff options
Diffstat (limited to 'unittests/Transforms')
-rw-r--r-- | unittests/Transforms/CMakeLists.txt | 1 | ||||
-rw-r--r-- | unittests/Transforms/DebugIR/CMakeLists.txt | 7 | ||||
-rw-r--r-- | unittests/Transforms/DebugIR/DebugIR.cpp | 307 | ||||
-rw-r--r-- | unittests/Transforms/DebugIR/Makefile | 15 | ||||
-rw-r--r-- | unittests/Transforms/Makefile | 2 | ||||
-rw-r--r-- | unittests/Transforms/Utils/CMakeLists.txt | 1 | ||||
-rw-r--r-- | unittests/Transforms/Utils/SpecialCaseList.cpp | 232 |
7 files changed, 564 insertions, 1 deletions
diff --git a/unittests/Transforms/CMakeLists.txt b/unittests/Transforms/CMakeLists.txt index e3ce185e0d5b4..8ec56f10d9739 100644 --- a/unittests/Transforms/CMakeLists.txt +++ b/unittests/Transforms/CMakeLists.txt @@ -1 +1,2 @@ +add_subdirectory(DebugIR) add_subdirectory(Utils) diff --git a/unittests/Transforms/DebugIR/CMakeLists.txt b/unittests/Transforms/DebugIR/CMakeLists.txt new file mode 100644 index 0000000000000..4b471939ef1fa --- /dev/null +++ b/unittests/Transforms/DebugIR/CMakeLists.txt @@ -0,0 +1,7 @@ +set(LLVM_LINK_COMPONENTS + Instrumentation + ) + +add_llvm_unittest(DebugIRTests + DebugIR.cpp + ) diff --git a/unittests/Transforms/DebugIR/DebugIR.cpp b/unittests/Transforms/DebugIR/DebugIR.cpp new file mode 100644 index 0000000000000..7d213fd0567ad --- /dev/null +++ b/unittests/Transforms/DebugIR/DebugIR.cpp @@ -0,0 +1,307 @@ +//===- DebugIR.cpp - Unit tests for the DebugIR pass ----------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// The tests in this file verify the DebugIR pass that generates debug metadata +// for LLVM IR. +// +//===----------------------------------------------------------------------===// + +#include "llvm/ADT/Triple.h" +#include "llvm/Config/config.h" +#include "llvm/DebugInfo.h" +#include "llvm/DIBuilder.h" +#include "llvm/IR/Module.h" +#include "llvm/Support/Host.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/Path.h" +#include "llvm/Transforms/Instrumentation.h" + +#include "../lib/Transforms/Instrumentation/DebugIR.h" + +// These tests do not depend on MCJIT, but we use the TrivialModuleBuilder +// helper class to construct some trivial Modules. +#include "../unittests/ExecutionEngine/MCJIT/MCJITTestBase.h" + +#include <string> + +#include "gtest/gtest.h" + +#if defined(LLVM_ON_WIN32) +#include <direct.h> +#define getcwd_impl _getcwd +#elif defined (HAVE_GETCWD) +#include <unistd.h> +#define getcwd_impl getcwd +#endif // LLVM_ON_WIN32 + +using namespace llvm; +using namespace std; + +namespace { + +/// Insert a mock CUDescriptor with the specified producer +void insertCUDescriptor(Module *M, StringRef File, StringRef Dir, + StringRef Producer) { + DIBuilder B(*M); + B.createCompileUnit(dwarf::DW_LANG_C99, File, Dir, Producer, false, "", 0); + B.finalize(); +} + +/// Attempts to remove file at Path and returns true if it existed, or false if +/// it did not. +bool removeIfExists(StringRef Path) { + bool existed = false; + sys::fs::remove(Path, existed); + return existed; +} + +char * current_dir() { +#if defined(LLVM_ON_WIN32) || defined(HAVE_GETCWD) + // calling getcwd (or _getcwd() on windows) with a null buffer makes it + // allocate a sufficiently sized buffer to store the current working dir. + return getcwd_impl(0, 0); +#else + return 0; +#endif +} + +class TestDebugIR : public ::testing::Test, public TrivialModuleBuilder { +protected: + TestDebugIR() + : TrivialModuleBuilder(sys::getProcessTriple()) + , cwd(current_dir()) {} + + ~TestDebugIR() { free(cwd); } + + /// Returns a concatenated path string consisting of Dir and Filename + string getPath(const string &Dir, const string &Filename) { + SmallVector<char, 8> Path; + sys::path::append(Path, Dir, Filename); + Path.resize(Dir.size() + Filename.size() + 2); + Path[Dir.size() + Filename.size() + 1] = '\0'; + return string(Path.data()); + } + + LLVMContext Context; + char *cwd; + OwningPtr<Module> M; + OwningPtr<DebugIR> D; +}; + +// Test empty named Module that is not supposed to be output to disk. +TEST_F(TestDebugIR, EmptyNamedModuleNoWrite) { + string Dir = "MadeUpDirectory"; + string File = "empty_module.ll"; + string Path(getPath(Dir, File)); + + M.reset(createEmptyModule(Path)); + + // constructing DebugIR with no args should not result in any file generated. + D.reset(static_cast<DebugIR *>(llvm::createDebugIRPass())); + D->runOnModule(*M); + + // verify DebugIR did not generate a file + ASSERT_FALSE(removeIfExists(Path)) << "Unexpected file " << Path; +} + +// Test a non-empty unnamed module that is output to an autogenerated file name. +TEST_F(TestDebugIR, NonEmptyUnnamedModuleWriteToAutogeneratedFile) { + M.reset(createEmptyModule()); + insertAddFunction(M.get()); + D.reset(static_cast<DebugIR *>(llvm::createDebugIRPass(true, true))); + + string Path; + D->runOnModule(*M, Path); + + // verify DebugIR generated a file, and clean it up + ASSERT_TRUE(removeIfExists(Path)) << "Missing expected file at " << Path; +} + +// Test not specifying a name in the module -- DebugIR should generate a name +// and write the file contents. +TEST_F(TestDebugIR, EmptyModuleWriteAnonymousFile) { + M.reset(createEmptyModule()); + D.reset(static_cast<DebugIR *>(llvm::createDebugIRPass(false, false))); + + string Path; + D->runOnModule(*M, Path); + + // verify DebugIR generated a file and clean it up + ASSERT_TRUE(removeIfExists(Path)) << "Missing expected file at " << Path; +} + +#ifdef HAVE_GETCWD // These tests require get_current_dir_name() + +// Test empty named Module that is to be output to path specified at Module +// construction. +TEST_F(TestDebugIR, EmptyNamedModuleWriteFile) { + string Filename("NamedFile1"); + string ExpectedPath(getPath(cwd, Filename)); + + M.reset(createEmptyModule(ExpectedPath)); + D.reset(static_cast<DebugIR *>(llvm::createDebugIRPass(true, true))); + + string Path; + D->runOnModule(*M, Path); + + // verify DebugIR was able to correctly parse the file name from module ID + ASSERT_EQ(ExpectedPath, Path); + + // verify DebugIR generated a file, and clean it up + ASSERT_TRUE(removeIfExists(Path)) << "Missing expected file at " << Path; +} + +// Test an empty unnamed module generates an output file whose path is specified +// at DebugIR construction. +TEST_F(TestDebugIR, EmptyUnnamedModuleWriteNamedFile) { + string Filename("NamedFile2"); + + M.reset(createEmptyModule()); + D.reset(static_cast<DebugIR *>(llvm::createDebugIRPass( + false, false, StringRef(cwd), StringRef(Filename)))); + string Path; + D->runOnModule(*M, Path); + + string ExpectedPath(getPath(cwd, Filename)); + ASSERT_EQ(ExpectedPath, Path); + + // verify DebugIR generated a file, and clean it up + ASSERT_TRUE(removeIfExists(Path)) << "Missing expected file at " << Path; +} + +// Test an empty named module generates an output file at the path specified +// during DebugIR construction. +TEST_F(TestDebugIR, EmptyNamedModuleWriteNamedFile) { + string Filename("NamedFile3"); + + string UnexpectedPath(getPath(cwd, "UnexpectedFilename")); + M.reset(createEmptyModule(UnexpectedPath)); + + D.reset(static_cast<DebugIR *>(llvm::createDebugIRPass( + false, false, StringRef(cwd), StringRef(Filename)))); + string Path; + D->runOnModule(*M, Path); + + string ExpectedPath(getPath(cwd, Filename)); + ASSERT_EQ(ExpectedPath, Path); + + // verify DebugIR generated a file, and clean it up + ASSERT_TRUE(removeIfExists(Path)) << "Missing expected file at " << Path; + + // verify DebugIR did not generate a file at the path specified at Module + // construction. + ASSERT_FALSE(removeIfExists(UnexpectedPath)) << "Unexpected file " << Path; +} + +// Test a non-empty named module that is not supposed to be output to disk +TEST_F(TestDebugIR, NonEmptyNamedModuleNoWrite) { + string Filename("NamedFile4"); + string ExpectedPath(getPath(cwd, Filename)); + + M.reset(createEmptyModule(ExpectedPath)); + insertAddFunction(M.get()); + + D.reset(static_cast<DebugIR *>(llvm::createDebugIRPass())); + + string Path; + D->runOnModule(*M, Path); + ASSERT_EQ(ExpectedPath, Path); + + // verify DebugIR did not generate a file + ASSERT_FALSE(removeIfExists(Path)) << "Unexpected file " << Path; +} + +// Test a non-empty named module that is output to disk. +TEST_F(TestDebugIR, NonEmptyNamedModuleWriteFile) { + string Filename("NamedFile5"); + string ExpectedPath(getPath(cwd, Filename)); + + M.reset(createEmptyModule(ExpectedPath)); + insertAddFunction(M.get()); + + D.reset(static_cast<DebugIR *>(llvm::createDebugIRPass(true, true))); + + string Path; + D->runOnModule(*M, Path); + ASSERT_EQ(ExpectedPath, Path); + + // verify DebugIR generated a file, and clean it up + ASSERT_TRUE(removeIfExists(Path)) << "Missing expected file at " << Path; +} + +// Test a non-empty unnamed module is output to a path specified at DebugIR +// construction. +TEST_F(TestDebugIR, NonEmptyUnnamedModuleWriteToNamedFile) { + string Filename("NamedFile6"); + + M.reset(createEmptyModule()); + insertAddFunction(M.get()); + + D.reset(static_cast<DebugIR *>( + llvm::createDebugIRPass(true, true, cwd, Filename))); + string Path; + D->runOnModule(*M, Path); + + string ExpectedPath(getPath(cwd, Filename)); + ASSERT_EQ(ExpectedPath, Path); + + // verify DebugIR generated a file, and clean it up + ASSERT_TRUE(removeIfExists(Path)) << "Missing expected file at " << Path; +} + +// Test that information inside existing debug metadata is retained +TEST_F(TestDebugIR, ExistingMetadataRetained) { + string Filename("NamedFile7"); + string ExpectedPath(getPath(cwd, Filename)); + + M.reset(createEmptyModule(ExpectedPath)); + insertAddFunction(M.get()); + + StringRef Producer("TestProducer"); + insertCUDescriptor(M.get(), Filename, cwd, Producer); + + DebugInfoFinder Finder; + Finder.processModule(*M); + ASSERT_EQ((unsigned)1, Finder.compile_unit_count()); + D.reset(static_cast<DebugIR *>(llvm::createDebugIRPass())); + + string Path; + D->runOnModule(*M, Path); + ASSERT_EQ(ExpectedPath, Path); + + // verify DebugIR did not generate a file + ASSERT_FALSE(removeIfExists(Path)) << "Unexpected file " << Path; + + DICompileUnit CU(*Finder.compile_unit_begin()); + + // Verify original CU information is retained + ASSERT_EQ(Filename, CU.getFilename()); + ASSERT_EQ(cwd, CU.getDirectory()); + ASSERT_EQ(Producer, CU.getProducer()); +} + +#endif // HAVE_GETCWD + +#ifdef GTEST_HAS_DEATH_TEST + +// Test a non-empty unnamed module that is not supposed to be output to disk +// NOTE: this test is expected to die with LLVM_ERROR, and such depends on +// google test's "death test" mode. +TEST_F(TestDebugIR, NonEmptyUnnamedModuleNoWrite) { + M.reset(createEmptyModule(StringRef())); + insertAddFunction(M.get()); + D.reset(static_cast<DebugIR *>(llvm::createDebugIRPass())); + + // No name in module or on DebugIR construction ==> DebugIR should assert + EXPECT_DEATH(D->runOnModule(*M), + "DebugIR unable to determine file name in input."); +} + +#endif // GTEST_HAS_DEATH_TEST +} diff --git a/unittests/Transforms/DebugIR/Makefile b/unittests/Transforms/DebugIR/Makefile new file mode 100644 index 0000000000000..9ace8c33c41ce --- /dev/null +++ b/unittests/Transforms/DebugIR/Makefile @@ -0,0 +1,15 @@ +##===- unittests/Transforms/Utils/Makefile -----------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL = ../../.. +TESTNAME = DebugIR +LINK_COMPONENTS := Instrumentation + +include $(LEVEL)/Makefile.config +include $(LLVM_SRC_ROOT)/unittests/Makefile.unittest diff --git a/unittests/Transforms/Makefile b/unittests/Transforms/Makefile index 599b18a057dcf..d5cca397b6af3 100644 --- a/unittests/Transforms/Makefile +++ b/unittests/Transforms/Makefile @@ -9,7 +9,7 @@ LEVEL = ../.. -PARALLEL_DIRS = Utils +PARALLEL_DIRS = DebugIR Utils include $(LEVEL)/Makefile.common diff --git a/unittests/Transforms/Utils/CMakeLists.txt b/unittests/Transforms/Utils/CMakeLists.txt index 730d83b838fb6..0656390cbbeaf 100644 --- a/unittests/Transforms/Utils/CMakeLists.txt +++ b/unittests/Transforms/Utils/CMakeLists.txt @@ -6,4 +6,5 @@ add_llvm_unittest(UtilsTests Cloning.cpp IntegerDivision.cpp Local.cpp + SpecialCaseList.cpp ) diff --git a/unittests/Transforms/Utils/SpecialCaseList.cpp b/unittests/Transforms/Utils/SpecialCaseList.cpp new file mode 100644 index 0000000000000..07ac908caabcc --- /dev/null +++ b/unittests/Transforms/Utils/SpecialCaseList.cpp @@ -0,0 +1,232 @@ +//===- SpecialCaseList.cpp - Unit tests for SpecialCaseList ---------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/IR/Function.h" +#include "llvm/IR/LLVMContext.h" +#include "llvm/IR/Module.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Transforms/Utils/SpecialCaseList.h" +#include "gtest/gtest.h" + +using namespace llvm; + +namespace { + +class SpecialCaseListTest : public ::testing::Test { +protected: + Function *makeFunction(StringRef Name, Module &M) { + return Function::Create(FunctionType::get(Type::getVoidTy(Ctx), false), + GlobalValue::ExternalLinkage, + Name, + &M); + } + + GlobalVariable *makeGlobal(StringRef Name, StringRef StructName, Module &M) { + StructType *ST = + StructType::create(StructName, Type::getInt32Ty(Ctx), (Type*)0); + return new GlobalVariable( + M, ST, false, GlobalValue::ExternalLinkage, 0, Name); + } + + GlobalAlias *makeAlias(StringRef Name, GlobalValue *Aliasee) { + return new GlobalAlias(Aliasee->getType(), GlobalValue::ExternalLinkage, + Name, Aliasee, Aliasee->getParent()); + } + + SpecialCaseList *makeSpecialCaseList(StringRef List, std::string &Error) { + OwningPtr<MemoryBuffer> MB(MemoryBuffer::getMemBuffer(List)); + return SpecialCaseList::create(MB.get(), Error); + } + + SpecialCaseList *makeSpecialCaseList(StringRef List) { + std::string Error; + SpecialCaseList *SCL = makeSpecialCaseList(List, Error); + assert(SCL); + assert(Error == ""); + return SCL; + } + + LLVMContext Ctx; +}; + +TEST_F(SpecialCaseListTest, ModuleIsIn) { + Module M("hello", Ctx); + Function *F = makeFunction("foo", M); + GlobalVariable *GV = makeGlobal("bar", "t", M); + + OwningPtr<SpecialCaseList> SCL(makeSpecialCaseList("# This is a comment.\n" + "\n" + "src:hello\n")); + EXPECT_TRUE(SCL->isIn(M)); + EXPECT_TRUE(SCL->isIn(*F)); + EXPECT_TRUE(SCL->isIn(*GV)); + + SCL.reset(makeSpecialCaseList("src:he*o\n")); + EXPECT_TRUE(SCL->isIn(M)); + EXPECT_TRUE(SCL->isIn(*F)); + EXPECT_TRUE(SCL->isIn(*GV)); + + SCL.reset(makeSpecialCaseList("src:hi\n")); + EXPECT_FALSE(SCL->isIn(M)); + EXPECT_FALSE(SCL->isIn(*F)); + EXPECT_FALSE(SCL->isIn(*GV)); +} + +TEST_F(SpecialCaseListTest, FunctionIsIn) { + Module M("hello", Ctx); + Function *Foo = makeFunction("foo", M); + Function *Bar = makeFunction("bar", M); + + OwningPtr<SpecialCaseList> SCL(makeSpecialCaseList("fun:foo\n")); + EXPECT_TRUE(SCL->isIn(*Foo)); + EXPECT_FALSE(SCL->isIn(*Bar)); + + SCL.reset(makeSpecialCaseList("fun:b*\n")); + EXPECT_FALSE(SCL->isIn(*Foo)); + EXPECT_TRUE(SCL->isIn(*Bar)); + + SCL.reset(makeSpecialCaseList("fun:f*\n" + "fun:bar\n")); + EXPECT_TRUE(SCL->isIn(*Foo)); + EXPECT_TRUE(SCL->isIn(*Bar)); + + SCL.reset(makeSpecialCaseList("fun:foo=functional\n")); + EXPECT_TRUE(SCL->isIn(*Foo, "functional")); + StringRef Category; + EXPECT_FALSE(SCL->isIn(*Bar, "functional")); +} + +TEST_F(SpecialCaseListTest, GlobalIsIn) { + Module M("hello", Ctx); + GlobalVariable *Foo = makeGlobal("foo", "t1", M); + GlobalVariable *Bar = makeGlobal("bar", "t2", M); + + OwningPtr<SpecialCaseList> SCL(makeSpecialCaseList("global:foo\n")); + EXPECT_TRUE(SCL->isIn(*Foo)); + EXPECT_FALSE(SCL->isIn(*Bar)); + EXPECT_FALSE(SCL->isIn(*Foo, "init")); + EXPECT_FALSE(SCL->isIn(*Bar, "init")); + + SCL.reset(makeSpecialCaseList("global:foo=init\n")); + EXPECT_FALSE(SCL->isIn(*Foo)); + EXPECT_FALSE(SCL->isIn(*Bar)); + EXPECT_TRUE(SCL->isIn(*Foo, "init")); + EXPECT_FALSE(SCL->isIn(*Bar, "init")); + + SCL.reset(makeSpecialCaseList("global-init:foo\n")); + EXPECT_FALSE(SCL->isIn(*Foo)); + EXPECT_FALSE(SCL->isIn(*Bar)); + EXPECT_TRUE(SCL->isIn(*Foo, "init")); + EXPECT_FALSE(SCL->isIn(*Bar, "init")); + + SCL.reset(makeSpecialCaseList("type:t2=init\n")); + EXPECT_FALSE(SCL->isIn(*Foo)); + EXPECT_FALSE(SCL->isIn(*Bar)); + EXPECT_FALSE(SCL->isIn(*Foo, "init")); + EXPECT_TRUE(SCL->isIn(*Bar, "init")); + + SCL.reset(makeSpecialCaseList("global-init-type:t2\n")); + EXPECT_FALSE(SCL->isIn(*Foo)); + EXPECT_FALSE(SCL->isIn(*Bar)); + EXPECT_FALSE(SCL->isIn(*Foo, "init")); + EXPECT_TRUE(SCL->isIn(*Bar, "init")); + + SCL.reset(makeSpecialCaseList("src:hello=init\n")); + EXPECT_FALSE(SCL->isIn(*Foo)); + EXPECT_FALSE(SCL->isIn(*Bar)); + EXPECT_TRUE(SCL->isIn(*Foo, "init")); + EXPECT_TRUE(SCL->isIn(*Bar, "init")); + + SCL.reset(makeSpecialCaseList("global-init-src:hello\n")); + EXPECT_FALSE(SCL->isIn(*Foo)); + EXPECT_FALSE(SCL->isIn(*Bar)); + EXPECT_TRUE(SCL->isIn(*Foo, "init")); + EXPECT_TRUE(SCL->isIn(*Bar, "init")); +} + +TEST_F(SpecialCaseListTest, AliasIsIn) { + Module M("hello", Ctx); + Function *Foo = makeFunction("foo", M); + GlobalVariable *Bar = makeGlobal("bar", "t", M); + GlobalAlias *FooAlias = makeAlias("fooalias", Foo); + GlobalAlias *BarAlias = makeAlias("baralias", Bar); + + OwningPtr<SpecialCaseList> SCL(makeSpecialCaseList("fun:foo\n")); + EXPECT_FALSE(SCL->isIn(*FooAlias)); + EXPECT_FALSE(SCL->isIn(*BarAlias)); + + SCL.reset(makeSpecialCaseList("global:bar\n")); + EXPECT_FALSE(SCL->isIn(*FooAlias)); + EXPECT_FALSE(SCL->isIn(*BarAlias)); + + SCL.reset(makeSpecialCaseList("global:fooalias\n")); + EXPECT_FALSE(SCL->isIn(*FooAlias)); + EXPECT_FALSE(SCL->isIn(*BarAlias)); + + SCL.reset(makeSpecialCaseList("fun:fooalias\n")); + EXPECT_TRUE(SCL->isIn(*FooAlias)); + EXPECT_FALSE(SCL->isIn(*BarAlias)); + + SCL.reset(makeSpecialCaseList("global:baralias=init\n")); + EXPECT_FALSE(SCL->isIn(*FooAlias, "init")); + EXPECT_TRUE(SCL->isIn(*BarAlias, "init")); + + SCL.reset(makeSpecialCaseList("type:t=init\n")); + EXPECT_FALSE(SCL->isIn(*FooAlias, "init")); + EXPECT_TRUE(SCL->isIn(*BarAlias, "init")); + + SCL.reset(makeSpecialCaseList("fun:baralias=init\n")); + EXPECT_FALSE(SCL->isIn(*FooAlias, "init")); + EXPECT_FALSE(SCL->isIn(*BarAlias, "init")); +} + +TEST_F(SpecialCaseListTest, Substring) { + Module M("othello", Ctx); + Function *F = makeFunction("tomfoolery", M); + GlobalVariable *GV = makeGlobal("bartender", "t", M); + GlobalAlias *GA1 = makeAlias("buffoonery", F); + GlobalAlias *GA2 = makeAlias("foobar", GV); + + OwningPtr<SpecialCaseList> SCL(makeSpecialCaseList("src:hello\n" + "fun:foo\n" + "global:bar\n")); + EXPECT_FALSE(SCL->isIn(M)); + EXPECT_FALSE(SCL->isIn(*F)); + EXPECT_FALSE(SCL->isIn(*GV)); + EXPECT_FALSE(SCL->isIn(*GA1)); + EXPECT_FALSE(SCL->isIn(*GA2)); + + SCL.reset(makeSpecialCaseList("fun:*foo*\n")); + EXPECT_TRUE(SCL->isIn(*F)); + EXPECT_TRUE(SCL->isIn(*GA1)); +} + +TEST_F(SpecialCaseListTest, InvalidSpecialCaseList) { + std::string Error; + EXPECT_EQ(0, makeSpecialCaseList("badline", Error)); + EXPECT_EQ("Malformed line 1: 'badline'", Error); + EXPECT_EQ(0, makeSpecialCaseList("src:bad[a-", Error)); + EXPECT_EQ("Malformed regex in line 1: 'bad[a-': invalid character range", + Error); + EXPECT_EQ(0, makeSpecialCaseList("src:a.c\n" + "fun:fun(a\n", + Error)); + EXPECT_EQ("Malformed regex in line 2: 'fun(a': parentheses not balanced", + Error); + EXPECT_EQ(0, SpecialCaseList::create("unexisting", Error)); + EXPECT_EQ(0U, Error.find("Can't open file 'unexisting':")); +} + +TEST_F(SpecialCaseListTest, EmptySpecialCaseList) { + OwningPtr<SpecialCaseList> SCL(makeSpecialCaseList("")); + Module M("foo", Ctx); + EXPECT_FALSE(SCL->isIn(M)); +} + +} |