Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1089764rdb; Sat, 18 Nov 2023 02:42:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IElechEhjfJpXpANMXdYl+TUNaW3gncWsJmGv6WDjwBfr5ClQSv9B1nJS7Ui16/Xj9cfnhJ X-Received: by 2002:a05:6602:400f:b0:787:1555:efca with SMTP id bk15-20020a056602400f00b007871555efcamr3088186iob.5.1700304142637; Sat, 18 Nov 2023 02:42:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700304142; cv=none; d=google.com; s=arc-20160816; b=H/EZwr4Q61ry1/5YfDCTNj6KroJw3guQjRCsrskaRUva8BwvzBOp4bX7tZTq78lcdc 0GZszpDeD2MtRKe4WLcao/J8Maf62nBnfSoNb6fyhzTLS+a5IO1x9dyDFdlePP74W6dU wyureDdoJyF/XQ9jkLI3DLjv4g/XtlHO43YO6OCMeHiMCVLfWEmQxZkkAT5mByv/v1ri 5Xwa+s8FDp8wR/YgM5W8wzWkB/kHvvUe5qir1lkdGBMFdJkstZpPTOzSmAr6rEna+tz4 Ewi1sArJTNegGaERXkD61HOJJlY0CD8jZ6lhKkNo8klRfKWuyV3gko1CYcTRk5ctnIG+ M9AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from; bh=xgJ/SLzRWjYXRlGNR2oxAxDwdYATvAMR1wdF6CAS/ZA=; fh=cKgRupAwAqvDHHS6VAzGoPs3pyLdUCOVkk/Q20cDUOo=; b=iZmZQzleKOlEFZpp/WDfA9bh2/EPPE0XLBc3xpKiUTMBV81SUWMPyDzROFS08hifYG 0UMPhnYqgtPS6VN1shRtUNu71S/zphVy3xqViNu+EbuDeCjRBb7MEugwUmgDFIpmR+n8 IkaElv/B7F3XHFXEtmNliYnLtCqYpOZYsiR1FWXuNYVc2c5FF7sQF2SWoChNhV4vEWba yIGhE3itGLhDRZuj2IZekMGJbS3cUE/SAKQER8za4Vyya6fu79mTOjyRdybVm0Sq+CqK njAPaqjY3C/zkiOPq/Ss6PXhpaxyJg76cDgfOA5cCWqqGz8QClIzNC7bUf+m2W1iE43B +kWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id pf18-20020a17090b1d9200b0027995cf4342si4187480pjb.55.2023.11.18.02.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 02:42:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id DA34280C1130; Sat, 18 Nov 2023 02:42:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233146AbjKRKmH (ORCPT + 99 others); Sat, 18 Nov 2023 05:42:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232664AbjKRKlo (ORCPT ); Sat, 18 Nov 2023 05:41:44 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C861D10D0; Sat, 18 Nov 2023 02:41:40 -0800 (PST) Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4SXVgd4krCz4f3lg9; Sat, 18 Nov 2023 18:41:33 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id C5AE71A016E; Sat, 18 Nov 2023 18:41:37 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.101.107]) by APP1 (Coremail) with SMTP id cCh0CgDn6hDQlFhlQPAFBQ--.58135S15; Sat, 18 Nov 2023 18:41:37 +0800 (CST) From: Zhang Xiaoxu To: zhangxiaoxu5@huawei.com, weiyongjun1@huawei.com, linux-kernel@vger.kernel.org, broonie@kernel.org, rostedt@goodmis.org, mingo@redhat.com, frowand.list@gmail.com, linux-spi@vger.kernel.org Subject: [PATCH -next 11/14] kddv/tests/hwmon: Add test cases for max31722 driver Date: Sat, 18 Nov 2023 18:40:37 +0800 Message-Id: <20231118104040.386381-12-zhangxiaoxu@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231118104040.386381-1-zhangxiaoxu@huaweicloud.com> References: <20231118104040.386381-1-zhangxiaoxu@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: cCh0CgDn6hDQlFhlQPAFBQ--.58135S15 X-Coremail-Antispam: 1UD129KBjvJXoW7ZFy5Aw1xKFW7AFWkJF4fKrg_yoW8ZF15pF 1fGr1Y9Fn2qr1fXwnakF1a9FyrZF4xuF4Ykr47Aw15WFn8JrySkrZIkFyUAF13XrWFgFWr Z348WF4akw43JaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU90b4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAV Cq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0 rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E 14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7 xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Y z7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7 v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF 1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Gr0_Xr1lIx AIcVC0I7IYx2IY6xkF7I0E14v26F4j6r4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4l IxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIda VFxhVjvjDU0xZFpf9x07UZo7tUUUUU= X-CM-SenderInfo: x2kd0wp0ld053x6k3tpzhluzxrxghudrp/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sat, 18 Nov 2023 02:42:21 -0800 (PST) From: Zhang Xiaoxu This add test case for max31722 hwmon driver, test for the device loading and read temperature from the device. Signed-off-by: Wei Yongjun Signed-off-by: Zhang Xiaoxu --- .../kddv/kddv/tests/hwmon/test_max31722.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 tools/testing/kddv/kddv/tests/hwmon/test_max31722.py diff --git a/tools/testing/kddv/kddv/tests/hwmon/test_max31722.py b/tools/testing/kddv/kddv/tests/hwmon/test_max31722.py new file mode 100755 index 000000000000..70223eb0ef7b --- /dev/null +++ b/tools/testing/kddv/kddv/tests/hwmon/test_max31722.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 +# +# Kernel device driver verification +# +# Copyright (C) 2022-2023 Huawei Technologies Co., Ltd +# Author: Wei Yongjun + +from kddv.core import SPIDriverTest +from kddv.core.consts import CFG_REG_MASK +from . import HwMonDriver +import errno + +MAX31722_REG_CFG = 0x00 +MAX31722_REG_TEMP_LSB = 0x01 +MAX31722_MODE_CONTINUOUS = 0x00 +MAX31722_RESOLUTION_12BIT = 0x06 + +class TestMax31722(SPIDriverTest, HwMonDriver): + name = 'max31722' + + @property + def configs(self): + return { CFG_REG_MASK: 0x7f } + + def test_device_probe(self): + with self.assertRaisesFault(): + with self.device() as dev: + self.assertRegEqual(MAX31722_REG_CFG, MAX31722_RESOLUTION_12BIT) + + def test_read_temp_input(self): + with self.device() as dev: + self.write_regs(MAX31722_REG_TEMP_LSB, [0x12, 0x34]) + temp = self.hwmon_read_temp_input(dev) + self.assertEqual(temp, int(0x3412 * 125 / 32)) + + self.trigger_io_fault() + with self.assertRaises(OSError) as cm: + self.hwmon_read_temp_input(dev) + self.assertEqual(cm.exception.errno, errno.EIO) -- 2.34.1