lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 18 Nov 2023 18:40:37 +0800
From:   Zhang Xiaoxu <zhangxiaoxu@...weicloud.com>
To:     zhangxiaoxu5@...wei.com, weiyongjun1@...wei.com,
        linux-kernel@...r.kernel.org, broonie@...nel.org,
        rostedt@...dmis.org, mingo@...hat.com, frowand.list@...il.com,
        linux-spi@...r.kernel.org
Subject: [PATCH -next 11/14] kddv/tests/hwmon: Add test cases for max31722 driver

From: Zhang Xiaoxu <zhangxiaoxu5@...wei.com>

This add test case for max31722 hwmon driver, test for
the device loading and read temperature from the device.

Signed-off-by: Wei Yongjun <weiyongjun1@...wei.com>
Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@...wei.com>
---
 .../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 <weiyongjun1@...wei.com>
+
+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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ