Skip to content

Commit 4996976

Browse files
mpeShuah Khan
authored andcommitted
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>
1 parent eff33cf commit 4996976

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎tools/testing/selftests/sync/sync_test.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <unistd.h>
3030
#include <stdlib.h>
3131
#include <sys/types.h>
32+
#include <sys/stat.h>
3233
#include <sys/wait.h>
3334

3435
#include "synctest.h"
@@ -52,10 +53,22 @@ static int run_test(int (*test)(void), char *name)
5253
exit(test());
5354
}
5455

56+
static int sync_api_supported(void)
57+
{
58+
struct stat sbuf;
59+
60+
return 0 == stat("/sys/kernel/debug/sync/sw_sync", &sbuf);
61+
}
62+
5563
int main(void)
5664
{
5765
int err = 0;
5866

67+
if (!sync_api_supported()) {
68+
printf("SKIP: Sync framework not supported by kernel\n");
69+
return 0;
70+
}
71+
5972
printf("[RUN]\tTesting sync framework\n");
6073

6174
err += RUN_TEST(test_alloc_timeline);

0 commit comments

Comments
 (0)