aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/sync/sync_test.c
diff options
context:
space:
mode:
authorShuah Khan <shuahkh@osg.samsung.com>2017-07-21 22:23:11 -0400
committerShuah Khan <shuahkh@osg.samsung.com>2017-07-28 15:19:55 -0400
commitf6c44bbb79aa875d60dbd29ed1fa63923fb1fe81 (patch)
treeb778390a9ec001c235fd17174d3f5efb4ebefaee /tools/testing/selftests/sync/sync_test.c
parent97e49368515830586b09ccadcdc567283b11afb9 (diff)
selftests: sync: differentiate between sync unsupported and access errors
Sync test doesn't differentiate between sync unsupported and test run by non-root user and treats both as unsupported cases. Fix it to add handling for these two different scenarios. Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com> Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Diffstat (limited to 'tools/testing/selftests/sync/sync_test.c')
-rw-r--r--tools/testing/selftests/sync/sync_test.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/tools/testing/selftests/sync/sync_test.c b/tools/testing/selftests/sync/sync_test.c
index 62fa666e501a..86ae45ad0347 100644
--- a/tools/testing/selftests/sync/sync_test.c
+++ b/tools/testing/selftests/sync/sync_test.c
@@ -31,6 +31,7 @@
31#include <sys/types.h> 31#include <sys/types.h>
32#include <sys/stat.h> 32#include <sys/stat.h>
33#include <sys/wait.h> 33#include <sys/wait.h>
34#include <errno.h>
34 35
35#include "synctest.h" 36#include "synctest.h"
36 37
@@ -56,18 +57,32 @@ static int run_test(int (*test)(void), char *name)
56static int sync_api_supported(void) 57static int sync_api_supported(void)
57{ 58{
58 struct stat sbuf; 59 struct stat sbuf;
60 int ret;
61
62 ret = stat("/sys/kernel/debug/sync/sw_sync", &sbuf);
63 if (!ret)
64 return 0;
65
66 if (errno == ENOENT) {
67 printf("SKIP: Sync framework not supported by kernel\n");
68 exit(0);
69 }
70 if (errno == EACCES) {
71 printf("SKIP: Run Sync test as root.\n");
72 exit(0);
73 }
74
75 perror("stat");
76 exit(ret);
59 77
60 return 0 == stat("/sys/kernel/debug/sync/sw_sync", &sbuf);
61} 78}
62 79
63int main(void) 80int main(void)
64{ 81{
65 int err = 0; 82 int err = 0;
66 83
67 if (!sync_api_supported()) { 84 if (!sync_api_supported())
68 printf("SKIP: Sync framework not supported by kernel\n");
69 return 0; 85 return 0;
70 }
71 86
72 printf("[RUN]\tTesting sync framework\n"); 87 printf("[RUN]\tTesting sync framework\n");
73 88