@@@ much mess, mostly manpages
[mLib] / test / t / tvec-test.c
index 8b27f7f..2f15779 100644 (file)
 
 /*----- Header files ------------------------------------------------------*/
 
+#include "tv.h"
 #include "tvec.h"
 
-/*----- Register definitions ----------------------------------------------*/
-
-enum {
-  /* Standard outputs. */
-  RRC,                                 /* return code from deserialize */
-
-  /* Output registers, one for each register type. */
-  RI, RU, RIE, RUE, RPE, RF, RSTR, RBY, RBUF,
+#include <sys/select.h>
+#include <sys/time.h>
 
-  /* Additional diagnostic outputs. */
-  RSER,                                        /* serialized data */
-
-  NROUT,
-
-  /* Some additional inputs. */
-  RSAB = NROUT,                                /* which register to sabotage */
-
-  NREG,
-
-  /* Single register for copy tests. */
-  RV = 0
-};
+/*----- Register definitions ----------------------------------------------*/
 
 static const struct tvec_iassoc ienum_assocs[] = {
   { "less",           -1 },
@@ -66,6 +49,13 @@ static const struct tvec_uassoc uenum_assocs[] = {
   { 0 }
 };
 
+static const struct tvec_fassoc fenum_assocs[] = {
+  { "e",               2.718281828459045 },
+  { "pi",              3.141592653589793 },
+  { "tau",             6.283185307179586 },
+  { 0 }
+};
+
 static const struct tvec_passoc penum_assocs[] = {
   { "alice",           &uenum_assocs[0] },
   { "bob",             &uenum_assocs[1] },
@@ -73,19 +63,28 @@ static const struct tvec_passoc penum_assocs[] = {
   { 0 }
 };
 
-#if __STDC_VERSION__ >= 199901
+#if __STDC_VERSION__x >= 199901
 #  define DSGINIT(x) x
 #else
 #  define DSGINIT(x)
 #endif
 
-static DSGINIT(const) struct tvec_enuminfo
-  ienum_info = { "order", TVMISC_INT,
-                DSGINIT({ .i = { ienum_assocs COMMA &tvrange_i16 } }) },
-  uenum_info = { "fruit", TVMISC_UINT,
-                DSGINIT({ .u = { uenum_assocs COMMA &tvrange_u16 } }) },
-  penum_info = { "player", TVMISC_PTR,
-                DSGINIT({ .p = { penum_assocs } }) };
+static const struct tvec_floatinfo fenum_fltinfo =
+  { TVFF_ABSDELTA, -10, +10, 1e-3 };
+
+#define DEFENUM(tag, ty, slot)                                         \
+  static const struct tvec_##slot##enuminfo slot##enum_info =          \
+    { slot##enum_NAME, slot##enum_assocs slot##enum_ARGS };
+#define ienum_NAME "order"
+#define ienum_ARGS , &tvrange_i16
+#define uenum_NAME "fruit"
+#define uenum_ARGS , &tvrange_u16
+#define fenum_NAME "const"
+#define fenum_ARGS , &fenum_fltinfo
+#define penum_NAME "actor"
+#define penum_ARGS
+TVEC_MISCSLOTS(DEFENUM)
+#undef DEFENUM
 
 static const struct tvec_flag attr_flags[] = {
   { "black-fg",                0x07, 0x00 },
@@ -116,90 +115,110 @@ static const struct tvec_flag attr_flags[] = {
 static const struct tvec_flaginfo attr_info =
   { "attr", attr_flags, &tvrange_u16 };
 
+static const struct tvec_floatinfo fltish_info =
+  { TVFF_RELDELTA, -1.0, +1.0, 1e-6 };
+
 static const struct tvec_urange range_32 = { 0, 31 };
 
 #define TYPEREGS(_)                                                    \
   _(int,       RI,     int,                    p, &tvrange_i16)        \
   _(uint,      RU,     uint,                   p, &tvrange_u16)        \
-  _(ienum,     RIE,    enum,                   p, &ienum_info)         \
-  _(uenum,     RUE,    enum,                   p, &uenum_info)         \
-  _(penum,     RPE,    enum,                   p, &penum_info)         \
+  _(size,      RSZ,    size,                   p, 0)                   \
+  _(float,     RFP,    float,                  p, 0)                   \
+  _(fltish,    RFISH,  float,                  p, &fltish_info)        \
+  _(dur,       RDUR,   duration,               p, 0)                   \
+  _(char,      RCH,    char,                   p, 0)                   \
+  _(ienum,     RIE,    ienum,                  p, &ienum_info)         \
+  _(uenum,     RUE,    uenum,                  p, &uenum_info)         \
+  _(fenum,     RFE,    fenum,                  p, &fenum_info)         \
+  _(penum,     RPE,    penum,                  p, &penum_info)         \
   _(flags,     RF,     flags,                  p, &attr_info)          \
-  _(string,    RSTR,   string,                 p, &range_32)           \
+  _(text,      RTXT,   text,                   p, &range_32)           \
   _(bytes,     RBY,    bytes,                  p, &tvrange_byte)       \
-  _(buffer,    RBUF,   buffer,                 p, &tvrange_u16)
+  _(buffer,    RBUF,   buffer,                 p, 0)
 
-/*----- Serialization test ------------------------------------------------*/
+enum {
+  /* Output registers, one for each register type. */
+#define DEFREG(name, i, ty, argslot, argval) i,
+  TYPEREGS(DEFREG)
+#undef DEFREG
+  NTY,
+
+  /* Outputs. */
+  RRC = NTY,                           /* return code from deserialize */
+  RSEROUT,                             /* serialized output */
+
+  NROUT,
+
+  /* Alternative outputs. */
+  RVOUT = 0,                           /* output/copy value */
+  RLEFT,                               /* size data remaining in input */
+
+  /* Additional inputs. */
+  RSAB = NROUT,                                /* which register to sabotage */
+  RV,                                  /* input value */
+  RSER,                                        /* serialized input */
+
+  NREG
+};
+
+/*----- Common execution environment --------------------------------------*/
 
 struct test_context {
   struct tvec_state *tv;
+  unsigned f;
+#define SF_SHOW 1u
 };
 
-static int capture_state_and_run(struct tvec_state *tv)
+static void common_setup(struct tvec_state *tv,
+                        const struct tvec_env *env, void *pctx, void *ctx)
 {
-  struct test_context tctx;
+  struct test_context *tctx = ctx;
 
-  tctx.tv = tv; tv->test->fn(tv->in, tv->out, &tctx);
-  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;
-  }
-  tvec_check(tv, 0);
+  tctx->tv = tv;
+  tctx->f = 0;
+}
+
+static int common_setvar(struct tvec_state *tv, const char *var,
+                        const union tvec_regval *rv, void *ctx)
+{
+  struct test_context *tctx = ctx;
+
+  if (STRCMP(var, ==, "@show")) {
+    if (rv->i) tctx->f |= SF_SHOW;
+  } else assert(!"unknown var");
   return (0);
 }
 
-static void test_serialization
-  (const struct tvec_reg *in, struct tvec_reg *out, void *ctx)
+static const struct tvec_vardef show_var =
+  { sizeof(struct tvec_reg), common_setvar,
+    { "@show", &tvty_ienum, -1, 0, { &tvenum_bool } } };
+
+static const struct tvec_vardef *common_findvar
+  (struct tvec_state *tv, const char *var, void **ctx_out, void *ctx)
+{
+  if (STRCMP(var, ==, "@show")) { *ctx_out = ctx; return (&show_var); }
+  return (0);
+}
+
+static void common_run(struct tvec_state *tv, tvec_testfn *fn, void *ctx)
 {
   struct test_context *tctx = ctx;
-  struct tvec_state *tv = tctx->tv;
-  const struct tvec_regdef *rd;
-  union tvec_regval *rv;
-  void *p; size_t sz;
-
-  if (tvec_serialize(tv->in, tv->test->regs,
-                    NROUT, sizeof(struct tvec_reg), &p, &sz))
-    { out[RRC].v.i = -1; return; }
-  out[RSER].f |= TVRF_LIVE;
-  out[RSER].v.bytes.p = p; out[RSER].v.bytes.sz = sz;
-
-  if (tvec_deserialize(tv->out, tv->test->regs,
-                       NROUT, sizeof(struct tvec_reg), p, sz))
-    { out[RRC].v.i = -1; return; }
-
-  if (in[RSAB].f&TVRF_LIVE) {
-    for (rd = tv->test->regs; rd->name; rd++)
-      if (STRCMP(in[RSAB].v.str.p, ==, rd->name)) {
-       rv = &out[rd->i].v;
-       if (rd->ty == &tvty_int ||
-           (rd->ty == &tvty_enum &&
-            ((struct tvec_enuminfo *)rd->arg.p)->mv == TVMISC_INT))
-         rv->i ^= 1;
-       else if (rd->ty == &tvty_uint || rd->ty == &tvty_flags ||
-                (rd->ty == &tvty_enum &&
-                 ((struct tvec_enuminfo *)rd->arg.p)->mv == TVMISC_INT))
-         rv->u ^= 1;
-       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; }
-      }
-  }
+  unsigned f = tctx->f;
 
-  out[RRC].v.i = 0;
+  fn(tv->in, tv->out, tctx);
+  if (tvec_checkregs(tv)) { tvec_fail(tv, 0); f |= SF_SHOW; }
+  if (f&SF_SHOW) tvec_mismatch(tv, TVMF_IN | TVMF_OUT);
 }
 
-DSGINIT(static) const struct tvec_regdef test_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", RSER,        &tvty_bytes,    TVRF_OPT },
-  { "sabotage",        RSAB,   &tvty_string,   TVRF_OPT,       { &tvrange_byte } },
+static void common_after(struct tvec_state *tv, void *ctx)
+  { struct test_context *tctx = ctx; tctx->f = 0; }
 
-  { 0 }
+static const struct tvec_env common_testenv = {
+  sizeof(struct test_context),
+  common_setup, common_findvar,
+  0, common_run, common_after,
+  0
 };
 
 /*----- Single-type copy tests --------------------------------------------*/
@@ -208,68 +227,327 @@ static void test_copy_simple
   (const struct tvec_reg *in, struct tvec_reg *out, void *ctx)
   { out->v = in->v; }
 
-static void test_copy_string
+static void test_copy_text
   (const struct tvec_reg *in, struct tvec_reg *out, void *ctx)
 {
-  tvec_allocstring(&out->v, in->v.str.sz);
-  memcpy(out->v.str.p, in->v.str.p, in->v.str.sz);
+  tvec_alloctext(&out->v, in->v.text.sz);
+  memcpy(out->v.text.p, in->v.text.p, in->v.text.sz);
 }
 
 static void test_copy_bytes
   (const struct tvec_reg *in, struct tvec_reg *out, void *ctx)
 {
-  tvec_allocstring(&out->v, in->v.str.sz);
-  memcpy(out->v.str.p, in->v.str.p, in->v.str.sz);
+  tvec_allocbytes(&out->v, in->v.bytes.sz);
+  memcpy(out->v.bytes.p, in->v.bytes.p, in->v.bytes.sz);
 }
 
+static void test_copy_buffer
+  (const struct tvec_reg *in, struct tvec_reg *out, void *ctx)
+  { tvec_initbuffer(&out->v, &in->v, in->v.buf.sz); }
+
 #define test_copy_int test_copy_simple
 #define test_copy_uint test_copy_simple
+#define test_copy_size test_copy_simple
 #define test_copy_ienum test_copy_simple
 #define test_copy_uenum test_copy_simple
+#define test_copy_fenum test_copy_simple
 #define test_copy_penum test_copy_simple
+#define test_copy_char test_copy_simple
 #define test_copy_flags test_copy_simple
-#define test_copy_buffer test_copy_bytes
+#define test_copy_float test_copy_simple
+#define test_copy_fltish test_copy_simple
+#define test_copy_dur test_copy_simple
 
-#define SINGLEREG(name, i, ty, argslot, argval)                                \
-       DSGINIT(const) struct tvec_regdef name##_regs[] = {             \
-         { #name, RV, &tvty_##ty, 0, DSGINIT({ .argslot = argval }) }, \
+#define COPYREG(name, i, ty, argslot, argval)                          \
+       static DSGINIT(const) struct tvec_regdef name##_copyregs[] = {  \
+         { #name, &tvty_##ty, RVOUT, 0, DSGINIT({ .argslot = argval }) }, \
          { 0 }                                                         \
        };
-TYPEREGS(SINGLEREG)
-#undef SINGLEREG
+TYPEREGS(COPYREG)
+#undef COPYREG
 
-/*----- Front end ---------------------------------------------------------*/
+/*----- Single-type serialization tests -----------------------------------*/
 
-static const struct tvec_test tests[] = {
-  { "types",   test_regs,      0,      capture_state_and_run,
-                                                       test_serialization },
+static void setup_regdef(struct tvec_regdef *rd, unsigned i,
+                        struct tvec_state *tv)
+{
+  const struct tvec_regdef *r;
 
-#define DEFCOPY(name, i, ty, argslot, argval)                          \
-  { #name,     name##_regs,    0,      tvec_runtest,   test_copy_##name },
-  TYPEREGS(DEFCOPY)
-#undef DEFCOPY
+  for (r = tv->test->regs; r->name; r++) if (r->i == i) goto found;
+  tvec_error(tv, "internel: register definition not found"); exit(2);
+found:
+  rd[0] = *r; rd[1].name = 0;
+}
 
-  { 0 }
+static void test_single_serialize
+  (const struct tvec_reg *in, struct tvec_reg *out, void *ctx)
+{
+  struct test_context *tctx = ctx;
+  struct tvec_state *tv = tctx->tv;
+  struct tvec_regdef rd[2];
+  dbuf b = DBUF_INIT;
+  int rc;
+
+  setup_regdef(rd, RV, tv);
+  rc = tvec_serialize(tv->in, DBUF_BUF(&b), rd, NREG,
+                     sizeof(struct tvec_reg));
+  out[RRC].v.i = rc;
+  if (rc)
+    out[RSEROUT].f &= ~TVRF_LIVE;
+  else {
+    tvec_allocbytes(&out[RSEROUT].v, BLEN(DBUF_BUF(&b)));
+    memcpy(out[RSEROUT].v.bytes.p, BBASE(DBUF_BUF(&b)), BLEN(DBUF_BUF(&b)));
+  }
+}
+
+static void test_single_deserialize
+  (const struct tvec_reg *in, struct tvec_reg *out, void *ctx)
+{
+  struct test_context *tctx = ctx;
+  struct tvec_state *tv = tctx->tv;
+  struct tvec_regdef rd[2];
+  buf b;
+  int rc;
+
+  setup_regdef(rd, RV, tv);
+  buf_init(&b, in[RSER].v.bytes.p, in[RSER].v.bytes.sz);
+  rc = tvec_deserialize(tv->out, &b, rd, NREG, sizeof(struct tvec_reg));
+  out[RRC].v.i = rc;
+  if (rc) out[RVOUT].f &= ~TVRF_LIVE;
+}
+
+#define SERREG(name, i, ty, argslot, argval)                           \
+       static DSGINIT(const) struct tvec_regdef name##_serregs[] = {   \
+         { #name,      &tvty_##ty,     RV,     0,                      \
+                                     DSGINIT({ .argslot = argval }) }, \
+         { "buf",      &tvty_bytes,    RSEROUT, 0 },                   \
+         { "rc",       &tvty_int,      RRC,    TVRF_OPT,               \
+                                                   { &tvrange_int } }, \
+         TVEC_ENDREGS                                                  \
+       };                                                              \
+       static DSGINIT(const) struct tvec_regdef name##_deserregs[] = { \
+         { "buf",      &tvty_bytes,    RSER,   0 },                    \
+         { #name,      &tvty_##ty,     RVOUT,  0,                      \
+                                     DSGINIT({ .argslot = argval }) }, \
+         { "left",     &tvty_uint,     RLEFT,  TVRF_OPT,               \
+                                                  { &tvrange_size } }, \
+         { "rc",       &tvty_int,      RRC,    TVRF_OPT,               \
+                                                   { &tvrange_int } }, \
+         TVEC_ENDREGS                                                  \
+       };
+TYPEREGS(SERREG)
+#undef SERREG
+
+static void before_single_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;
+  }
+}
+
+static void before_single_deserialize(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;
+  }
+  if (!(tv->in[RLEFT].f&TVRF_LIVE)) {
+    tv->in[RLEFT].v.u = 0; tv->in[RLEFT].f |= TVRF_LIVE;
+    tv->out[RLEFT].f |= TVRF_LIVE;
+  }
+}
+
+static const struct tvec_env single_serialize_testenv = {
+  sizeof(struct test_context),
+  common_setup, common_findvar,
+  before_single_serialize, common_run, common_after,
+  0
+}, single_deserialize_testenv = {
+  sizeof(struct test_context),
+  common_setup, common_findvar,
+  before_single_deserialize, common_run, common_after,
+  0
 };
 
-static const struct tvec_info testinfo = {
+/*----- Multi-type serialization test -------------------------------------*/
+
+static void test_multi_serialize
+  (const struct tvec_reg *in, struct tvec_reg *out, void *ctx)
+{
+  struct test_context *tctx = ctx;
+  struct tvec_state *tv = tctx->tv;
+  const struct tvec_regdef *rd;
+  union tvec_regval *rv;
+  dbuf b = DBUF_INIT;
+
+  if (tvec_serialize(tv->in, DBUF_BUF(&b), tv->test->regs,
+                    NTY, sizeof(struct tvec_reg)))
+    { out[RRC].v.i = -1; goto end; }
+  tvec_allocbytes(&out[RSEROUT].v, DBLEN(&b));
+  memcpy(out[RSEROUT].v.bytes.p, DBBASE(&b), DBLEN(&b));
+  out[RSEROUT].f |= TVRF_LIVE;
+  buf_flip(DBUF_BUF(&b));
+
+  if (tvec_deserialize(tv->out, DBUF_BUF(&b), tv->test->regs,
+                      NTY, sizeof(struct tvec_reg)))
+    { out[RRC].v.i = -2; goto end; }
+  if (BLEFT(&b._b))
+    { out[RRC].v.i = -3; goto end; }
+
+  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_text)
+      { if (rv->text.sz) rv->text.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,     &tvty_##ty,     i,      TVRF_OPT,                       \
+                                     DSGINIT({ .argslot = argval }) },
+  TYPEREGS(DEFREG)
+#undef DEFREG
+
+  { "rc",      &tvty_int,      RRC,    TVRF_OPT,       { &tvrange_int } },
+  { "serialized", &tvty_bytes, RSEROUT, TVRF_OPT },
+  { "sabotage",        &tvty_ienum,    RSAB,   TVRF_OPT,       { &reg_enum } },
+
+  TVEC_ENDREGS
+};
+
+static void 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;
+  }
+}
+
+static const struct tvec_env multi_serialize_testenv = {
+  sizeof(struct test_context),
+  common_setup, common_findvar,
+  before_multi_serialize, common_run, common_after,
+  0
+};
+
+/*----- Crash test --------------------------------------------------------*/
+
+static void test_crash(const struct tvec_reg *in, struct tvec_reg *out,
+                      void *ctx)
+{
+  out[RVOUT].v.u = in[RV].v.u;
+  if (in[RSAB].v.i) abort();
+}
+
+static const struct tvec_remotefork crash_testenv =
+  { TVEC_REMOTEFORK(0, 0) };
+
+static const struct tvec_regdef crash_regs[] = {
+  { "crash",   &tvty_ienum,    RSAB,   0,              { &tvenum_bool } },
+  { "x",       &tvty_uint,     RV,     0,              { &tvrange_uint } },
+  { "z",       &tvty_uint,     RVOUT,  0,              { &tvrange_uint } },
+  TVEC_ENDREGS
+};
+
+/*----- Sleep test --------------------------------------------------------*/
+
+static void test_sleep(const struct tvec_reg *in, struct tvec_reg *out,
+                      void *ctx)
+{
+  struct timeval now, when, tv;
+  int rc;
+
+  rc = gettimeofday(&now, 0); assert(!rc);
+  tv.tv_sec = in[RV].v.f; tv.tv_usec = 1e6*(in[RV].v.f - tv.tv_sec);
+
+  TV_ADD(&when, &now, &tv);
+  for (;;) {
+    rc = select(0, 0, 0, 0, &tv); assert(!rc);
+    rc = gettimeofday(&now, 0); assert(!rc);
+    if (TV_CMP(&now, >=, &when)) break;
+    TV_SUB(&tv, &when, &now);
+  }
+  out[RVOUT].v.f = in[RV].v.f;
+}
+
+static const struct tvec_timeoutenv sleep_subenv =
+  { TVEC_TIMEOUTINIT(ITIMER_REAL, 0.25) };
+static const struct tvec_remotefork sleep_testenv =
+  { TVEC_REMOTEFORK(&sleep_subenv._env, 0) };
+
+static const struct tvec_regdef sleep_regs[] = {
+  { "time",    &tvty_duration, RV,     0,              { &tvflt_nonneg } },
+  { "z",       &tvty_float,    RVOUT,  0,              { &tvflt_nonneg } },
+  TVEC_ENDREGS
+};
+
+/*----- 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
+
+  { "crash",   crash_regs,     &crash_testenv._env, test_crash },
+  { "sleep",   sleep_regs,     &sleep_testenv._env, test_sleep },
+
+  TVEC_ENDTESTS
+};
+
+static const struct tvec_config testconfig = {
   tests,
   NROUT, NREG, sizeof(struct tvec_reg)
 };
 
 int main(int argc, char *argv[])
 {
-#if __STDC_VERSION__ < 199901
-#  define POKE(tag, ty, slot)                                          \
-       slot##enum_info.u.slot.av = slot##enum_assocs;                  \
-  TVEC_MISCSLOTS(POKE)
-#  undef POKE
+#if __STDC_VERSION__x < 199901
 #  define POKE(name, i, ty, argslot, argval)                           \
-       name##_regs->arg.argslot = argval;
+       multi_serialize_regs[i].arg.argslot = argval;                   \
+       name##_copyregs->arg.argslot = argval;                          \
+       name##_serregs->arg.argslot = argval;                           \
+       name##_deserregs->arg.argslot = argval;
   TYPEREGS(POKE)
 #  undef POKE
 #endif
-  return (tvec_main(argc, argv, &testinfo, 0));
+  return (tvec_main(argc, argv, &testconfig, 0));
 }
 
 /*----- That's all, folks -------------------------------------------------*/