On Thu, 21 Apr 2022 15:49:27 -0700 Axel Rasmussen axelrasmussen@google.com wrote:
Previously, each test printed out its own header, dealt with its own return code, etc. By just putting this standard stuff in a function, we can delete > 300 lines from the script.
This also makes adding future tests easier. And, it gets rid of various inconsistencies that already exist:
- Some tests correctly deal with ksft_skip, but others don't.
- Some tests just print the executable name, others print arguments, and yet others print some comment in the header.
- Most tests print out a header with two separator lines, but not the HMM smoke test or the memfd_secret test, which only print one.
- We had a redundant "exit" at the end, with all the boilerplate it's an easy oversight.
Signed-off-by: Axel Rasmussen axelrasmussen@google.com
tools/testing/selftests/vm/run_vmtests.sh | 459 +++------------------- 1 file changed, 64 insertions(+), 395 deletions(-)
Well that's nice.
There were a bunch of changes already pending in this file but I think with this patch, they become unneeded. So I just reverted them all. please double check?
--- a/tools/testing/selftests/vm/run_vmtests.sh~revert-1 +++ a/tools/testing/selftests/vm/run_vmtests.sh @@ -162,32 +162,22 @@ echo "---------------------------------- echo "running: gup_test -u # get_user_pages_fast() benchmark" echo "------------------------------------------------------" ./gup_test -u -ret_val=$? - -if [ $ret_val -eq 0 ]; then - echo "[PASS]" -elif [ $ret_val -eq $ksft_skip ]; then - echo "[SKIP]" - exitcode=$ksft_skip -else +if [ $? -ne 0 ]; then echo "[FAIL]" exitcode=1 +else + echo "[PASS]" fi
echo "------------------------------------------------------" echo "running: gup_test -a # pin_user_pages_fast() benchmark" echo "------------------------------------------------------" ./gup_test -a -ret_val=$? - -if [ $ret_val -eq 0 ]; then - echo "[PASS]" -elif [ $ret_val -eq $ksft_skip ]; then - echo "[SKIP]" - exitcode=$ksft_skip -else +if [ $? -ne 0 ]; then echo "[FAIL]" exitcode=1 +else + echo "[PASS]" fi
echo "------------------------------------------------------------" @@ -195,16 +185,11 @@ echo "# Dump pages 0, 19, and 4096, usin echo "running: gup_test -ct -F 0x1 0 19 0x1000 # dump_page() test" echo "------------------------------------------------------------" ./gup_test -ct -F 0x1 0 19 0x1000 -ret_val=$? - -if [ $ret_val -eq 0 ]; then - echo "[PASS]" -elif [ $ret_val -eq $ksft_skip ]; then - echo "[SKIP]" - exitcode=$ksft_skip -else +if [ $? -ne 0 ]; then echo "[FAIL]" exitcode=1 +else + echo "[PASS]" fi
echo "-------------------" @@ -306,16 +291,11 @@ echo "-------------------" echo "running mremap_test" echo "-------------------" ./mremap_test -ret_val=$? - -if [ $ret_val -eq 0 ]; then - echo "[PASS]" -elif [ $ret_val -eq $ksft_skip ]; then - echo "[SKIP]" - exitcode=$ksft_skip -else +if [ $? -ne 0 ]; then echo "[FAIL]" exitcode=1 +else + echo "[PASS]" fi
echo "-----------------" _