Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp349267imm; Fri, 21 Sep 2018 15:55:36 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbivpYGPYIMOdC96Nkybj7HU1HCKc0ounT0UaLFzxHc4lds1LRbQcG13HVUB4K6t30RR5EF X-Received: by 2002:a63:ee15:: with SMTP id e21-v6mr43251954pgi.421.1537570536195; Fri, 21 Sep 2018 15:55:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537570536; cv=none; d=google.com; s=arc-20160816; b=Kxw7ZWVKuonTEWKMWbICGFY5fzQx9/oOdwO1P28MHyNHY5nAAqH24heai21jw1HHWg 9//YmdjEnQZmBeWuGjuFuG+CYCouUaX6OHOuZ98p7ietkckRx0hFwYxaXQOsOisqnMoL r8Noxoh9eod76w8sCL6w+6knhcI/L/WHJGlGzt2Gxjqj4xXpFokbu1diBLAPXY3AZu7f kUb9XD2eZHzTLgAUx05RQGD4a/Z/AxOEL8H1KlCJDo2PanDvIqfYTVJ5AK2uQ/S4p3OP eyRl/HdX0Io9BCRhpwdQo0rxV16aw8yBtNW2X6Fkd21DJeV34DxnmgmhehvuWHqzVZt8 wKzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=4l6lregJCqSG5h06HTs601n2Tp+EKaB7Ugb7FBe5dZs=; b=eU6gZzQT3TpdIqYUj88jMasb+OsFloB0XdMLz1mGkFOQs0tffGoveJHg7+mrj4O+JF cdtRBkLmorUFD13hS4q7BP/lIgxcoZ3puj28j8hEbuN7Ciyh34VfKPUhMOR/7FNsijEM sacUKij8H3/oE1Cmay1COMpaazQ+btS0r4xvGrInnjzIAjkPy/a5zA729kEwmtOLdTTq 1aBDxe80B/f1N/6WZeUcM1DTscsLcnYdtmgGIELQkOTO4W5WHr9XNTpbbrEHfT2w6Kz2 3gH5S7qrnQO2yHzRxY5LGA7fLdruHw8onCYKBC5iBvgrC1hurYTZCVlrmpGPCISMIIlG pPQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k5-v6si8065130pgr.511.2018.09.21.15.55.20; Fri, 21 Sep 2018 15:55:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725984AbeIVEow (ORCPT + 99 others); Sat, 22 Sep 2018 00:44:52 -0400 Received: from mailout.easymail.ca ([64.68.200.34]:50116 "EHLO mailout.easymail.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725750AbeIVEow (ORCPT ); Sat, 22 Sep 2018 00:44:52 -0400 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id B4293C13DF; Fri, 21 Sep 2018 22:53:50 +0000 (UTC) Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (emo01-pco.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9kd2_r0P_uQ4; Fri, 21 Sep 2018 22:53:50 +0000 (UTC) Received: from [192.168.1.87] (c-24-9-64-241.hsd1.co.comcast.net [24.9.64.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailout.easymail.ca (Postfix) with ESMTPSA id 768A9C0D4A; Fri, 21 Sep 2018 22:53:44 +0000 (UTC) Subject: Re: [PATCH v4] selftests: membarrier: reorganized test for LTS supportability To: Rafael David Tinoco Cc: linux-kernel@vger.kernel.org, "linux-kselftest@vger.kernel.org" , Shuah Khan References: <1a86c3c5-66f5-24d8-4fcc-367302ecec35@kernel.org> <20180903190457.27088-1-rafael.tinoco@linaro.org> From: Shuah Khan Message-ID: Date: Fri, 21 Sep 2018 16:53:44 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180903190457.27088-1-rafael.tinoco@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/03/2018 01:04 PM, Rafael David Tinoco wrote: > This commit re-organizes membarrier test, solving issues when testing > LTS kernels. Now, the code: > > - always run the same amount of tests (even on older kernels). > - allows each test to succeed, fail or be skipped independently. > - allows testing features even when explicitly unsupported (force=1). > - able to consider different return codes for diff kernel versions. > - checks false positive/negative by checking ret code and errno. > - can be extended easily: to expand an array with commands. > > Link: https://bugs.linaro.org/show_bug.cgi?id=3771 > Signed-off-by: Rafael David Tinoco > --- > .../selftests/membarrier/membarrier_test.c | 482 +++++++++--------- > 1 file changed, 241 insertions(+), 241 deletions(-) > > diff --git a/tools/testing/selftests/membarrier/membarrier_test.c b/tools/testing/selftests/membarrier/membarrier_test.c > index 6793f8ecc8e7..151bc8a944a3 100644 > --- a/tools/testing/selftests/membarrier/membarrier_test.c > +++ b/tools/testing/selftests/membarrier/membarrier_test.c > @@ -1,6 +1,7 @@ > // SPDX-License-Identifier: GPL-2.0 > #define _GNU_SOURCE > #include > +#include > #include > #include > #include > @@ -8,305 +9,304 @@ > > #include "../kselftest.h" > > -static int sys_membarrier(int cmd, int flags) > +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) > +#define KERNEL_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c)) > + > +struct memb_tests { > + char testname[80]; > + int command; > + int flags; > + int exp_ret; > + int exp_errno; > + int enabled; > + int force; > + int force_exp_errno; > + int above; > + int bellow; > +}; > + > +struct memb_tests mbt[] = { > + { > + .testname = "cmd_fail\0", > + .command = -1, > + .exp_ret = -1, > + .exp_errno = EINVAL, > + .enabled = 1, > + }, > + { > + .testname = "cmd_flags_fail\0", > + .command = MEMBARRIER_CMD_QUERY, > + .flags = 1, > + .exp_ret = -1, > + .exp_errno = EINVAL, > + .enabled = 1, > + }, > + { > + .testname = "cmd_global_success\0", > + .command = MEMBARRIER_CMD_GLOBAL, > + .flags = 0, > + .exp_ret = 0, > + }, > + /* > + * PRIVATE EXPEDITED (forced) > + */ > + { > + .testname = "cmd_private_expedited_fail\0", > + .command = MEMBARRIER_CMD_PRIVATE_EXPEDITED, > + .flags = 0, > + .exp_ret = -1, > + .exp_errno = EPERM, > + .force = 1, > + .force_exp_errno = EINVAL, > + .bellow = KERNEL_VERSION(4, 10, 0), > + }, > + { > + .testname = "cmd_private_expedited_fail\0", > + .command = MEMBARRIER_CMD_PRIVATE_EXPEDITED, > + .flags = 0, > + .exp_ret = -1, > + .exp_errno = EPERM, > + .force = 1, > + .force_exp_errno = EPERM, > + .above = KERNEL_VERSION(4, 10, 0), > + }, > + { > + .testname = "cmd_register_private_expedited_success\0", > + .command = MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED, > + .flags = 0, > + .exp_ret = 0, > + .force = 1, > + .force_exp_errno = EINVAL, > + }, > + { > + .testname = "cmd_private_expedited_success\0", > + .command = MEMBARRIER_CMD_PRIVATE_EXPEDITED, > + .flags = 0, > + .exp_ret = 0, > + .force = 1, > + .force_exp_errno = EINVAL, > + }, > + /* > + * PRIVATE EXPEDITED SYNC CORE > + */ > + { > + .testname = "cmd_private_expedited_sync_core_fail\0", > + .command = MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE, > + .flags = 0, > + .exp_ret = -1, > + .exp_errno = EPERM, > + }, > + { > + .testname = "cmd_register_private_expedited_sync_core_success\0", > + .command = MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE, > + .flags = 0, > + .exp_ret = 0, > + }, > + { > + .testname = "cmd_private_expedited_sync_core_success\0", > + .command = MEMBARRIER_CMD_PRIVATE_EXPEDITED, > + .flags = 0, > + .exp_ret = 0, > + }, > + /* > + * GLOBAL EXPEDITED > + * global membarrier from a non-registered process is valid > + */ > + { > + .testname = "cmd_global_expedited_success\0", > + .command = MEMBARRIER_CMD_GLOBAL_EXPEDITED, > + .flags = 0, > + .exp_ret = 0, > + }, > + { > + .testname = "cmd_register_global_expedited_success\0", > + .command = MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED, > + .flags = 0, > + .exp_ret = 0, > + }, > + { > + .testname = "cmd_global_expedited_success\0", > + .command = MEMBARRIER_CMD_GLOBAL_EXPEDITED, > + .flags = 0, > + .exp_ret = 0, > + }, > +}; > + > +static void > +info_passed_ok(struct memb_tests test) > { > - return syscall(__NR_membarrier, cmd, flags); > + ksft_test_result_pass("sys_membarrier(): %s succeeded.\n", > + test.testname); > } > Why do we need to add new routines for these conditions. Why can't handle these strings in array. For example you can define an array of strings for passed unexpectedly etc. and the pass the string to appropriate ksft_* interface instead of adding of these routines. Also it is hard to review the code this way. I do like the direction though. Also please run get_maintainer.pl and cc everybody it suggests. thanks, -- Shuah