qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 4/5] tests/test-vmstate.c: test array of ptr wit


From: Halil Pasic
Subject: Re: [Qemu-devel] [PATCH 4/5] tests/test-vmstate.c: test array of ptr with null
Date: Tue, 21 Feb 2017 12:07:28 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0


On 02/21/2017 11:49 AM, Dr. David Alan Gilbert wrote:
>> +static void test_arr_ptr_str_0_save(void)
>> +{
>> +    TestStructTriv ar[AR_SIZE] = {{.i = 0}, {.i = 1}, {.i = 2}, {.i = 3} };
>> +    TestArrayOfPtrToStuct sample = {.ar = {&ar[0], NULL, &ar[2], &ar[3]} };
>> +    uint8_t wire_sample[] = {
>> +        0x00, 0x00, 0x00, 0x00,
>> +        VMS_NULLPTR_MARKER,
>> +        0x00, 0x00, 0x00, 0x02,
>> +        0x00, 0x00, 0x00, 0x03,
>> +        QEMU_VM_EOF
>> +    };
>> +
>> +    save_vmstate(&vmsd_arps, &sample);
>> +    compare_vmstate(wire_sample, sizeof(wire_sample));
>> +}
>> +
>> +static void test_arr_ptr_str_0_load(void)
>> +{
>> +    TestStructTriv ar_gt[AR_SIZE] = {{.i = 0}, {.i = 0}, {.i = 2}, {.i = 3} 
>> };
>> +    TestStructTriv ar[AR_SIZE] = {};
>> +    TestArrayOfPtrToStuct obj = {.ar = {&ar[0], NULL, &ar[2], &ar[3]} };
>> +    int idx;
>> +    uint8_t wire_sample[] = {
>> +        0x00, 0x00, 0x00, 0x00,
>> +        VMS_NULLPTR_MARKER,
>> +        0x00, 0x00, 0x00, 0x02,
>> +        0x00, 0x00, 0x00, 0x03,
>> +        QEMU_VM_EOF
>> +    };
> If possible; it would be better if you could share the wire_sample, and ar_gt 
> between
> the two functions rather than copying them.
> 
> Dave
> 

Certainly possible. I did it this way because I prefer
unit tests as self contained as possible, but consistent
style is also important.

Will factor wire_sample out for the next version.

Cheers,
Halil




reply via email to

[Prev in Thread] Current Thread [Next in Thread]