hw/core/machine: Add an unit test for smp_parse
v3 cover hw/core/machine: Add an unit test for smp_parse
Hi,
This is v3 which introduces an unit test for generic smp_parse.
We have had enough discussions about what kind of SMP configurations by the user should be considered valid and what should be invalid. Since we have finished optimizing the SMP parsing code, then this test normatively listed all the possible valid/invalid configurations that the user can provide. This can be a testing tool when we introduce new topology members and need to touch the parsing code.
For your reference, some related discussion is here:
https://lore.kernel.org/qemu-devel/[email protected]/
Changelog:v2->v3:
- add Andrew's R-b for PATCH #1
- drop an unused macro definition in PATCH #2
- v2: https://lore.kernel.org/qemu-devel/[email protected]/
v1->v2:
- split smp_parse out into a separate .c file instead of a header (patch #1)
- dropped an unnecessary function and add Andrew's R-b (patch #2)
- v1: https://lore.kernel.org/qemu-devel/[email protected]/
Yanan Wang (2):
hw/core/machine: Split out the smp parsing code
tests/unit: Add an unit test for smp parsing
MAINTAINERS | 2 + hw/core/machine-smp.c | 181 +++++++++++ hw/core/machine.c | 159 ---------- hw/core/meson.build | 2 + include/hw/boards.h | 1 + tests/unit/meson.build | 1 + tests/unit/test-smp-parse.c | 594 ++++++++++++++++++++++++++++++++++++ 7 files changed, 781 insertions(+), 159 deletions(-) create mode 100644 hw/core/machine-smp.c create mode 100644 tests/unit/test-smp-parse.c
--
2.19.1
PATCH v3 1/2 hw/core/machine: Split out the smp parsing code
We are going to introduce an unit test for the parser smp_parse() in hw/core/machine.c, but now machine.c is only built in softmmu.
In order to solve the build dependency on the smp parsing code and avoid building unrelated stuff for the unit tests, move the tested code from machine.c into a separate file, i.e., machine-smp.c and build it in common field.
--- MAINTAINERS | 1 + hw/core/machine-smp.c | 181 ++++++++++++++++++++++++++++++++++++++++++ hw/core/machine.c | 159 ------------------------------------- hw/core/meson.build | 2 + include/hw/boards.h | 1 + 5 files changed, 185 insertions(+), 159 deletions(-) create mode 100644 hw/core/machine-smp.c
MAINTAINERS +1 -0
@@ -1623,6 +1623,7 @@ F: cpu.c F: hw/core/cpu.c F: hw/core/machine-qmp-cmds.c F: hw/core/machine.c +F: hw/core/machine-smp.c F: hw/core/null-machine.c F: hw/core/numa.c F: hw/cpu/cluster.c
hw/core/machine-smp.c new file +181 -0
181 lines not on this page · raw message
hw/core/machine.c +0 -159
165 lines not on this page · raw message
hw/core/meson.build +2 -0
@@ -14,6 +14,8 @@ hwcore_files = files( ) common_ss.add(files('cpu-common.c')) +# machine-smp.c needed for -smp parsing, used by softmmu and unit tests +common_ss.add(files('machine-smp.c')) common_ss.add(when: 'CONFIG_FITLOADER', if_true: files('loader-fit.c')) common_ss.add(when: 'CONFIG_GENERIC_LOADER', if_true: files('generic-loader.c')) common_ss.add(when: ['CONFIG_GUEST_LOADER', fdt], if_true: files('guest-loader.c'))
include/hw/boards.h +1 -0
@@ -34,6 +34,7 @@ HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine);void machine_set_cpu_numa_node (MachineState *machine,const CpuInstanceProperties *props,Error **errp); +void smp_parse (MachineState *ms,SMPConfiguration *config,Error **errp);/** * machine_class_allow_dynamic_sysbus_dev: Add type to list of valid devices
Signature · 1 line
2.19.1
PATCH v3 2/2 tests/unit: Add an unit test for smp parsing
In reply to Yanan WangNow that we have a generic parser smp_parse(), let's add an unit test for the code. All possible valid/invalid SMP configurations that the user can specify are covered.
--- MAINTAINERS | 1 + tests/unit/meson.build | 1 + tests/unit/test-smp-parse.c | 594 ++++++++++++++++++++++++++++++++++++ 3 files changed, 596 insertions(+) create mode 100644 tests/unit/test-smp-parse.c
MAINTAINERS +1 -0
@@ -1633,6 +1633,7 @@ F: include/hw/boards.h F: include/hw/core/cpu.h F: include/hw/cpu/cluster.h F: include/sysemu/numa.h +F: tests/unit/test-smp-parse.c T: git https://gitlab.com/ehabkost/qemu.git machine-next Xtensa Machines
tests/unit/meson.build +1 -0
@@ -45,6 +45,7 @@ tests = { 'test-uuid': [], 'ptimer-test': ['ptimer-test-stubs.c', meson.project_source_root() / 'hw/core/ptimer.c'], 'test-qapi-util': [], + 'test-smp-parse': [qom, meson.project_source_root() / 'hw/core/machine-smp.c'], } if have_system or have_tools
tests/unit/test-smp-parse.c new file +594 -0
594 lines not on this page · raw message
Signature · 1 line
2.19.1
Hi,
Does this short series have a chance to get on the train for 6.2 before the closely coming soft-feature freeze? It would be very nice to have a test finally, since all the previous work on -smp code has been completed and merged, IMO. 😉
Regards,
Yanan
Quoted 44 lines · Yanan Wang
Hi,
This is v3 which introduces an unit test for generic
smp_parse.We have had enough discussions about what kind of SMP configurations by the user should be considered valid and what should be invalid. Since we have finished optimizing the SMP parsing code, then this test normatively listed all the possible valid/invalid configurations that the user can provide. This can be a testing tool when we introduce new topology members and need to touch the parsing code.
For your reference, some related discussion is here:
https://lore.kernel.org/qemu-devel/[email protected]/Changelog:
v2->v3:
- add Andrew's R-b for PATCH #1
- drop an unused macro definition in PATCH #2
- v2: https://lore.kernel.org/qemu-devel/[email protected]/
v1->v2:
- splitsmp_parseout into a separate .c file instead of a header (patch #1)
- dropped an unnecessary function and add Andrew's R-b (patch #2)
- v1: https://lore.kernel.org/qemu-devel/[email protected]/Yanan Wang (2):
hw/core/machine: Split out the smp parsing code tests/unit: Add an unit test for smp parsingMAINTAINERS | 2 + hw/core/machine-smp.c | 181 +++++++++++ hw/core/machine.c | 159 ---------- hw/core/meson.build | 2 + include/hw/boards.h | 1 + tests/unit/meson.build | 1 + tests/unit/test-smp-parse.c | 594 ++++++++++++++++++++++++++++++++++++ 7 files changed, 781 insertions(+), 159 deletions(-)create mode 100644
hw/core/machine-smp.c
create mode 100644tests/unit/test-smp-parse.c--
2.19.1.
Quoted 20 lines · Yanan Wang
Hi,
This is v3 which introduces an unit test for generic
smp_parse.We have had enough discussions about what kind of SMP configurations by the user should be considered valid and what should be invalid. Since we have finished optimizing the SMP parsing code, then this test normatively listed all the possible valid/invalid configurations that the user can provide. This can be a testing tool when we introduce new topology members and need to touch the parsing code.
For your reference, some related discussion is here:
https://lore.kernel.org/qemu-devel/[email protected]/Changelog:
v2->v3:
- add Andrew's R-b for PATCH #1
- drop an unused macro definition in PATCH #2
- v2: https://lore.kernel.org/qemu-devel/[email protected]/
Quoted 8 lines
v1->v2:
- splitsmp_parseout into a separate .c file instead of a header (patch #1)
- dropped an unnecessary function and add Andrew's R-b (patch #2)
- v1: https://lore.kernel.org/qemu-devel/[email protected]/Yanan Wang (2):
hw/core/machine: Split out the smp parsing code
tests/unit: Add an unit test for smp parsing
Quoted 26 lines · Philippe Mathieu-Daudé
Quoted 25 lines · Yanan Wang
Hi,
This is v3 which introduces an unit test for generic
smp_parse.We have had enough discussions about what kind of SMP configurations by the user should be considered valid and what should be invalid. Since we have finished optimizing the SMP parsing code, then this test normatively listed all the possible valid/invalid configurations that the user can provide. This can be a testing tool when we introduce new topology members and need to touch the parsing code.
For your reference, some related discussion is here:
https://lore.kernel.org/qemu-devel/[email protected]/Changelog:
v2->v3:
- add Andrew's R-b for PATCH #1
- drop an unused macro definition in PATCH #2
- v2: https://lore.kernel.org/qemu-devel/[email protected]/
v1->v2:
- splitsmp_parseout into a separate .c file instead of a header (patch #1)
- dropped an unnecessary function and add Andrew's R-b (patch #2)
- v1: https://lore.kernel.org/qemu-devel/[email protected]/
Quoted 5 lines
Quoted 3 lines
Yanan Wang (2):
hw/core/machine: Split out the smp parsing code tests/unit: Add an unit test for smp parsing
Thank you for the testing/review and the help of v4 respin.
Thanks,
Yanan
.