This is an archive of the discontinued LLVM Phabricator instance.

[llvm-ar][test] Add testing for bitcode file handling
ClosedPublic

Authored by gbreynoo on Jul 4 2022, 9:00 AM.

Details

Summary

This change adds testing for handling of bitcode files in archives, particularly the creation of symbol tables and through MRI scripts. Although there is some testing of bitcode handling in the archive library testing, this was not covered.

Diff Detail

Event Timeline

gbreynoo created this revision.Jul 4 2022, 9:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 4 2022, 9:00 AM
gbreynoo requested review of this revision.Jul 4 2022, 9:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 4 2022, 9:00 AM
jhenderson added inline comments.Jul 5 2022, 12:40 AM
llvm/test/tools/llvm-ar/bitcode-add.ll
4–5 ↗(On Diff #442110)

Fold these two into one line and then cd into them immediately before doing the mkdir and llvm-as commands, so that you can drop the %t from those commands.

11 ↗(On Diff #442110)

I'd add c to this command, to suppress the new archive creation warning (it's not generally an issue, but could cause confusion if a user tried to inspect the verbose output or run the command directly and started getting additional output). Ditto elsewhere in the file.

15 ↗(On Diff #442110)

Should you check that there are no other files too (e.g. by adding --implicit-check-not={{.}} to your FileCheck command)?

17–18 ↗(On Diff #442110)

This is only going to prevent ldata and lfunc appearing before gdata and gfunc. Given that you sort before the checks, this will always pass, regardless of whats in the output!

You probably want to be using --implicit-check-not={{.}} and check the entire contents of the output (using SYMS-NEXT as appropriate too for improved output messages).

30 ↗(On Diff #442110)
31 ↗(On Diff #442110)

What's in the output in this case? Can we check for that and use --implicit-check-not={{.}} to make the test more robust to changes in how the "Archive map" header is formatted?

38 ↗(On Diff #442110)

These "update" test cases are about creating a symbol table in an existing archive, but the test is called "bitcode-add.ll". Is the test misnamed? These update cases, aren't really "adding" anything.

41 ↗(On Diff #442110)
48 ↗(On Diff #442110)

Do you need the S here? What does suppressing the archive symtab in this case actually achieve? Ditto below.

60–62 ↗(On Diff #442110)

Again, not a test case to do with "adding" anything.

llvm/test/tools/llvm-ar/mri-bitcode.ll
1 ↗(On Diff #442110)

This test basically looks identical to the other test, except that MRI scripts are used to drive the program. I feel like it would be better to include the MRI cases alongside the non-MRI cases in the same test file.

gbreynoo updated this revision to Diff 442610.Jul 6 2022, 9:26 AM

Combined tests into one file, added us of --implicit-check-not, supressed archive creation warnings and fixed comments.

gbreynoo marked 8 inline comments as done.Jul 6 2022, 9:31 AM
gbreynoo added inline comments.
llvm/test/tools/llvm-ar/bitcode-add.ll
38 ↗(On Diff #442110)

I agree the test is poorly named, hopefully the more general name is more fitting?

60 ↗(On Diff #442110)

I forgot to change these uses of %t, I'll fix it.

60–62 ↗(On Diff #442110)

As mentioned above.

llvm/test/tools/llvm-ar/mri-bitcode.ll
1 ↗(On Diff #442110)

Agreed, I've combined them.

gbreynoo updated this revision to Diff 442614.Jul 6 2022, 9:35 AM
gbreynoo marked an inline comment as done.

Removed missed use of %t.

MaskRay accepted this revision.Jul 6 2022, 10:14 AM
MaskRay added inline comments.
llvm/test/tools/llvm-ar/bitcode.ll
23

These lines can use -NEXT:

36

These lines can use -NEXT:

90

Prefer cmp for binary files.

This revision is now accepted and ready to land.Jul 6 2022, 10:14 AM
jhenderson accepted this revision.Jul 7 2022, 12:56 AM

Looks good once the outstanding comments have been addressed.

llvm/test/tools/llvm-ar/bitcode.ll
82

This comment looks garbled.

This revision was landed with ongoing or failed builds.Jul 14 2022, 2:56 AM
This revision was automatically updated to reflect the committed changes.
thakis added a subscriber: thakis.Jul 14 2022, 3:29 AM

As far as I can tell, this test doesn't pass: http://45.33.8.238/linux/81164/step_12.txt

Please take a look and revert for now if it takes a while to fix.

Thanks, reverting

Currently testing on other machines.

The issue stemmed from the output of sort differing between OS, removing it's use should fix things.