+ if ((in[RSAB].f&TVRF_LIVE) && in[RSAB].v.i >= 0) {
+ rd = &tv->test->regs[in[RSAB].v.i]; rv = &out[in[RSAB].v.i].v;
+ if (rd->ty == &tvty_int || rd->ty == &tvty_ienum)
+ rv->i ^= 1;
+ else if (rd->ty == &tvty_uint ||
+ rd->ty == &tvty_flags || rd->ty == &tvty_uenum)
+ rv->u ^= 1;
+ else if (rd->ty == &tvty_float || rd->ty == &tvty_fenum) {
+ if (rv->f == rv->f) rv->f = -rv->f;
+ else rv->f = 1.0;
+ } else if (rd->ty == &tvty_penum)
+ rv->p = rv->p
+ ? 0
+ : (/*unconst*/ void *)
+ ((const struct tvec_penuminfo *)rd->arg.p)->av[0].p;
+ else if (rd->ty == &tvty_string)
+ { if (rv->str.sz) rv->str.p[0] ^= 1; }
+ else if (rd->ty == &tvty_bytes)
+ { if (rv->bytes.sz) rv->bytes.p[0] ^= 1; }
+ }
+
+ out[RRC].v.i = 0;
+end:
+ dbuf_destroy(&b);
+}
+
+static const struct tvec_iassoc reg_assocs[] = {
+ { "none", -1 },
+#define DEFASSOC(name, i, ty, argslot, argval) { #name, i },
+ TYPEREGS(DEFASSOC)
+#undef DEFASSOC
+ { 0, 0 }
+};
+static const struct tvec_ienuminfo reg_enum = { "reg", reg_assocs, 0 };
+
+static DSGINIT(const) struct tvec_regdef multi_serialize_regs[] = {
+#define DEFREG(name, i, ty, argslot, argval) \
+ { #name, i, &tvty_##ty, TVRF_OPT, \
+ DSGINIT({ .argslot = argval }) },
+ TYPEREGS(DEFREG)
+#undef DEFREG
+
+ { "rc", RRC, &tvty_int, TVRF_OPT, { &tvrange_int } },
+ { "serialized", RSEROUT, &tvty_bytes, TVRF_OPT },
+ { "sabotage", RSAB, &tvty_ienum, TVRF_OPT, { ®_enum } },
+
+ TVEC_ENDREGS
+};
+
+static int before_multi_serialize(struct tvec_state *tv, void *ctx)
+{
+ if (!(tv->in[RRC].f&TVRF_LIVE)) {
+ tv->in[RRC].v.i = 0; tv->in[RRC].f |= TVRF_LIVE;
+ tv->out[RRC].f |= TVRF_LIVE;
+ }
+ return (0);
+}
+
+static const struct tvec_env multi_serialize_testenv = {
+ sizeof(struct test_context),
+ common_setup, common_set,
+ before_multi_serialize, common_run, common_after,
+ 0
+};
+
+/*----- Front end ---------------------------------------------------------*/
+
+static const struct tvec_test tests[] = {
+ { "multi", multi_serialize_regs, &multi_serialize_testenv,
+ test_multi_serialize },
+
+#define DEFSINGLE(name, i, ty, argslot, argval) \
+ { "copy-" #name, name##_copyregs, &common_testenv, test_copy_##name }, \
+ { "serialize-" #name, name##_serregs, &single_serialize_testenv, \
+ test_single_serialize }, \
+ { "deserialize-" #name, name##_deserregs, &single_deserialize_testenv, \
+ test_single_deserialize },
+ TYPEREGS(DEFSINGLE)
+#undef DEFSINGLE
+
+ TVEC_ENDTESTS