[PATCH 19/22] tests/qtest/migration: Add migration-test-smoke

Fabiano Rosas posted 22 patches 2 weeks, 4 days ago
There is a newer version of this series
[PATCH 19/22] tests/qtest/migration: Add migration-test-smoke
Posted by Fabiano Rosas 2 weeks, 4 days ago
Add a new migration test to be ran as smoke test for each QEMU
target. This test will run only when the QEMU binary being used has no
KVM support, i.e. smoke tests run only on TCG.

Also modify the existing migration-test to run only when KVM is
present, i.e. the full set of tests will only run on a KVM host. To
still enable the full set to be ran anywhere for debug, ignore the
accel restriction when -m thorough is used.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
 tests/qtest/meson.build                   |  7 +++-
 tests/qtest/migration-test-smoke.c        | 40 +++++++++++++++++++++++
 tests/qtest/migration-test.c              | 12 +++++++
 tests/qtest/migration/compression-tests.c |  8 ++++-
 tests/qtest/migration/cpr-tests.c         |  8 ++++-
 tests/qtest/migration/file-tests.c        |  8 ++++-
 tests/qtest/migration/migration-common.h  |  8 +++++
 tests/qtest/migration/misc-tests.c        |  8 ++++-
 tests/qtest/migration/postcopy-tests.c    |  7 ++++
 tests/qtest/migration/precopy-tests.c     |  8 ++++-
 tests/qtest/migration/tls-tests.c         |  7 +++-
 11 files changed, 114 insertions(+), 7 deletions(-)
 create mode 100644 tests/qtest/migration-test-smoke.c

diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 6bfed0553d..806af512d0 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -5,6 +5,7 @@ slow_qtests = {
   'cdrom-test' : 610,
   'device-introspect-test' : 720,
   'ide-test' : 120,
+  'migration-test-smoke' : 480,
   'migration-test' : 480,
   'npcm7xx_pwm-test': 300,
   'npcm7xx_watchdog_timer-test': 120,
@@ -110,6 +111,7 @@ qtests_i386 = \
    'device-plug-test',
    'drive_del-test',
    'cpu-plug-test',
+   'migration-test-smoke',
    'migration-test',
   ]
 
@@ -183,7 +185,7 @@ qtests_ppc64 = \
   (slirp.found() ? ['pxe-test'] : []) +              \
   (config_all_devices.has_key('CONFIG_USB_UHCI') ? ['usb-hcd-uhci-test'] : []) +             \
   (config_all_devices.has_key('CONFIG_USB_XHCI_NEC') ? ['usb-hcd-xhci-test'] : []) +         \
-  qtests_pci + ['migration-test', 'cpu-plug-test', 'drive_del-test']
+  qtests_pci + ['migration-test-smoke', 'migration-test', 'cpu-plug-test', 'drive_del-test']
 
 qtests_sh4 = (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : [])
 qtests_sh4eb = (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : [])
@@ -255,6 +257,7 @@ qtests_aarch64 = \
   ['arm-cpu-features',
    'numa-test',
    'boot-serial-test',
+   'migration-test-smoke',
    'migration-test']
 
 qtests_s390x = \
@@ -264,6 +267,7 @@ qtests_s390x = \
    'device-plug-test',
    'virtio-ccw-test',
    'cpu-plug-test',
+   'migration-test-smoke',
    'migration-test']
 
 qtests_riscv32 = \
@@ -357,6 +361,7 @@ qtests = {
   'dbus-vmstate-test': files('migration/migration-qmp.c', 'migration/migration-util.c') + dbus_vmstate1,
   'erst-test': files('erst-test.c'),
   'ivshmem-test': [rt, '../../contrib/ivshmem-server/ivshmem-server.c'],
+  'migration-test-smoke': migration_files + migration_tls_files,
   'migration-test': migration_files + migration_tls_files,
   'pxe-test': files('boot-sector.c'),
   'qos-test': [chardev, io, qos_test_ss.apply({}).sources()],
diff --git a/tests/qtest/migration-test-smoke.c b/tests/qtest/migration-test-smoke.c
new file mode 100644
index 0000000000..d2129121b5
--- /dev/null
+++ b/tests/qtest/migration-test-smoke.c
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include "qemu/osdep.h"
+#include "libqtest.h"
+#include "migration/bootfile.h"
+#include "migration/migration-common.h"
+#include "qemu/module.h"
+
+int main(int argc, char **argv)
+{
+    MigrationTestEnv *env;
+    int ret;
+
+    g_test_init(&argc, &argv, NULL);
+    env = migration_get_env();
+    module_call_init(MODULE_INIT_QOM);
+
+    if (env->has_kvm) {
+        g_test_message("Smoke tests already run as part of the full suite on KVM hosts");
+        goto out;
+    }
+
+    migration_test_add_tls_smoke(env);
+    migration_test_add_compression_smoke(env);
+    migration_test_add_postcopy_smoke(env);
+    migration_test_add_file_smoke(env);
+    migration_test_add_precopy_smoke(env);
+    migration_test_add_cpr_smoke(env);
+    migration_test_add_misc_smoke(env);
+
+out:
+    ret = g_test_run();
+
+    g_assert_cmpint(ret, ==, 0);
+
+    bootfile_delete();
+    ret = migration_env_clean(env);
+
+    return ret;
+}
diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index 38a4a78c5c..9ca6f2a785 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -26,6 +26,17 @@ int main(int argc, char **argv)
     env = migration_get_env();
     module_call_init(MODULE_INIT_QOM);
 
+    /*
+     * Restrict the full set of tests to KVM hosts only. For tests
+     * that run in all platforms, see migration-test-smoke.c. Ignore
+     * the restriction if -m thorough was passed in the command line.
+     */
+    if (!g_test_thorough() && !env->has_kvm) {
+        g_test_message("Full test suite only runs on KVM hosts "
+                       "(override with -m thorough)");
+        goto out;
+    }
+
     migration_test_add_tls(env);
     migration_test_add_compression(env);
     migration_test_add_postcopy(env);
@@ -34,6 +45,7 @@ int main(int argc, char **argv)
     migration_test_add_cpr(env);
     migration_test_add_misc(env);
 
+out:
     ret = g_test_run();
 
     g_assert_cmpint(ret, ==, 0);
diff --git a/tests/qtest/migration/compression-tests.c b/tests/qtest/migration/compression-tests.c
index 32f3d44586..87629e3b44 100644
--- a/tests/qtest/migration/compression-tests.c
+++ b/tests/qtest/migration/compression-tests.c
@@ -204,9 +204,15 @@ static void test_multifd_tcp_zlib(void)
     test_precopy_common(&args);
 }
 
-void migration_test_add_compression(MigrationTestEnv *env)
+void migration_test_add_compression_smoke(MigrationTestEnv *env)
 {
     tmpfs = env->tmpfs;
+    /* TODO: add smoke tests */
+}
+
+void migration_test_add_compression(MigrationTestEnv *env)
+{
+    migration_test_add_compression_smoke(env);
 
 #ifdef CONFIG_ZSTD
     migration_test_add("/migration/multifd/tcp/plain/zstd",
diff --git a/tests/qtest/migration/cpr-tests.c b/tests/qtest/migration/cpr-tests.c
index a3b4e6dac1..905b74f8dc 100644
--- a/tests/qtest/migration/cpr-tests.c
+++ b/tests/qtest/migration/cpr-tests.c
@@ -43,9 +43,15 @@ static void test_mode_reboot(void)
     test_file_common(&args, true);
 }
 
-void migration_test_add_cpr(MigrationTestEnv *env)
+void migration_test_add_cpr_smoke(MigrationTestEnv *env)
 {
     tmpfs = env->tmpfs;
+    /* TODO: add smoke tests */
+}
+
+void migration_test_add_cpr(MigrationTestEnv *env)
+{
+    migration_test_add_cpr_smoke(env);
 
     /*
      * Our CI system has problems with shared memory.
diff --git a/tests/qtest/migration/file-tests.c b/tests/qtest/migration/file-tests.c
index 5942404807..011404e08c 100644
--- a/tests/qtest/migration/file-tests.c
+++ b/tests/qtest/migration/file-tests.c
@@ -292,9 +292,15 @@ static void test_multifd_file_mapped_ram_fdset_dio(void)
 }
 #endif /* !_WIN32 */
 
-void migration_test_add_file(MigrationTestEnv *env)
+void migration_test_add_file_smoke(MigrationTestEnv *env)
 {
     tmpfs = env->tmpfs;
+    /* TODO: add smoke tests */
+}
+
+void migration_test_add_file(MigrationTestEnv *env)
+{
+    migration_test_add_file_smoke(env);
 
     migration_test_add("/migration/precopy/file",
                        test_precopy_file);
diff --git a/tests/qtest/migration/migration-common.h b/tests/qtest/migration/migration-common.h
index 293371e200..05bf8ca3b6 100644
--- a/tests/qtest/migration/migration-common.h
+++ b/tests/qtest/migration/migration-common.h
@@ -213,14 +213,22 @@ int migration_env_clean(MigrationTestEnv *env);
 
 #ifdef CONFIG_GNUTLS
 void migration_test_add_tls(MigrationTestEnv *env);
+void migration_test_add_tls_smoke(MigrationTestEnv *env);
 #else
 static inline void migration_test_add_tls(MigrationTestEnv *env) {};
+static inline void migration_test_add_tls_smoke(MigrationTestEnv *env) {}
 #endif
 void migration_test_add_compression(MigrationTestEnv *env);
+void migration_test_add_compression_smoke(MigrationTestEnv *env);
 void migration_test_add_postcopy(MigrationTestEnv *env);
+void migration_test_add_postcopy_smoke(MigrationTestEnv *env);
 void migration_test_add_file(MigrationTestEnv *env);
+void migration_test_add_file_smoke(MigrationTestEnv *env);
 void migration_test_add_precopy(MigrationTestEnv *env);
+void migration_test_add_precopy_smoke(MigrationTestEnv *env);
 void migration_test_add_cpr(MigrationTestEnv *env);
+void migration_test_add_cpr_smoke(MigrationTestEnv *env);
 void migration_test_add_misc(MigrationTestEnv *env);
+void migration_test_add_misc_smoke(MigrationTestEnv *env);
 
 #endif /* MIGRATION_COMMON_H */
diff --git a/tests/qtest/migration/misc-tests.c b/tests/qtest/migration/misc-tests.c
index 03d11e9599..12736e4184 100644
--- a/tests/qtest/migration/misc-tests.c
+++ b/tests/qtest/migration/misc-tests.c
@@ -249,9 +249,15 @@ static void test_validate_uri_channels_none_set(void)
     do_test_validate_uri_channel(&args);
 }
 
-void migration_test_add_misc(MigrationTestEnv *env)
+void migration_test_add_misc_smoke(MigrationTestEnv *env)
 {
     tmpfs = env->tmpfs;
+    /* TODO: add smoke tests */
+}
+
+void migration_test_add_misc(MigrationTestEnv *env)
+{
+    migration_test_add_misc_smoke(env);
 
     migration_test_add("/migration/bad_dest", test_baddest);
 #ifndef _WIN32
diff --git a/tests/qtest/migration/postcopy-tests.c b/tests/qtest/migration/postcopy-tests.c
index 30ce54339c..d08b61f12f 100644
--- a/tests/qtest/migration/postcopy-tests.c
+++ b/tests/qtest/migration/postcopy-tests.c
@@ -79,8 +79,15 @@ static void test_postcopy_preempt_recovery(void)
     test_postcopy_recovery_common(&args);
 }
 
+void migration_test_add_postcopy_smoke(MigrationTestEnv *env)
+{
+    /* TODO: add smoke tests */
+}
+
 void migration_test_add_postcopy(MigrationTestEnv *env)
 {
+    migration_test_add_postcopy_smoke(env);
+
     if (env->has_uffd) {
         migration_test_add("/migration/postcopy/plain", test_postcopy);
         migration_test_add("/migration/postcopy/recovery/plain",
diff --git a/tests/qtest/migration/precopy-tests.c b/tests/qtest/migration/precopy-tests.c
index d73245ed37..743ecf281b 100644
--- a/tests/qtest/migration/precopy-tests.c
+++ b/tests/qtest/migration/precopy-tests.c
@@ -939,9 +939,15 @@ static void test_dirty_limit(void)
     migrate_end(from, to, true);
 }
 
-void migration_test_add_precopy(MigrationTestEnv *env)
+void migration_test_add_precopy_smoke(MigrationTestEnv *env)
 {
     tmpfs = env->tmpfs;
+    /* TODO: add smoke tests */
+}
+
+void migration_test_add_precopy(MigrationTestEnv *env)
+{
+    migration_test_add_precopy_smoke(env);
 
     if (env->is_x86) {
         migration_test_add("/migration/precopy/unix/suspend/live",
diff --git a/tests/qtest/migration/tls-tests.c b/tests/qtest/migration/tls-tests.c
index 07d8d376f2..e923edbe7b 100644
--- a/tests/qtest/migration/tls-tests.c
+++ b/tests/qtest/migration/tls-tests.c
@@ -721,10 +721,15 @@ static void test_multifd_tcp_tls_x509_reject_anon_client(void)
 }
 #endif /* CONFIG_TASN1 */
 
-void migration_test_add_tls(MigrationTestEnv *env)
+void migration_test_add_tls_smoke(MigrationTestEnv *env)
 {
     tmpfs = env->tmpfs;
+    /* TODO: add smoke tests */
+}
 
+void migration_test_add_tls(MigrationTestEnv *env)
+{
+    migration_test_add_tls_smoke(env);
     migration_test_add("/migration/precopy/unix/tls/psk",
                        test_precopy_unix_tls_psk);
 
-- 
2.35.3