Use common STANZA for bn and exp tests
[openssl.git] / test / testutil.h
index 36b7823e397f90d7acc5a651648b0eeaaed82658..48c4eb3677354cd82170e4e6d2925dd331a9e476 100644 (file)
@@ -140,6 +140,7 @@ void add_test(const char *test_case_name, int (*test_fn) ());
 void add_all_tests(const char *test_case_name, int (*test_fn)(int idx), int num,
                    int subtest);
 __owur int run_tests(const char *test_prog_name);
+void set_test_title(const char *title);
 
 /*
  * Declarations for user defined functions
@@ -356,6 +357,10 @@ void test_openssl_errors(void);
 
 # define TEST_BN_eq(a, b)     test_BN_eq(__FILE__, __LINE__, #a, #b, a, b)
 # define TEST_BN_ne(a, b)     test_BN_ne(__FILE__, __LINE__, #a, #b, a, b)
+# define TEST_BN_lt(a, b)     test_BN_lt(__FILE__, __LINE__, #a, #b, a, b)
+# define TEST_BN_gt(a, b)     test_BN_gt(__FILE__, __LINE__, #a, #b, a, b)
+# define TEST_BN_le(a, b)     test_BN_le(__FILE__, __LINE__, #a, #b, a, b)
+# define TEST_BN_ge(a, b)     test_BN_ge(__FILE__, __LINE__, #a, #b, a, b)
 # define TEST_BN_eq_zero(a)   test_BN_eq_zero(__FILE__, __LINE__, #a, a)
 # define TEST_BN_ne_zero(a)   test_BN_ne_zero(__FILE__, __LINE__, #a, a)
 # define TEST_BN_lt_zero(a)   test_BN_lt_zero(__FILE__, __LINE__, #a, a)
@@ -397,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 */