This is an archive of the discontinued LLVM Phabricator instance.

[NFC][AVR][clang] Add test for D107672
Needs ReviewPublic

Authored by mhjacobson on Aug 6 2021, 9:05 PM.

Details

Reviewers
MaskRay
benshi001
Summary

Add test that ensures that an avr-libc in $SYSROOT/avr is found, modeled after the similar test checking for $SYSROOT/usr/lib/avr.

Diff Detail

Event Timeline

mhjacobson created this revision.Aug 6 2021, 9:05 PM
mhjacobson requested review of this revision.Aug 6 2021, 9:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 6 2021, 9:05 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
benshi001 added inline comments.Aug 7 2021, 1:37 AM
clang/test/Driver/avr-toolchain.c
22–23

Please do not change existing tests, you can add new lines.

We need not add another basic_avr_tree_opt_local, since you added /avr to possible avr-libc pathes, you can test your change by specifying --sysroot %S/Inputs/basic_avr_tree/usr/lib/ .

We need not add another basic_avr_tree_opt_local, since you added /avr to possible avr-libc pathes, you can test your change by specifying --sysroot %S/Inputs/basic_avr_tree/usr/lib/ .

Oh, good idea.

We need not add another basic_avr_tree_opt_local, since you added /avr to possible avr-libc pathes, you can test your change by specifying --sysroot %S/Inputs/basic_avr_tree/usr/lib/ .

Oh, good idea.

Sorry, only spefifying --sysroot %S/Inputs/basic_avr_tree/usr/lib/ does not work, since the search for avr-ld also relies on --sysroot.

So I suggest adding a new dir name avr inside Inputs/basic_avr_tree/, and also put a copy of the fake avr-libc files at Inputs/basic_avr_tree/avr.

In this way the searchs for both avr-gcc and avr-libc should work.

mhjacobson marked an inline comment as done.Aug 7 2021, 2:33 AM

We need not add another basic_avr_tree_opt_local, since you added /avr to possible avr-libc pathes, you can test your change by specifying --sysroot %S/Inputs/basic_avr_tree/usr/lib/ .

Oh, good idea.

Sorry, only spefifying --sysroot %S/Inputs/basic_avr_tree/usr/lib/ does not work, since the search for avr-ld also relies on --sysroot.

For the purpose of the test, that doesn't matter, since we're just looking for the existence of the -internal-isystem argument.

@MaskRay

I think this test is OK. What is your opinion ?

MaskRay added inline comments.Aug 8 2021, 11:42 AM
clang/test/Driver/avr-toolchain.c
29

Please use the pattern in linux-cross.cpp

mhjacobson added inline comments.Aug 9 2021, 3:58 PM
clang/test/Driver/avr-toolchain.c
29

To be clear, which pattern? Placing each checked argument in its own check line? I'm happy to do that, although the other tests here don't do so...

mhjacobson updated this revision to Diff 365343.Aug 9 2021, 8:50 PM

Rebase atop recent changes; use separate check lines and string substitution for SYSROOT.

mhjacobson marked an inline comment as done.Aug 9 2021, 8:50 PM

--sysroot %S/Inputs/basic_avr_tree/usr/lib seems incorrect.

sysroot is usually a directory which contains usr/lib and lib/. somewhere/usr/lib is not usually used as a sysroot.

--sysroot %S/Inputs/basic_avr_tree/usr/lib seems incorrect.

sysroot is usually a directory which contains usr/lib and lib/. somewhere/usr/lib is not usually used as a sysroot.

Yeah, I agree it's weird. This is basically a shortcut to avoid creating a duplicate sysroot in Inputs. Would you prefer I create the duplicate tree?

--sysroot %S/Inputs/basic_avr_tree/usr/lib seems incorrect.

sysroot is usually a directory which contains usr/lib and lib/. somewhere/usr/lib is not usually used as a sysroot.

Yeah, I agree it's weird. This is basically a shortcut to avoid creating a duplicate sysroot in Inputs. Would you prefer I create the duplicate tree?

A duplicate tree is better. Otherwise you can use unittests/Driver/ToolChainTest.cpp

It seems we need not adding this test, since a similiar test is added in https://reviews.llvm.org/rGb31199bab4865deef4e778d7a028c8ec64285654

benshi001 resigned from this revision.Sep 1 2021, 7:58 PM