- while (tok == tok_word)
- tok = test__gettok(fp);
- if (tok != ';')
- die(1, "expected `;'; found `%s'", test__decode(tok));
- }
+ while (t == TOK_WORD)
+ t = gettok(fp);
+ if (t != ';') {
+ moan("expected `;'; found `%s'", decode(t));
+ goto done;
+ }
+ }
+ }
+ rc = results->failed;
+
+ /* --- All done --- */
+
+done:
+ for (i = 0; i < TEST_FIELDMAX; i++)
+ dstr_destroy(&dv[i]);
+ return (rc);
+}
+
+/* --- @test_run@ --- *
+ *
+ * Arguments: @int argc@ = number of command line arguments
+ * @char *argv[]@ = pointer to command line arguments
+ * @const test_chunk chunk[]@ = pointer to chunk definitions
+ * @const char *vec@ = name of default test vector file
+ *
+ * Returns: Doesn't.
+ *
+ * Use: Runs a set of test vectors to ensure that a component is
+ * working properly.
+ */
+
+void test_run(int argc, char *argv[],
+ const test_chunk chunk[],
+ const char *vec)
+{
+ FILE *fp;
+ test_results res;
+ int rc;
+ test_suite suite[2];
+
+ /* --- Silly bits of initialization --- */
+
+ ego(argv[0]);
+
+ /* --- Parse command line arguments --- */
+
+ {
+ const char *p = 0;
+ int i = 0;
+
+ for (;;) {
+ if (!p || !*p) {
+ if (i >= argc - 1)
+ break;
+ p = argv[++i];
+ if (strcmp(p, "--") == 0) {
+ i++;
+ break;
+ }
+ if (p[0] != '-' || p[1] == 0)
+ break;
+ p++;
+ }
+ switch (*p++) {
+ case 'h':
+ printf("%s test driver\n"
+ "Usage: %s [-f FILENAME]\n", QUIS, QUIS);
+ exit(0);
+ case 'f':
+ if (!*p) {
+ if (i >= argc - 1)
+ die(1, "option `-f' expects an argument");
+ p = argv[++i];
+ }
+ vec = p;
+ p = 0;
+ break;
+ default:
+ die(1, "option `-%c' unknown", p[-1]);
+ break;
+ }
+ }