]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.17.12/selftests-memfd-return-kselftest-skip-code-for-skipped-tests.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.17.12 / selftests-memfd-return-kselftest-skip-code-for-skipped-tests.patch
1 From foo@baz Sat Jul 28 10:14:30 CEST 2018
2 From: "Shuah Khan (Samsung OSG)" <shuah@kernel.org>
3 Date: Fri, 4 May 2018 13:33:37 -0600
4 Subject: selftests: memfd: return Kselftest Skip code for skipped tests
5
6 From: "Shuah Khan (Samsung OSG)" <shuah@kernel.org>
7
8 [ Upstream commit b27f0259e8cea74c627327c063742a83613dd460 ]
9
10 When memfd test is skipped because of unmet dependencies and/or unsupported
11 configuration, it returns non-zero value which is treated as a fail by the
12 Kselftest framework. This leads to false negative result even when the test
13 could not be run.
14
15 Change it to return kselftest skip code when a test gets skipped to clearly
16 report that the test could not be run.
17
18 Added an explicit check for root user at the start of memfd hugetlbfs test
19 and return skip code if a non-root user attempts to run it.
20
21 In addition, return skip code when not enough huge pages are available to
22 run the test.
23
24 Kselftest framework SKIP code is 4 and the framework prints appropriate
25 messages to indicate that the test is skipped.
26
27 Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
28 Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
29 Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
30 Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
31 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
32 ---
33 tools/testing/selftests/memfd/run_tests.sh | 14 +++++++++-----
34 1 file changed, 9 insertions(+), 5 deletions(-)
35
36 --- a/tools/testing/selftests/memfd/run_tests.sh
37 +++ b/tools/testing/selftests/memfd/run_tests.sh
38 @@ -1,6 +1,9 @@
39 #!/bin/bash
40 # please run as root
41
42 +# Kselftest framework requirement - SKIP code is 4.
43 +ksft_skip=4
44 +
45 #
46 # Normal tests requiring no special resources
47 #
48 @@ -29,12 +32,13 @@ if [ -n "$freepgs" ] && [ $freepgs -lt $
49 nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
50 hpages_needed=`expr $hpages_test - $freepgs`
51
52 + if [ $UID != 0 ]; then
53 + echo "Please run memfd with hugetlbfs test as root"
54 + exit $ksft_skip
55 + fi
56 +
57 echo 3 > /proc/sys/vm/drop_caches
58 echo $(( $hpages_needed + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
59 - if [ $? -ne 0 ]; then
60 - echo "Please run this test as root"
61 - exit 1
62 - fi
63 while read name size unit; do
64 if [ "$name" = "HugePages_Free:" ]; then
65 freepgs=$size
66 @@ -53,7 +57,7 @@ if [ $freepgs -lt $hpages_test ]; then
67 fi
68 printf "Not enough huge pages available (%d < %d)\n" \
69 $freepgs $needpgs
70 - exit 1
71 + exit $ksft_skip
72 fi
73
74 #