mirror of https://github.com/xemu-project/xemu.git
tests: Use &error_abort where appropriate
Receiving the error in a local variable only to assert there is none is less clear than passing &error_abort. Clean up. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <20200630090351.1247703-5-armbru@redhat.com>
This commit is contained in:
parent
9261ef5e32
commit
d8da9e71b6
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "block/qdict.h"
|
#include "block/qdict.h"
|
||||||
|
#include "qapi/error.h"
|
||||||
#include "qapi/qmp/qbool.h"
|
#include "qapi/qmp/qbool.h"
|
||||||
#include "qapi/qmp/qdict.h"
|
#include "qapi/qmp/qdict.h"
|
||||||
#include "qapi/qmp/qlist.h"
|
#include "qapi/qmp/qlist.h"
|
||||||
|
@ -213,7 +214,6 @@ static void qobject_is_equal_list_test(void)
|
||||||
|
|
||||||
static void qobject_is_equal_dict_test(void)
|
static void qobject_is_equal_dict_test(void)
|
||||||
{
|
{
|
||||||
Error *local_err = NULL;
|
|
||||||
QDict *dict_0, *dict_1, *dict_cloned;
|
QDict *dict_0, *dict_1, *dict_cloned;
|
||||||
QDict *dict_different_key, *dict_different_value, *dict_different_null_key;
|
QDict *dict_different_key, *dict_different_value, *dict_different_null_key;
|
||||||
QDict *dict_longer, *dict_shorter, *dict_nested;
|
QDict *dict_longer, *dict_shorter, *dict_nested;
|
||||||
|
@ -276,8 +276,7 @@ static void qobject_is_equal_dict_test(void)
|
||||||
dict_different_null_key, dict_longer, dict_shorter,
|
dict_different_null_key, dict_longer, dict_shorter,
|
||||||
dict_nested);
|
dict_nested);
|
||||||
|
|
||||||
dict_crumpled = qobject_to(QDict, qdict_crumple(dict_1, &local_err));
|
dict_crumpled = qobject_to(QDict, qdict_crumple(dict_1, &error_abort));
|
||||||
g_assert(!local_err);
|
|
||||||
check_equal(dict_crumpled, dict_nested);
|
check_equal(dict_crumpled, dict_nested);
|
||||||
|
|
||||||
qdict_flatten(dict_nested);
|
qdict_flatten(dict_nested);
|
||||||
|
|
|
@ -419,9 +419,7 @@ static void test_dummy_createcmdl(void)
|
||||||
g_assert(dobj->bv == true);
|
g_assert(dobj->bv == true);
|
||||||
g_assert(dobj->av == DUMMY_PLATYPUS);
|
g_assert(dobj->av == DUMMY_PLATYPUS);
|
||||||
|
|
||||||
user_creatable_del("dev0", &err);
|
user_creatable_del("dev0", &error_abort);
|
||||||
g_assert(err == NULL);
|
|
||||||
error_free(err);
|
|
||||||
|
|
||||||
object_unref(OBJECT(dobj));
|
object_unref(OBJECT(dobj));
|
||||||
|
|
||||||
|
@ -485,8 +483,7 @@ static void test_dummy_getenum(void)
|
||||||
val = object_property_get_enum(OBJECT(dobj),
|
val = object_property_get_enum(OBJECT(dobj),
|
||||||
"av",
|
"av",
|
||||||
"DummyAnimal",
|
"DummyAnimal",
|
||||||
&err);
|
&error_abort);
|
||||||
g_assert(err == NULL);
|
|
||||||
g_assert(val == DUMMY_PLATYPUS);
|
g_assert(val == DUMMY_PLATYPUS);
|
||||||
|
|
||||||
/* A bad enum type name */
|
/* A bad enum type name */
|
||||||
|
|
|
@ -113,7 +113,6 @@ static void test_logfile_write(gconstpointer data)
|
||||||
QemuLogFile *logfile;
|
QemuLogFile *logfile;
|
||||||
QemuLogFile *logfile2;
|
QemuLogFile *logfile2;
|
||||||
gchar const *dir = data;
|
gchar const *dir = data;
|
||||||
Error *err = NULL;
|
|
||||||
g_autofree gchar *file_path = NULL;
|
g_autofree gchar *file_path = NULL;
|
||||||
g_autofree gchar *file_path1 = NULL;
|
g_autofree gchar *file_path1 = NULL;
|
||||||
FILE *orig_fd;
|
FILE *orig_fd;
|
||||||
|
@ -132,8 +131,7 @@ static void test_logfile_write(gconstpointer data)
|
||||||
* Test that even if an open file handle is changed,
|
* Test that even if an open file handle is changed,
|
||||||
* our handle remains valid due to RCU.
|
* our handle remains valid due to RCU.
|
||||||
*/
|
*/
|
||||||
qemu_set_log_filename(file_path, &err);
|
qemu_set_log_filename(file_path, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
logfile = atomic_rcu_read(&qemu_logfile);
|
logfile = atomic_rcu_read(&qemu_logfile);
|
||||||
orig_fd = logfile->fd;
|
orig_fd = logfile->fd;
|
||||||
|
@ -142,8 +140,7 @@ static void test_logfile_write(gconstpointer data)
|
||||||
fflush(logfile->fd);
|
fflush(logfile->fd);
|
||||||
|
|
||||||
/* Change the logfile and ensure that the handle is still valid. */
|
/* Change the logfile and ensure that the handle is still valid. */
|
||||||
qemu_set_log_filename(file_path1, &err);
|
qemu_set_log_filename(file_path1, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
logfile2 = atomic_rcu_read(&qemu_logfile);
|
logfile2 = atomic_rcu_read(&qemu_logfile);
|
||||||
g_assert(logfile->fd == orig_fd);
|
g_assert(logfile->fd == orig_fd);
|
||||||
g_assert(logfile2->fd != logfile->fd);
|
g_assert(logfile2->fd != logfile->fd);
|
||||||
|
@ -156,7 +153,6 @@ static void test_logfile_lock(gconstpointer data)
|
||||||
{
|
{
|
||||||
FILE *logfile;
|
FILE *logfile;
|
||||||
gchar const *dir = data;
|
gchar const *dir = data;
|
||||||
Error *err = NULL;
|
|
||||||
g_autofree gchar *file_path = NULL;
|
g_autofree gchar *file_path = NULL;
|
||||||
|
|
||||||
file_path = g_build_filename(dir, "qemu_test_logfile_lock0.log", NULL);
|
file_path = g_build_filename(dir, "qemu_test_logfile_lock0.log", NULL);
|
||||||
|
@ -166,7 +162,7 @@ static void test_logfile_lock(gconstpointer data)
|
||||||
* that even if an open file handle is closed,
|
* that even if an open file handle is closed,
|
||||||
* our handle remains valid for use due to RCU.
|
* our handle remains valid for use due to RCU.
|
||||||
*/
|
*/
|
||||||
qemu_set_log_filename(file_path, &err);
|
qemu_set_log_filename(file_path, &error_abort);
|
||||||
logfile = qemu_log_lock();
|
logfile = qemu_log_lock();
|
||||||
g_assert(logfile);
|
g_assert(logfile);
|
||||||
fprintf(logfile, "%s 1st write to file\n", __func__);
|
fprintf(logfile, "%s 1st write to file\n", __func__);
|
||||||
|
@ -180,8 +176,6 @@ static void test_logfile_lock(gconstpointer data)
|
||||||
fprintf(logfile, "%s 2nd write to file\n", __func__);
|
fprintf(logfile, "%s 2nd write to file\n", __func__);
|
||||||
fflush(logfile);
|
fflush(logfile);
|
||||||
qemu_log_unlock(logfile);
|
qemu_log_unlock(logfile);
|
||||||
|
|
||||||
g_assert(!err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove a directory and all its entries (non-recursive). */
|
/* Remove a directory and all its entries (non-recursive). */
|
||||||
|
|
|
@ -187,7 +187,6 @@ static void test_qemu_opt_get(void)
|
||||||
|
|
||||||
static void test_qemu_opt_get_bool(void)
|
static void test_qemu_opt_get_bool(void)
|
||||||
{
|
{
|
||||||
Error *err = NULL;
|
|
||||||
QemuOptsList *list;
|
QemuOptsList *list;
|
||||||
QemuOpts *opts;
|
QemuOpts *opts;
|
||||||
bool opt;
|
bool opt;
|
||||||
|
@ -210,16 +209,14 @@ static void test_qemu_opt_get_bool(void)
|
||||||
opt = qemu_opt_get_bool(opts, "bool1", false);
|
opt = qemu_opt_get_bool(opts, "bool1", false);
|
||||||
g_assert(opt == false);
|
g_assert(opt == false);
|
||||||
|
|
||||||
qemu_opt_set_bool(opts, "bool1", true, &err);
|
qemu_opt_set_bool(opts, "bool1", true, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
|
|
||||||
/* now we have set bool1, should know about it */
|
/* now we have set bool1, should know about it */
|
||||||
opt = qemu_opt_get_bool(opts, "bool1", false);
|
opt = qemu_opt_get_bool(opts, "bool1", false);
|
||||||
g_assert(opt == true);
|
g_assert(opt == true);
|
||||||
|
|
||||||
/* having reset the value, opt should be the reset one not defval */
|
/* having reset the value, opt should be the reset one not defval */
|
||||||
qemu_opt_set_bool(opts, "bool1", false, &err);
|
qemu_opt_set_bool(opts, "bool1", false, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
|
|
||||||
opt = qemu_opt_get_bool(opts, "bool1", true);
|
opt = qemu_opt_get_bool(opts, "bool1", true);
|
||||||
g_assert(opt == false);
|
g_assert(opt == false);
|
||||||
|
@ -233,7 +230,6 @@ static void test_qemu_opt_get_bool(void)
|
||||||
|
|
||||||
static void test_qemu_opt_get_number(void)
|
static void test_qemu_opt_get_number(void)
|
||||||
{
|
{
|
||||||
Error *err = NULL;
|
|
||||||
QemuOptsList *list;
|
QemuOptsList *list;
|
||||||
QemuOpts *opts;
|
QemuOpts *opts;
|
||||||
uint64_t opt;
|
uint64_t opt;
|
||||||
|
@ -256,16 +252,14 @@ static void test_qemu_opt_get_number(void)
|
||||||
opt = qemu_opt_get_number(opts, "number1", 5);
|
opt = qemu_opt_get_number(opts, "number1", 5);
|
||||||
g_assert(opt == 5);
|
g_assert(opt == 5);
|
||||||
|
|
||||||
qemu_opt_set_number(opts, "number1", 10, &err);
|
qemu_opt_set_number(opts, "number1", 10, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
|
|
||||||
/* now we have set number1, should know about it */
|
/* now we have set number1, should know about it */
|
||||||
opt = qemu_opt_get_number(opts, "number1", 5);
|
opt = qemu_opt_get_number(opts, "number1", 5);
|
||||||
g_assert(opt == 10);
|
g_assert(opt == 10);
|
||||||
|
|
||||||
/* having reset it, the returned should be the reset one not defval */
|
/* having reset it, the returned should be the reset one not defval */
|
||||||
qemu_opt_set_number(opts, "number1", 15, &err);
|
qemu_opt_set_number(opts, "number1", 15, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
|
|
||||||
opt = qemu_opt_get_number(opts, "number1", 5);
|
opt = qemu_opt_get_number(opts, "number1", 5);
|
||||||
g_assert(opt == 15);
|
g_assert(opt == 15);
|
||||||
|
@ -367,7 +361,6 @@ static void test_qemu_opt_unset(void)
|
||||||
|
|
||||||
static void test_qemu_opts_reset(void)
|
static void test_qemu_opts_reset(void)
|
||||||
{
|
{
|
||||||
Error *err = NULL;
|
|
||||||
QemuOptsList *list;
|
QemuOptsList *list;
|
||||||
QemuOpts *opts;
|
QemuOpts *opts;
|
||||||
uint64_t opt;
|
uint64_t opt;
|
||||||
|
@ -390,8 +383,7 @@ static void test_qemu_opts_reset(void)
|
||||||
opt = qemu_opt_get_number(opts, "number1", 5);
|
opt = qemu_opt_get_number(opts, "number1", 5);
|
||||||
g_assert(opt == 5);
|
g_assert(opt == 5);
|
||||||
|
|
||||||
qemu_opt_set_number(opts, "number1", 10, &err);
|
qemu_opt_set_number(opts, "number1", 10, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
|
|
||||||
/* now we have set number1, should know about it */
|
/* now we have set number1, should know about it */
|
||||||
opt = qemu_opt_get_number(opts, "number1", 5);
|
opt = qemu_opt_get_number(opts, "number1", 5);
|
||||||
|
@ -406,7 +398,6 @@ static void test_qemu_opts_reset(void)
|
||||||
|
|
||||||
static void test_qemu_opts_set(void)
|
static void test_qemu_opts_set(void)
|
||||||
{
|
{
|
||||||
Error *err = NULL;
|
|
||||||
QemuOptsList *list;
|
QemuOptsList *list;
|
||||||
QemuOpts *opts;
|
QemuOpts *opts;
|
||||||
const char *opt;
|
const char *opt;
|
||||||
|
@ -421,8 +412,7 @@ static void test_qemu_opts_set(void)
|
||||||
g_assert(opts == NULL);
|
g_assert(opts == NULL);
|
||||||
|
|
||||||
/* implicitly create opts and set str3 value */
|
/* implicitly create opts and set str3 value */
|
||||||
qemu_opts_set(list, NULL, "str3", "value", &err);
|
qemu_opts_set(list, NULL, "str3", "value", &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
g_assert(!QTAILQ_EMPTY(&list->head));
|
g_assert(!QTAILQ_EMPTY(&list->head));
|
||||||
|
|
||||||
/* get the just created opts */
|
/* get the just created opts */
|
||||||
|
|
|
@ -139,8 +139,6 @@ static void make_temp(char *template)
|
||||||
|
|
||||||
static void prepare_imgs(void)
|
static void prepare_imgs(void)
|
||||||
{
|
{
|
||||||
Error *local_err = NULL;
|
|
||||||
|
|
||||||
make_temp(p_local_disk);
|
make_temp(p_local_disk);
|
||||||
make_temp(s_local_disk);
|
make_temp(s_local_disk);
|
||||||
make_temp(s_active_disk);
|
make_temp(s_active_disk);
|
||||||
|
@ -148,19 +146,15 @@ static void prepare_imgs(void)
|
||||||
|
|
||||||
/* Primary */
|
/* Primary */
|
||||||
bdrv_img_create(p_local_disk, "qcow2", NULL, NULL, NULL, IMG_SIZE,
|
bdrv_img_create(p_local_disk, "qcow2", NULL, NULL, NULL, IMG_SIZE,
|
||||||
BDRV_O_RDWR, true, &local_err);
|
BDRV_O_RDWR, true, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
/* Secondary */
|
/* Secondary */
|
||||||
bdrv_img_create(s_local_disk, "qcow2", NULL, NULL, NULL, IMG_SIZE,
|
bdrv_img_create(s_local_disk, "qcow2", NULL, NULL, NULL, IMG_SIZE,
|
||||||
BDRV_O_RDWR, true, &local_err);
|
BDRV_O_RDWR, true, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
bdrv_img_create(s_active_disk, "qcow2", NULL, NULL, NULL, IMG_SIZE,
|
bdrv_img_create(s_active_disk, "qcow2", NULL, NULL, NULL, IMG_SIZE,
|
||||||
BDRV_O_RDWR, true, &local_err);
|
BDRV_O_RDWR, true, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
bdrv_img_create(s_hidden_disk, "qcow2", NULL, NULL, NULL, IMG_SIZE,
|
bdrv_img_create(s_hidden_disk, "qcow2", NULL, NULL, NULL, IMG_SIZE,
|
||||||
BDRV_O_RDWR, true, &local_err);
|
BDRV_O_RDWR, true, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cleanup_imgs(void)
|
static void cleanup_imgs(void)
|
||||||
|
@ -179,7 +173,6 @@ static BlockBackend *start_primary(void)
|
||||||
BlockBackend *blk;
|
BlockBackend *blk;
|
||||||
QemuOpts *opts;
|
QemuOpts *opts;
|
||||||
QDict *qdict;
|
QDict *qdict;
|
||||||
Error *local_err = NULL;
|
|
||||||
char *cmdline;
|
char *cmdline;
|
||||||
|
|
||||||
cmdline = g_strdup_printf("driver=replication,mode=primary,node-name=xxx,"
|
cmdline = g_strdup_printf("driver=replication,mode=primary,node-name=xxx,"
|
||||||
|
@ -193,12 +186,10 @@ static BlockBackend *start_primary(void)
|
||||||
qdict_set_default_str(qdict, BDRV_OPT_CACHE_DIRECT, "off");
|
qdict_set_default_str(qdict, BDRV_OPT_CACHE_DIRECT, "off");
|
||||||
qdict_set_default_str(qdict, BDRV_OPT_CACHE_NO_FLUSH, "off");
|
qdict_set_default_str(qdict, BDRV_OPT_CACHE_NO_FLUSH, "off");
|
||||||
|
|
||||||
blk = blk_new_open(NULL, NULL, qdict, BDRV_O_RDWR, &local_err);
|
blk = blk_new_open(NULL, NULL, qdict, BDRV_O_RDWR, &error_abort);
|
||||||
g_assert(blk);
|
g_assert(blk);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
monitor_add_blk(blk, P_ID, &local_err);
|
monitor_add_blk(blk, P_ID, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
qemu_opts_del(opts);
|
qemu_opts_del(opts);
|
||||||
|
|
||||||
|
@ -248,12 +239,10 @@ static void test_primary_write(void)
|
||||||
static void test_primary_start(void)
|
static void test_primary_start(void)
|
||||||
{
|
{
|
||||||
BlockBackend *blk = NULL;
|
BlockBackend *blk = NULL;
|
||||||
Error *local_err = NULL;
|
|
||||||
|
|
||||||
blk = start_primary();
|
blk = start_primary();
|
||||||
|
|
||||||
replication_start_all(REPLICATION_MODE_PRIMARY, &local_err);
|
replication_start_all(REPLICATION_MODE_PRIMARY, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
/* read from 0 to IMG_SIZE */
|
/* read from 0 to IMG_SIZE */
|
||||||
test_blk_read(blk, 0, 0, IMG_SIZE, 0, IMG_SIZE, true);
|
test_blk_read(blk, 0, 0, IMG_SIZE, 0, IMG_SIZE, true);
|
||||||
|
@ -266,46 +255,35 @@ static void test_primary_start(void)
|
||||||
|
|
||||||
static void test_primary_stop(void)
|
static void test_primary_stop(void)
|
||||||
{
|
{
|
||||||
Error *local_err = NULL;
|
|
||||||
bool failover = true;
|
bool failover = true;
|
||||||
|
|
||||||
start_primary();
|
start_primary();
|
||||||
|
|
||||||
replication_start_all(REPLICATION_MODE_PRIMARY, &local_err);
|
replication_start_all(REPLICATION_MODE_PRIMARY, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
replication_stop_all(failover, &local_err);
|
replication_stop_all(failover, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
teardown_primary();
|
teardown_primary();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_primary_do_checkpoint(void)
|
static void test_primary_do_checkpoint(void)
|
||||||
{
|
{
|
||||||
Error *local_err = NULL;
|
|
||||||
|
|
||||||
start_primary();
|
start_primary();
|
||||||
|
|
||||||
replication_start_all(REPLICATION_MODE_PRIMARY, &local_err);
|
replication_start_all(REPLICATION_MODE_PRIMARY, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
replication_do_checkpoint_all(&local_err);
|
replication_do_checkpoint_all(&error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
teardown_primary();
|
teardown_primary();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_primary_get_error_all(void)
|
static void test_primary_get_error_all(void)
|
||||||
{
|
{
|
||||||
Error *local_err = NULL;
|
|
||||||
|
|
||||||
start_primary();
|
start_primary();
|
||||||
|
|
||||||
replication_start_all(REPLICATION_MODE_PRIMARY, &local_err);
|
replication_start_all(REPLICATION_MODE_PRIMARY, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
replication_get_error_all(&local_err);
|
replication_get_error_all(&error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
teardown_primary();
|
teardown_primary();
|
||||||
}
|
}
|
||||||
|
@ -316,7 +294,6 @@ static BlockBackend *start_secondary(void)
|
||||||
QDict *qdict;
|
QDict *qdict;
|
||||||
BlockBackend *blk;
|
BlockBackend *blk;
|
||||||
char *cmdline;
|
char *cmdline;
|
||||||
Error *local_err = NULL;
|
|
||||||
|
|
||||||
/* add s_local_disk and forge S_LOCAL_DISK_ID */
|
/* add s_local_disk and forge S_LOCAL_DISK_ID */
|
||||||
cmdline = g_strdup_printf("file.filename=%s,driver=qcow2,"
|
cmdline = g_strdup_printf("file.filename=%s,driver=qcow2,"
|
||||||
|
@ -329,10 +306,9 @@ static BlockBackend *start_secondary(void)
|
||||||
qdict_set_default_str(qdict, BDRV_OPT_CACHE_DIRECT, "off");
|
qdict_set_default_str(qdict, BDRV_OPT_CACHE_DIRECT, "off");
|
||||||
qdict_set_default_str(qdict, BDRV_OPT_CACHE_NO_FLUSH, "off");
|
qdict_set_default_str(qdict, BDRV_OPT_CACHE_NO_FLUSH, "off");
|
||||||
|
|
||||||
blk = blk_new_open(NULL, NULL, qdict, BDRV_O_RDWR, &local_err);
|
blk = blk_new_open(NULL, NULL, qdict, BDRV_O_RDWR, &error_abort);
|
||||||
assert(blk);
|
assert(blk);
|
||||||
monitor_add_blk(blk, S_LOCAL_DISK_ID, &local_err);
|
monitor_add_blk(blk, S_LOCAL_DISK_ID, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
/* format s_local_disk with pattern "0x11" */
|
/* format s_local_disk with pattern "0x11" */
|
||||||
test_blk_write(blk, 0x11, 0, IMG_SIZE, false);
|
test_blk_write(blk, 0x11, 0, IMG_SIZE, false);
|
||||||
|
@ -356,10 +332,9 @@ static BlockBackend *start_secondary(void)
|
||||||
qdict_set_default_str(qdict, BDRV_OPT_CACHE_DIRECT, "off");
|
qdict_set_default_str(qdict, BDRV_OPT_CACHE_DIRECT, "off");
|
||||||
qdict_set_default_str(qdict, BDRV_OPT_CACHE_NO_FLUSH, "off");
|
qdict_set_default_str(qdict, BDRV_OPT_CACHE_NO_FLUSH, "off");
|
||||||
|
|
||||||
blk = blk_new_open(NULL, NULL, qdict, BDRV_O_RDWR, &local_err);
|
blk = blk_new_open(NULL, NULL, qdict, BDRV_O_RDWR, &error_abort);
|
||||||
assert(blk);
|
assert(blk);
|
||||||
monitor_add_blk(blk, S_ID, &local_err);
|
monitor_add_blk(blk, S_ID, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
qemu_opts_del(opts);
|
qemu_opts_del(opts);
|
||||||
|
|
||||||
|
@ -420,12 +395,10 @@ static void test_secondary_write(void)
|
||||||
static void test_secondary_start(void)
|
static void test_secondary_start(void)
|
||||||
{
|
{
|
||||||
BlockBackend *top_blk, *local_blk;
|
BlockBackend *top_blk, *local_blk;
|
||||||
Error *local_err = NULL;
|
|
||||||
bool failover = true;
|
bool failover = true;
|
||||||
|
|
||||||
top_blk = start_secondary();
|
top_blk = start_secondary();
|
||||||
replication_start_all(REPLICATION_MODE_SECONDARY, &local_err);
|
replication_start_all(REPLICATION_MODE_SECONDARY, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
/* read from s_local_disk (0, IMG_SIZE) */
|
/* read from s_local_disk (0, IMG_SIZE) */
|
||||||
test_blk_read(top_blk, 0x11, 0, IMG_SIZE, 0, IMG_SIZE, false);
|
test_blk_read(top_blk, 0x11, 0, IMG_SIZE, 0, IMG_SIZE, false);
|
||||||
|
@ -446,8 +419,7 @@ static void test_secondary_start(void)
|
||||||
0, IMG_SIZE / 2, false);
|
0, IMG_SIZE / 2, false);
|
||||||
|
|
||||||
/* unblock top_bs */
|
/* unblock top_bs */
|
||||||
replication_stop_all(failover, &local_err);
|
replication_stop_all(failover, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
teardown_secondary();
|
teardown_secondary();
|
||||||
}
|
}
|
||||||
|
@ -456,12 +428,10 @@ static void test_secondary_start(void)
|
||||||
static void test_secondary_stop(void)
|
static void test_secondary_stop(void)
|
||||||
{
|
{
|
||||||
BlockBackend *top_blk, *local_blk;
|
BlockBackend *top_blk, *local_blk;
|
||||||
Error *local_err = NULL;
|
|
||||||
bool failover = true;
|
bool failover = true;
|
||||||
|
|
||||||
top_blk = start_secondary();
|
top_blk = start_secondary();
|
||||||
replication_start_all(REPLICATION_MODE_SECONDARY, &local_err);
|
replication_start_all(REPLICATION_MODE_SECONDARY, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
/* write 0x22 to s_local_disk (IMG_SIZE / 2, IMG_SIZE) */
|
/* write 0x22 to s_local_disk (IMG_SIZE / 2, IMG_SIZE) */
|
||||||
local_blk = blk_by_name(S_LOCAL_DISK_ID);
|
local_blk = blk_by_name(S_LOCAL_DISK_ID);
|
||||||
|
@ -475,8 +445,7 @@ static void test_secondary_stop(void)
|
||||||
test_blk_write(top_blk, 0x33, 0, IMG_SIZE / 2, false);
|
test_blk_write(top_blk, 0x33, 0, IMG_SIZE / 2, false);
|
||||||
|
|
||||||
/* do active commit */
|
/* do active commit */
|
||||||
replication_stop_all(failover, &local_err);
|
replication_stop_all(failover, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
/* read from s_local_disk (0, IMG_SIZE / 2) */
|
/* read from s_local_disk (0, IMG_SIZE / 2) */
|
||||||
test_blk_read(top_blk, 0x33, 0, IMG_SIZE / 2,
|
test_blk_read(top_blk, 0x33, 0, IMG_SIZE / 2,
|
||||||
|
@ -493,11 +462,9 @@ static void test_secondary_stop(void)
|
||||||
static void test_secondary_continuous_replication(void)
|
static void test_secondary_continuous_replication(void)
|
||||||
{
|
{
|
||||||
BlockBackend *top_blk, *local_blk;
|
BlockBackend *top_blk, *local_blk;
|
||||||
Error *local_err = NULL;
|
|
||||||
|
|
||||||
top_blk = start_secondary();
|
top_blk = start_secondary();
|
||||||
replication_start_all(REPLICATION_MODE_SECONDARY, &local_err);
|
replication_start_all(REPLICATION_MODE_SECONDARY, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
/* write 0x22 to s_local_disk (IMG_SIZE / 2, IMG_SIZE) */
|
/* write 0x22 to s_local_disk (IMG_SIZE / 2, IMG_SIZE) */
|
||||||
local_blk = blk_by_name(S_LOCAL_DISK_ID);
|
local_blk = blk_by_name(S_LOCAL_DISK_ID);
|
||||||
|
@ -511,22 +478,18 @@ static void test_secondary_continuous_replication(void)
|
||||||
test_blk_write(top_blk, 0x33, 0, IMG_SIZE / 2, false);
|
test_blk_write(top_blk, 0x33, 0, IMG_SIZE / 2, false);
|
||||||
|
|
||||||
/* do failover (active commit) */
|
/* do failover (active commit) */
|
||||||
replication_stop_all(true, &local_err);
|
replication_stop_all(true, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
/* it should ignore all requests from now on */
|
/* it should ignore all requests from now on */
|
||||||
|
|
||||||
/* start after failover */
|
/* start after failover */
|
||||||
replication_start_all(REPLICATION_MODE_PRIMARY, &local_err);
|
replication_start_all(REPLICATION_MODE_PRIMARY, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
/* checkpoint */
|
/* checkpoint */
|
||||||
replication_do_checkpoint_all(&local_err);
|
replication_do_checkpoint_all(&error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
/* stop */
|
/* stop */
|
||||||
replication_stop_all(true, &local_err);
|
replication_stop_all(true, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
/* read from s_local_disk (0, IMG_SIZE / 2) */
|
/* read from s_local_disk (0, IMG_SIZE / 2) */
|
||||||
test_blk_read(top_blk, 0x33, 0, IMG_SIZE / 2,
|
test_blk_read(top_blk, 0x33, 0, IMG_SIZE / 2,
|
||||||
|
@ -543,12 +506,10 @@ static void test_secondary_continuous_replication(void)
|
||||||
static void test_secondary_do_checkpoint(void)
|
static void test_secondary_do_checkpoint(void)
|
||||||
{
|
{
|
||||||
BlockBackend *top_blk, *local_blk;
|
BlockBackend *top_blk, *local_blk;
|
||||||
Error *local_err = NULL;
|
|
||||||
bool failover = true;
|
bool failover = true;
|
||||||
|
|
||||||
top_blk = start_secondary();
|
top_blk = start_secondary();
|
||||||
replication_start_all(REPLICATION_MODE_SECONDARY, &local_err);
|
replication_start_all(REPLICATION_MODE_SECONDARY, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
/* write 0x22 to s_local_disk (IMG_SIZE / 2, IMG_SIZE) */
|
/* write 0x22 to s_local_disk (IMG_SIZE / 2, IMG_SIZE) */
|
||||||
local_blk = blk_by_name(S_LOCAL_DISK_ID);
|
local_blk = blk_by_name(S_LOCAL_DISK_ID);
|
||||||
|
@ -559,35 +520,29 @@ static void test_secondary_do_checkpoint(void)
|
||||||
test_blk_read(top_blk, 0x11, IMG_SIZE / 2,
|
test_blk_read(top_blk, 0x11, IMG_SIZE / 2,
|
||||||
IMG_SIZE / 2, 0, IMG_SIZE, false);
|
IMG_SIZE / 2, 0, IMG_SIZE, false);
|
||||||
|
|
||||||
replication_do_checkpoint_all(&local_err);
|
replication_do_checkpoint_all(&error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
/* after checkpoint, read pattern 0x22 from s_local_disk */
|
/* after checkpoint, read pattern 0x22 from s_local_disk */
|
||||||
test_blk_read(top_blk, 0x22, IMG_SIZE / 2,
|
test_blk_read(top_blk, 0x22, IMG_SIZE / 2,
|
||||||
IMG_SIZE / 2, 0, IMG_SIZE, false);
|
IMG_SIZE / 2, 0, IMG_SIZE, false);
|
||||||
|
|
||||||
/* unblock top_bs */
|
/* unblock top_bs */
|
||||||
replication_stop_all(failover, &local_err);
|
replication_stop_all(failover, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
teardown_secondary();
|
teardown_secondary();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_secondary_get_error_all(void)
|
static void test_secondary_get_error_all(void)
|
||||||
{
|
{
|
||||||
Error *local_err = NULL;
|
|
||||||
bool failover = true;
|
bool failover = true;
|
||||||
|
|
||||||
start_secondary();
|
start_secondary();
|
||||||
replication_start_all(REPLICATION_MODE_SECONDARY, &local_err);
|
replication_start_all(REPLICATION_MODE_SECONDARY, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
replication_get_error_all(&local_err);
|
replication_get_error_all(&error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
/* unblock top_bs */
|
/* unblock top_bs */
|
||||||
replication_stop_all(failover, &local_err);
|
replication_stop_all(failover, &error_abort);
|
||||||
g_assert(!local_err);
|
|
||||||
|
|
||||||
teardown_secondary();
|
teardown_secondary();
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,8 +53,7 @@ static void test_visitor_in_int(TestInputVisitorData *data,
|
||||||
|
|
||||||
v = visitor_input_test_init(data, "-42");
|
v = visitor_input_test_init(data, "-42");
|
||||||
|
|
||||||
visit_type_int(v, NULL, &res, &err);
|
visit_type_int(v, NULL, &res, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
g_assert_cmpint(res, ==, value);
|
g_assert_cmpint(res, ==, value);
|
||||||
|
|
||||||
v = visitor_input_test_init(data, "not an int");
|
v = visitor_input_test_init(data, "not an int");
|
||||||
|
@ -327,44 +326,37 @@ static void test_visitor_in_uintList(TestInputVisitorData *data,
|
||||||
static void test_visitor_in_bool(TestInputVisitorData *data,
|
static void test_visitor_in_bool(TestInputVisitorData *data,
|
||||||
const void *unused)
|
const void *unused)
|
||||||
{
|
{
|
||||||
Error *err = NULL;
|
|
||||||
bool res = false;
|
bool res = false;
|
||||||
Visitor *v;
|
Visitor *v;
|
||||||
|
|
||||||
v = visitor_input_test_init(data, "true");
|
v = visitor_input_test_init(data, "true");
|
||||||
|
|
||||||
visit_type_bool(v, NULL, &res, &err);
|
visit_type_bool(v, NULL, &res, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
g_assert_cmpint(res, ==, true);
|
g_assert_cmpint(res, ==, true);
|
||||||
|
|
||||||
v = visitor_input_test_init(data, "yes");
|
v = visitor_input_test_init(data, "yes");
|
||||||
|
|
||||||
visit_type_bool(v, NULL, &res, &err);
|
visit_type_bool(v, NULL, &res, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
g_assert_cmpint(res, ==, true);
|
g_assert_cmpint(res, ==, true);
|
||||||
|
|
||||||
v = visitor_input_test_init(data, "on");
|
v = visitor_input_test_init(data, "on");
|
||||||
|
|
||||||
visit_type_bool(v, NULL, &res, &err);
|
visit_type_bool(v, NULL, &res, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
g_assert_cmpint(res, ==, true);
|
g_assert_cmpint(res, ==, true);
|
||||||
|
|
||||||
v = visitor_input_test_init(data, "false");
|
v = visitor_input_test_init(data, "false");
|
||||||
|
|
||||||
visit_type_bool(v, NULL, &res, &err);
|
visit_type_bool(v, NULL, &res, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
g_assert_cmpint(res, ==, false);
|
g_assert_cmpint(res, ==, false);
|
||||||
|
|
||||||
v = visitor_input_test_init(data, "no");
|
v = visitor_input_test_init(data, "no");
|
||||||
|
|
||||||
visit_type_bool(v, NULL, &res, &err);
|
visit_type_bool(v, NULL, &res, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
g_assert_cmpint(res, ==, false);
|
g_assert_cmpint(res, ==, false);
|
||||||
|
|
||||||
v = visitor_input_test_init(data, "off");
|
v = visitor_input_test_init(data, "off");
|
||||||
|
|
||||||
visit_type_bool(v, NULL, &res, &err);
|
visit_type_bool(v, NULL, &res, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
g_assert_cmpint(res, ==, false);
|
g_assert_cmpint(res, ==, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,8 +369,7 @@ static void test_visitor_in_number(TestInputVisitorData *data,
|
||||||
|
|
||||||
v = visitor_input_test_init(data, "3.14");
|
v = visitor_input_test_init(data, "3.14");
|
||||||
|
|
||||||
visit_type_number(v, NULL, &res, &err);
|
visit_type_number(v, NULL, &res, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
g_assert_cmpfloat(res, ==, value);
|
g_assert_cmpfloat(res, ==, value);
|
||||||
|
|
||||||
/* NaN and infinity has to be rejected */
|
/* NaN and infinity has to be rejected */
|
||||||
|
@ -399,13 +390,11 @@ static void test_visitor_in_string(TestInputVisitorData *data,
|
||||||
const void *unused)
|
const void *unused)
|
||||||
{
|
{
|
||||||
char *res = NULL, *value = (char *) "Q E M U";
|
char *res = NULL, *value = (char *) "Q E M U";
|
||||||
Error *err = NULL;
|
|
||||||
Visitor *v;
|
Visitor *v;
|
||||||
|
|
||||||
v = visitor_input_test_init(data, value);
|
v = visitor_input_test_init(data, value);
|
||||||
|
|
||||||
visit_type_str(v, NULL, &res, &err);
|
visit_type_str(v, NULL, &res, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
g_assert_cmpstr(res, ==, value);
|
g_assert_cmpstr(res, ==, value);
|
||||||
|
|
||||||
g_free(res);
|
g_free(res);
|
||||||
|
@ -414,7 +403,6 @@ static void test_visitor_in_string(TestInputVisitorData *data,
|
||||||
static void test_visitor_in_enum(TestInputVisitorData *data,
|
static void test_visitor_in_enum(TestInputVisitorData *data,
|
||||||
const void *unused)
|
const void *unused)
|
||||||
{
|
{
|
||||||
Error *err = NULL;
|
|
||||||
Visitor *v;
|
Visitor *v;
|
||||||
EnumOne i;
|
EnumOne i;
|
||||||
|
|
||||||
|
@ -423,8 +411,7 @@ static void test_visitor_in_enum(TestInputVisitorData *data,
|
||||||
|
|
||||||
v = visitor_input_test_init(data, EnumOne_str(i));
|
v = visitor_input_test_init(data, EnumOne_str(i));
|
||||||
|
|
||||||
visit_type_EnumOne(v, NULL, &res, &err);
|
visit_type_EnumOne(v, NULL, &res, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
g_assert_cmpint(i, ==, res);
|
g_assert_cmpint(i, ==, res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,11 +71,9 @@ static void test_visitor_out_int(TestOutputVisitorData *data,
|
||||||
const void *unused)
|
const void *unused)
|
||||||
{
|
{
|
||||||
int64_t value = 42;
|
int64_t value = 42;
|
||||||
Error *err = NULL;
|
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
visit_type_int(data->ov, NULL, &value, &err);
|
visit_type_int(data->ov, NULL, &value, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
|
|
||||||
str = visitor_get(data);
|
str = visitor_get(data);
|
||||||
if (data->human) {
|
if (data->human) {
|
||||||
|
@ -120,12 +118,10 @@ static void test_visitor_out_intList(TestOutputVisitorData *data,
|
||||||
static void test_visitor_out_bool(TestOutputVisitorData *data,
|
static void test_visitor_out_bool(TestOutputVisitorData *data,
|
||||||
const void *unused)
|
const void *unused)
|
||||||
{
|
{
|
||||||
Error *err = NULL;
|
|
||||||
bool value = true;
|
bool value = true;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
visit_type_bool(data->ov, NULL, &value, &err);
|
visit_type_bool(data->ov, NULL, &value, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
|
|
||||||
str = visitor_get(data);
|
str = visitor_get(data);
|
||||||
g_assert_cmpstr(str, ==, "true");
|
g_assert_cmpstr(str, ==, "true");
|
||||||
|
@ -135,11 +131,9 @@ static void test_visitor_out_number(TestOutputVisitorData *data,
|
||||||
const void *unused)
|
const void *unused)
|
||||||
{
|
{
|
||||||
double value = 3.14;
|
double value = 3.14;
|
||||||
Error *err = NULL;
|
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
visit_type_number(data->ov, NULL, &value, &err);
|
visit_type_number(data->ov, NULL, &value, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
|
|
||||||
str = visitor_get(data);
|
str = visitor_get(data);
|
||||||
g_assert_cmpstr(str, ==, "3.140000");
|
g_assert_cmpstr(str, ==, "3.140000");
|
||||||
|
@ -150,11 +144,9 @@ static void test_visitor_out_string(TestOutputVisitorData *data,
|
||||||
{
|
{
|
||||||
char *string = (char *) "Q E M U";
|
char *string = (char *) "Q E M U";
|
||||||
const char *string_human = "\"Q E M U\"";
|
const char *string_human = "\"Q E M U\"";
|
||||||
Error *err = NULL;
|
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
visit_type_str(data->ov, NULL, &string, &err);
|
visit_type_str(data->ov, NULL, &string, &error_abort);
|
||||||
g_assert(!err);
|
|
||||||
|
|
||||||
str = visitor_get(data);
|
str = visitor_get(data);
|
||||||
if (data->human) {
|
if (data->human) {
|
||||||
|
|
Loading…
Reference in New Issue