[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
- [Qemu-devel] [PATCH 0/5] vmstate: handle arrays with null ptrs, Halil Pasic, 2017/02/16
- [Qemu-devel] [PATCH 1/5] migration/vmstate: renames in (load|save)_state, Halil Pasic, 2017/02/16
- [Qemu-devel] [PATCH 3/5] migration/vmstate: fix array of ptr with nullptrs, Halil Pasic, 2017/02/16
- [Qemu-devel] [PATCH 2/5] migration/vmstate: split up vmstate_base_addr, Halil Pasic, 2017/02/16
- [Qemu-devel] [PATCH 4/5] tests/test-vmstate.c: test array of ptr with null, Halil Pasic, 2017/02/16
- [Qemu-devel] [PATCH 5/5] tests/test-vmstate.c: test array of ptr to primitive, Halil Pasic, 2017/02/16