Kernel selftests: Add check if TPM devices are supported
authorNikita Sobolev <Nikita.Sobolev@synopsys.com>
Thu, 21 May 2020 14:43:44 +0000 (17:43 +0300)
committerShuah Khan <skhan@linuxfoundation.org>
Fri, 22 May 2020 19:19:57 +0000 (13:19 -0600)
TPM2 tests set uses /dev/tpm0 and /dev/tpmrm0 without check if they
are available. In case, when these devices are not available test
fails, but expected behaviour is skipped test.

Signed-off-by: Nikita Sobolev <Nikita.Sobolev@synopsys.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Petr Vorel <petr.vorel@gmail.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/tpm2/test_smoke.sh
tools/testing/selftests/tpm2/test_space.sh

index 8155c2ea7ccbb6ed1b9685f3c602105eb2c26173..663062701d5aa6772d56d467181b187aa0b02587 100755 (executable)
@@ -1,6 +1,11 @@
 #!/bin/bash
 # SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
 
+# Kselftest framework requirement - SKIP code is 4.
+ksft_skip=4
+
+[ -f /dev/tpm0 ] || exit $ksft_skip
+
 python -m unittest -v tpm2_tests.SmokeTest
 python -m unittest -v tpm2_tests.AsyncTest
 
index a6f5e346635e560db7c7767b22f32f760922600a..36c9d030a1c636e0719576d183116f61a99539ec 100755 (executable)
@@ -1,4 +1,9 @@
 #!/bin/bash
 # SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
 
+# Kselftest framework requirement - SKIP code is 4.
+ksft_skip=4
+
+[ -f /dev/tpmrm0 ] || exit $ksft_skip
+
 python -m unittest -v tpm2_tests.SpaceTest