summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell2020-07-02 16:54:09 +0200
committerPeter Maydell2020-07-02 16:54:09 +0200
commit64f0ad8ad8e13257e7c912df470d46784b55c3fd (patch)
treeb13ba33035f5f8a059327bd66b175c219f3235c4 /tests
parentMerge remote-tracking branch 'remotes/kraxel/tags/vga-20200701-pull-request' ... (diff)
parentmigration/rdma: Plug memory leaks in qemu_rdma_registration_stop() (diff)
downloadqemu-64f0ad8ad8e13257e7c912df470d46784b55c3fd.tar.gz
qemu-64f0ad8ad8e13257e7c912df470d46784b55c3fd.tar.xz
qemu-64f0ad8ad8e13257e7c912df470d46784b55c3fd.zip
Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2020-07-02' into staging
Error reporting patches patches for 2020-07-02 # gpg: Signature made Thu 02 Jul 2020 10:55:48 BST # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-error-2020-07-02: (28 commits) migration/rdma: Plug memory leaks in qemu_rdma_registration_stop() arm/{bcm2835,fsl-imx25,fsl-imx6}: Fix realize error API violations hw/arm/armsse: Fix armsse_realize() error API violation aspeed: Fix realize error API violation arm/stm32f205 arm/stm32f405: Fix realize error API violation amd_iommu: Fix amdvi_realize() error API violation x86: Fix x86_cpu_new() error handling mips/cps: Fix mips_cps_realize() error API violations riscv_hart: Fix riscv_harts_realize() error API violations riscv/sifive_u: Fix sifive_u_soc_realize() error API violations hw/arm: Drop useless object_property_set_link() error handling hw: Fix error API violation around object_property_set_link() qdev: Drop qbus_set_hotplug_handler() parameter @errp qdev: Drop qbus_set_bus_hotplug_handler() parameter @errp aspeed: Clean up roundabout error propagation vnc: Plug minor memory leak in vnc_display_open() test-util-filemonitor: Plug unlikely memory leak sd/milkymist-memcard: Plug minor memory leak in realize qga: Plug unlikely memory leak in guest-set-memory-blocks spapr: Plug minor memory leak in spapr_machine_init() ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/check-block-qdict.c24
-rw-r--r--tests/check-qobject.c5
-rw-r--r--tests/check-qom-proplist.c14
-rw-r--r--tests/test-base64.c3
-rw-r--r--tests/test-bdrv-graph-mod.c4
-rw-r--r--tests/test-block-iothread.c3
-rw-r--r--tests/test-crypto-cipher.c8
-rw-r--r--tests/test-io-task.c4
-rw-r--r--tests/test-logging.c12
-rw-r--r--tests/test-qemu-opts.c22
-rw-r--r--tests/test-replication.c109
-rw-r--r--tests/test-string-input-visitor.c33
-rw-r--r--tests/test-string-output-visitor.c16
-rw-r--r--tests/test-util-filemonitor.c1
14 files changed, 74 insertions, 184 deletions
diff --git a/tests/check-block-qdict.c b/tests/check-block-qdict.c
index 73d3e9f574..5a25825093 100644
--- a/tests/check-block-qdict.c
+++ b/tests/check-block-qdict.c
@@ -610,9 +610,7 @@ static void qdict_rename_keys_test(void)
copy = qdict_clone_shallow(dict);
qdict_rename_keys(copy, renames, &local_err);
- g_assert(local_err != NULL);
- error_free(local_err);
- local_err = NULL;
+ error_free_or_abort(&local_err);
g_assert_cmpstr(qdict_get_str(copy, "abc"), ==, "foo");
g_assert_cmpstr(qdict_get_str(copy, "abcdef"), ==, "bar");
@@ -649,9 +647,7 @@ static void qdict_crumple_test_bad_inputs(void)
qdict_put_str(src, "rule.0.policy", "allow");
g_assert(qdict_crumple(src, &error) == NULL);
- g_assert(error != NULL);
- error_free(error);
- error = NULL;
+ error_free_or_abort(&error);
qobject_unref(src);
src = qdict_new();
@@ -660,9 +656,7 @@ static void qdict_crumple_test_bad_inputs(void)
qdict_put_str(src, "rule.a", "allow");
g_assert(qdict_crumple(src, &error) == NULL);
- g_assert(error != NULL);
- error_free(error);
- error = NULL;
+ error_free_or_abort(&error);
qobject_unref(src);
src = qdict_new();
@@ -673,9 +667,7 @@ static void qdict_crumple_test_bad_inputs(void)
qdict_put_str(src, "rule.b", "allow");
g_assert(qdict_crumple(src, &error) == NULL);
- g_assert(error != NULL);
- error_free(error);
- error = NULL;
+ error_free_or_abort(&error);
qobject_unref(src);
src = qdict_new();
@@ -684,9 +676,7 @@ static void qdict_crumple_test_bad_inputs(void)
qdict_put_str(src, "rule.3", "allow");
g_assert(qdict_crumple(src, &error) == NULL);
- g_assert(error != NULL);
- error_free(error);
- error = NULL;
+ error_free_or_abort(&error);
qobject_unref(src);
src = qdict_new();
@@ -695,9 +685,7 @@ static void qdict_crumple_test_bad_inputs(void)
qdict_put_str(src, "rule.+1", "allow");
g_assert(qdict_crumple(src, &error) == NULL);
- g_assert(error != NULL);
- error_free(error);
- error = NULL;
+ error_free_or_abort(&error);
qobject_unref(src);
}
diff --git a/tests/check-qobject.c b/tests/check-qobject.c
index 593c3a0618..6b6deaeb8b 100644
--- a/tests/check-qobject.c
+++ b/tests/check-qobject.c
@@ -9,6 +9,7 @@
#include "qemu/osdep.h"
#include "block/qdict.h"
+#include "qapi/error.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qdict.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)
{
- Error *local_err = NULL;
QDict *dict_0, *dict_1, *dict_cloned;
QDict *dict_different_key, *dict_different_value, *dict_different_null_key;
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_nested);
- dict_crumpled = qobject_to(QDict, qdict_crumple(dict_1, &local_err));
- g_assert(!local_err);
+ dict_crumpled = qobject_to(QDict, qdict_crumple(dict_1, &error_abort));
check_equal(dict_crumpled, dict_nested);
qdict_flatten(dict_nested);
diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c
index 13a824cfae..e1e0a96661 100644
--- a/tests/check-qom-proplist.c
+++ b/tests/check-qom-proplist.c
@@ -419,9 +419,7 @@ static void test_dummy_createcmdl(void)
g_assert(dobj->bv == true);
g_assert(dobj->av == DUMMY_PLATYPUS);
- user_creatable_del("dev0", &err);
- g_assert(err == NULL);
- error_free(err);
+ user_creatable_del("dev0", &error_abort);
object_unref(OBJECT(dobj));
@@ -485,8 +483,7 @@ static void test_dummy_getenum(void)
val = object_property_get_enum(OBJECT(dobj),
"av",
"DummyAnimal",
- &err);
- g_assert(err == NULL);
+ &error_abort);
g_assert(val == DUMMY_PLATYPUS);
/* A bad enum type name */
@@ -494,17 +491,14 @@ static void test_dummy_getenum(void)
"av",
"BadAnimal",
&err);
- g_assert(err != NULL);
- error_free(err);
- err = NULL;
+ error_free_or_abort(&err);
/* A non-enum property name */
val = object_property_get_enum(OBJECT(dobj),
"iv",
"DummyAnimal",
&err);
- g_assert(err != NULL);
- error_free(err);
+ error_free_or_abort(&err);
object_unparent(OBJECT(dobj));
}
diff --git a/tests/test-base64.c b/tests/test-base64.c
index ec122ceba5..a7f722c459 100644
--- a/tests/test-base64.c
+++ b/tests/test-base64.c
@@ -54,10 +54,9 @@ static void test_base64_bad(const char *input,
&len,
&err);
- g_assert(err != NULL);
+ error_free_or_abort(&err);
g_assert(actual == NULL);
g_assert_cmpint(len, ==, 0);
- error_free(err);
}
diff --git a/tests/test-bdrv-graph-mod.c b/tests/test-bdrv-graph-mod.c
index f93f3168b0..8cff13830e 100644
--- a/tests/test-bdrv-graph-mod.c
+++ b/tests/test-bdrv-graph-mod.c
@@ -115,9 +115,7 @@ static void test_update_perm_tree(void)
BDRV_CHILD_FILTERED | BDRV_CHILD_PRIMARY, &error_abort);
bdrv_append(filter, bs, &local_err);
-
- g_assert_nonnull(local_err);
- error_free(local_err);
+ error_free_or_abort(&local_err);
blk_unref(root);
}
diff --git a/tests/test-block-iothread.c b/tests/test-block-iothread.c
index a953794be2..3f866a35c6 100644
--- a/tests/test-block-iothread.c
+++ b/tests/test-block-iothread.c
@@ -650,8 +650,7 @@ static void test_propagate_mirror(void)
blk_insert_bs(blk, src, &error_abort);
bdrv_try_set_aio_context(target, ctx, &local_err);
- g_assert(local_err);
- error_free(local_err);
+ error_free_or_abort(&local_err);
g_assert(blk_get_aio_context(blk) == main_ctx);
g_assert(bdrv_get_aio_context(src) == main_ctx);
diff --git a/tests/test-crypto-cipher.c b/tests/test-crypto-cipher.c
index 07fa2fa616..bebba1a4f4 100644
--- a/tests/test-crypto-cipher.c
+++ b/tests/test-crypto-cipher.c
@@ -761,10 +761,7 @@ static void test_cipher_short_plaintext(void)
sizeof(plaintext1),
&err);
g_assert(ret == -1);
- g_assert(err != NULL);
-
- error_free(err);
- err = NULL;
+ error_free_or_abort(&err);
/* Should report an error as plaintext is larger than
* block size, but not a multiple of block size
@@ -775,9 +772,8 @@ static void test_cipher_short_plaintext(void)
sizeof(plaintext2),
&err);
g_assert(ret == -1);
- g_assert(err != NULL);
+ error_free_or_abort(&err);
- error_free(err);
qcrypto_cipher_free(cipher);
}
diff --git a/tests/test-io-task.c b/tests/test-io-task.c
index c8a3813d49..85e7a98da5 100644
--- a/tests/test-io-task.c
+++ b/tests/test-io-task.c
@@ -240,9 +240,7 @@ static void test_task_thread_failure(void)
object_unref(obj);
g_assert(data.source == obj);
- g_assert(data.err != NULL);
-
- error_free(data.err);
+ error_free_or_abort(&data.err);
self = g_thread_self();
diff --git a/tests/test-logging.c b/tests/test-logging.c
index 8580b82420..8a1161de1d 100644
--- a/tests/test-logging.c
+++ b/tests/test-logging.c
@@ -113,7 +113,6 @@ static void test_logfile_write(gconstpointer data)
QemuLogFile *logfile;
QemuLogFile *logfile2;
gchar const *dir = data;
- Error *err = NULL;
g_autofree gchar *file_path = NULL;
g_autofree gchar *file_path1 = NULL;
FILE *orig_fd;
@@ -132,8 +131,7 @@ static void test_logfile_write(gconstpointer data)
* Test that even if an open file handle is changed,
* our handle remains valid due to RCU.
*/
- qemu_set_log_filename(file_path, &err);
- g_assert(!err);
+ qemu_set_log_filename(file_path, &error_abort);
rcu_read_lock();
logfile = atomic_rcu_read(&qemu_logfile);
orig_fd = logfile->fd;
@@ -142,8 +140,7 @@ static void test_logfile_write(gconstpointer data)
fflush(logfile->fd);
/* Change the logfile and ensure that the handle is still valid. */
- qemu_set_log_filename(file_path1, &err);
- g_assert(!err);
+ qemu_set_log_filename(file_path1, &error_abort);
logfile2 = atomic_rcu_read(&qemu_logfile);
g_assert(logfile->fd == orig_fd);
g_assert(logfile2->fd != logfile->fd);
@@ -156,7 +153,6 @@ static void test_logfile_lock(gconstpointer data)
{
FILE *logfile;
gchar const *dir = data;
- Error *err = NULL;
g_autofree gchar *file_path = 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,
* 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();
g_assert(logfile);
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__);
fflush(logfile);
qemu_log_unlock(logfile);
-
- g_assert(!err);
}
/* Remove a directory and all its entries (non-recursive). */
diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c
index 2a0f42a09b..297ffe79dd 100644
--- a/tests/test-qemu-opts.c
+++ b/tests/test-qemu-opts.c
@@ -187,7 +187,6 @@ static void test_qemu_opt_get(void)
static void test_qemu_opt_get_bool(void)
{
- Error *err = NULL;
QemuOptsList *list;
QemuOpts *opts;
bool opt;
@@ -210,16 +209,14 @@ static void test_qemu_opt_get_bool(void)
opt = qemu_opt_get_bool(opts, "bool1", false);
g_assert(opt == false);
- qemu_opt_set_bool(opts, "bool1", true, &err);
- g_assert(!err);
+ qemu_opt_set_bool(opts, "bool1", true, &error_abort);
/* now we have set bool1, should know about it */
opt = qemu_opt_get_bool(opts, "bool1", false);
g_assert(opt == true);
/* having reset the value, opt should be the reset one not defval */
- qemu_opt_set_bool(opts, "bool1", false, &err);
- g_assert(!err);
+ qemu_opt_set_bool(opts, "bool1", false, &error_abort);
opt = qemu_opt_get_bool(opts, "bool1", true);
g_assert(opt == false);
@@ -233,7 +230,6 @@ static void test_qemu_opt_get_bool(void)
static void test_qemu_opt_get_number(void)
{
- Error *err = NULL;
QemuOptsList *list;
QemuOpts *opts;
uint64_t opt;
@@ -256,16 +252,14 @@ static void test_qemu_opt_get_number(void)
opt = qemu_opt_get_number(opts, "number1", 5);
g_assert(opt == 5);
- qemu_opt_set_number(opts, "number1", 10, &err);
- g_assert(!err);
+ qemu_opt_set_number(opts, "number1", 10, &error_abort);
/* now we have set number1, should know about it */
opt = qemu_opt_get_number(opts, "number1", 5);
g_assert(opt == 10);
/* having reset it, the returned should be the reset one not defval */
- qemu_opt_set_number(opts, "number1", 15, &err);
- g_assert(!err);
+ qemu_opt_set_number(opts, "number1", 15, &error_abort);
opt = qemu_opt_get_number(opts, "number1", 5);
g_assert(opt == 15);
@@ -367,7 +361,6 @@ static void test_qemu_opt_unset(void)
static void test_qemu_opts_reset(void)
{
- Error *err = NULL;
QemuOptsList *list;
QemuOpts *opts;
uint64_t opt;
@@ -390,8 +383,7 @@ static void test_qemu_opts_reset(void)
opt = qemu_opt_get_number(opts, "number1", 5);
g_assert(opt == 5);
- qemu_opt_set_number(opts, "number1", 10, &err);
- g_assert(!err);
+ qemu_opt_set_number(opts, "number1", 10, &error_abort);
/* now we have set number1, should know about it */
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)
{
- Error *err = NULL;
QemuOptsList *list;
QemuOpts *opts;
const char *opt;
@@ -421,8 +412,7 @@ static void test_qemu_opts_set(void)
g_assert(opts == NULL);
/* implicitly create opts and set str3 value */
- qemu_opts_set(list, NULL, "str3", "value", &err);
- g_assert(!err);
+ qemu_opts_set(list, NULL, "str3", "value", &error_abort);
g_assert(!QTAILQ_EMPTY(&list->head));
/* get the just created opts */
diff --git a/tests/test-replication.c b/tests/test-replication.c
index cbc37db2df..e0b03dafc2 100644
--- a/tests/test-replication.c
+++ b/tests/test-replication.c
@@ -139,8 +139,6 @@ static void make_temp(char *template)
static void prepare_imgs(void)
{
- Error *local_err = NULL;
-
make_temp(p_local_disk);
make_temp(s_local_disk);
make_temp(s_active_disk);
@@ -148,19 +146,15 @@ static void prepare_imgs(void)
/* Primary */
bdrv_img_create(p_local_disk, "qcow2", NULL, NULL, NULL, IMG_SIZE,
- BDRV_O_RDWR, true, &local_err);
- g_assert(!local_err);
+ BDRV_O_RDWR, true, &error_abort);
/* Secondary */
bdrv_img_create(s_local_disk, "qcow2", NULL, NULL, NULL, IMG_SIZE,
- BDRV_O_RDWR, true, &local_err);
- g_assert(!local_err);
+ BDRV_O_RDWR, true, &error_abort);
bdrv_img_create(s_active_disk, "qcow2", NULL, NULL, NULL, IMG_SIZE,
- BDRV_O_RDWR, true, &local_err);
- g_assert(!local_err);
+ BDRV_O_RDWR, true, &error_abort);
bdrv_img_create(s_hidden_disk, "qcow2", NULL, NULL, NULL, IMG_SIZE,
- BDRV_O_RDWR, true, &local_err);
- g_assert(!local_err);
+ BDRV_O_RDWR, true, &error_abort);
}
static void cleanup_imgs(void)
@@ -179,7 +173,6 @@ static BlockBackend *start_primary(void)
BlockBackend *blk;
QemuOpts *opts;
QDict *qdict;
- Error *local_err = NULL;
char *cmdline;
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_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(!local_err);
- monitor_add_blk(blk, P_ID, &local_err);
- g_assert(!local_err);
+ monitor_add_blk(blk, P_ID, &error_abort);
qemu_opts_del(opts);
@@ -248,12 +239,10 @@ static void test_primary_write(void)
static void test_primary_start(void)
{
BlockBackend *blk = NULL;
- Error *local_err = NULL;
blk = start_primary();
- replication_start_all(REPLICATION_MODE_PRIMARY, &local_err);
- g_assert(!local_err);
+ replication_start_all(REPLICATION_MODE_PRIMARY, &error_abort);
/* read from 0 to IMG_SIZE */
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)
{
- Error *local_err = NULL;
bool failover = true;
start_primary();
- replication_start_all(REPLICATION_MODE_PRIMARY, &local_err);
- g_assert(!local_err);
+ replication_start_all(REPLICATION_MODE_PRIMARY, &error_abort);
- replication_stop_all(failover, &local_err);
- g_assert(!local_err);
+ replication_stop_all(failover, &error_abort);
teardown_primary();
}
static void test_primary_do_checkpoint(void)
{
- Error *local_err = NULL;
-
start_primary();
- replication_start_all(REPLICATION_MODE_PRIMARY, &local_err);
- g_assert(!local_err);
+ replication_start_all(REPLICATION_MODE_PRIMARY, &error_abort);
- replication_do_checkpoint_all(&local_err);
- g_assert(!local_err);
+ replication_do_checkpoint_all(&error_abort);
teardown_primary();
}
static void test_primary_get_error_all(void)
{
- Error *local_err = NULL;
-
start_primary();
- replication_start_all(REPLICATION_MODE_PRIMARY, &local_err);
- g_assert(!local_err);
+ replication_start_all(REPLICATION_MODE_PRIMARY, &error_abort);
- replication_get_error_all(&local_err);
- g_assert(!local_err);
+ replication_get_error_all(&error_abort);
teardown_primary();
}
@@ -316,7 +294,6 @@ static BlockBackend *start_secondary(void)
QDict *qdict;
BlockBackend *blk;
char *cmdline;
- Error *local_err = NULL;
/* add s_local_disk and forge S_LOCAL_DISK_ID */
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_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);
- monitor_add_blk(blk, S_LOCAL_DISK_ID, &local_err);
- g_assert(!local_err);
+ monitor_add_blk(blk, S_LOCAL_DISK_ID, &error_abort);
/* format s_local_disk with pattern "0x11" */
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_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);
- monitor_add_blk(blk, S_ID, &local_err);
- g_assert(!local_err);
+ monitor_add_blk(blk, S_ID, &error_abort);
qemu_opts_del(opts);
@@ -420,12 +395,10 @@ static void test_secondary_write(void)
static void test_secondary_start(void)
{
BlockBackend *top_blk, *local_blk;
- Error *local_err = NULL;
bool failover = true;
top_blk = start_secondary();
- replication_start_all(REPLICATION_MODE_SECONDARY, &local_err);
- g_assert(!local_err);
+ replication_start_all(REPLICATION_MODE_SECONDARY, &error_abort);
/* read from s_local_disk (0, IMG_SIZE) */
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);
/* unblock top_bs */
- replication_stop_all(failover, &local_err);
- g_assert(!local_err);
+ replication_stop_all(failover, &error_abort);
teardown_secondary();
}
@@ -456,12 +428,10 @@ static void test_secondary_start(void)
static void test_secondary_stop(void)
{
BlockBackend *top_blk, *local_blk;
- Error *local_err = NULL;
bool failover = true;
top_blk = start_secondary();
- replication_start_all(REPLICATION_MODE_SECONDARY, &local_err);
- g_assert(!local_err);
+ replication_start_all(REPLICATION_MODE_SECONDARY, &error_abort);
/* write 0x22 to s_local_disk (IMG_SIZE / 2, IMG_SIZE) */
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);
/* do active commit */
- replication_stop_all(failover, &local_err);
- g_assert(!local_err);
+ replication_stop_all(failover, &error_abort);
/* read from s_local_disk (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)
{
BlockBackend *top_blk, *local_blk;
- Error *local_err = NULL;
top_blk = start_secondary();
- replication_start_all(REPLICATION_MODE_SECONDARY, &local_err);
- g_assert(!local_err);
+ replication_start_all(REPLICATION_MODE_SECONDARY, &error_abort);
/* write 0x22 to s_local_disk (IMG_SIZE / 2, IMG_SIZE) */
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);
/* do failover (active commit) */
- replication_stop_all(true, &local_err);
- g_assert(!local_err);
+ replication_stop_all(true, &error_abort);
/* it should ignore all requests from now on */
/* start after failover */
- replication_start_all(REPLICATION_MODE_PRIMARY, &local_err);
- g_assert(!local_err);
+ replication_start_all(REPLICATION_MODE_PRIMARY, &error_abort);
/* checkpoint */
- replication_do_checkpoint_all(&local_err);
- g_assert(!local_err);
+ replication_do_checkpoint_all(&error_abort);
/* stop */
- replication_stop_all(true, &local_err);
- g_assert(!local_err);
+ replication_stop_all(true, &error_abort);
/* read from s_local_disk (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)
{
BlockBackend *top_blk, *local_blk;
- Error *local_err = NULL;
bool failover = true;
top_blk = start_secondary();
- replication_start_all(REPLICATION_MODE_SECONDARY, &local_err);
- g_assert(!local_err);
+ replication_start_all(REPLICATION_MODE_SECONDARY, &error_abort);
/* write 0x22 to s_local_disk (IMG_SIZE / 2, IMG_SIZE) */
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,
IMG_SIZE / 2, 0, IMG_SIZE, false);
- replication_do_checkpoint_all(&local_err);
- g_assert(!local_err);
+ replication_do_checkpoint_all(&error_abort);
/* after checkpoint, read pattern 0x22 from s_local_disk */
test_blk_read(top_blk, 0x22, IMG_SIZE / 2,
IMG_SIZE / 2, 0, IMG_SIZE, false);
/* unblock top_bs */
- replication_stop_all(failover, &local_err);
- g_assert(!local_err);
+ replication_stop_all(failover, &error_abort);
teardown_secondary();
}
static void test_secondary_get_error_all(void)
{
- Error *local_err = NULL;
bool failover = true;
start_secondary();
- replication_start_all(REPLICATION_MODE_SECONDARY, &local_err);
- g_assert(!local_err);
+ replication_start_all(REPLICATION_MODE_SECONDARY, &error_abort);
- replication_get_error_all(&local_err);
- g_assert(!local_err);
+ replication_get_error_all(&error_abort);
/* unblock top_bs */
- replication_stop_all(failover, &local_err);
- g_assert(!local_err);
+ replication_stop_all(failover, &error_abort);
teardown_secondary();
}
diff --git a/tests/test-string-input-visitor.c b/tests/test-string-input-visitor.c
index 5418e085a4..249faafc9d 100644
--- a/tests/test-string-input-visitor.c
+++ b/tests/test-string-input-visitor.c
@@ -53,8 +53,7 @@ static void test_visitor_in_int(TestInputVisitorData *data,
v = visitor_input_test_init(data, "-42");
- visit_type_int(v, NULL, &res, &err);
- g_assert(!err);
+ visit_type_int(v, NULL, &res, &error_abort);
g_assert_cmpint(res, ==, value);
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,
const void *unused)
{
- Error *err = NULL;
bool res = false;
Visitor *v;
v = visitor_input_test_init(data, "true");
- visit_type_bool(v, NULL, &res, &err);
- g_assert(!err);
+ visit_type_bool(v, NULL, &res, &error_abort);
g_assert_cmpint(res, ==, true);
v = visitor_input_test_init(data, "yes");
- visit_type_bool(v, NULL, &res, &err);
- g_assert(!err);
+ visit_type_bool(v, NULL, &res, &error_abort);
g_assert_cmpint(res, ==, true);
v = visitor_input_test_init(data, "on");
- visit_type_bool(v, NULL, &res, &err);
- g_assert(!err);
+ visit_type_bool(v, NULL, &res, &error_abort);
g_assert_cmpint(res, ==, true);
v = visitor_input_test_init(data, "false");
- visit_type_bool(v, NULL, &res, &err);
- g_assert(!err);
+ visit_type_bool(v, NULL, &res, &error_abort);
g_assert_cmpint(res, ==, false);
v = visitor_input_test_init(data, "no");
- visit_type_bool(v, NULL, &res, &err);
- g_assert(!err);
+ visit_type_bool(v, NULL, &res, &error_abort);
g_assert_cmpint(res, ==, false);
v = visitor_input_test_init(data, "off");
- visit_type_bool(v, NULL, &res, &err);
- g_assert(!err);
+ visit_type_bool(v, NULL, &res, &error_abort);
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");
- visit_type_number(v, NULL, &res, &err);
- g_assert(!err);
+ visit_type_number(v, NULL, &res, &error_abort);
g_assert_cmpfloat(res, ==, value);
/* NaN and infinity has to be rejected */
@@ -399,13 +390,11 @@ static void test_visitor_in_string(TestInputVisitorData *data,
const void *unused)
{
char *res = NULL, *value = (char *) "Q E M U";
- Error *err = NULL;
Visitor *v;
v = visitor_input_test_init(data, value);
- visit_type_str(v, NULL, &res, &err);
- g_assert(!err);
+ visit_type_str(v, NULL, &res, &error_abort);
g_assert_cmpstr(res, ==, value);
g_free(res);
@@ -414,7 +403,6 @@ static void test_visitor_in_string(TestInputVisitorData *data,
static void test_visitor_in_enum(TestInputVisitorData *data,
const void *unused)
{
- Error *err = NULL;
Visitor *v;
EnumOne i;
@@ -423,8 +411,7 @@ static void test_visitor_in_enum(TestInputVisitorData *data,
v = visitor_input_test_init(data, EnumOne_str(i));
- visit_type_EnumOne(v, NULL, &res, &err);
- g_assert(!err);
+ visit_type_EnumOne(v, NULL, &res, &error_abort);
g_assert_cmpint(i, ==, res);
}
}
diff --git a/tests/test-string-output-visitor.c b/tests/test-string-output-visitor.c
index 3bd732222c..9f6581439a 100644
--- a/tests/test-string-output-visitor.c
+++ b/tests/test-string-output-visitor.c
@@ -71,11 +71,9 @@ static void test_visitor_out_int(TestOutputVisitorData *data,
const void *unused)
{
int64_t value = 42;
- Error *err = NULL;
char *str;
- visit_type_int(data->ov, NULL, &value, &err);
- g_assert(!err);
+ visit_type_int(data->ov, NULL, &value, &error_abort);
str = visitor_get(data);
if (data->human) {
@@ -120,12 +118,10 @@ static void test_visitor_out_intList(TestOutputVisitorData *data,
static void test_visitor_out_bool(TestOutputVisitorData *data,
const void *unused)
{
- Error *err = NULL;
bool value = true;
char *str;
- visit_type_bool(data->ov, NULL, &value, &err);
- g_assert(!err);
+ visit_type_bool(data->ov, NULL, &value, &error_abort);
str = visitor_get(data);
g_assert_cmpstr(str, ==, "true");
@@ -135,11 +131,9 @@ static void test_visitor_out_number(TestOutputVisitorData *data,
const void *unused)
{
double value = 3.14;
- Error *err = NULL;
char *str;
- visit_type_number(data->ov, NULL, &value, &err);
- g_assert(!err);
+ visit_type_number(data->ov, NULL, &value, &error_abort);
str = visitor_get(data);
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";
const char *string_human = "\"Q E M U\"";
- Error *err = NULL;
char *str;
- visit_type_str(data->ov, NULL, &string, &err);
- g_assert(!err);
+ visit_type_str(data->ov, NULL, &string, &error_abort);
str = visitor_get(data);
if (data->human) {
diff --git a/tests/test-util-filemonitor.c b/tests/test-util-filemonitor.c
index 45009c69f4..8f0eff3d03 100644
--- a/tests/test-util-filemonitor.c
+++ b/tests/test-util-filemonitor.c
@@ -495,6 +495,7 @@ test_file_monitor_events(void)
if (*op->watchid < 0) {
g_printerr("Unable to add watch %s",
error_get_pretty(local_err));
+ error_free(local_err);
goto cleanup;
}
if (debug) {