QemuOpt: add unit tests
PATCH v2 1/1 QemuOpt: add unit tests
Cover basic aspects and API usage for QemuOpt. The current implementation covers the API's planned to be changed by Chunyan Liu in his QEMUOptionParameter replacement/cleanup job.
Other APIs should be covered in future improvements.
Changes:
v2:
+ fixed comments;
+ make use of g_assert_cmpstr();
+ use error_abort instead of a local_err for qemu_opts_absorb_qdict();
+ asserts on QemuOptsList (empty and list name);
+ added test_qemu_opt_unset();
+ asserts on qemu_opt_*_set() return;
+ added test_qemu_opts_reset();
+ added test_qemu_opts_set();
--- tests/Makefile | 3 + tests/test-qemu-opts.c | 455 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 458 insertions(+) create mode 100644 tests/test-qemu-opts.c
tests/Makefile +3 -0
@@ -60,6 +60,8 @@ check-unit-y += tests/test-qdev-global-props$(EXESUF) check-unit-y += tests/check-qom-interface$(EXESUF) gcov-files-check-qom-interface-y = qom/object.c check-unit-y += tests/test-vmstate$(EXESUF) +check-unit-y += tests/test-qemu-opts$(EXESUF) +gcov-files-test-qemu-opts-y = qom/test-qemu-opts.c check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh
@@ -272,6 +274,7 @@ tests/qom-test$(EXESUF): tests/qom-test.o tests/blockdev-test$(EXESUF): tests/blockdev-test.o $(libqos-pc-obj-y) tests/qdev-monitor-test$(EXESUF): tests/qdev-monitor-test.o $(libqos-pc-obj-y) tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o +tests/test-qemu-opts$(EXESUF): tests/test-qemu-opts.o libqemuutil.a libqemustub.a # QTest rules
tests/test-qemu-opts.c new file +455 -0
455 lines not on this page · raw message
Signature · 1 line
1.9.0
Quoted 7 lines · Leandro Dorileo
Cover basic aspects and API usage for QemuOpt. The current implementation covers the API's planned to be changed by Chunyan Liu in his QEMUOptionParameter replacement/cleanup job.
Other APIs should be covered in future improvements.
Signed-off-by Leandro Dorileo <[email protected]>
Right here is where you should stick a --- marker.
Quoted 12 lines
Changes:
v2:
+ fixed comments;
+ make use ofg_assert_cmpstr();
+ useerror_abortinstead of alocal_errforqemu_opts_absorb_qdict();
+ asserts on QemuOptsList (empty and list name);
+ addedtest_qemu_opt_unset();
+ asserts on qemu_opt_*_set() return;
+ addedtest_qemu_opts_reset();
+ addedtest_qemu_opts_set();
---
It's okay to have a duplicate one; but the main point is that the v2 changelog is useful to reviewers but not to the git log; and anything after the --- marker gets omitted by 'git am' when a maintainer accepts your patch into their pull request.
Quoted 18 lines
tests/Makefile | 3 + tests/test-qemu-opts.c | 455 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 458 insertions(+) create mode 100644 tests/test-qemu-opts.ctests/test-qemu-opts.c new file +13
-0+static void test_qemu_find_opts (void ) +{ +QemuOptsList *list; + +register_opts (); + +/* we have an "opts_list_01" option, should return it */ + list =qemu_find_opts ("opts_list_01" ); +g_assert (list !=NULL ); + g_assert_cmpstr(list->name, ==, "opts_list_01"); +} + +static void test_qemu_opts_create (void )
tests/test-qemu-opts.c line 108
Quoted 10 lines
tests/test-qemu-opts.c new file +10
-0+{ +QemuOptsList *list; +QemuOpts *opts; + +register_opts (); + + list =qemu_find_opts ("opts_list_01" ); +g_assert (list !=NULL ); +g_assert (QTAILQ_EMPTY (&list->head)); + g_assert_cmpstr(list->name, ==, "opts_list_01");
This test starts as a duplicate of test_qemu_find_opts; I guess that's okay (having both tests means a bit more insight into what broke if one fails but the other passes).
tests/test-qemu-opts.c line 336
Quoted 8 lines
tests/test-qemu-opts.c new file +8
-0+ +static void test_qemu_opt_unset (void ) +{ +QemuOpts *opts; +const char *value; +int ret; + +/* dinamically initialized (parsed) opts */
s/dinamically/dynamically/
That's trivially fixable, so feel free to add:
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Hi Eric,
Quoted 24 lines · Eric Blake
Quoted 7 lines · Leandro Dorileo
Cover basic aspects and API usage for QemuOpt. The current implementation covers the API's planned to be changed by Chunyan Liu in his QEMUOptionParameter replacement/cleanup job.
Other APIs should be covered in future improvements.
Signed-off-by Leandro Dorileo <[email protected]>Right here is where you should stick a --- marker.
Quoted 12 lines
Changes:
v2:
+ fixed comments;
+ make use ofg_assert_cmpstr();
+ useerror_abortinstead of alocal_errforqemu_opts_absorb_qdict();
+ asserts on QemuOptsList (empty and list name);
+ addedtest_qemu_opt_unset();
+ asserts on qemu_opt_*_set() return;
+ addedtest_qemu_opts_reset();
+ addedtest_qemu_opts_set();
---
Quoted 4 lines
It's okay to have a duplicate one; but the main point is that the v2 changelog is useful to reviewers but not to the git log; and anything after the --- marker gets omitted by 'git am' when a maintainer accepts your patch into their pull request.
I would say that I even know about the --- marker, but have misplaced it... :(
Quoted 45 lines
Quoted 19 lines
tests/Makefile | 3 + tests/test-qemu-opts.c | 455 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 458 insertions(+) create mode 100644 tests/test-qemu-opts.ctests/test-qemu-opts.c new file +13
-0+static void test_qemu_find_opts (void ) +{ +QemuOptsList *list; + +register_opts (); + +/* we have an "opts_list_01" option, should return it */ + list =qemu_find_opts ("opts_list_01" ); +g_assert (list !=NULL ); + g_assert_cmpstr(list->name, ==, "opts_list_01"); +} + +static void test_qemu_opts_create (void )tests/test-qemu-opts.c line 108
Quoted 10 lines
tests/test-qemu-opts.c new file +10
-0+{ +QemuOptsList *list; +QemuOpts *opts; + +register_opts (); + + list =qemu_find_opts ("opts_list_01" ); +g_assert (list !=NULL ); +g_assert (QTAILQ_EMPTY (&list->head)); + g_assert_cmpstr(list->name, ==, "opts_list_01");This test starts as a duplicate of
test_qemu_find_opts; I guess that's okay (having both tests means a bit more insight into what broke if one fails but the other passes).tests/test-qemu-opts.c line 336
Quoted 8 lines
tests/test-qemu-opts.c new file +8
-0+ +static void test_qemu_opt_unset (void ) +{ +QemuOpts *opts; +const char *value; +int ret; + +/* dinamically initialized (parsed) opts */ s/dinamically/dynamically/
Quoted 1 line
That's trivially fixable, so feel free to add:
Ok...
Quoted 2 lines
Reviewed-by Eric Blake <[email protected]>
Thanks for reviewing...
Signature · 1 line
Leandro Dorileo
Quoted 27 lines · Leandro Dorileo
Hi Eric,
Quoted 24 lines · Eric Blake
Quoted 7 lines · Leandro Dorileo
Cover basic aspects and API usage for QemuOpt. The current implementation covers the API's planned to be changed by Chunyan Liu in his QEMUOptionParameter replacement/cleanup job.
Other APIs should be covered in future improvements.
Signed-off-by Leandro Dorileo <[email protected]>Right here is where you should stick a --- marker.
Quoted 12 lines
Changes:
v2:
+ fixed comments;
+ make use ofg_assert_cmpstr();
+ useerror_abortinstead of alocal_errforqemu_opts_absorb_qdict();
+ asserts on QemuOptsList (empty and list name);
+ addedtest_qemu_opt_unset();
+ asserts on qemu_opt_*_set() return;
+ addedtest_qemu_opts_reset();
+ addedtest_qemu_opts_set();
---
Quoted 6 lines
Quoted 4 lines
It's okay to have a duplicate one; but the main point is that the v2 changelog is useful to reviewers but not to the git log; and anything after the --- marker gets omitted by 'git am' when a maintainer accepts your patch into their pull request.
I would say that I even know about the --- marker, but have misplaced it... :(
Off-topic: I suggest to include a reference to git-notes(1) in our patch submission guidelines.
- git-notes(1) lets you manage such v(n)->v(n+1) changelogs inside git,
- the notes are pushable,
- they are carried across rebases,
- they are *not* part of the commit messages (consequently, they are not part of the commit hashes either),
- they are (can be) correctly displayed by git-log, git-show, gitk, and git-format-patch (notably, in the last case, under the --- separator)
When you start using git-notes, you don't understand how you could exist without it.
Git-notes(1) takes some minimal configuration before use; the web offers easily searchable, good advice.
Thanks,
Laszlo
Hi Laszlo,
Quoted 45 lines · Laszlo Ersek
Quoted 27 lines · Leandro Dorileo
Hi Eric,
Quoted 24 lines · Eric Blake
Quoted 7 lines · Leandro Dorileo
Cover basic aspects and API usage for QemuOpt. The current implementation covers the API's planned to be changed by Chunyan Liu in his QEMUOptionParameter replacement/cleanup job.
Other APIs should be covered in future improvements.
Signed-off-by Leandro Dorileo <[email protected]>Right here is where you should stick a --- marker.
Quoted 12 lines
Changes:
v2:
+ fixed comments;
+ make use ofg_assert_cmpstr();
+ useerror_abortinstead of alocal_errforqemu_opts_absorb_qdict();
+ asserts on QemuOptsList (empty and list name);
+ addedtest_qemu_opt_unset();
+ asserts on qemu_opt_*_set() return;
+ addedtest_qemu_opts_reset();
+ addedtest_qemu_opts_set();
---Quoted 6 lines
Quoted 4 lines
It's okay to have a duplicate one; but the main point is that the v2 changelog is useful to reviewers but not to the git log; and anything after the --- marker gets omitted by 'git am' when a maintainer accepts your patch into their pull request.
I would say that I even know about the --- marker, but have misplaced it... :(
Off-topic: I suggest to include a reference to git-notes(1) in our patch submission guidelines.
- git-notes(1) lets you manage such v(n)->v(n+1) changelogs inside git,
- the notes are pushable,
- they are carried across rebases,
- they are *not* part of the commit messages (consequently, they are not part of the commit hashes either),
- they are (can be) correctly displayed by git-log, git-show, gitk, and git-format-patch (notably, in the last case, under the --- separator)
Quoted 2 lines
When you start using git-notes, you don't understand how you could exist without it.
Definitely, I wasn't aware of git-notes. Thanks...
Quoted 6 lines
Git-notes(1) takes some minimal configuration before use; the web offers easily searchable, good advice.
Thanks,
Laszlo
Signature · 1 line
Leandro Dorileo