mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
Path: Add tests for existing file magics.
llvm-svn: 194607
This commit is contained in:
parent
0c4d35a376
commit
84aa3c1f2c
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user