]> git.proxmox.com Git - mirror_qemu.git/commit
tests: unit: simplify test-visitor-serialization list tests
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 5 Sep 2022 10:59:46 +0000 (12:59 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Sun, 18 Sep 2022 07:17:40 +0000 (09:17 +0200)
commitac9e723fb6baaf9d9afa31f81c57f38ef7610616
tree6011dd94c4e3b2d3a4c6921469c70d2eae324e08
parent57e3069641d057a9ca90bb603c86477d5b331ecd
tests: unit: simplify test-visitor-serialization list tests

test-visitor-serialization list tests is using an "if" to pick either the first
element of the list or the next one.  This was done presumably to mimic the
code that creates the list, which has to fill in either the head pointer
or the next pointer of the last element.  However, the code in the insert
phase is a pretty standard singly-linked list insertion, while the one
in the visit phase looks weird and even looks at the first item twice:
this is confusing because the test puts in 32 items and finishes with
an assertion that i == 33.

So, move the "else" step in a separate switch statement, and change
the do...while loop to a while, because cur_head has already been
initialized beforehand.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tests/unit/test-visitor-serialization.c