| Kyungwoo Lee | 9bb5556 | 2024-08-20 07:26:50 -0700 | [diff] [blame] | 1 | # 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 Lee | ffcf3c8 | 2024-11-04 17:32:50 -0800 | [diff] [blame] | 9 | # uint64_t StableFunctionMapOffset; |
| Kyungwoo Lee | 9bb5556 | 2024-08-20 07:26:50 -0700 | [diff] [blame] | 10 | # } |
| 11 | RUN: touch %t_empty.cgdata |
| 12 | RUN: not llvm-cgdata --show %t_empty.cgdata 2>&1 | FileCheck %s --check-prefix=EMPTY |
| 13 | EMPTY: {{.}}cgdata: empty codegen data |
| 14 | |
| 15 | # Not a magic. |
| Aiden Grossman | c745c54 | 2025-09-10 12:45:33 -0700 | [diff] [blame] | 16 | RUN: printf '\377' > %t_malformed.cgdata |
| Kyungwoo Lee | 9bb5556 | 2024-08-20 07:26:50 -0700 | [diff] [blame] | 17 | RUN: not llvm-cgdata --show %t_malformed.cgdata 2>&1 | FileCheck %s --check-prefix=MALFORMED |
| 18 | MALFORMED: {{.}}cgdata: malformed codegen data |
| 19 | |
| 20 | # The minimum header size is 24. |
| Aiden Grossman | c745c54 | 2025-09-10 12:45:33 -0700 | [diff] [blame] | 21 | RUN: printf '\377cgdata\201' > %t_corrupt.cgdata |
| Kyungwoo Lee | 9bb5556 | 2024-08-20 07:26:50 -0700 | [diff] [blame] | 22 | RUN: not llvm-cgdata --show %t_corrupt.cgdata 2>&1 | FileCheck %s --check-prefix=CORRUPT |
| 23 | CORRUPT: {{.}}cgdata: invalid codegen data (file header is corrupt) |
| 24 | |
| Zhaoxuan Jiang | 2738828 | 2025-08-20 21:15:04 +0800 | [diff] [blame] | 25 | # The current version 4 while the header says 5. |
| Aiden Grossman | c745c54 | 2025-09-10 12:45:33 -0700 | [diff] [blame] | 26 | RUN: printf '\377cgdata\201' > %t_version.cgdata |
| 27 | RUN: printf '\005\000\000\000' >> %t_version.cgdata |
| 28 | RUN: printf '\000\000\000\000' >> %t_version.cgdata |
| 29 | RUN: printf '\040\000\000\000\000\000\000\000' >> %t_version.cgdata |
| 30 | RUN: printf '\040\000\000\000\000\000\000\000' >> %t_version.cgdata |
| Kyungwoo Lee | 9bb5556 | 2024-08-20 07:26:50 -0700 | [diff] [blame] | 31 | RUN: not llvm-cgdata --show %t_version.cgdata 2>&1 | FileCheck %s --check-prefix=BAD_VERSION |
| 32 | BAD_VERSION: {{.}}cgdata: unsupported codegen data version |
| 33 | |
| 34 | # Header says an outlined hash tree, but the file ends after the header. |
| Aiden Grossman | c745c54 | 2025-09-10 12:45:33 -0700 | [diff] [blame] | 35 | RUN: printf '\377cgdata\201' > %t_eof.cgdata |
| 36 | RUN: printf '\002\000\000\000' >> %t_eof.cgdata |
| 37 | RUN: printf '\001\000\000\000' >> %t_eof.cgdata |
| 38 | RUN: printf '\040\000\000\000\000\000\000\000' >> %t_eof.cgdata |
| 39 | RUN: printf '\040\000\000\000\000\000\000\000' >> %t_eof.cgdata |
| Kyungwoo Lee | 9bb5556 | 2024-08-20 07:26:50 -0700 | [diff] [blame] | 40 | RUN: not llvm-cgdata --show %t_eof.cgdata 2>&1 | FileCheck %s --check-prefix=EOF |
| 41 | EOF: {{.}}cgdata: end of File |