blob: bf5e3ff6a4ed07ac7d6ba7769d3be96fffb62972 [file] [log] [blame]
Kyungwoo Lee9bb55562024-08-20 07:26:50 -07001# Test various error cases
2
3# Synthesize a header only cgdata.
4# struct Header {
5# uint64_t Magic;
6# uint32_t Version;
7# uint32_t DataKind;
8# uint64_t OutlinedHashTreeOffset;
Kyungwoo Leeffcf3c82024-11-04 17:32:50 -08009# uint64_t StableFunctionMapOffset;
Kyungwoo Lee9bb55562024-08-20 07:26:50 -070010# }
11RUN: touch %t_empty.cgdata
12RUN: not llvm-cgdata --show %t_empty.cgdata 2>&1 | FileCheck %s --check-prefix=EMPTY
13EMPTY: {{.}}cgdata: empty codegen data
14
15# Not a magic.
Aiden Grossmanc745c542025-09-10 12:45:33 -070016RUN: printf '\377' > %t_malformed.cgdata
Kyungwoo Lee9bb55562024-08-20 07:26:50 -070017RUN: not llvm-cgdata --show %t_malformed.cgdata 2>&1 | FileCheck %s --check-prefix=MALFORMED
18MALFORMED: {{.}}cgdata: malformed codegen data
19
20# The minimum header size is 24.
Aiden Grossmanc745c542025-09-10 12:45:33 -070021RUN: printf '\377cgdata\201' > %t_corrupt.cgdata
Kyungwoo Lee9bb55562024-08-20 07:26:50 -070022RUN: not llvm-cgdata --show %t_corrupt.cgdata 2>&1 | FileCheck %s --check-prefix=CORRUPT
23CORRUPT: {{.}}cgdata: invalid codegen data (file header is corrupt)
24
Zhaoxuan Jiang27388282025-08-20 21:15:04 +080025# The current version 4 while the header says 5.
Aiden Grossmanc745c542025-09-10 12:45:33 -070026RUN: printf '\377cgdata\201' > %t_version.cgdata
27RUN: printf '\005\000\000\000' >> %t_version.cgdata
28RUN: printf '\000\000\000\000' >> %t_version.cgdata
29RUN: printf '\040\000\000\000\000\000\000\000' >> %t_version.cgdata
30RUN: printf '\040\000\000\000\000\000\000\000' >> %t_version.cgdata
Kyungwoo Lee9bb55562024-08-20 07:26:50 -070031RUN: not llvm-cgdata --show %t_version.cgdata 2>&1 | FileCheck %s --check-prefix=BAD_VERSION
32BAD_VERSION: {{.}}cgdata: unsupported codegen data version
33
34# Header says an outlined hash tree, but the file ends after the header.
Aiden Grossmanc745c542025-09-10 12:45:33 -070035RUN: printf '\377cgdata\201' > %t_eof.cgdata
36RUN: printf '\002\000\000\000' >> %t_eof.cgdata
37RUN: printf '\001\000\000\000' >> %t_eof.cgdata
38RUN: printf '\040\000\000\000\000\000\000\000' >> %t_eof.cgdata
39RUN: printf '\040\000\000\000\000\000\000\000' >> %t_eof.cgdata
Kyungwoo Lee9bb55562024-08-20 07:26:50 -070040RUN: not llvm-cgdata --show %t_eof.cgdata 2>&1 | FileCheck %s --check-prefix=EOF
41EOF: {{.}}cgdata: end of File