Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1695100 > unrolled thread

[PATCH 1/3] selftests: sync: differentiate between sync unsupported and access errors

Started byShuah Khan <shuahkh@osg.samsung.com>
First post2017-07-24 23:10 +0200
Last post2017-07-24 23:10 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 1/3] selftests: sync: differentiate between sync unsupported and access errors Shuah Khan <shuahkh@osg.samsung.com> - 2017-07-24 23:10 +0200

#1695100 — [PATCH 1/3] selftests: sync: differentiate between sync unsupported and access errors

FromShuah Khan <shuahkh@osg.samsung.com>
Date2017-07-24 23:10 +0200
Subject[PATCH 1/3] selftests: sync: differentiate between sync unsupported and access errors
Message-ID<u6SM3-1Y8-43@gated-at.bofh.it>
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>
---
 tools/testing/selftests/sync/sync_test.c | 23 +++++++++++++++++++----
 1 file 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");
 
-- 
2.11.0

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web