Re: [PATCH net-next v4 02/10] selftests: net: add helpers for running a command on other targets

Petr Machata
2026-03-31T11:59:37Z

Jakub Kicinski <kuba@kernel.org> writes:

> On Mon, 30 Mar 2026 13:02:12 +0200 Petr Machata wrote:
>> > +run_on()
>> > +{
>> > + local iface=$1; shift
>> > + local target="local:"
>> > +
>> > + if declare -p TARGETS &>/dev/null; then
>> > + target="${TARGETS[$iface]}"
>>
>> So I think Jakub's runs fail because there's a shell export somewhere
>> that gets inherited through make to the launched test. I guess it would
>> be enough for the test to validate that TARGETS is an array, because
>> those don't get inherited.
>
> Great catch, FWIW. Yes TARGETS is what ksft makefiles use to define
> the group of tests. We do
>
> make ... TARGETS=drivers/net ... run_tests

That'll do it. I thought the make command line-defined variables don't
get inherited, which is why I said shell exports, but indeed they do:

$ cat foo.mk
all:
echo TARGETS=$(TARGETS)
bash x.sh

$ cat x.sh
echo $TARGETS

$ make TARGETS=TARGETS -f foo.mk
echo TARGETS=TARGETS
TARGETS=TARGETS
bash x.sh
TARGETS