summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShuah Khan <shuahkh@osg.samsung.com>2017-07-22 05:23:11 +0300
committerShuah Khan <shuahkh@osg.samsung.com>2017-07-28 22:19:55 +0300
commitf6c44bbb79aa875d60dbd29ed1fa63923fb1fe81 (patch)
treeb778390a9ec001c235fd17174d3f5efb4ebefaee
parent97e49368515830586b09ccadcdc567283b11afb9 (diff)
downloadlinux-f6c44bbb79aa875d60dbd29ed1fa63923fb1fe81.tar.xz
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>
-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 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
+#include <errno.h>
#include "synctest.h"
@@ -56,18 +57,32 @@ static int run_test(int (*test)(void), char *name)
static int sync_api_supported(void)
{
struct stat sbuf;
+ int ret;
+
+ ret = stat("/sys/kernel/debug/sync/sw_sync", &sbuf);
+ if (!ret)
+ return 0;
+
+ if (errno == ENOENT) {
+ printf("SKIP: Sync framework not supported by kernel\n");
+ exit(0);
+ }
+ if (errno == EACCES) {
+ printf("SKIP: Run Sync test as root.\n");
+ exit(0);
+ }
+
+ perror("stat");
+ exit(ret);
- 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");
+ if (!sync_api_supported())
return 0;
- }
printf("[RUN]\tTesting sync framework\n");