unsigned long u; /* unsigned integer */
void *p; /* pointer */
double f; /* floating point */
- struct { unsigned char *p; size_t sz; } bytes; /* binary string of bytes */
struct { char *p; size_t sz; } text; /* text string */
+ struct { unsigned char *p; size_t sz; } bytes; /* binary string of bytes */
struct { /* buffer */
unsigned char *p; size_t sz; /* binary string */
size_t a, m; /* residue and modulus */
*/
const char *name; /* register name (for input files) */
- unsigned i; /* register index */
const struct tvec_regty *ty; /* register type descriptor */
+ unsigned i; /* register index */
unsigned f; /* flags */
#define TVRF_OPT 1u /* optional register */
#define TVRF_ID 2u /* part of test identity */
/*----- Test descriptions -------------------------------------------------*/
+struct tvec_env;
+
typedef void tvec_testfn(const struct tvec_reg */*in*/,
struct tvec_reg */*out*/,
void */*ctx*/);
* anything to do with the test function's context.
*/
-struct tvec_env;
-
typedef int tvec_setvarfn(struct tvec_state */*tv*/, const char */*var*/,
const union tvec_regval */*rv*/, void */*ctx*/);
/* Called after a variable is read. Return zero on success or %$-1$% on
};
#define TVEC_ENDTESTS { 0, 0, 0, 0 }
-enum {
- /* Register output dispositions. */
-
- TVRD_INPUT, /* input-only register */
- TVRD_OUTPUT, /* output-only (input is dead) */
- TVRD_MATCH, /* matching (equal) registers */
- TVRD_FOUND, /* mismatching output register */
- TVRD_EXPECT, /* mismatching input register */
- TVRD_LIMIT /* (number of dispositions) */
-};
-
/*----- Test state --------------------------------------------------------*/
enum {
TVOUT_LIMIT /* (number of possible outcomes) */
};
+struct tvec_config {
+ /* An overall test configuration. */
+
+ const struct tvec_test *tests; /* the tests to be performed */
+ unsigned nrout, nreg; /* number of output/total regs */
+ size_t regsz; /* size of a register */
+};
+
struct tvec_state {
/* The primary state structure for the test vector machinery. */
+ /* Flags. Read-only for all callers. */
unsigned f; /* flags */
#define TVSF_SKIP 0x0001u /* skip this test group */
#define TVSF_OPEN 0x0002u /* test is open */
#define TVSF_XFAIL 0x0100u /* test expected to fail */
#define TVSF_MUFFLE 0x0200u /* muffle errors */
- /* Registers. Available to execution environments. */
- unsigned nrout, nreg; /* number of output/total registers */
- size_t regsz; /* size of register entry */
+ /* Test configuration. Read-only for all callers. */
+ struct tvec_config cfg; /* test configuration */
+
+ /* Registers. Available to execution environments, which may modify the
+ * contents of the active registers, as defined by the current test group,
+ * but not the vector pointers themselves or inactive registers.
+ */
struct tvec_reg *in, *out; /* register vectors */
- /* Test groups state. Available to output formatters. */
- const struct tvec_test *tests, *test; /* all tests and current test */
+ /* Test group state. Read-only for all callers. */
+ const struct tvec_test *test; /* current test */
/* Test scoreboard. Available to output formatters. */
unsigned curr[TVOUT_LIMIT], all[TVOUT_LIMIT], grps[TVOUT_LIMIT];
* @out@, and @i@ is an integer, then this evaluates to the address of the
* @i@th register in the selected vector.
*/
-#define TVEC_REG(tv, vec, i) TVEC_GREG((tv)->vec, (i), (tv)->regsz)
-
-struct tvec_config {
- /* An overall test configuration. */
-
- const struct tvec_test *tests; /* the tests to be performed */
- unsigned nrout, nreg; /* number of output/total regs */
- size_t regsz; /* size of a register */
-};
+#define TVEC_REG(tv, vec, i) TVEC_GREG((tv)->vec, (i), (tv)->cfg.regsz)
/*----- Output formatting -------------------------------------------------*/
const struct tvec_outops *ops; /* pointer to operations */
};
+enum {
+ /* Register output dispositions. */
+
+ TVRD_INPUT, /* input-only register */
+ TVRD_OUTPUT, /* output-only (input is dead) */
+ TVRD_MATCH, /* matching (equal) registers */
+ TVRD_FOUND, /* mismatching output register */
+ TVRD_EXPECT, /* mismatching input register */
+ TVRD_LIMIT /* (number of dispositions) */
+};
+
+#define TVEC_LEVELS(_) \
+ _(NOTE, "notice", 4) \
+ _(ERR, "ERROR", 8)
+enum {
+#define TVEC_DEFLEVEL(tag, name, val) TVLEV_##tag = val,
+ TVEC_LEVELS(TVEC_DEFLEVEL)
+#undef TVEC_DEFLEVEL
+ TVLEV_LIMIT
+};
+
/* Benchmarking details. */
enum {
TVBU_OP, /* counting operations of some kind */
/* Release any resources acquired by the driver. */
};
-#define TVEC_LEVELS(_) \
- _(NOTE, "notice", 4) \
- _(ERR, "ERROR", 8)
-
-enum {
-#define TVEC_DEFLEVEL(tag, name, val) TVLEV_##tag = val,
- TVEC_LEVELS(TVEC_DEFLEVEL)
-#undef TVEC_DEFLEVEL
- TVLEV_LIMIT
-};
-
/*----- Session lifecycle -------------------------------------------------*/
/* --- @tvec_begin@ --- *
/*----- Remote execution --------------------------------------------------*/
+struct tvec_remoteenv;
+
struct tvec_remotecomms {
int infd, outfd; /* input and output descriptors */
dbuf bout; /* output buffer */
struct tvec_timeoutenv {
struct tvec_env _env;
- int timer; /* the timer (@ITIMER_...@) */
+ int timer; /* the timer (@ITIMER_...@) */
double t; /* time to wait (in seconds) */
const struct tvec_env *env; /* subsidiary environment */
};
* message.
*/
-extern const char *tvec_strlevel(unsigned /*level*/);
+extern const char *tvec_strlevel(unsigned /*level*/);
/* --- @tvec_report@, @tvec_report_v@ --- *
*
extern PRINTF_LIKE(2, 3)
void tvec_notice(struct tvec_state */*tv*/, const char */*msg*/, ...);
+/* --- @tvec_unkreg@ --- *
+ *
+ * Arguments: @struct tvec_state *tv@ = test-vector state
+ * @const char *name@ = register or pseudoregister name
+ *
+ * Returns: %$-1$%.
+ *
+ * Use: Reports an error that the register or pseudoregister is
+ * unrecognized.
+ */
+
+extern int tvec_unkreg(struct tvec_state */*tv*/, const char */*name*/);
+
+/* --- @tvec_dupreg@ --- *
+ *
+ * Arguments: @struct tvec_state *tv@ = test-vector state
+ * @const char *name@ = register or pseudoregister name
+ *
+ * Returns: %$-1$%.
+ *
+ * Use: Reports an error that the register or pseudoregister has been
+ * assigned already in the current test.
+ */
+
+extern int tvec_dupreg(struct tvec_state */*tv*/, const char */*name*/);
+
/* --- @tvec_humanoutput@ --- *
*
* Arguments: @FILE *fp@ = output file to write on
extern int tvec_syntax_v(struct tvec_state */*tv*/, int /*ch*/,
const char */*expect*/, va_list */*ap*/);
-/* --- @tvec_unkreg@ --- *
- *
- * Arguments: @struct tvec_state *tv@ = test-vector state
- * @const char *name@ = register or pseudoregister name
- *
- * Returns: %$-1$%.
- *
- * Use: Reports an error that the register or pseudoregister is
- * unrecognized.
- */
-
-extern int tvec_unkreg(struct tvec_state */*tv*/, const char */*name*/);
-
-/* --- @tvec_dupreg@ --- *
- *
- * Arguments: @struct tvec_state *tv@ = test-vector state
- * @const char *name@ = register or pseudoregister name
- *
- * Returns: %$-1$%.
- *
- * Use: Reports an error that the register or pseudoregister has been
- * assigned already in the current test.
- */
-
-extern int tvec_dupreg(struct tvec_state */*tv*/, const char */*name*/);
-
/* --- @tvec_skipspc@ --- *
*
* Arguments: @struct tvec_state *tv@ = test-vector state
double delta; /* maximum tolerable difference */
};
+extern const struct tvec_floatinfo tvflt_finite, tvflt_nonneg;
+
/* --- @tvec_claimeqish_float@, @TVEC_CLAIMEQISH_FLOAT@ --- *
*
* Arguments: @struct tvec_state *tv@ = test-vector state
#define TVEC_CLAIMEQ_FLOAT(tv, f0, f1) \
(tvec_claimeq_float(tv, f0, f1, __FILE__, __LINE__, #f0 " /= " #f1))
-extern const struct tvec_floatinfo tvflt_finite, tvflt_nonneg;
-
/*----- Durations ---------------------------------------------------------*/
/* A duration measures a time interval in seconds. The input format consists
extern const struct tvec_regty tvty_text, tvty_bytes;
+/* --- @tvec_alloctext@, @tvec_allocbytes@ --- *
+ *
+ * Arguments: @union tvec_regval *rv@ = register value
+ * @size_t sz@ = required size
+ *
+ * Returns: ---
+ *
+ * Use: Allocated space in a text or binary string register. If the
+ * current register size is sufficient, its buffer is left
+ * alone; otherwise, the old buffer, if any, is freed and a
+ * fresh buffer allocated. These functions are not intended to
+ * be used to adjust a buffer repeatedly, e.g., while building
+ * output incrementally: (a) they will perform badly, and (b)
+ * the old buffer contents are simply discarded if reallocation
+ * is necessary. Instead, use a @dbuf@ or @dstr@.
+ *
+ * The @tvec_alloctext@ function sneakily allocates an extra
+ * byte for a terminating zero. The @tvec_allocbytes@ function
+ * doesn't do this.
+ */
+
+extern void tvec_alloctext(union tvec_regval */*rv*/, size_t /*sz*/);
+extern void tvec_allocbytes(union tvec_regval */*rv*/, size_t /*sz*/);
+
/* --- @tvec_claimeq_text@, @TVEC_CLAIMEQ_TEXT@ --- *
*
* Arguments: @struct tvec_state *tv@ = test-vector state
(tvec_claimeq(tv, p0, sz0, p1, sz1, __FILE__, __LINE__, \
#p0 "[" #sz0 "] /= " #p1 "[" #sz1 "]"))
-/* --- @tvec_alloctext@, @tvec_allocbytes@ --- *
- *
- * Arguments: @union tvec_regval *rv@ = register value
- * @size_t sz@ = required size
- *
- * Returns: ---
- *
- * Use: Allocated space in a text or binary string register. If the
- * current register size is sufficient, its buffer is left
- * alone; otherwise, the old buffer, if any, is freed and a
- * fresh buffer allocated. These functions are not intended to
- * be used to adjust a buffer repeatedly, e.g., while building
- * output incrementally: (a) they will perform badly, and (b)
- * the old buffer contents are simply discarded if reallocation
- * is necessary. Instead, use a @dbuf@ or @dstr@.
- *
- * The @tvec_alloctext@ function sneakily allocates an extra
- * byte for a terminating zero. The @tvec_allocbytes@ function
- * doesn't do this.
- */
-
-extern void tvec_alloctext(union tvec_regval */*rv*/, size_t /*sz*/);
-extern void tvec_allocbytes(union tvec_regval */*rv*/, size_t /*sz*/);
-
/*----- Buffer type -------------------------------------------------------*/
/* Buffer registers are primarily used for benchmarking. Only a buffer's
/* --- @tvec_initbuffer@ --- *
*
* Arguments: @union tvec_regval *rv@ = register value
- * @const union tvec_regval *src@ = source buffer
+ * @const union tvec_regval *ref@ = reference buffer
* @size_t sz@ = size to allocate
*
* Returns: ---
*
- * Use: Initialize the alignment parameters in @rv@ to match @src@,
+ * Use: Initialize the alignment parameters in @rv@ to match @ref@,
* and the size to @sz@.
*/
extern void tvec_initbuffer(union tvec_regval */*rv*/,
- const union tvec_regval */*src*/, size_t /*sz*/);
+ const union tvec_regval */*ref*/, size_t /*sz*/);
/* --- @tvec_allocbuffer@ --- *
*