[Skiboot] [PATCH 3/3] test-ipmi-hiomap: Add write-one-byte test
Vasant Hegde
hegdevasant at linux.vnet.ibm.com
Mon Apr 8 15:39:13 AEST 2019
On 04/08/2019 07:53 AM, Andrew Jeffery wrote:
>
>
> On Fri, 5 Apr 2019, at 00:03, Vasant Hegde wrote:
>> Add test case to write:
>> - 1 byte
>> - 1 block and 1 byte data
>>
>> Cc: Andrew Jeffery <andrew at aj.id.au>
>> Cc: skiboot-stable at lists.ozlabs.org
>> Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
>> ---
>> libflash/test/test-ipmi-hiomap.c | 38 ++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 38 insertions(+)
>>
>> diff --git a/libflash/test/test-ipmi-hiomap.c b/libflash/test/test-ipmi-hiomap.c
>> index c4cc76d8c..315d76248 100644
>> --- a/libflash/test/test-ipmi-hiomap.c
>> +++ b/libflash/test/test-ipmi-hiomap.c
>> @@ -1061,6 +1061,23 @@ static void test_hiomap_protocol_write_one_block(void)
>> scenario_exit();
>> }
>>
>> +static void test_hiomap_protocol_write_one_byte(void)
>> +{
>> + struct blocklevel_device *bl;
>> + uint8_t *buf;
>> + size_t len;
>> +
>> + scenario_enter(scenario_hiomap_protocol_write_one_block);
>> + assert(!ipmi_hiomap_init(&bl));
>> + len = 1;
>> + buf = calloc(1, len);
>> + assert(buf);
>> + assert(!bl->write(bl, 0, buf, len));
>> + free(buf);
>> + ipmi_hiomap_exit(bl);
>> + scenario_exit();
>> +}
>> +
>> static const struct scenario_event
>> scenario_hiomap_protocol_write_two_blocks[] = {
>> { .type = scenario_event_p, .p = &hiomap_ack_call, },
>> @@ -1128,6 +1145,25 @@ static void test_hiomap_protocol_write_two_blocks(void)
>> scenario_exit();
>> }
>>
>> +static void test_hiomap_protocol_write_1block_1byte(void)
>> +{
>> + struct blocklevel_device *bl;
>> + struct ipmi_hiomap *ctx;
>> + uint8_t *buf;
>> + size_t len;
>> +
>> + scenario_enter(scenario_hiomap_protocol_write_two_blocks);
>> + assert(!ipmi_hiomap_init(&bl));
>> + ctx = container_of(bl, struct ipmi_hiomap, bl);
>> + len = (1 << ctx->block_size_shift) + 1;
>> + buf = calloc(1, len);
>> + assert(buf);
>> + assert(!bl->write(bl, 0, buf, len));
>> + free(buf);
>> + ipmi_hiomap_exit(bl);
>> + scenario_exit();
>> +}
>> +
>
> Looks good. Nice idea with the scenario reuse.
>
> Patch 1/3 also modifies the read-path behaviour because
> hiomap_window_move() is common to both read and write windows.
> I think we should have a test for the read path too - i.e. that the
> requested size at the protocol level least encapsulates the requested
> size at the blocklevel API level.
Yeah. You are right. My bad. I should have added test cases for read path
as well. Will fix it in v2.
-Vasant
More information about the Skiboot
mailing list