]> git.proxmox.com Git - mirror_zfs.git/commitdiff
ztest: Clean up use of ASSERT and VERIFY
authorRyan Moeller <ryan@iXsystems.com>
Wed, 13 Jan 2021 01:21:01 +0000 (20:21 -0500)
committerGitHub <noreply@github.com>
Wed, 13 Jan 2021 01:21:01 +0000 (17:21 -0800)
Try to use more appropriate ASSERT and VERIFY variants in ztest.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #11454

cmd/ztest/ztest.c

index b64dab0fdba4a97e4298dcc2a3c4407ef61fb788..ab20a635d55a820788effacd7228dae0a0bc0936 100644 (file)
@@ -998,13 +998,13 @@ process_options(int argc, char **argv)
                cmd = umem_alloc(MAXPATHLEN, UMEM_NOFAIL);
                realaltdir = umem_alloc(MAXPATHLEN, UMEM_NOFAIL);
 
-               VERIFY(NULL != realpath(getexecname(), cmd));
+               VERIFY3P(NULL, !=, realpath(getexecname(), cmd));
                if (0 != access(altdir, F_OK)) {
                        ztest_dump_core = B_FALSE;
                        fatal(B_TRUE, "invalid alternate ztest path: %s",
                            altdir);
                }
-               VERIFY(NULL != realpath(altdir, realaltdir));
+               VERIFY3P(NULL, !=, realpath(altdir, realaltdir));
 
                /*
                 * 'cmd' should be of the form "<anything>/usr/bin/<isa>/ztest".
@@ -1217,7 +1217,7 @@ make_vdev_root(char *path, char *aux, char *pool, size_t size, uint64_t ashift,
        int c;
        boolean_t log;
 
-       ASSERT(t > 0);
+       ASSERT3S(t, >, 0);
 
        log = (class != NULL && strcmp(class, "log") == 0);
 
@@ -1272,7 +1272,7 @@ ztest_random_spa_version(uint64_t initial_version)
 static int
 ztest_random_blocksize(void)
 {
-       ASSERT(ztest_spa->spa_max_ashift != 0);
+       ASSERT3U(ztest_spa->spa_max_ashift, !=, 0);
 
        /*
         * Choose a block size >= the ashift.
@@ -1330,7 +1330,7 @@ ztest_random_vdev_top(spa_t *spa, boolean_t log_ok)
        vdev_t *rvd = spa->spa_root_vdev;
        vdev_t *tvd;
 
-       ASSERT(spa_config_held(spa, SCL_ALL, RW_READER) != 0);
+       ASSERT3U(spa_config_held(spa, SCL_ALL, RW_READER), !=, 0);
 
        do {
                top = ztest_random(rvd->vdev_children);
@@ -1481,8 +1481,8 @@ ztest_rll_init(rll_t *rll)
 static void
 ztest_rll_destroy(rll_t *rll)
 {
-       ASSERT(rll->rll_writer == NULL);
-       ASSERT(rll->rll_readers == 0);
+       ASSERT3P(rll->rll_writer, ==, NULL);
+       ASSERT0(rll->rll_readers);
        mutex_destroy(&rll->rll_lock);
        cv_destroy(&rll->rll_cv);
 }
@@ -1511,11 +1511,11 @@ ztest_rll_unlock(rll_t *rll)
        mutex_enter(&rll->rll_lock);
 
        if (rll->rll_writer) {
-               ASSERT(rll->rll_readers == 0);
+               ASSERT0(rll->rll_readers);
                rll->rll_writer = NULL;
        } else {
-               ASSERT(rll->rll_readers != 0);
-               ASSERT(rll->rll_writer == NULL);
+               ASSERT3S(rll->rll_readers, >, 0);
+               ASSERT3P(rll->rll_writer, ==, NULL);
                rll->rll_readers--;
        }
 
@@ -1621,7 +1621,7 @@ ztest_tx_assign(dmu_tx_t *tx, uint64_t txg_how, const char *tag)
        error = dmu_tx_assign(tx, txg_how);
        if (error) {
                if (error == ERESTART) {
-                       ASSERT(txg_how == TXG_NOWAIT);
+                       ASSERT3U(txg_how, ==, TXG_NOWAIT);
                        dmu_tx_wait(tx);
                } else {
                        ASSERT3U(error, ==, ENOSPC);
@@ -1631,7 +1631,7 @@ ztest_tx_assign(dmu_tx_t *tx, uint64_t txg_how, const char *tag)
                return (0);
        }
        txg = dmu_tx_get_txg(tx);
-       ASSERT(txg != 0);
+       ASSERT3U(txg, !=, 0);
        return (txg);
 }
 
@@ -1854,8 +1854,8 @@ ztest_replay_create(void *arg1, void *arg2, boolean_t byteswap)
        if (byteswap)
                byteswap_uint64_array(lr, sizeof (*lr));
 
-       ASSERT(lr->lr_doid == ZTEST_DIROBJ);
-       ASSERT(name[0] != '\0');
+       ASSERT3U(lr->lr_doid, ==, ZTEST_DIROBJ);
+       ASSERT3S(name[0], !=, '\0');
 
        tx = dmu_tx_create(os);
 
@@ -1871,7 +1871,7 @@ ztest_replay_create(void *arg1, void *arg2, boolean_t byteswap)
        if (txg == 0)
                return (ENOSPC);
 
-       ASSERT(dmu_objset_zil(os)->zl_replay == !!lr->lr_foid);
+       ASSERT3U(dmu_objset_zil(os)->zl_replay, ==, !!lr->lr_foid);
        bonuslen = DN_BONUS_SIZE(lr->lrz_dnodesize);
 
        if (lr->lrz_type == DMU_OT_ZAP_OTHER) {
@@ -1903,13 +1903,13 @@ ztest_replay_create(void *arg1, void *arg2, boolean_t byteswap)
                return (error);
        }
 
-       ASSERT(lr->lr_foid != 0);
+       ASSERT3U(lr->lr_foid, !=, 0);
 
        if (lr->lrz_type != DMU_OT_ZAP_OTHER)
-               VERIFY3U(0, ==, dmu_object_set_blocksize(os, lr->lr_foid,
+               VERIFY0(dmu_object_set_blocksize(os, lr->lr_foid,
                    lr->lrz_blocksize, lr->lrz_ibshift, tx));
 
-       VERIFY3U(0, ==, dmu_bonus_hold(os, lr->lr_foid, FTAG, &db));
+       VERIFY0(dmu_bonus_hold(os, lr->lr_foid, FTAG, &db));
        bbt = ztest_bt_bonus(db);
        dmu_buf_will_dirty(db, tx);
        ztest_bt_generate(bbt, os, lr->lr_foid, lr->lrz_dnodesize, -1ULL,
@@ -1917,7 +1917,7 @@ ztest_replay_create(void *arg1, void *arg2, boolean_t byteswap)
        ztest_fill_unused_bonus(db, bbt, lr->lr_foid, os, lr->lr_gen);
        dmu_buf_rele(db, FTAG);
 
-       VERIFY3U(0, ==, zap_add(os, lr->lr_doid, name, sizeof (uint64_t), 1,
+       VERIFY0(zap_add(os, lr->lr_doid, name, sizeof (uint64_t), 1,
            &lr->lr_foid, tx));
 
        (void) ztest_log_create(zd, tx, lr);
@@ -1941,16 +1941,16 @@ ztest_replay_remove(void *arg1, void *arg2, boolean_t byteswap)
        if (byteswap)
                byteswap_uint64_array(lr, sizeof (*lr));
 
-       ASSERT(lr->lr_doid == ZTEST_DIROBJ);
-       ASSERT(name[0] != '\0');
+       ASSERT3U(lr->lr_doid, ==, ZTEST_DIROBJ);
+       ASSERT3S(name[0], !=, '\0');
 
-       VERIFY3U(0, ==,
+       VERIFY0(
            zap_lookup(os, lr->lr_doid, name, sizeof (object), 1, &object));
-       ASSERT(object != 0);
+       ASSERT3U(object, !=, 0);
 
        ztest_object_lock(zd, object, RL_WRITER);
 
-       VERIFY3U(0, ==, dmu_object_info(os, object, &doi));
+       VERIFY0(dmu_object_info(os, object, &doi));
 
        tx = dmu_tx_create(os);
 
@@ -1964,12 +1964,12 @@ ztest_replay_remove(void *arg1, void *arg2, boolean_t byteswap)
        }
 
        if (doi.doi_type == DMU_OT_ZAP_OTHER) {
-               VERIFY3U(0, ==, zap_destroy(os, object, tx));
+               VERIFY0(zap_destroy(os, object, tx));
        } else {
-               VERIFY3U(0, ==, dmu_object_free(os, object, tx));
+               VERIFY0(dmu_object_free(os, object, tx));
        }
 
-       VERIFY3U(0, ==, zap_remove(os, lr->lr_doid, name, tx));
+       VERIFY0(zap_remove(os, lr->lr_doid, name, tx));
 
        (void) ztest_log_remove(zd, tx, lr, object);
 
@@ -2021,7 +2021,7 @@ ztest_replay_write(void *arg1, void *arg2, boolean_t byteswap)
        ztest_object_lock(zd, lr->lr_foid, RL_READER);
        rl = ztest_range_lock(zd, lr->lr_foid, offset, length, RL_WRITER);
 
-       VERIFY3U(0, ==, dmu_bonus_hold(os, lr->lr_foid, FTAG, &db));
+       VERIFY0(dmu_bonus_hold(os, lr->lr_foid, FTAG, &db));
 
        dmu_object_info_from_db(db, &doi);
 
@@ -2055,7 +2055,7 @@ ztest_replay_write(void *arg1, void *arg2, boolean_t byteswap)
                 * but not always, because we also want to verify correct
                 * behavior when the data was not recently read into cache.
                 */
-               ASSERT(offset % doi.doi_data_block_size == 0);
+               ASSERT0(offset % doi.doi_data_block_size);
                if (ztest_random(4) != 0) {
                        int prefetch = ztest_random(2) ?
                            DMU_READ_PREFETCH : DMU_READ_NO_PREFETCH;
@@ -2136,8 +2136,8 @@ ztest_replay_truncate(void *arg1, void *arg2, boolean_t byteswap)
                return (ENOSPC);
        }
 
-       VERIFY(dmu_free_range(os, lr->lr_foid, lr->lr_offset,
-           lr->lr_length, tx) == 0);
+       VERIFY0(dmu_free_range(os, lr->lr_foid, lr->lr_offset,
+           lr->lr_length, tx));
 
        (void) ztest_log_truncate(zd, tx, lr);
 
@@ -2165,7 +2165,7 @@ ztest_replay_setattr(void *arg1, void *arg2, boolean_t byteswap)
 
        ztest_object_lock(zd, lr->lr_foid, RL_WRITER);
 
-       VERIFY3U(0, ==, dmu_bonus_hold(os, lr->lr_foid, FTAG, &db));
+       VERIFY0(dmu_bonus_hold(os, lr->lr_foid, FTAG, &db));
 
        tx = dmu_tx_create(os);
        dmu_tx_hold_bonus(tx, lr->lr_foid);
@@ -2184,9 +2184,9 @@ ztest_replay_setattr(void *arg1, void *arg2, boolean_t byteswap)
        dnodesize = bbt->bt_dnodesize;
 
        if (zd->zd_zilog->zl_replay) {
-               ASSERT(lr->lr_size != 0);
-               ASSERT(lr->lr_mode != 0);
-               ASSERT(lrtxg != 0);
+               ASSERT3U(lr->lr_size, !=, 0);
+               ASSERT3U(lr->lr_mode, !=, 0);
+               ASSERT3U(lrtxg, !=, 0);
        } else {
                /*
                 * Randomly change the size and increment the generation.
@@ -2194,7 +2194,7 @@ ztest_replay_setattr(void *arg1, void *arg2, boolean_t byteswap)
                lr->lr_size = (ztest_random(db->db_size / sizeof (*bbt)) + 1) *
                    sizeof (*bbt);
                lr->lr_mode = bbt->bt_gen + 1;
-               ASSERT(lrtxg == 0);
+               ASSERT0(lrtxg);
        }
 
        /*
@@ -2316,13 +2316,13 @@ ztest_get_data(void *arg, lr_write_t *lr, char *buf, struct lwb *lwb,
 
                error = dmu_read(os, object, offset, size, buf,
                    DMU_READ_NO_PREFETCH);
-               ASSERT(error == 0);
+               ASSERT0(error);
        } else {
                size = doi.doi_data_block_size;
                if (ISP2(size)) {
                        offset = P2ALIGN(offset, size);
                } else {
-                       ASSERT(offset < size);
+                       ASSERT3U(offset, <, size);
                        offset = 0;
                }
 
@@ -2338,8 +2338,8 @@ ztest_get_data(void *arg, lr_write_t *lr, char *buf, struct lwb *lwb,
                        zgd->zgd_db = db;
                        zgd->zgd_bp = bp;
 
-                       ASSERT(db->db_offset == offset);
-                       ASSERT(db->db_size == size);
+                       ASSERT3U(db->db_offset, ==, offset);
+                       ASSERT3U(db->db_size, ==, size);
 
                        error = dmu_sync(zio, lr->lr_common.lrc_txg,
                            ztest_get_done, zgd);
@@ -2393,20 +2393,20 @@ ztest_lookup(ztest_ds_t *zd, ztest_od_t *od, int count)
                error = zap_lookup(zd->zd_os, od->od_dir, od->od_name,
                    sizeof (uint64_t), 1, &od->od_object);
                if (error) {
-                       ASSERT(error == ENOENT);
-                       ASSERT(od->od_object == 0);
+                       ASSERT3S(error, ==, ENOENT);
+                       ASSERT0(od->od_object);
                        missing++;
                } else {
                        dmu_buf_t *db;
                        ztest_block_tag_t *bbt;
                        dmu_object_info_t doi;
 
-                       ASSERT(od->od_object != 0);
-                       ASSERT(missing == 0);   /* there should be no gaps */
+                       ASSERT3U(od->od_object, !=, 0);
+                       ASSERT0(missing);       /* there should be no gaps */
 
                        ztest_object_lock(zd, od->od_object, RL_READER);
-                       VERIFY3U(0, ==, dmu_bonus_hold(zd->zd_os,
-                           od->od_object, FTAG, &db));
+                       VERIFY0(dmu_bonus_hold(zd->zd_os, od->od_object,
+                           FTAG, &db));
                        dmu_object_info_from_db(db, &doi);
                        bbt = ztest_bt_bonus(db);
                        ASSERT3U(bbt->bt_magic, ==, BT_MAGIC);
@@ -2449,7 +2449,7 @@ ztest_create(ztest_ds_t *zd, ztest_od_t *od, int count)
                lr->lr_crtime[0] = time(NULL);
 
                if (ztest_replay_create(zd, lr, B_FALSE) != 0) {
-                       ASSERT(missing == 0);
+                       ASSERT0(missing);
                        od->od_object = 0;
                        missing++;
                } else {
@@ -2457,7 +2457,7 @@ ztest_create(ztest_ds_t *zd, ztest_od_t *od, int count)
                        od->od_type = od->od_crtype;
                        od->od_blocksize = od->od_crblocksize;
                        od->od_gen = od->od_crgen;
-                       ASSERT(od->od_object != 0);
+                       ASSERT3U(od->od_object, !=, 0);
                }
 
                ztest_lr_free(lr, sizeof (*lr), od->od_name);
@@ -2608,7 +2608,7 @@ ztest_io(ztest_ds_t *zd, uint64_t object, uint64_t offset)
        uint64_t blocksize;
        void *data;
 
-       VERIFY(dmu_object_info(zd->zd_os, object, &doi) == 0);
+       VERIFY0(dmu_object_info(zd->zd_os, object, &doi));
        blocksize = doi.doi_data_block_size;
        data = umem_alloc(blocksize, UMEM_NOFAIL);
 
@@ -2746,7 +2746,7 @@ ztest_zil_commit(ztest_ds_t *zd, uint64_t id)
         * will verify that the log really does contain this record.
         */
        mutex_enter(&zilog->zl_lock);
-       ASSERT(zd->zd_shared != NULL);
+       ASSERT3P(zd->zd_shared, !=, NULL);
        ASSERT3U(zd->zd_shared->zd_seq, <=, zilog->zl_commit_lr_seq);
        zd->zd_shared->zd_seq = zilog->zl_commit_lr_seq;
        mutex_exit(&zilog->zl_lock);
@@ -2784,7 +2784,7 @@ ztest_zil_remount(ztest_ds_t *zd, uint64_t id)
        zil_close(zd->zd_zilog);
 
        /* zfsvfs_setup() */
-       VERIFY(zil_open(os, ztest_get_data) == zd->zd_zilog);
+       VERIFY3P(zil_open(os, ztest_get_data), ==, zd->zd_zilog);
        zil_replay(os, zd, ztest_replay_vector);
 
        (void) pthread_rwlock_unlock(&zd->zd_zilog_lock);
@@ -2844,7 +2844,7 @@ ztest_spa_create_destroy(ztest_ds_t *zd, uint64_t id)
         *      For the case that there is another ztest thread doing
         *      an export concurrently.
         */
-       VERIFY3U(0, ==, spa_open(zo->zo_pool, &spa, FTAG));
+       VERIFY0(spa_open(zo->zo_pool, &spa, FTAG));
        int error = spa_destroy(zo->zo_pool);
        if (error != EBUSY && error != ZFS_ERR_EXPORT_IN_PROGRESS) {
                fatal(0, "spa_destroy(%s) returned unexpected value %d",
@@ -2961,11 +2961,11 @@ ztest_spa_upgrade(ztest_ds_t *zd, uint64_t id)
        props = fnvlist_alloc();
        fnvlist_add_uint64(props,
            zpool_prop_to_name(ZPOOL_PROP_VERSION), version);
-       VERIFY3S(spa_create(name, nvroot, props, NULL, NULL), ==, 0);
+       VERIFY0(spa_create(name, nvroot, props, NULL, NULL));
        fnvlist_free(nvroot);
        fnvlist_free(props);
 
-       VERIFY3S(spa_open(name, &spa, FTAG), ==, 0);
+       VERIFY0(spa_open(name, &spa, FTAG));
        VERIFY3U(spa_version(spa), ==, version);
        newversion = ztest_random_spa_version(version + 1);
 
@@ -3512,18 +3512,18 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id)
 
        /* pick a child from the mirror */
        if (zs->zs_mirrors >= 1) {
-               ASSERT(oldvd->vdev_ops == &vdev_mirror_ops);
-               ASSERT(oldvd->vdev_children >= zs->zs_mirrors);
+               ASSERT3P(oldvd->vdev_ops, ==, &vdev_mirror_ops);
+               ASSERT3U(oldvd->vdev_children, >=, zs->zs_mirrors);
                oldvd = oldvd->vdev_child[leaf / ztest_opts.zo_raid_children];
        }
 
        /* pick a child out of the raidz group */
        if (ztest_opts.zo_raid_children > 1) {
                if (strcmp(oldvd->vdev_ops->vdev_op_type, "raidz") == 0)
-                       ASSERT(oldvd->vdev_ops == &vdev_raidz_ops);
+                       ASSERT3P(oldvd->vdev_ops, ==, &vdev_raidz_ops);
                else
-                       ASSERT(oldvd->vdev_ops == &vdev_draid_ops);
-               ASSERT(oldvd->vdev_children == ztest_opts.zo_raid_children);
+                       ASSERT3P(oldvd->vdev_ops, ==, &vdev_draid_ops);
+               ASSERT3U(oldvd->vdev_children, ==, ztest_opts.zo_raid_children);
                oldvd = oldvd->vdev_child[leaf % ztest_opts.zo_raid_children];
        }
 
@@ -3533,7 +3533,7 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id)
         */
        while (oldvd->vdev_children != 0) {
                oldvd_has_siblings = B_TRUE;
-               ASSERT(oldvd->vdev_children >= 2);
+               ASSERT3U(oldvd->vdev_children, >=, 2);
                oldvd = oldvd->vdev_child[ztest_random(oldvd->vdev_children)];
        }
 
@@ -3760,14 +3760,14 @@ grow_vdev(vdev_t *vd, void *arg)
        size_t fsize;
        int fd;
 
-       ASSERT(spa_config_held(spa, SCL_STATE, RW_READER) == SCL_STATE);
+       ASSERT3S(spa_config_held(spa, SCL_STATE, RW_READER), ==, SCL_STATE);
        ASSERT(vd->vdev_ops->vdev_op_leaf);
 
        if ((fd = open(vd->vdev_path, O_RDWR)) == -1)
                return (vd);
 
        fsize = lseek(fd, 0, SEEK_END);
-       VERIFY(ftruncate(fd, *newsize) == 0);
+       VERIFY0(ftruncate(fd, *newsize));
 
        if (ztest_opts.zo_verbose >= 6) {
                (void) printf("%s grew from %lu to %lu bytes\n",
@@ -3791,7 +3791,7 @@ online_vdev(vdev_t *vd, void *arg)
        vdev_state_t newstate = VDEV_STATE_UNKNOWN;
        int error;
 
-       ASSERT(spa_config_held(spa, SCL_STATE, RW_READER) == SCL_STATE);
+       ASSERT3S(spa_config_held(spa, SCL_STATE, RW_READER), ==, SCL_STATE);
        ASSERT(vd->vdev_ops->vdev_op_leaf);
 
        /* Calling vdev_online will initialize the new metaslabs */
@@ -3922,7 +3922,7 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id)
                mutex_exit(&ztest_checkpoint_lock);
                return;
        }
-       ASSERT(psize > 0);
+       ASSERT3U(psize, >, 0);
        newsize = psize + MAX(psize / 8, SPA_MAXBLOCKSIZE);
        ASSERT3U(newsize, >, psize);
 
@@ -4024,8 +4024,8 @@ ztest_objset_create_cb(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx)
        /*
         * Create the objects common to all ztest datasets.
         */
-       VERIFY(zap_create_claim(os, ZTEST_DIROBJ,
-           DMU_OT_ZAP_OTHER, DMU_OT_NONE, 0, tx) == 0);
+       VERIFY0(zap_create_claim(os, ZTEST_DIROBJ,
+           DMU_OT_ZAP_OTHER, DMU_OT_NONE, 0, tx));
 }
 
 static int
@@ -4261,7 +4261,7 @@ ztest_dmu_objset_create_destroy(ztest_ds_t *zd, uint64_t id)
        /*
         * Verify that we can hold an objset that is also owned.
         */
-       VERIFY3U(0, ==, dmu_objset_hold(name, FTAG, &os2));
+       VERIFY0(dmu_objset_hold(name, FTAG, &os2));
        dmu_objset_rele(os2, FTAG);
 
        /*
@@ -4573,7 +4573,7 @@ ztest_dmu_read_write(ztest_ds_t *zd, uint64_t id)
        bigobj = od[0].od_object;
        packobj = od[1].od_object;
        chunksize = od[0].od_gen;
-       ASSERT(chunksize == od[1].od_gen);
+       ASSERT3U(chunksize, ==, od[1].od_gen);
 
        /*
         * Prefetch a random chunk of the big object.
@@ -4668,8 +4668,8 @@ ztest_dmu_read_write(ztest_ds_t *zd, uint64_t id)
                /* LINTED */
                bigT = (bufwad_t *)((char *)bigH + chunksize) - 1;
 
-               ASSERT((uintptr_t)bigH - (uintptr_t)bigbuf < bigsize);
-               ASSERT((uintptr_t)bigT - (uintptr_t)bigbuf < bigsize);
+               ASSERT3U((uintptr_t)bigH - (uintptr_t)bigbuf, <, bigsize);
+               ASSERT3U((uintptr_t)bigT - (uintptr_t)bigbuf, <, bigsize);
 
                if (pack->bw_txg > txg)
                        fatal(0, "future leak: got %llx, open txg is %llx",
@@ -4710,7 +4710,7 @@ ztest_dmu_read_write(ztest_ds_t *zd, uint64_t id)
                            (u_longlong_t)bigsize,
                            (u_longlong_t)txg);
                }
-               VERIFY(0 == dmu_free_range(os, bigobj, bigoff, bigsize, tx));
+               VERIFY0(dmu_free_range(os, bigobj, bigoff, bigsize, tx));
        } else {
                if (ztest_opts.zo_verbose >= 7) {
                        (void) printf("writing offset %llx size %llx"
@@ -4731,13 +4731,13 @@ ztest_dmu_read_write(ztest_ds_t *zd, uint64_t id)
                void *packcheck = umem_alloc(packsize, UMEM_NOFAIL);
                void *bigcheck = umem_alloc(bigsize, UMEM_NOFAIL);
 
-               VERIFY(0 == dmu_read(os, packobj, packoff,
+               VERIFY0(dmu_read(os, packobj, packoff,
                    packsize, packcheck, DMU_READ_PREFETCH));
-               VERIFY(0 == dmu_read(os, bigobj, bigoff,
+               VERIFY0(dmu_read(os, bigobj, bigoff,
                    bigsize, bigcheck, DMU_READ_PREFETCH));
 
-               ASSERT(bcmp(packbuf, packcheck, packsize) == 0);
-               ASSERT(bcmp(bigbuf, bigcheck, bigsize) == 0);
+               ASSERT0(bcmp(packbuf, packcheck, packsize));
+               ASSERT0(bcmp(bigbuf, bigcheck, bigsize));
 
                umem_free(packcheck, packsize);
                umem_free(bigcheck, bigsize);
@@ -4771,8 +4771,8 @@ compare_and_update_pbbufs(uint64_t s, bufwad_t *packbuf, bufwad_t *bigbuf,
                /* LINTED */
                bigT = (bufwad_t *)((char *)bigH + chunksize) - 1;
 
-               ASSERT((uintptr_t)bigH - (uintptr_t)bigbuf < bigsize);
-               ASSERT((uintptr_t)bigT - (uintptr_t)bigbuf < bigsize);
+               ASSERT3U((uintptr_t)bigH - (uintptr_t)bigbuf, <, bigsize);
+               ASSERT3U((uintptr_t)bigT - (uintptr_t)bigbuf, <, bigsize);
 
                if (pack->bw_txg > txg)
                        fatal(0, "future leak: got %llx, open txg is %llx",
@@ -4857,12 +4857,12 @@ ztest_dmu_read_write_zcopy(ztest_ds_t *zd, uint64_t id)
        packobj = od[1].od_object;
        blocksize = od[0].od_blocksize;
        chunksize = blocksize;
-       ASSERT(chunksize == od[1].od_gen);
+       ASSERT3U(chunksize, ==, od[1].od_gen);
 
-       VERIFY(dmu_object_info(os, bigobj, &doi) == 0);
+       VERIFY0(dmu_object_info(os, bigobj, &doi));
        VERIFY(ISP2(doi.doi_data_block_size));
-       VERIFY(chunksize == doi.doi_data_block_size);
-       VERIFY(chunksize >= 2 * sizeof (bufwad_t));
+       VERIFY3U(chunksize, ==, doi.doi_data_block_size);
+       VERIFY3U(chunksize, >=, 2 * sizeof (bufwad_t));
 
        /*
         * Pick a random index and compute the offsets into packobj and bigobj.
@@ -4879,7 +4879,7 @@ ztest_dmu_read_write_zcopy(ztest_ds_t *zd, uint64_t id)
        packbuf = umem_zalloc(packsize, UMEM_NOFAIL);
        bigbuf = umem_zalloc(bigsize, UMEM_NOFAIL);
 
-       VERIFY3U(0, ==, dmu_bonus_hold(os, bigobj, FTAG, &bonus_db));
+       VERIFY0(dmu_bonus_hold(os, bigobj, FTAG, &bonus_db));
 
        bigbuf_arcbufs = umem_zalloc(2 * s * sizeof (arc_buf_t *), UMEM_NOFAIL);
 
@@ -5148,19 +5148,19 @@ ztest_zap(ztest_ds_t *zd, uint64_t id)
                goto out;
        for (i = 0; i < 2; i++) {
                value[i] = i;
-               VERIFY3U(0, ==, zap_add(os, object, hc[i], sizeof (uint64_t),
+               VERIFY0(zap_add(os, object, hc[i], sizeof (uint64_t),
                    1, &value[i], tx));
        }
        for (i = 0; i < 2; i++) {
                VERIFY3U(EEXIST, ==, zap_add(os, object, hc[i],
                    sizeof (uint64_t), 1, &value[i], tx));
-               VERIFY3U(0, ==,
+               VERIFY0(
                    zap_length(os, object, hc[i], &zl_intsize, &zl_ints));
                ASSERT3U(zl_intsize, ==, sizeof (uint64_t));
                ASSERT3U(zl_ints, ==, 1);
        }
        for (i = 0; i < 2; i++) {
-               VERIFY3U(0, ==, zap_remove(os, object, hc[i], tx));
+               VERIFY0(zap_remove(os, object, hc[i], tx));
        }
        dmu_tx_commit(tx);
 
@@ -5183,17 +5183,17 @@ ztest_zap(ztest_ds_t *zd, uint64_t id)
                ASSERT3U(zl_intsize, ==, sizeof (uint64_t));
                ASSERT3U(zl_ints, ==, 1);
 
-               VERIFY(zap_lookup(os, object, txgname, zl_intsize,
-                   zl_ints, &last_txg) == 0);
+               VERIFY0(zap_lookup(os, object, txgname, zl_intsize,
+                   zl_ints, &last_txg));
 
-               VERIFY(zap_length(os, object, propname, &zl_intsize,
-                   &zl_ints) == 0);
+               VERIFY0(zap_length(os, object, propname, &zl_intsize,
+                   &zl_ints));
 
                ASSERT3U(zl_intsize, ==, sizeof (uint64_t));
                ASSERT3U(zl_ints, ==, ints);
 
-               VERIFY(zap_lookup(os, object, propname, zl_intsize,
-                   zl_ints, value) == 0);
+               VERIFY0(zap_lookup(os, object, propname, zl_intsize,
+                   zl_ints, value));
 
                for (i = 0; i < ints; i++) {
                        ASSERT3U(value[i], ==, last_txg + object + i);
@@ -5221,9 +5221,9 @@ ztest_zap(ztest_ds_t *zd, uint64_t id)
        for (i = 0; i < ints; i++)
                value[i] = txg + object + i;
 
-       VERIFY3U(0, ==, zap_update(os, object, txgname, sizeof (uint64_t),
+       VERIFY0(zap_update(os, object, txgname, sizeof (uint64_t),
            1, &txg, tx));
-       VERIFY3U(0, ==, zap_update(os, object, propname, sizeof (uint64_t),
+       VERIFY0(zap_update(os, object, propname, sizeof (uint64_t),
            ints, value, tx));
 
        dmu_tx_commit(tx);
@@ -5247,8 +5247,8 @@ ztest_zap(ztest_ds_t *zd, uint64_t id)
        txg = ztest_tx_assign(tx, TXG_MIGHTWAIT, FTAG);
        if (txg == 0)
                goto out;
-       VERIFY3U(0, ==, zap_remove(os, object, txgname, tx));
-       VERIFY3U(0, ==, zap_remove(os, object, propname, tx));
+       VERIFY0(zap_remove(os, object, txgname, tx));
+       VERIFY0(zap_remove(os, object, propname, tx));
        dmu_tx_commit(tx);
 out:
        umem_free(od, sizeof (ztest_od_t));
@@ -5350,7 +5350,7 @@ ztest_zap_parallel(ztest_ds_t *zd, uint64_t id)
 
        count = -1ULL;
        VERIFY0(zap_count(os, object, &count));
-       ASSERT(count != -1ULL);
+       ASSERT3S(count, !=, -1ULL);
 
        /*
         * Select an operation: length, lookup, add, update, remove.
@@ -5402,7 +5402,7 @@ ztest_zap_parallel(ztest_ds_t *zd, uint64_t id)
                break;
 
        case 3:
-               VERIFY(zap_update(os, object, name, wsize, wc, data, tx) == 0);
+               VERIFY0(zap_update(os, object, name, wsize, wc, data, tx));
                break;
 
        case 4:
@@ -5436,7 +5436,7 @@ ztest_commit_callback(void *arg, int error)
        ztest_cb_data_t *data = arg;
        uint64_t synced_txg;
 
-       VERIFY(data != NULL);
+       VERIFY3P(data, !=, NULL);
        VERIFY3S(data->zcd_expected_err, ==, error);
        VERIFY(!data->zcd_called);
 
@@ -5562,7 +5562,7 @@ ztest_dmu_commit_callbacks(ztest_ds_t *zd, uint64_t id)
        /*
         * Read existing data to make sure there isn't a future leak.
         */
-       VERIFY(0 == dmu_read(os, od->od_object, 0, sizeof (uint64_t),
+       VERIFY0(dmu_read(os, od->od_object, 0, sizeof (uint64_t),
            &old_txg, DMU_READ_PREFETCH));
 
        if (old_txg > txg)
@@ -5898,7 +5898,7 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id)
        mirror_save = zs->zs_mirrors;
        mutex_exit(&ztest_vdev_lock);
 
-       ASSERT(leaves >= 1);
+       ASSERT3U(leaves, >=, 1);
 
        /*
         * While ztest is running the number of leaves will not change.  This
@@ -6027,7 +6027,7 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id)
                        if (islog)
                                (void) pthread_rwlock_wrlock(&ztest_name_lock);
 
-                       VERIFY(vdev_offline(spa, guid0, flags) != EBUSY);
+                       VERIFY3U(vdev_offline(spa, guid0, flags), !=, EBUSY);
 
                        if (islog)
                                (void) pthread_rwlock_unlock(&ztest_name_lock);
@@ -6398,7 +6398,7 @@ ztest_get_zdb_bin(char *bin, int len)
                return;
        }
 
-       VERIFY(realpath(getexecname(), bin) != NULL);
+       VERIFY3P(realpath(getexecname(), bin), !=, NULL);
        if (strstr(bin, "/ztest/")) {
                strstr(bin, "/ztest/")[0] = '\0'; /* In-tree */
                strcat(bin, "/zdb/zdb");
@@ -6428,7 +6428,7 @@ ztest_random_concrete_vdev_leaf(vdev_t *vd)
                        eligible[eligible_idx++] = cvd;
                }
        }
-       VERIFY(eligible_idx > 0);
+       VERIFY3S(eligible_idx, >, 0);
 
        uint64_t child_no = ztest_random(eligible_idx);
        return (ztest_random_concrete_vdev_leaf(eligible[child_no]));
@@ -6670,7 +6670,7 @@ ztest_spa_import_export(char *oldname, char *newname)
        /*
         * Get the pool's configuration and guid.
         */
-       VERIFY3U(0, ==, spa_open(oldname, &spa, FTAG));
+       VERIFY0(spa_open(oldname, &spa, FTAG));
 
        /*
         * Kick off a scrub to tickle scrub/export races.
@@ -6686,7 +6686,7 @@ ztest_spa_import_export(char *oldname, char *newname)
        /*
         * Export it.
         */
-       VERIFY3U(0, ==, spa_export(oldname, &config, B_FALSE, B_FALSE));
+       VERIFY0(spa_export(oldname, &config, B_FALSE, B_FALSE));
 
        ztest_walk_pool_directory("pools after export");
 
@@ -6694,7 +6694,7 @@ ztest_spa_import_export(char *oldname, char *newname)
         * Try to import it.
         */
        newconfig = spa_tryimport(config);
-       ASSERT(newconfig != NULL);
+       ASSERT3P(newconfig, !=, NULL);
        fnvlist_free(newconfig);
 
        /*
@@ -6727,8 +6727,8 @@ ztest_spa_import_export(char *oldname, char *newname)
        /*
         * Verify that we can open and close the pool using the new name.
         */
-       VERIFY3U(0, ==, spa_open(newname, &spa, FTAG));
-       ASSERT(pool_guid == spa_guid(spa));
+       VERIFY0(spa_open(newname, &spa, FTAG));
+       ASSERT3U(pool_guid, ==, spa_guid(spa));
        spa_close(spa, FTAG);
 
        fnvlist_free(config);
@@ -6935,7 +6935,7 @@ ztest_dataset_dirobj_verify(ztest_ds_t *zd)
         * That's because zap_count() returns the open-context value,
         * while dmu_objset_space() returns the rootbp fill count.
         */
-       VERIFY3U(0, ==, zap_count(zd->zd_os, ZTEST_DIROBJ, &dirobjs));
+       VERIFY0(zap_count(zd->zd_os, ZTEST_DIROBJ, &dirobjs));
        dmu_objset_space(zd->zd_os, &scratch, &scratch, &usedobjs, &scratch);
        ASSERT3U(dirobjs + 1, ==, usedobjs);
 }
@@ -7053,8 +7053,8 @@ ztest_freeze(void)
                (void) printf("testing spa_freeze()...\n");
 
        kernel_init(SPA_MODE_READ | SPA_MODE_WRITE);
-       VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG));
-       VERIFY3U(0, ==, ztest_dataset_open(0));
+       VERIFY0(spa_open(ztest_opts.zo_pool, &spa, FTAG));
+       VERIFY0(ztest_dataset_open(0));
        ztest_spa = spa;
 
        /*
@@ -7120,9 +7120,9 @@ ztest_freeze(void)
         * Open and close the pool and dataset to induce log replay.
         */
        kernel_init(SPA_MODE_READ | SPA_MODE_WRITE);
-       VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG));
-       ASSERT(spa_freeze_txg(spa) == UINT64_MAX);
-       VERIFY3U(0, ==, ztest_dataset_open(0));
+       VERIFY0(spa_open(ztest_opts.zo_pool, &spa, FTAG));
+       ASSERT3U(spa_freeze_txg(spa), ==, UINT64_MAX);
+       VERIFY0(ztest_dataset_open(0));
        ztest_spa = spa;
        txg_wait_synced(spa_get_dsl(spa), 0);
        ztest_dataset_close(0);
@@ -7514,7 +7514,7 @@ ztest_init(ztest_shared_t *zs)
        fnvlist_free(nvroot);
        fnvlist_free(props);
 
-       VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG));
+       VERIFY0(spa_open(ztest_opts.zo_pool, &spa, FTAG));
        zs->zs_metaslab_sz =
            1ULL << spa->spa_root_vdev->vdev_child[0]->vdev_ms_shift;
        spa_close(spa, FTAG);
@@ -7564,9 +7564,9 @@ setup_hdr(void)
 
        hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()),
            PROT_READ | PROT_WRITE, MAP_SHARED, ztest_fd_data, 0);
-       ASSERT(hdr != MAP_FAILED);
+       ASSERT3P(hdr, !=, MAP_FAILED);
 
-       VERIFY3U(0, ==, ftruncate(ztest_fd_data, sizeof (ztest_shared_hdr_t)));
+       VERIFY0(ftruncate(ztest_fd_data, sizeof (ztest_shared_hdr_t)));
 
        hdr->zh_hdr_size = sizeof (ztest_shared_hdr_t);
        hdr->zh_opts_size = sizeof (ztest_shared_opts_t);
@@ -7577,7 +7577,7 @@ setup_hdr(void)
        hdr->zh_ds_count = ztest_opts.zo_datasets;
 
        size = shared_data_size(hdr);
-       VERIFY3U(0, ==, ftruncate(ztest_fd_data, size));
+       VERIFY0(ftruncate(ztest_fd_data, size));
 
        (void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize()));
 }
@@ -7591,14 +7591,14 @@ setup_data(void)
 
        hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()),
            PROT_READ, MAP_SHARED, ztest_fd_data, 0);
-       ASSERT(hdr != MAP_FAILED);
+       ASSERT3P(hdr, !=, MAP_FAILED);
 
        size = shared_data_size(hdr);
 
        (void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize()));
        hdr = ztest_shared_hdr = (void *)mmap(0, P2ROUNDUP(size, getpagesize()),
            PROT_READ | PROT_WRITE, MAP_SHARED, ztest_fd_data, 0);
-       ASSERT(hdr != MAP_FAILED);
+       ASSERT3P(hdr, !=, MAP_FAILED);
        buf = (uint8_t *)hdr;
 
        offset = hdr->zh_hdr_size;
@@ -7637,12 +7637,13 @@ exec_child(char *cmd, char *libpath, boolean_t ignorekill, int *statusp)
                (void) setrlimit(RLIMIT_NOFILE, &rl);
 
                (void) close(ztest_fd_rand);
-               VERIFY(11 >= snprintf(fd_data_str, 12, "%d", ztest_fd_data));
-               VERIFY(0 == setenv("ZTEST_FD_DATA", fd_data_str, 1));
+               VERIFY3S(11, >=,
+                   snprintf(fd_data_str, 12, "%d", ztest_fd_data));
+               VERIFY0(setenv("ZTEST_FD_DATA", fd_data_str, 1));
 
                (void) enable_extended_FILE_stdio(-1, -1);
                if (libpath != NULL)
-                       VERIFY(0 == setenv("LD_LIBRARY_PATH", libpath, 1));
+                       VERIFY0(setenv("LD_LIBRARY_PATH", libpath, 1));
                (void) execv(cmd, emptyargv);
                ztest_dump_core = B_FALSE;
                fatal(B_TRUE, "exec failed: %s", cmd);
@@ -7794,8 +7795,8 @@ main(int argc, char **argv)
        ASSERT3U(ztest_opts.zo_datasets, ==, ztest_shared_hdr->zh_ds_count);
 
        /* Override location of zpool.cache */
-       VERIFY(asprintf((char **)&spa_config_path, "%s/zpool.cache",
-           ztest_opts.zo_dir) != -1);
+       VERIFY3S(asprintf((char **)&spa_config_path, "%s/zpool.cache",
+           ztest_opts.zo_dir), !=, -1);
 
        ztest_ds = umem_alloc(ztest_opts.zo_datasets * sizeof (ztest_ds_t),
            UMEM_NOFAIL);