QemuOpt: add unit tests
PATCH 1/1 QemuOpt: add unit tests
Cover basic aspects and API usage for QemuOpt. The current implementation covers the API's planed to be changed by Chunyan Liu in his QEMUOptionParameter replacement/cleanup job.
Other APIs should be covered in future improvements.
--- tests/Makefile | 3 + tests/test-qemu-opts.c | 309 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 312 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 +309 -0
309 lines not on this page · raw message
Signature · 1 line
1.9.0
Quoted 2 lines · Leandro Dorileo
Cover basic aspects and API usage for QemuOpt. The current implementation covers the API's planed to be changed by Chunyan Liu in his QEMUOptionParameter
s/planed/planned/
Quoted 12 lines
replacement/cleanup job.
Other APIs should be covered in future improvements.
Signed-off-by Leandro Dorileo <[email protected]>--- tests/Makefile | 3 + tests/test-qemu-opts.c | 309 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 312 insertions(+) create mode 100644 tests/test-qemu-opts.c
tests/test-qemu-opts.c line 71
Quoted 8 lines
tests/test-qemu-opts.c new file +8
-0+ +static void test_find_unknown_opts (void ) +{ +QemuOptsList *list; + +register_opts (); + +/** should not return anything, we don't known "unknown" option */
s/known/have an/
Here, and throughout the file: /** */ comments are special to doc markup, and should only be needed prior to declaring a function. Within a function body, use the simpler /* */ comment.
tests/test-qemu-opts.c line 84
Quoted 9 lines
tests/test-qemu-opts.c new file +9
-0+static void test_qemu_find_opts (void ) +{ +QemuOptsList *list; + +register_opts (); + +/** we have an rtc option, should return it */ + list =qemu_find_opts ("opts_list_01" ); +g_assert (list !=NULL );
Should you do any further testing on the contents of the returned list?
tests/test-qemu-opts.c line 143
Quoted 6 lines
tests/test-qemu-opts.c new file +5
-0+static void test_qemu_opt_get (void ) +{ +/** now we have set str2, should know about it */ + opt =qemu_opt_get (opts,"str2" ); +g_assert (opt !=NULL && !strcmp (opt,"value" ));
Isn't g_assert_cmpstr nicer for this, as in:
g_assert_cmpstr(opt, ==, "value");
tests/test-qemu-opts.c line 271
Quoted 7 lines
tests/test-qemu-opts.c new file +6
-0+static void test_qemu_opt_get_size (void ) +{ +QemuOptsList *list; + +qemu_opts_absorb_qdict (opts, dict, &local_err); +g_assert (local_err ==NULL );
shorter as:
qemu_opts_absorb_qdict(opts, dict, &error_abort);
Overall, I like where this is headed; looking forward to v2.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 18 lines · Eric Blake
Quoted 2 lines · Leandro Dorileo
Cover basic aspects and API usage for QemuOpt. The current implementation covers the API's planed to be changed by Chunyan Liu in his QEMUOptionParameter
s/planed/planned/
Quoted 11 lines
replacement/cleanup job.
Other APIs should be covered in future improvements.
Signed-off-by Leandro Dorileo <[email protected]>--- tests/Makefile | 3 + tests/test-qemu-opts.c | 309 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 312 insertions(+) create mode 100644 tests/test-qemu-opts.c
Quoted 10 lines
tests/test-qemu-opts.c line 71
Quoted 8 lines
tests/test-qemu-opts.c new file +8
-0+ +static void test_find_unknown_opts (void ) +{ +QemuOptsList *list; + +register_opts (); + +/** should not return anything, we don't known "unknown" option */ s/known/have an/
ok.
Quoted 5 lines
Here, and throughout the file: /** */ comments are special to doc markup, and should only be needed prior to declaring a function. Within a function body, use the simpler /* */ comment.
Quoted 11 lines
tests/test-qemu-opts.c line 84
Quoted 9 lines
tests/test-qemu-opts.c new file +9
-0+static void test_qemu_find_opts (void ) +{ +QemuOptsList *list; + +register_opts (); + +/** we have an rtc option, should return it */ + list =qemu_find_opts ("opts_list_01" ); +g_assert (list !=NULL );Should you do any further testing on the contents of the returned list?
ok. I'll see the API.
Quoted 11 lines
tests/test-qemu-opts.c line 143
Quoted 7 lines
tests/test-qemu-opts.c new file +5
-0+static void test_qemu_opt_get (void ) +{ +/** now we have set str2, should know about it */ + opt =qemu_opt_get (opts,"str2" ); +g_assert (opt !=NULL && !strcmp (opt,"value" ));Isn't
g_assert_cmpstrnicer for this, as in:
g_assert_cmpstr(opt, ==, "value");
Yep, sure, I wasn't awere of g_assert_cmpstr, thanks.
Quoted 5 lines
Quoted 4 lines
tests/test-qemu-opts.c new file +3
-0+static void test_qemu_opt_get_size (void ) +{ +QemuOptsList *list;
Quoted 7 lines
tests/test-qemu-opts.c line 271
Quoted 3 lines
tests/test-qemu-opts.c new file +3
-0+ +qemu_opts_absorb_qdict (opts, dict, &local_err); +g_assert (local_err ==NULL );shorter as:
qemu_opts_absorb_qdict(opts, dict, &error_abort);
I see.
Quoted 3 lines
Overall, I like where this is headed; looking forward to v2.
Thanks for reviewing...
Signature · 1 line
Leandro Dorileo