• Benjamin Poirier's avatar
    selftests: Introduce Makefile variable to list shared bash scripts · 2a0683be
    Benjamin Poirier authored
    Some tests written in bash source other files in a parent directory. For
    example, drivers/net/bonding/dev_addr_lists.sh sources
    net/forwarding/lib.sh. If a subset of tests is exported and run outside the
    source tree (for example by using `make -C tools/testing/selftests gen_tar
    TARGETS="drivers/net/bonding"`), these other files must be made available
    as well.
    
    Commit ae108c48 ("selftests: net: Fix cross-tree inclusion of scripts")
    addressed this problem by symlinking and copying the sourced files but this
    only works for direct dependencies. Commit 25ae948b ("selftests/net:
    add lib.sh") changed net/forwarding/lib.sh to source net/lib.sh. As a
    result, that latter file must be included as well when the former is
    exported. This was not handled and was reverted in commit 2114e833
    ("selftests: forwarding: Avoid failures to source net/lib.sh"). In order to
    allow reinstating the inclusion of net/lib.sh from net/forwarding/lib.sh,
    add a mechanism to list dependent files in a new Makefile variable and
    export them. This allows sourcing those files using the same expression
    whether tests are run in-tree or exported.
    
    Dependencies are not resolved recursively so transitive dependencies must
    be listed in TEST_INCLUDES. For example, if net/forwarding/lib.sh sources
    net/lib.sh; the Makefile related to a test that sources
    net/forwarding/lib.sh from a parent directory must list:
    TEST_INCLUDES := \
    	../../../net/forwarding/lib.sh \
    	../../../net/lib.sh
    
    v2:
    Fix rst syntax in Documentation/dev-tools/kselftest.rst (Jakub Kicinski)
    
    v1 (from RFC):
    * changed TEST_INCLUDES to take relative paths, like other TEST_* variables
      (Vladimir Oltean)
    * preserved common "$(MAKE) OUTPUT=... -C ... target" ordering in Makefile
      (Petr Machata)
    Signed-off-by: default avatarBenjamin Poirier <bpoirier@nvidia.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    2a0683be
kselftest.rst 14 KB