Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756476AbdGXVIE (ORCPT ); Mon, 24 Jul 2017 17:08:04 -0400 Received: from ec2-52-27-115-49.us-west-2.compute.amazonaws.com ([52.27.115.49]:50868 "EHLO osg.samsung.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753768AbdGXVHq (ORCPT ); Mon, 24 Jul 2017 17:07:46 -0400 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" From: Shuah Khan To: shuah@kernel.org, emilio.lopez@collabora.co.uk, mpe@ellerman.id.au, gustavo.padovan@collabora.com Cc: Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] selftests: sync: differentiate between sync unsupported and access errors Date: Mon, 24 Jul 2017 15:07:38 -0600 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1478 Lines: 61 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 --- 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 #include #include +#include #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