summaryrefslogtreecommitdiffstats
path: root/test/testutil.h
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2017-06-05 13:32:05 -0400
committerRich Salz <rsalz@openssl.org>2017-06-05 13:41:30 -0400
commitae269dd8b72dbed1f2c5f92dbe0fbf5b7b905e7b (patch)
tree53de9420e6c8c8c3808967cbc1418c94f7880a98 /test/testutil.h
parent71dd3b6464df1ba524601c3705e1d1e3c7c5406d (diff)
Use common STANZA for bn and exp tests
Standardize file:line messages Reduce buff size; move to end of STANZA Add some Title entries (with blank line after) Add Title to some BN test files. Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3608)
Diffstat (limited to 'test/testutil.h')
-rw-r--r--test/testutil.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/testutil.h b/test/testutil.h
index d8acd7380f..48c4eb3677 100644
--- a/test/testutil.h
+++ b/test/testutil.h
@@ -402,4 +402,48 @@ void test_openssl_errors(void);
extern BIO *bio_out;
extern BIO *bio_err;
+/*
+ * Utilities to parse a test file.
+ */
+#define TESTMAXPAIRS 20
+
+typedef struct pair_st {
+ char *key;
+ char *value;
+} PAIR;
+
+typedef struct stanza_st {
+ const char *test_file; /* Input file name */
+ BIO *fp; /* Input file */
+ int curr; /* Current line in file */
+ int start; /* Line where test starts */
+ int errors; /* Error count */
+ int numtests; /* Number of tests */
+ int numskip; /* Number of skipped tests */
+ int numpairs;
+ PAIR pairs[TESTMAXPAIRS];
+ BIO *key; /* temp memory BIO for reading in keys */
+ char buff[4096]; /* Input buffer for a single key/value */
+} STANZA;
+
+/*
+ * Prepare to start reading the file |testfile| as input.
+ */
+int test_start_file(STANZA *s, const char *testfile);
+int test_end_file(STANZA *s);
+
+/*
+ * Read a stanza from the test file. A stanza consists of a block
+ * of lines of the form
+ * key = value
+ * The block is terminated by EOF or a blank line.
+ * Return 1 if found, 0 on EOF or error.
+ */
+int test_readstanza(STANZA *s);
+
+/*
+ * Clear a stanza, release all allocated memory.
+ */
+void test_clearstanza(STANZA *s);
+
#endif /* HEADER_TESTUTIL_H */