On Wed, 18 May 2022 14:01:43 +0800 Hangbin Liu wrote:
+files=$(git show --name-status --oneline | grep -P '^A\ttools/testing/selftests/net/' | grep '.sh$' | sed 's@A\ttools/testing/selftests/net/@@')
FWIW this will list just the names of bash scripts with no decoration:
git show --pretty="" --name-only -- tools/testing/selftests/*.sh
And we can get the names of the files with basename:
for f in $(git show --pretty="" --name-only); do basename $f; done
+for file in $files; do
- if echo $file | grep forwarding; then
file=$(echo $file | sed 's/forwarding\///')
if ! grep -P "[\t| ]$file" tools/testing/selftests/net/forwarding/Makefile;then
echo "new test $file not in selftests/net/forwarding/Makefile" >&$DESC_FD
rc=1
fi
- else
if ! grep -P "[\t| ]$file" tools/testing/selftests/net/Makefile;then
echo "new test $file not in selftests/net/Makefile" >&$DESC_FD
rc=1
fi
Does it matter which exact selftest makefile the changes are?
I only checked the tools/testing/selftests/net/Makefile and tools/testing/selftests/net/forwarding/Makefile at present. Maybe mptcp should also added?
Right, mptcp is one example, then we also have tools/testing/selftests/drivers/net/
There may be new directories added, then we'd need to keep updating the test.
Maybe as a first stab we should just check if there are changes to anything in tools/testing/selftests/.*/Makefile?
In my checking only shell scripts are checked, as most net net/forwarding tests using shell script for testing. But other sub-component may use c binary or python for testing. So I think there is no need to check all tools/testing/selftests/.*/Makefile. WDYT?
Not sure I understand, let me explain what I meant in more detail. I think we should make it generic. For example check the Makefile in the same location as the script:
grep $(basename $f) $(dirname $f)/Makefile
And maybe just to be safe one directory level down?
grep $(basename $f) $(dirname $(dirname $f))/Makefile
Instead of hardcoding the expected paths.