On 1/16/20 4:40 PM, Stefan Reiter wrote: > Requires a mock CPU-model config, which is given as a raw string to also > test parsing capabilities. Also tests defaulting behaviour. > > Signed-off-by: Stefan Reiter <s.rei...@proxmox.com> > --- > test/cfg2cmd/custom-cpu-model-defaults.conf | 8 ++++++ > .../custom-cpu-model-defaults.conf.cmd | 24 +++++++++++++++++ > test/cfg2cmd/custom-cpu-model.conf | 8 ++++++ > test/cfg2cmd/custom-cpu-model.conf.cmd | 27 +++++++++++++++++++ > test/run_config2command_tests.pl | 23 ++++++++++++++++ > 5 files changed, 90 insertions(+) > create mode 100644 test/cfg2cmd/custom-cpu-model-defaults.conf > create mode 100644 test/cfg2cmd/custom-cpu-model-defaults.conf.cmd > create mode 100644 test/cfg2cmd/custom-cpu-model.conf > create mode 100644 test/cfg2cmd/custom-cpu-model.conf.cmd >
> index bad6501..fb77279 100755 > --- a/test/run_config2command_tests.pl > +++ b/test/run_config2command_tests.pl > @@ -17,6 +17,7 @@ use PVE::QemuConfig; > use PVE::QemuServer; > use PVE::QemuServer::Monitor; > use PVE::QemuServer::Machine; > +use PVE::QemuServer::CPUConfig; > > my $base_env = { > storage_config => { > @@ -170,6 +171,28 @@ $pve_common_tools->mock( > > return '61000'; > }, > +); just for the record, as we talked already off-list: This is wrong, it moves the mocking of "getaddrinfo_all" to another module mock definition, and thus makes that useless. I then get test failure becuase the realworld method is then called again and "localhost" resolves to "::1" here, while the test have it at "127.0.0.1".. I almost rewrote that mock before detecting that it just got moved :D > + > +my $pve_cpuconfig; > +$pve_cpuconfig = Test::MockModule->new('PVE::QemuServer::CPUConfig'); > +$pve_cpuconfig->mock( > + load_custom_model_conf => sub { > + # mock custom CPU model config > + return PVE::QemuServer::CPUConfig->parse_config("cpu-models.conf", > +<<EOF > + > +# "qemu64" is also a default CPU, used here to test that this doesn't matter > +cpu-model: qemu64 > + reported-model athlon > + flags +aes;+avx;-kvm_pv_unhalt > + hv-vendor-id testvend > + phys-bits 40 > + > +cpu-model: alldefault > + > +EOF > + ) > + }, > getaddrinfo_all => sub { ^^^^^^^^^^ > my ($hostname, @opts) = @_; > die "need stable hostname" if $hostname ne 'localhost'; > _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel