From aa45f148926e3461a1fd8b10c990f0a51a908cc9 Mon Sep 17 00:00:00 2001 From: dim Date: Mon, 10 Jun 2013 20:36:52 +0000 Subject: Vendor import of llvm tags/RELEASE_33/final r183502 (effectively, 3.3 release): http://llvm.org/svn/llvm-project/llvm/tags/RELEASE_33/final@183502 --- unittests/Support/Path.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'unittests/Support/Path.cpp') diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp index 4511259..eec8c62 100644 --- a/unittests/Support/Path.cpp +++ b/unittests/Support/Path.cpp @@ -298,12 +298,19 @@ TEST_F(FileSystemTest, DirectoryIteration) { ASSERT_LT(z0, za1); } +const char elf[] = {0x7f, 'E', 'L', 'F', 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; + TEST_F(FileSystemTest, Magic) { struct type { const char *filename; const char *magic_str; - size_t magic_str_len; - } types [] = {{"magic.archive", "!\x0A", 8}}; + size_t magic_str_len; + fs::file_magic magic; + } types [] = { + {"magic.archive", "!\x0A", 8, fs::file_magic::archive}, + {"magic.elf", elf, sizeof(elf), + fs::file_magic::elf_relocatable} + }; // Create some files filled with magic. for (type *i = types, *e = types + (sizeof(types) / sizeof(type)); i != e; @@ -320,6 +327,7 @@ TEST_F(FileSystemTest, Magic) { bool res = false; ASSERT_NO_ERROR(fs::has_magic(file_pathname.c_str(), magic, res)); EXPECT_TRUE(res); + EXPECT_EQ(i->magic, fs::identify_magic(magic)); } } -- cgit v1.1