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; 9# uint64_t StableFunctionMapOffset; 10# } 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. 16RUN: printf '\xff' > %t_malformed.cgdata 17RUN: 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. 21RUN: printf '\xffcgdata\x81' > %t_corrupt.cgdata 22RUN: not llvm-cgdata --show %t_corrupt.cgdata 2>&1 | FileCheck %s --check-prefix=CORRUPT 23CORRUPT: {{.}}cgdata: invalid codegen data (file header is corrupt) 24 25# The current version 2 while the header says 3. 26RUN: printf '\xffcgdata\x81' > %t_version.cgdata 27RUN: printf '\x03\x00\x00\x00' >> %t_version.cgdata 28RUN: printf '\x00\x00\x00\x00' >> %t_version.cgdata 29RUN: printf '\x20\x00\x00\x00\x00\x00\x00\x00' >> %t_version.cgdata 30RUN: printf '\x20\x00\x00\x00\x00\x00\x00\x00' >> %t_version.cgdata 31RUN: 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. 35RUN: printf '\xffcgdata\x81' > %t_eof.cgdata 36RUN: printf '\x02\x00\x00\x00' >> %t_eof.cgdata 37RUN: printf '\x01\x00\x00\x00' >> %t_eof.cgdata 38RUN: printf '\x20\x00\x00\x00\x00\x00\x00\x00' >> %t_eof.cgdata 39RUN: printf '\x20\x00\x00\x00\x00\x00\x00\x00' >> %t_eof.cgdata 40RUN: not llvm-cgdata --show %t_eof.cgdata 2>&1 | FileCheck %s --check-prefix=EOF 41EOF: {{.}}cgdata: end of File 42