If the clean up task in the end of this script has successed, this test will be considered as passed regardless the sub tests results.
$ sudo ./run_hugetlbfs_test.sh memfd-hugetlb: CREATE memfd-hugetlb: BASIC memfd-hugetlb: SEAL-EXEC memfd-hugetlb: Apply SEAL_EXEC fchmod(/memfd:kern_memfd_seal_exec (deleted), 00777) didn't fail as expected ./run_hugetlbfs_test.sh: line 60: 16833 Aborted (core dumped) ./memfd_test hugetlbfs opening: ./mnt/memfd ADD_SEALS(4, 0 -> 8) failed: Device or resource busy 8 != 0 = GET_SEALS(4) Aborted (core dumped) $ echo $? 0
Fix this by checking the return value of each sub-test.
With this patch, the return value of this test will be reflected correctly and we can avoid a false-negative result: $ sudo ./run_hugetlbfs_test.sh memfd-hugetlb: CREATE memfd-hugetlb: BASIC memfd-hugetlb: SEAL-EXEC memfd-hugetlb: Apply SEAL_EXEC fchmod(/memfd:kern_memfd_seal_exec (deleted), 00777) didn't fail as expected ./run_hugetlbfs_test.sh: line 68: 16688 Aborted (core dumped) ./memfd_test hugetlbfs opening: ./mnt/memfd ADD_SEALS(4, 0 -> 8) failed: Device or resource busy 8 != 0 = GET_SEALS(4) Aborted (core dumped) $ echo $? 134
Po-Hsu Lin (1): selftests/memfd: fix return value override issue in run_hugetlbfs_test.sh
tools/testing/selftests/memfd/run_hugetlbfs_test.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+)
If the clean up task in the end of this script has successed, this test will be considered as passed regardless the sub tests results.
$ sudo ./run_hugetlbfs_test.sh memfd-hugetlb: CREATE memfd-hugetlb: BASIC memfd-hugetlb: SEAL-EXEC memfd-hugetlb: Apply SEAL_EXEC fchmod(/memfd:kern_memfd_seal_exec (deleted), 00777) didn't fail as expected ./run_hugetlbfs_test.sh: line 60: 16833 Aborted (core dumped) ./memfd_test hugetlbfs opening: ./mnt/memfd ADD_SEALS(4, 0 -> 8) failed: Device or resource busy 8 != 0 = GET_SEALS(4) Aborted (core dumped) $ echo $? 0
Fix this by checking the return value of each sub-test.
With this patch, the return value of this test will be reflected correctly and we can avoid a false-negative result: $ sudo ./run_hugetlbfs_test.sh memfd-hugetlb: CREATE memfd-hugetlb: BASIC memfd-hugetlb: SEAL-EXEC memfd-hugetlb: Apply SEAL_EXEC fchmod(/memfd:kern_memfd_seal_exec (deleted), 00777) didn't fail as expected ./run_hugetlbfs_test.sh: line 68: 16688 Aborted (core dumped) ./memfd_test hugetlbfs opening: ./mnt/memfd ADD_SEALS(4, 0 -> 8) failed: Device or resource busy 8 != 0 = GET_SEALS(4) Aborted (core dumped) $ echo $? 134
Fixes: 8eecdd4d04 ("selftests: memfd: split regular and hugetlbfs tests") Cc: stable@vger.kernel.org Signed-off-by: Po-Hsu Lin po-hsu.lin@canonical.com --- tools/testing/selftests/memfd/run_hugetlbfs_test.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/tools/testing/selftests/memfd/run_hugetlbfs_test.sh b/tools/testing/selftests/memfd/run_hugetlbfs_test.sh index fb633eeb0290..48f701983604 100755 --- a/tools/testing/selftests/memfd/run_hugetlbfs_test.sh +++ b/tools/testing/selftests/memfd/run_hugetlbfs_test.sh @@ -4,12 +4,21 @@ # Kselftest framework requirement - SKIP code is 4. ksft_skip=4
+ret=0 # # To test memfd_create with hugetlbfs, there needs to be hpages_test # huge pages free. Attempt to allocate enough pages to test. # hpages_test=8
+# set global exit status, but never reset nonzero one. +check_err() +{ + if [ $ret -eq 0 ]; then + ret=$1 + fi +} + # # Get count of free huge pages from /proc/meminfo # @@ -58,7 +67,9 @@ fi # Run the hugetlbfs test # ./memfd_test hugetlbfs +check_err $? ./run_fuse_test.sh hugetlbfs +check_err $?
# # Give back any huge pages allocated for the test @@ -66,3 +77,4 @@ fi if [ -n "$nr_hugepgs" ]; then echo $nr_hugepgs > /proc/sys/vm/nr_hugepages fi +exit $ret
linux-kselftest-mirror@lists.linaro.org