xref: /qemu/tests/qtest/migration-test.c (revision 513823e7521a09ed7ad1e32e6454bac3b2cbf52d)
1 /*
2  * QTest testcase for migration
3  *
4  * Copyright (c) 2016-2018 Red Hat, Inc. and/or its affiliates
5  *   based on the vhost-user-test.c that is:
6  *      Copyright (c) 2014 Virtual Open Systems Sarl.
7  *
8  * This work is licensed under the terms of the GNU GPL, version 2 or later.
9  * See the COPYING file in the top-level directory.
10  *
11  */
12 
13 #include "qemu/osdep.h"
14 #include "migration/framework.h"
15 #include "qemu/module.h"
16 
17 static void parse_args(int *argc_p, char ***argv_p, bool *full_set)
18 {
19     int argc = *argc_p;
20     char **argv = *argv_p;
21     int i, j;
22 
23     j = 1;
24     for (i = 1; i < argc; i++) {
25         if (g_str_equal(argv[i], "--full")) {
26             *full_set = true;
27             continue;
28         }
29         argv[j++] = argv[i];
30         if (i >= j) {
31             argv[i] = NULL;
32         }
33     }
34     *argc_p = j;
35 }
36 
37 int main(int argc, char **argv)
38 {
39     MigrationTestEnv *env;
40     int ret;
41     bool full_set = false;
42 
43     /* strip the --full option if it's present */
44     parse_args(&argc, &argv, &full_set);
45 
46     g_test_init(&argc, &argv, NULL);
47     env = migration_get_env();
48     env->full_set = full_set;
49     module_call_init(MODULE_INIT_QOM);
50 
51     migration_test_add_tls(env);
52     migration_test_add_compression(env);
53     migration_test_add_postcopy(env);
54     migration_test_add_file(env);
55     migration_test_add_precopy(env);
56     migration_test_add_cpr(env);
57     migration_test_add_misc(env);
58 
59     ret = g_test_run();
60 
61     g_assert_cmpint(ret, ==, 0);
62 
63     ret = migration_env_clean(env);
64 
65     return ret;
66 }
67