[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/2] tests: Add tests for query-netdevs command
From: |
Thomas Huth |
Subject: |
Re: [PATCH 2/2] tests: Add tests for query-netdevs command |
Date: |
Thu, 14 Nov 2019 12:28:31 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 |
On 13/11/2019 22.25, Alexey Kirillov wrote:
> Signed-off-by: Alexey Kirillov <address@hidden>
> ---
> tests/Makefile.include | 2 +
> tests/test-query-netdevs.c | 114 +++++++++++++++++++++++++++++++++++++
> 2 files changed, 116 insertions(+)
> create mode 100644 tests/test-query-netdevs.c
>
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index 534ee48743..4d199e463b 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -297,6 +297,7 @@ check-qtest-s390x-y += tests/migration-test$(EXESUF)
> check-qtest-generic-y += tests/machine-none-test$(EXESUF)
> check-qtest-generic-y += tests/qom-test$(EXESUF)
> check-qtest-generic-y += tests/test-hmp$(EXESUF)
> +check-qtest-generic-y += tests/test-query-netdevs$(EXESUF)
Please use -$(CONFIG_SLIRP) instead of "-y" here.
> qapi-schema += alternate-any.json
> qapi-schema += alternate-array.json
> @@ -844,6 +845,7 @@ tests/numa-test$(EXESUF): tests/numa-test.o
> tests/vmgenid-test$(EXESUF): tests/vmgenid-test.o tests/boot-sector.o
> tests/acpi-utils.o
> tests/cdrom-test$(EXESUF): tests/cdrom-test.o tests/boot-sector.o
> $(libqos-obj-y)
> tests/arm-cpu-features$(EXESUF): tests/arm-cpu-features.o
> +tests/test-query-netdevs$(EXESUF): tests/test-query-netdevs.o
>
> tests/migration/stress$(EXESUF): tests/migration/stress.o
> $(call quiet-command, $(LINKPROG) -static -O3 $(PTHREAD_LIB) -o $@ $<
> ,"LINK","$(TARGET_DIR)$@")
> diff --git a/tests/test-query-netdevs.c b/tests/test-query-netdevs.c
> new file mode 100644
> index 0000000000..2afde36114
> --- /dev/null
> +++ b/tests/test-query-netdevs.c
> @@ -0,0 +1,114 @@
> +/*
> + * QTest testcase for the query-netdevs
> + *
> + * Copyright Yandex N.V., 2019
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2. See
Please use "GNU GPL, version 2 or later" for new code (as described in
the bottom part of the LICENSE file in the top directory).
> + * the COPYING file in the top-level directory.
> + *
> + */
[...]
> +static void test_query_netdevs(void)
> +{
> + const char *arch = qtest_get_arch();
> + size_t correction = 0;
> + QObject *resp;
> + QTestState *state;
> +
> + if (strcmp(arch, "arm") == 0 ||
> + strcmp(arch, "aarch64") == 0 ||
> + strcmp(arch, "tricore") == 0) {
> + g_test_skip("Not supported without machine type");
Since you're doing the check for the target architecture anyway, you
could also use "-M virt" for arm/aarch64 and "-M tricore_testboard" for
tricore, I think.
> + return;
> + }
> +
> + /* Archs with default not unpluggable netdev */
maybe better: "Archs which still have a netdev despite of -nodefaults" ?
> + if (strcmp(arch, "cris") == 0 ||
> + strcmp(arch, "microblaze") == 0 ||
> + strcmp(arch, "microblazeel") == 0 ||
> + strcmp(arch, "sparc") == 0) {
> + correction = 1;
> + }
Just a matter of taste, but I like "g_str_equal()" more than the
old-fashioned "strcmp() == 0".
Thomas