From: Mark Brown <broonie@kernel.org>
To: Vincent Whitchurch <vincent.whitchurch@axis.com>
Cc: linux-kernel@vger.kernel.org, kernel@axis.com,
devicetree@vger.kernel.org, linux-um@lists.infradead.org,
shuah@kernel.org, brendanhiggins@google.com,
linux-kselftest@vger.kernel.org, jic23@kernel.org,
linux-iio@vger.kernel.org, lgirdwood@gmail.com,
a.zummo@towertech.it, alexandre.belloni@bootlin.com,
linux-rtc@vger.kernel.org, corbet@lwn.net,
linux-doc@vger.kernel.org
Subject: Re: [RFC v1 09/10] regulator: tps62864: add roadtest
Date: Fri, 11 Mar 2022 18:06:54 +0000 [thread overview]
Message-ID: <YiuPvkQroV/WdFpx@sirena.org.uk> (raw)
In-Reply-To: <20220311162445.346685-10-vincent.whitchurch@axis.com>
[-- Attachment #1: Type: text/plain, Size: 4029 bytes --]
On Fri, Mar 11, 2022 at 05:24:44PM +0100, Vincent Whitchurch wrote:
This looks like it could be useful, modulo the general concerns with
mocking stuff. I've not looked at the broader framework stuff in any
meanigful way.
> + @classmethod
> + def setUpClass(cls) -> None:
> + insmod("tps6286x-regulator")
Shouldn't this get figured out when the device gets created in DT (if it
doesn't I guess the tests found a bug...)?
> + def setUp(self) -> None:
> + self.driver = I2CDriver("tps6286x")
> + self.hw = Hardware("i2c")
> + self.hw.load_model(TPS62864)
This feels like there could be some syntactic sugar to say "create this
I2C device" in one call? In general a lot of the frameworkish stuff
feels verbose.
> + def test_voltage(self) -> None:
> + with (
> + self.driver.bind(self.dts["normal"]),
> + PlatformDriver("reg-virt-consumer").bind(
> + "tps62864_normal_consumer"
> + ) as consumerdev,
> + ):
> + maxfile = consumerdev.path / "max_microvolts"
> + minfile = consumerdev.path / "min_microvolts"
> +
> + write_int(maxfile, 1675000)
> + write_int(minfile, 800000)
> +
> + mock = self.hw.update_mock()
> + mock.assert_reg_write_once(self, REG_CONTROL, 1 << 5)
> + mock.assert_reg_write_once(self, REG_VOUT1, 0x50)
> + mock.reset_mock()
Some comments about the assertations here would seem to be in order.
It's not altogether clear what this is testing - it looks to be
verifying that the regulator is enabled with the voltage set to 800mV
mapping to 0x50 in VOUT1 but I'm not sure that the idle reader would
pick that up.
> + mV = 1000
> + data = [
> + (400 * mV, 0x00),
> + (900 * mV, 0x64),
> + (1675 * mV, 0xFF),
> + ]
> +
> + for voltage, val in data:
> + write_int(minfile, voltage)
> + mock = self.hw.update_mock()
> + mock.assert_reg_write_once(self, REG_VOUT1, val)
> + mock.reset_mock()
For covering regulators in general (especially those like this that use
the generic helpers) I'd be inclined to go through every single voltage
that can be set which isn't so interesting for this driver with it's
linear voltage control but more interesting for something that's not
continuous. I'd also put a cross check in that the voltage and enable
state that's reported via the read interface in sysfs is the one that we
think we've just set, that'd validate that the framework's model of
what's going on matches both what the driver did to the "hardware" and
what the running kernel thinks is going on so we're joined up top to
bottom (for the regulator framework the read values come from the
driver so it is actually covering the driver).
This all feels like it could readily be factored out into a generic
helper, much as the actual drivers are especially when they're more data
driven. Ideally with the ability to override the default I/O operations
for things with sequences that need to be followed instead of just a
bitfield to update. Callbacks to validate enable state, voltage, mode
and so on in the hardware. If we did that then rather than open coding
every single test for every single device we could approach things at
the framework level and give people working on a given device a pile of
off the shelf tests which are more likely to catch things that an
individual driver author might've missed, it also avoids the test
coverage being more laborious than writing the actual driver.
This does raise the questions I mentioned about how useful the testing
really is of course, even more so when someone works out how to generate
the data tables for the test and the driver from the same source, but
that's just generally an issue for mocked tests at the conceptual level
and clearly it's an approach that's fairly widely used and people get
value from.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2022-03-11 18:07 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-11 16:24 [RFC v1 00/10] roadtest: a driver testing framework Vincent Whitchurch
2022-03-11 16:24 ` [RFC v1 01/10] roadtest: import libvhost-user from QEMU Vincent Whitchurch
2022-03-24 13:00 ` Johannes Berg
2022-04-05 13:54 ` Vincent Whitchurch
2022-03-11 16:24 ` [RFC v1 02/10] roadtest: add C backend Vincent Whitchurch
2022-03-11 16:24 ` [RFC v1 03/10] roadtest: add framework Vincent Whitchurch
2022-03-11 16:24 ` [RFC v1 04/10] roadtest: add base config Vincent Whitchurch
2022-03-11 16:24 ` [RFC v1 05/10] roadtest: add build files Vincent Whitchurch
2022-03-11 16:24 ` [RFC v1 06/10] roadtest: add documentation Vincent Whitchurch
2022-03-11 16:24 ` [RFC v1 07/10] iio: light: opt3001: add roadtest Vincent Whitchurch
2022-03-14 23:11 ` Brendan Higgins
2022-03-18 15:49 ` Vincent Whitchurch
2022-03-18 20:09 ` Johannes Berg
2022-03-29 14:43 ` Vincent Whitchurch
2022-03-29 14:50 ` Johannes Berg
2022-03-29 14:52 ` Johannes Berg
2022-03-11 16:24 ` [RFC v1 08/10] iio: light: vcnl4000: " Vincent Whitchurch
2022-03-20 17:02 ` Jonathan Cameron
2022-04-05 13:48 ` Vincent Whitchurch
2022-04-06 13:08 ` Jonathan Cameron
2022-04-14 10:20 ` Vincent Whitchurch
2022-03-11 16:24 ` [RFC v1 09/10] regulator: tps62864: " Vincent Whitchurch
2022-03-11 18:06 ` Mark Brown [this message]
2022-03-17 15:13 ` Vincent Whitchurch
2022-03-17 17:53 ` Mark Brown
2022-04-05 14:02 ` Vincent Whitchurch
2022-03-11 16:24 ` [RFC v1 10/10] rtc: pcf8563: " Vincent Whitchurch
2022-03-14 22:24 ` [RFC v1 00/10] roadtest: a driver testing framework Brendan Higgins
2022-03-17 16:09 ` Vincent Whitchurch
2022-04-18 19:44 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YiuPvkQroV/WdFpx@sirena.org.uk \
--to=broonie@kernel.org \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@bootlin.com \
--cc=brendanhiggins@google.com \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=kernel@axis.com \
--cc=lgirdwood@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=shuah@kernel.org \
--cc=vincent.whitchurch@axis.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®