@@@ output doc
[mLib] / test / t / tvec-test.c
index 91c4529..a9ef269 100644 (file)
@@ -129,7 +129,7 @@ static const struct tvec_urange range_32 = { 0, 31 };
   _(flags,     RF,     flags,                  p, &attr_info)          \
   _(string,    RSTR,   string,                 p, &range_32)           \
   _(bytes,     RBY,    bytes,                  p, &tvrange_byte)       \
-  _(buffer,    RBUF,   buffer,                 p, &tvrange_u16)
+  _(buffer,    RBUF,   buffer,                 p, 0)
 
 enum {
   /* Output registers, one for each register type. */
@@ -164,14 +164,13 @@ struct test_context {
 #define SF_SHOW 1u
 };
 
-static int common_setup(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 = ctx;
 
   tctx->tv = tv;
   tctx->f = 0;
-  return (0);
 }
 
 static int common_set(struct tvec_state *tv, const char *name,
@@ -320,16 +319,15 @@ static void test_single_deserialize
 TYPEREGS(SERREG)
 #undef SERREG
 
-static int before_single_serialize(struct tvec_state *tv, void *ctx)
+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;
   }
-  return (0);
 }
 
-static int before_single_deserialize(struct tvec_state *tv, void *ctx)
+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;
@@ -339,7 +337,6 @@ static int before_single_deserialize(struct tvec_state *tv, void *ctx)
     tv->in[RLEFT].v.u = 0; tv->in[RLEFT].f |= TVRF_LIVE;
     tv->out[RLEFT].f |= TVRF_LIVE;
   }
-  return (0);
 }
 
 static const struct tvec_env single_serialize_testenv = {
@@ -428,13 +425,12 @@ static DSGINIT(const) struct tvec_regdef multi_serialize_regs[] = {
   TVEC_ENDREGS
 };
 
-static int before_multi_serialize(struct tvec_state *tv, void *ctx)
+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;
   }
-  return (0);
 }
 
 static const struct tvec_env multi_serialize_testenv = {
@@ -444,6 +440,24 @@ static const struct tvec_env multi_serialize_testenv = {
   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",   RSAB,   &tvty_ienum,    0,              { &tvenum_bool } },
+  { "x",       RV,     &tvty_uint,     0,              { &tvrange_uint } },
+  { "z",       RVOUT,  &tvty_uint,     0,              { &tvrange_uint } },
+  TVEC_ENDREGS
+};
+
 /*----- Front end ---------------------------------------------------------*/
 
 static const struct tvec_test tests[] = {
@@ -459,6 +473,8 @@ static const struct tvec_test tests[] = {
   TYPEREGS(DEFSINGLE)
 #undef DEFSINGLE
 
+  { "crash",   crash_regs,     &crash_testenv._env, test_crash } ,
+
   TVEC_ENDTESTS
 };