From: Igor Mammedov <imammedo@redhat.com>
To: Julia Suvorova <jusual@redhat.com>
Cc: qemu-devel@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
Ani Sinha <ani@anisinha.ca>
Subject: Re: [PATCH v2 4/5] bios-tables-test: add test for number of cores > 255
Date: Thu, 25 Aug 2022 09:57:09 +0200 [thread overview]
Message-ID: <20220825095709.4a949ea7@redhat.com> (raw)
In-Reply-To: <20220731162141.178443-5-jusual@redhat.com>
On Sun, 31 Jul 2022 18:21:40 +0200
Julia Suvorova <jusual@redhat.com> wrote:
> The new test is run with a large number of cpus and checks if the
> core_count field in smbios_cpu_test (structure type 4) is correct.
>
> Choose q35 as it allows to run with -smp > 255.
>
> Signed-off-by: Julia Suvorova <jusual@redhat.com>
pls, run checkpatch on patches and fix up whatever it complains about
before posting
> ---
> tests/qtest/bios-tables-test.c | 53 +++++++++++++++++++++++++---------
> 1 file changed, 40 insertions(+), 13 deletions(-)
>
> diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c
> index e352d5249f..cebfa430ac 100644
> --- a/tests/qtest/bios-tables-test.c
> +++ b/tests/qtest/bios-tables-test.c
> @@ -92,6 +92,8 @@ typedef struct {
> SmbiosEntryPoint smbios_ep_table;
> uint16_t smbios_cpu_max_speed;
> uint16_t smbios_cpu_curr_speed;
> + uint8_t smbios_core_count;
> + uint16_t smbios_core_count2;
> uint8_t *required_struct_types;
> int required_struct_types_len;
> QTestState *qts;
> @@ -631,29 +633,38 @@ static inline bool smbios_single_instance(uint8_t type)
> }
> }
>
> -static bool smbios_cpu_test(test_data *data, uint32_t addr)
> +static void smbios_cpu_test(test_data *data, uint32_t addr)
> {
> - uint16_t expect_speed[2];
> - uint16_t real;
> + uint8_t core_count, expected_core_count = data->smbios_core_count;
> + uint16_t speed, core_count2, expected_core_count2 = data->smbios_core_count2;
> + uint16_t expected_speed[2];
> int offset[2];
> int i;
>
> /* Check CPU speed for backward compatibility */
> offset[0] = offsetof(struct smbios_type_4, max_speed);
> offset[1] = offsetof(struct smbios_type_4, current_speed);
> - expect_speed[0] = data->smbios_cpu_max_speed ? : 2000;
> - expect_speed[1] = data->smbios_cpu_curr_speed ? : 2000;
> + expected_speed[0] = data->smbios_cpu_max_speed ? : 2000;
> + expected_speed[1] = data->smbios_cpu_curr_speed ? : 2000;
>
> for (i = 0; i < 2; i++) {
> - real = qtest_readw(data->qts, addr + offset[i]);
> - if (real != expect_speed[i]) {
> - fprintf(stderr, "Unexpected SMBIOS CPU speed: real %u expect %u\n",
> - real, expect_speed[i]);
> - return false;
> - }
> + speed = qtest_readw(data->qts, addr + offset[i]);
> + g_assert_cmpuint(speed, ==, expected_speed[i]);
> }
>
> - return true;
> + core_count = qtest_readb(data->qts,
> + addr + offsetof(struct smbios_type_4, core_count));
> + core_count2 = qtest_readw(data->qts,
> + addr + offsetof(struct smbios_type_4, core_count2));
it doesn't really matter here, that we read bogus core_count2 in case of v2 tables,
but to be cleaner I'd move reads above below respective 'if's
> + if (expected_core_count) {
> + g_assert_cmpuint(core_count, ==, expected_core_count);
> + }
> +
> + /* Core Count has reached its limit, checking Core Count 2 */
> + if (expected_core_count == 0xFF && expected_core_count2) {
> + g_assert_cmpuint(core_count2, ==, expected_core_count2);
> + }
> }
>
> static void test_smbios_structs(test_data *data, SmbiosEntryPointType ep_type)
> @@ -686,7 +697,7 @@ static void test_smbios_structs(test_data *data, SmbiosEntryPointType ep_type)
> set_bit(type, struct_bitmap);
>
> if (type == 4) {
> - g_assert(smbios_cpu_test(data, addr));
> + smbios_cpu_test(data, addr);
> }
>
> /* seek to end of unformatted string area of this struct ("\0\0") */
> @@ -903,6 +914,21 @@ static void test_acpi_q35_tcg(void)
> free_test_data(&data);
> }
>
> +static void test_acpi_q35_tcg_core_count2(void)
> +{
> + test_data data = {
> + .machine = MACHINE_Q35,
> + .variant = ".core-count2",
> + .required_struct_types = base_required_struct_types,
> + .required_struct_types_len = ARRAY_SIZE(base_required_struct_types),
> + .smbios_core_count = 0xFF,
> + .smbios_core_count2 = 275,
> + };
> +
> + test_acpi_one("-machine smbios-entry-point-type=64 -smp 275", &data);
> + free_test_data(&data);
> +}
> +
> static void test_acpi_q35_tcg_bridge(void)
> {
> test_data data;
> @@ -1822,6 +1848,7 @@ int main(int argc, char *argv[])
> qtest_add_func("acpi/piix4/pci-hotplug/off",
> test_acpi_piix4_no_acpi_pci_hotplug);
> qtest_add_func("acpi/q35", test_acpi_q35_tcg);
> + qtest_add_func("acpi/q35/core-count2", test_acpi_q35_tcg_core_count2);
shouldn't we have a test for #cpus < 256 as well?
> qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge);
> qtest_add_func("acpi/q35/multif-bridge", test_acpi_q35_multif_bridge);
> qtest_add_func("acpi/q35/mmio64", test_acpi_q35_tcg_mmio64);
next prev parent reply other threads:[~2022-08-25 8:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-31 16:21 [PATCH v2 0/5] hw/smbios: add core_count2 to smbios table type 4 Julia Suvorova
2022-07-31 16:21 ` [PATCH v2 1/5] " Julia Suvorova
2022-08-24 16:00 ` Igor Mammedov
2022-07-31 16:21 ` [PATCH v2 2/5] bios-tables-test: teach test to use smbios 3.0 tables Julia Suvorova
2022-08-25 7:37 ` Igor Mammedov
2022-07-31 16:21 ` [PATCH v2 3/5] tests/acpi: allow changes for core_count2 test Julia Suvorova
2022-07-31 16:21 ` [PATCH v2 4/5] bios-tables-test: add test for number of cores > 255 Julia Suvorova
2022-08-25 7:57 ` Igor Mammedov [this message]
2022-07-31 16:21 ` [PATCH v2 5/5] tests/acpi: update tables for new core count test Julia Suvorova
2022-08-12 9:46 ` [PATCH v2 0/5] hw/smbios: add core_count2 to smbios table type 4 Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220825095709.4a949ea7@redhat.com \
--to=imammedo@redhat.com \
--cc=ani@anisinha.ca \
--cc=jusual@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.