xref: /llvm-project/llvm/test/tools/llvm-cgdata/empty.test (revision ffcf3c8688f57acaf6a404a1238673c9d197ba9a)
1# Test no input file
2RUN: not llvm-cgdata --convert --output - 2>&1 | FileCheck %s --check-prefix=NOFILE --ignore-case
3NOFILE: error: No input file is specified.
4
5# Test for empty cgdata file, which is invalid.
6RUN: touch %t_emptyfile.cgtext
7RUN: not llvm-cgdata --convert %t_emptyfile.cgtext --format text 2>&1 | FileCheck %s --check-prefix=EMPTY
8EMPTY: {{.}}emptyfile.cgtext: empty codegen data
9
10# Test for empty header in the text format. It can be converted to a valid binary file.
11RUN: printf '#' > %t_emptyheader.cgtext
12RUN: llvm-cgdata --convert %t_emptyheader.cgtext --format binary -o %t_emptyheader.cgdata
13
14# Without any cgdata other than the header, no data shows by default.
15RUN: llvm-cgdata --show %t_emptyheader.cgdata | count 0
16
17# The version number appears when asked, as it's in the header
18RUN: llvm-cgdata --show --cgdata-version %t_emptyheader.cgdata | FileCheck %s --check-prefix=VERSION
19VERSION: Version: 2
20
21# When converting a binary file (w/ the header only) to a text file, it's an empty file as the text format does not have an explicit header.
22RUN: llvm-cgdata --convert %t_emptyheader.cgdata --format text | count 0
23
24# Synthesize a header only cgdata.
25# struct Header {
26#   uint64_t Magic;
27#   uint32_t Version;
28#   uint32_t DataKind;
29#   uint64_t OutlinedHashTreeOffset;
30#   uint64_t StableFunctionMapOffset;
31# }
32RUN: printf '\xffcgdata\x81' > %t_header.cgdata
33RUN: printf '\x02\x00\x00\x00' >> %t_header.cgdata
34RUN: printf '\x00\x00\x00\x00' >> %t_header.cgdata
35RUN: printf '\x20\x00\x00\x00\x00\x00\x00\x00' >> %t_header.cgdata
36RUN: printf '\x20\x00\x00\x00\x00\x00\x00\x00' >> %t_header.cgdata
37RUN: diff %t_header.cgdata %t_emptyheader.cgdata
38