Skip to content

Commit b32694c

Browse files
Nikita Sobolevshuahkh
authored andcommitted
Kernel selftests: tpm2: check for tpm support
tpm2 tests set fails if there is no /dev/tpm0 and /dev/tpmrm0 supported. Check if these files exist before run and mark test as skipped in case of absence. Signed-off-by: Nikita Sobolev <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent a098d9c commit b32694c

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

tools/testing/selftests/tpm2/test_smoke.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
#!/bin/bash
22
# SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
3+
self.flags = flags
34

4-
python -m unittest -v tpm2_tests.SmokeTest
5-
python -m unittest -v tpm2_tests.AsyncTest
5+
# Kselftest framework requirement - SKIP code is 4.
6+
ksft_skip=4
7+
8+
9+
if [ -f /dev/tpm0 ] ; then
10+
python -m unittest -v tpm2_tests.SmokeTest
11+
python -m unittest -v tpm2_tests.AsyncTest
12+
else
13+
exit $ksft_skip
14+
fi
615

716
CLEAR_CMD=$(which tpm2_clear)
817
if [ -n $CLEAR_CMD ]; then
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
#!/bin/bash
22
# SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
33

4-
python -m unittest -v tpm2_tests.SpaceTest
4+
# Kselftest framework requirement - SKIP code is 4.
5+
ksft_skip=4
6+
7+
if [ -f /dev/tpmrm0 ] ; then
8+
python -m unittest -v tpm2_tests.SpaceTest
9+
else
10+
exit $ksft_skip
11+
fi

0 commit comments

Comments
 (0)