summaryrefslogtreecommitdiffstats
path: root/unittests
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2013-11-13 21:55:41 +0000
committerRui Ueyama <ruiu@google.com>2013-11-13 21:55:41 +0000
commitc9024c6ebcea89746e01207195eeb52c60c3c3bb (patch)
tree2a02d513788b6f278af076d3f74e318a29c3f243 /unittests
parente0573aab49d3835362d4f5e12cead20276ef4739 (diff)
downloadexternal_llvm-c9024c6ebcea89746e01207195eeb52c60c3c3bb.zip
external_llvm-c9024c6ebcea89746e01207195eeb52c60c3c3bb.tar.gz
external_llvm-c9024c6ebcea89746e01207195eeb52c60c3c3bb.tar.bz2
Path: Add tests for existing file magics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194607 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Support/Path.cpp42
1 files changed, 36 insertions, 6 deletions
diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp
index 7efaa5e..caf17b9 100644
--- a/unittests/Support/Path.cpp
+++ b/unittests/Support/Path.cpp
@@ -416,7 +416,23 @@ 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};
+const char archive[] = "!<arch>\x0A";
+const char bitcode[] = "\xde\xc0\x17\x0b";
+const char elf_relocatable[] = { 0x7f, 'E', 'L', 'F', 1, 2, 1, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 1 };
+const char macho_universal_binary[] = "\xca\xfe\xba\xbe...\0x00";
+const char macho_object[] = "\xfe\xed\xfa\xce..........\x00\x01";
+const char macho_executable[] = "\xfe\xed\xfa\xce..........\x00\x02";
+const char macho_fixed_virtual_memory_shared_lib[] =
+ "\xfe\xed\xfa\xce..........\x00\x03";
+const char macho_core[] = "\xfe\xed\xfa\xce..........\x00\x04";
+const char macho_preload_executable[] = "\xfe\xed\xfa\xce..........\x00\x05";
+const char macho_dynamically_linked_shared_lib[] =
+ "\xfe\xed\xfa\xce..........\x00\x06";
+const char macho_dynamic_linker[] = "\xfe\xed\xfa\xce..........\x00\x07";
+const char macho_bundle[] = "\xfe\xed\xfa\xce..........\x00\x08";
+const char macho_dsym_companion[] = "\xfe\xed\xfa\xce..........\x00\x0a";
+const char windows_resource[] = "\x00\x00\x00\x00\x020\x00\x00\x00\xff";
TEST_F(FileSystemTest, Magic) {
struct type {
@@ -424,11 +440,25 @@ TEST_F(FileSystemTest, Magic) {
const char *magic_str;
size_t magic_str_len;
fs::file_magic magic;
- } types [] = {
- {"magic.archive", "!<arch>\x0A", 8, fs::file_magic::archive},
- {"magic.elf", elf, sizeof(elf),
- fs::file_magic::elf_relocatable}
- };
+ } types[] = {
+#define DEFINE(magic) \
+ { #magic, magic, sizeof(magic), fs::file_magic::magic }
+ DEFINE(archive),
+ DEFINE(bitcode),
+ DEFINE(elf_relocatable),
+ DEFINE(macho_universal_binary),
+ DEFINE(macho_object),
+ DEFINE(macho_executable),
+ DEFINE(macho_fixed_virtual_memory_shared_lib),
+ DEFINE(macho_core),
+ DEFINE(macho_preload_executable),
+ DEFINE(macho_dynamically_linked_shared_lib),
+ DEFINE(macho_dynamic_linker),
+ DEFINE(macho_bundle),
+ DEFINE(macho_dsym_companion),
+ DEFINE(windows_resource)
+#undef DEFINE
+ };
// Create some files filled with magic.
for (type *i = types, *e = types + (sizeof(types) / sizeof(type)); i != e;