From nobody Mon Feb 9 08:28:40 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1A51C77B73 for ; Tue, 30 May 2023 19:40:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233273AbjE3Tk6 (ORCPT ); Tue, 30 May 2023 15:40:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231173AbjE3Tkr (ORCPT ); Tue, 30 May 2023 15:40:47 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93426F9 for ; Tue, 30 May 2023 12:40:45 -0700 (PDT) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34UJW1se002469; Tue, 30 May 2023 19:40:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=L43E44kWSr0c0jV9sRrZTB0m3KhuZQDOHJYJYhQ2QY0=; b=LBID6qz8tU+rqzg0SvjhycBU53t+UUPJaT7lUJmjW5b6vBJyezZDfzVN5xH4gPAB5Gl2 7H67q7TjzF9A+62JxWvNykzToPqmxUFidgEPhYK2ce3+oX1dUY/KbkyywbRZyGAX4RWL GZkXrILRj+adhncxsDfn0oRfKJ23LUEGzFXIWK0AH4vUlOsYWdOORevNmMKONK2CJVDk 09GZowJBn4EzQD+IQ9ncs+J1aRKyTGHDMoA+ab57OD2V99Rj07VaoWUUejlLFKdYNQhM jAG8xc/iHn4WE+uGk1qxPDeu4dNuauAmZ0gWYf6/K/irCHEzyOMikJqx51YuCy6MG/yX zg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qvhd9uuby-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 May 2023 19:40:38 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 34UIlE6u019825; Tue, 30 May 2023 19:40:37 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3qu8a4mb6b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 May 2023 19:40:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GjEN5tXh6NyFisHuBMk8r5StuZuRepbJx/R8DIrJew72bXJ9DNMztRiJ9upI7AQ5L/rGbdmH+wL5niFATf5gRUVWXYqWvHj4LEn2u3mekpTxOkBnLTQ34jFPuIGJlxl8Ki1uhJQ4zAnufOOuDlu8JvaHqOtlDY29x2fD276yQEAIxVcd9hjb8FhrVQotIMpgNuGLqHL5efRtcq4QhHZuCVAwqpAQIBqEDOxn0YJRV8ncfL7RcV8w/AreiSIANpydLmEn2URzlnRG5O47ZocQP5VuD8GHzF6Q04riEi8Ahnpu3yKRwyE7IdvZilSkkJ1Y2u4v5Dt3fWuE5L7mF5MzuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=L43E44kWSr0c0jV9sRrZTB0m3KhuZQDOHJYJYhQ2QY0=; b=NVqp5rm1PuGcU+KSTkGnAbFpKaioalpe2XnC/Ddo/oilKdiKxOi9yu37+ugYE1lwwnOqaezQ62pUPl974H9YtjKhro9OEBqNmmGDFV8DkU0kkzj1Tsput5i94dF1oVso3CY2T65UuInOUORYZzDBQqDVc1BFuM27Vdm+Jf/yM/G29/bDRsemP65cdDW4vkjDPeFe2sCa27aout07zpifgZfHKIbRuvJJ+yvgcKpGf6X87Ntc8H4SqtEJTFZ8stTdi5R3cVMwhrq/DsuqBG/QLP2tb6Py8fX48tHUS4DNendZ1X3ZNtkkAP93UhbRqrkJViWOTUcj0iM1xLWKmAKHrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=L43E44kWSr0c0jV9sRrZTB0m3KhuZQDOHJYJYhQ2QY0=; b=tpKePSeHy3hoXL03NZu9CalGqAQ4EQXQ+qKxHIOWv7KeGps+q9A8u/I43+Djcf2eANRdD3OrBWAmOT6WX0duKhrUQ6RJ742qrMZGI7VrPIoizGgYDJudGYAtYcbI0nk5RBphPzACINoGPEMf0V7DPz7+QHZTllZeUgWKn3rigio= Received: from CO1PR10MB4705.namprd10.prod.outlook.com (2603:10b6:303:96::11) by CY5PR10MB6214.namprd10.prod.outlook.com (2603:10b6:930:31::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Tue, 30 May 2023 19:40:35 +0000 Received: from CO1PR10MB4705.namprd10.prod.outlook.com ([fe80::11b8:4b2e:26c5:1bb3]) by CO1PR10MB4705.namprd10.prod.outlook.com ([fe80::11b8:4b2e:26c5:1bb3%2]) with mapi id 15.20.6433.022; Tue, 30 May 2023 19:40:35 +0000 From: chris hyser To: chris.hyser@oracle.com, linux-kernel@vger.kernel.org, peterz@infradead.org, gregkh@linuxfoundation.org, "Rafael J. Wysocki" Subject: [PATCH 3/4] debugfs: provide testing for the min/max simple debug files. Date: Tue, 30 May 2023 15:40:11 -0400 Message-Id: <20230530194012.44411-4-chris.hyser@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230530194012.44411-1-chris.hyser@oracle.com> References: <20230530194012.44411-1-chris.hyser@oracle.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SJ0PR03CA0382.namprd03.prod.outlook.com (2603:10b6:a03:3a1::27) To CO1PR10MB4705.namprd10.prod.outlook.com (2603:10b6:303:96::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4705:EE_|CY5PR10MB6214:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ca88047-85c1-4911-d352-08db6145bcbe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Trtk8dU6wD59R/GKVqVadu8aBrgJvDz2eaE5/JHexPZ9gBbBhRiCTZidPh4NQvTfT+527pA1wh6v51/7u5EnCpSyy8dOGQg2HT/j2DnhOptqa5cuXxkfhf1O8iBo5byMWbKzmv1VOcu6oHWiRlXrWamXP/LS15qU91I3SjZpfOj0auloZQbRtSAK1Br1KemA/UFPHEQ/l8R5+Bfvb4v1Ni+gJ+OCKugk2wmx3ZPWhZDVjwnrp+Wrf1VFBw+HaFwHMAEM16a+Bsrbyz6IQo186HDlp1N7fYe5ORMdkkaSEpgepKQoi37gmK2s0uoYj+ShVHMxHU0QlqwfZTS5P81GoE//c8K1i5fgvTOdTMGHYOfQoM/54P4bpeBxGZJGiBeuiaiWmrGCHHV222en8GauQ0aDbvY7Ndu8NEXGnEr8Qh9wE9dXbL+lf6N3WEucpEPJAT2zX7NGXUAJWaLpjr0oFHunOfLGY4Kv0wz2LNKDwKHr6tLziVrE3BDiYB9D9R4lt4aFipuEk+VuoW16TwIAWFs+AMNQl/BW04lpGJW8hzz5NpvN0lNymaskdFpEn9upDYnnZ6sPvcll7Njy64fv2eEsyWiNMkBjJ2+9X4psTGk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4705.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(39860400002)(396003)(366004)(346002)(136003)(376002)(451199021)(478600001)(8676002)(8936002)(5660300002)(6916009)(36756003)(2906002)(86362001)(66946007)(66556008)(66476007)(316002)(38100700002)(41300700001)(2616005)(186003)(6512007)(26005)(1076003)(6506007)(6486002)(6666004)(83380400001)(2004002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?1dUgy34BowQh5MoHiM1kt/DnD678Aagk42GJ2xixHw1CoiGTrLtbrZQ9goMS?= =?us-ascii?Q?ToAgmwAvHuOsPcONa67Ox0PZWFsL8NckMUBWdNUhS3IpZntkBz5HbURwhPGI?= =?us-ascii?Q?XYrZ6v4CtGOySNiHRDaVrmFVW7fdL8SuM0plbarNf+MHVV32RMmO9u43DN0D?= =?us-ascii?Q?8ce36zmiRrjxynQQeocAABf3mXzXj/hXoMpDrvNHZDceAABClTryjtegIDqQ?= =?us-ascii?Q?ZMKRDS+N+DEEWaTzRQbkVJAYk9J4hod5LJ7XEi2J//Hw0dbcehVc5kOS5inn?= =?us-ascii?Q?fY5rfMzx1UCnhNHivp9E/NHFkd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T0epD7y9yxmE2Us8xKGqQ15QFyH7iOBnK2MzmCJwRZGKYV5lwZqMtGBkoJ8YxbUt6jBNlsmP8DsgptaDlE6TD1GWzHEQaqLeRHwdnmZbPPJakF9Ostxz336ciXa7Yar46fro5Bqydj3JsuaTQ4nqyDsmOqx3CeYhgYaDjimYTzOc0fyKrNCVrLkQ1e+LKI1YZ+UJ4d4TOvCz8iC7zY3dPxvfu5LrGgX79cdHlP4hl1lIraKxhxwmwE+4PRDBVHiMyVI8CYV+JlBzhX9q8J7t+jFswVrvBANCILryIaLPiCoftJF7QVfd2v/gAZ9LnBXS5gTZRLckkj8wEHLgqx59lgIuCXdvy2OgxvHZIuu05oaQqmJ90ZGJjZj X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ca88047-85c1-4911-d352-08db6145bcbe X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4705.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 19:40:35.2130 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /InH29DAdB6ng/Nrj5oIGlmrwsBzoaUkRf3chrfeBALXIy7cvyy6TZg2FiOvtCqSvWJR+b8DIODq16SlmtcHgQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB6214 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-05-30_15,2023-05-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 adultscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305300159 X-Proofpoint-GUID: NCYLMpkoE6_OjbnK1UGAvw_OVnbvhB7x X-Proofpoint-ORIG-GUID: NCYLMpkoE6_OjbnK1UGAvw_OVnbvhB7x Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This patch contains a module and a bash script which tests the new simple "unsigned min/max checking" files. The module creates the debugfs files and encodes the test type and test parameters in the file name which the script decodes and tests. Currently the files were placed under testscripts though auto testing is not yet enabled. The hope is that this eases testing of the patches. Signed-off-by: Chris Hyser --- tools/testing/selftests/debugfs/Makefile | 15 ++ tools/testing/selftests/debugfs/minmax_test.c | 140 +++++++++++++++++ .../testing/selftests/debugfs/test_minmax.sh | 147 ++++++++++++++++++ 3 files changed, 302 insertions(+) create mode 100644 tools/testing/selftests/debugfs/Makefile create mode 100644 tools/testing/selftests/debugfs/minmax_test.c create mode 100755 tools/testing/selftests/debugfs/test_minmax.sh diff --git a/tools/testing/selftests/debugfs/Makefile b/tools/testing/selft= ests/debugfs/Makefile new file mode 100644 index 000000000000..5dddaaf6c7a2 --- /dev/null +++ b/tools/testing/selftests/debugfs/Makefile @@ -0,0 +1,15 @@ +obj-m :=3D minmax_test.o + +KDIR :=3D ../../../.. +PWD :=3D $(shell pwd) +WARN_FLAGS +=3D -Wall + +.PHONY: all +all: + $(MAKE) -C $(KDIR) M=3D$(PWD) modules + +clean: + $(MAKE) -C $(KDIR) M=3D$(PWD) clean + + +include ../lib.mk diff --git a/tools/testing/selftests/debugfs/minmax_test.c b/tools/testing/= selftests/debugfs/minmax_test.c new file mode 100644 index 000000000000..0e0f6bcd6302 --- /dev/null +++ b/tools/testing/selftests/debugfs/minmax_test.c @@ -0,0 +1,140 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Test debugfs minmax simple files. + * + * Copyright (c) 2023 Oracle and/or its affiliates. + * Author: Chris Hyser + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of version 2.1 of the GNU Lesser General Public License= as + * published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WIT= HOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public Li= cense + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#include +#include +#include +#include + +MODULE_LICENSE("GPL"); + +#define MIN_MAX 1 + +static struct dentry *dir =3D NULL; + +#ifdef MIN_MAX +u8 test_max_8 =3D 250; +DEBUGFS_MAX_ATTRIBUTES(test_max_8_p, &test_max_8, 252); + +u8 test_min_8 =3D 250; +DEBUGFS_MIN_ATTRIBUTES(test_min_8_p, &test_min_8, 25); + +u8 test_minmax_8 =3D 250; +DEBUGFS_MINMAX_ATTRIBUTES(test_minmax_8_p, &test_minmax_8, 100, 253); + + +u16 test_max_16 =3D 250; +DEBUGFS_MAX_ATTRIBUTES(test_max_16_p, &test_max_16, 0x1fff); + +u16 test_min_16 =3D 250; +DEBUGFS_MIN_ATTRIBUTES(test_min_16_p, &test_min_16, 100); + +u16 test_minmax_16 =3D 250; +DEBUGFS_MINMAX_ATTRIBUTES(test_minmax_16_p, &test_minmax_16, 100, 300); + + +u32 test_max_32 =3D 250; +DEBUGFS_MAX_ATTRIBUTES(test_max_32_p, &test_max_32, 0x1fffffff); + +u32 test_min_32 =3D 250; +DEBUGFS_MIN_ATTRIBUTES(test_min_32_p, &test_min_32, 100); + +u32 test_minmax_32 =3D 250; +DEBUGFS_MINMAX_ATTRIBUTES(test_minmax_32_p, &test_minmax_32, 100, 0x1fffff= ff); + +/* test setting everything directly */ +u32 test_minmax_32_s =3D 250; +static struct debugfs_minmax_params test_minmax_32_ps =3D { + .value =3D &test_minmax_32_s, + .min =3D 100, + .max =3D 0x1fffffff, + .flags =3D 3, +}; + +u64 test_max_64 =3D 250; +DEBUGFS_MAX_ATTRIBUTES(test_max_64_p, &test_max_64, 0x1fffffff); + +u64 test_min_64 =3D 250; +DEBUGFS_MIN_ATTRIBUTES(test_min_64_p, &test_min_64, 100); + +u64 test_minmax_64 =3D 250; +DEBUGFS_MINMAX_ATTRIBUTES(test_minmax_64_p, &test_minmax_64, 100, 300); +#endif + +u8 test_reg_8 =3D 250; +u16 test_reg_16 =3D 250; +u32 test_reg_32 =3D 250; +u64 test_reg_64 =3D 250; + +u8 test_regx_8 =3D 250; +u16 test_regx_16 =3D 250; +u32 test_regx_32 =3D 250; +u64 test_regx_64 =3D 250; + + +/* File names consist of test__<1st param>__. + */ + +int init_module(void) +{ + pr_err("minmax_test: init_module()\n"); + dir =3D debugfs_create_dir("minmax_test", 0); + if (dir =3D=3D NULL) { + printk(KERN_ALERT "minmax_test: can't create dir 'minmax_test'\n"); + return -1; + } + +#ifdef MIN_MAX + debugfs_create_u8_minmax("test_max_252_8", 0644, dir, &test_max_8_= p); + debugfs_create_u8_minmax("test_min_25_8", 0644, dir, &test_min_8_p= ); + debugfs_create_u8_minmax("test_minmax_100_253_8", 0644, dir, &test= _minmax_8_p); + + debugfs_create_u16_minmax("test_max_0x1fff_16", 0644, dir, &test_m= ax_16_p); + debugfs_create_u16_minmax("test_min_100_16", 0644, dir, &test_min_= 16_p); + debugfs_create_u16_minmax("test_minmax_100_300_16", 0644, dir, &te= st_minmax_16_p); + + debugfs_create_u32_minmax("test_max_0x1fffffff_32", 0644, dir, &te= st_max_32_p); + debugfs_create_u32_minmax("test_min_100_32", 0644, dir, &test_min_= 32_p); + debugfs_create_u32_minmax("test_minmax_100_0x1fffffff_32", 0644, d= ir, &test_minmax_32_p); + debugfs_create_u32_minmax("testss_minmax_100_0x1fffffff_32", 0644,= dir, &test_minmax_32_ps); + + debugfs_create_u64_minmax("test_max_0x1fffffff_64", 0644, dir, &te= st_max_64_p); + debugfs_create_u64_minmax("test_min_100_64", 0644, dir, &test_min_= 64_p); + debugfs_create_u64_minmax("test_minmax_100_300_64", 0644, dir, &te= st_minmax_64_p); +#endif + + debugfs_create_u8("test_reg_8", 0644, dir, &test_reg_8); + debugfs_create_u16("test_reg_16", 0644, dir, &test_reg_16); + debugfs_create_u32("test_reg_32", 0644, dir, &test_reg_32); + debugfs_create_u64("test_reg_64", 0644, dir, &test_reg_64); + + debugfs_create_x8("test_regx_8", 0644, dir, &test_regx_8); + debugfs_create_x16("test_regx_16", 0644, dir, &test_regx_16); + debugfs_create_x32("test_regx_32", 0644, dir, &test_regx_32); + debugfs_create_x64("test_regx_64", 0644, dir, &test_regx_64); + return 0; +} + +void cleanup_module(void) +{ + pr_err("minmax_test: cleanup_module()\n"); + debugfs_remove_recursive(dir); +} diff --git a/tools/testing/selftests/debugfs/test_minmax.sh b/tools/testing= /selftests/debugfs/test_minmax.sh new file mode 100755 index 000000000000..67ed7b9abac2 --- /dev/null +++ b/tools/testing/selftests/debugfs/test_minmax.sh @@ -0,0 +1,147 @@ +#!/bin/bash + +# SPDX-License-Identifier: GPL-2.0-only +# +# Test debugfs minmax simple files. +# +# Copyright (c) 2023 Oracle and/or its affiliates. +# Author: Chris Hyser +# +# This library is free software; you can redistribute it and/or modify it +# under the terms of version 2.1 of the GNU Lesser General Public License = as +# published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, but WITH= OUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public Lic= ense +# for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library; if not, see . + +rmmod minmax_test 2>/dev/null +insmod minmax_test.ko + +cd /sys/kernel/debug/minmax_test +pwd + +function split_wds() +{ + words=3D() + local IFS=3D_ + for w in $1; do + words+=3D($w) + done +} + +function test_max() +{ + echo $2 > $1 + local res=3D$? + local rv=3D$(cat $1) + if ! (( res =3D=3D 0 && $2 =3D=3D rv )); then + return 1 + fi + + local max=3D$(($2 + 1)) + echo $max > $1 2>/dev/null + res=3D$? + rv=3D$(cat $1) + if ! [[ $res -ne 0 && $2 -eq $rv ]]; then + return 1 + fi + return 0 +} + +function test_min() +{ + echo $2 > $1 + local res=3D$? + local rv=3D$(cat $1) + if ! [[ $res -eq 0 && $2 -eq $rv ]]; then + return 1 + fi + + local min=3D$(($2 - 1)) + echo $min > $1 2>/dev/null + res=3D$? + rv=3D$(cat $1) + if ! [[ $res -ne 0 && $2 -eq $rv ]]; then + return 1 + fi + return 0 +} + +function test_minmax() +{ + test_min $1 ${words[2]} + if [[ $? -ne 0 ]]; then + echo "$1: min error" + return 1 + fi + test_max $1 ${words[3]} + if [[ $? -ne 0 ]]; then + echo "$1: max error" + return 1 + fi + return 0 +} + +function test_reg() +{ + if [[ $2 -eq 64 ]]; then + local V=3D313 + + echo $V > $1 2>/dev/null + + local rv=3D$(cat $1) + if ! (( rv =3D=3D V )); then + return 1 + fi + return 0 + fi + + local max=3D$(((1 << $2) - 1)) + test_max $1 $max + if [[ $? -ne 0 ]]; then + echo "$1: reg/x error" + return 1 + fi + return 0 +} + +rc=3D0 +for f in *; do + split_wds $f + echo file: $f + + if [[ ${words[1]} =3D=3D "min" ]]; then + test_min $f ${words[2]} + if [[ $? -ne 0 ]]; then + echo "$f: min error" + rc=3D1 + fi + elif [[ ${words[1]} =3D=3D "max" ]]; then + test_max $f ${words[2]} + if [[ $? -ne 0 ]]; then + echo "$f: max error" + rc=3D1 + fi + elif [[ ${words[1]} =3D=3D "minmax" ]]; then + test_minmax $f ${words[2]} ${words[3]} + if [[ $? -ne 0 ]]; then + echo "$f: minmax error" + rc=3D1 + fi + elif [[ ${words[1]} =3D=3D "reg" || ${words[1]} =3D=3D "regx" ]]; then + test_reg $f ${words[2]} + if [[ $? -ne 0 ]]; then + echo "$f: reg/x error" + rc=3D1 + fi + fi +done + +rmmod minmax_test + +exit $rc --=20 2.31.1