diff options
author | Anastasia Klimchuk <aklm@chromium.org> | 2022-08-29 11:26:07 +1000 |
---|---|---|
committer | Anastasia Klimchuk <aklm@chromium.org> | 2022-09-04 22:47:22 +0000 |
commit | 549b3998e8a6f0c0b053792d67503ea3fb31b18d (patch) | |
tree | 0d379ec4a07cba7ddc6aca72a14af9cf0142279d /82802ab.c | |
parent | b6f3c00fbdec538154d4424da4ed117366ccae7e (diff) | |
download | flashrom-549b3998e8a6f0c0b053792d67503ea3fb31b18d.tar.gz flashrom-549b3998e8a6f0c0b053792d67503ea3fb31b18d.tar.bz2 flashrom-549b3998e8a6f0c0b053792d67503ea3fb31b18d.zip |
tests/parade_lspcon.c: Add emulation for ioctl, read, write operations
Previously, parade lspcon unit test had no custom emulation and
was running basic lifecycle with default mocks (default mocks do
nothing and return success). I have discovered that it does not
work in all environments.
Specifically, in functions `parade_lspcon_wait_command_done`
and `parade_lspcon_wait_rom_free` there is a local variable
`uint8_t val` which is declared and not explicitly initialised. It can
get different initial values depending on the environment/toolchain
(for example gcc vs clang).
Later during the code execution, this variable is used as a holder
for writing/reading data from register(s). For unit test, reading and
writing data from registers is emulated. With default mocks, initial
value of variable was propagated further as if it was "read" from
a register. So the unit test could pass or fail depending on the
initial value of local variable, which in turn depends on environment
and toolchain.
If initial value was 0 the test reliably passed (this is the case with
upstream build environment, locally I have gcc 11.3.0 on x86_64).
If it was 1 the test reliably failed (this is the case of chromium
flashrom tree, this is clang 15.0 under chroot, tested on x86_64 and
arm boards).
If it was any other value then it could be anything.
This patch adds custom mocks for ioctl/read/write operations
and emulates a successful scenario of running a lifecycle. Local
variable is initialised by reading from the register, same as it
happens in the real (non-test) run for this programmer.
BUG=b:242816982
TEST=ninja test
Change-Id: I98f52507a0ddbbfbeb390038d14192cacc2be683
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/67161
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Diffstat (limited to '82802ab.c')
0 files changed, 0 insertions, 0 deletions