summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/sync
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2017-05-31 20:40:15 +1000
committerShuah Khan <shuahkh@osg.samsung.com>2017-06-07 10:07:21 -0600
commit4996976fcde4bb738ce68ca01a8b358d71aab7bb (patch)
tree0525d3181decf3b433210f119efb446e824e6d57 /tools/testing/selftests/sync
parenteff33cfa0631a8f887df5f941e6ad1ae9a43a013 (diff)
downloadlinux-4996976fcde4bb738ce68ca01a8b358d71aab7bb.tar.bz2
selftests: sync: Skip the test if kernel support is not found
The "Sync framework" test doesn't work if the kernel has no support, obviously. Rather than reporting a failure, check for the kernel support by looking for /sys/kernel/debug/sync/sw_sync, and if not found skip the test. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Diffstat (limited to 'tools/testing/selftests/sync')
-rw-r--r--tools/testing/selftests/sync/sync_test.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/testing/selftests/sync/sync_test.c b/tools/testing/selftests/sync/sync_test.c
index 9ea08d9f0b13..62fa666e501a 100644
--- a/tools/testing/selftests/sync/sync_test.c
+++ b/tools/testing/selftests/sync/sync_test.c
@@ -29,6 +29,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include <sys/wait.h>
#include "synctest.h"
@@ -52,10 +53,22 @@ static int run_test(int (*test)(void), char *name)
exit(test());
}
+static int sync_api_supported(void)
+{
+ struct stat sbuf;
+
+ return 0 == stat("/sys/kernel/debug/sync/sw_sync", &sbuf);
+}
+
int main(void)
{
int err = 0;
+ if (!sync_api_supported()) {
+ printf("SKIP: Sync framework not supported by kernel\n");
+ return 0;
+ }
+
printf("[RUN]\tTesting sync framework\n");
err += RUN_TEST(test_alloc_timeline);