} PAIR;
typedef struct stanza_st {
- int start;
+ int curr; /* Current line in file */
+ int start; /* Line where test starts */
int numpairs;
PAIR pairs[MAXPAIRS];
} STANZA;
/*
* Read next test stanza; return 1 if found, 0 on EOF or error.
*/
-static int readstanza(STANZA *s, int *linesread)
+static int readstanza(STANZA *s)
{
PAIR *pp = s->pairs;
char *p, *equals, *key, *value;
char buff[1024];
while (BIO_gets(fp, buff, sizeof(buff))) {
- (*linesread)++;
+ s->curr++;
if (!TEST_ptr(p = strchr(buff, '\n'))) {
- TEST_info("Line %d too long", s->start);
+ TEST_info("Line %d too long", s->curr);
return 0;
}
*p = '\0';
if (buff[0] == '#')
continue;
- if (!TEST_ptr(equals = strchr(buff, '=')))
+ if (!TEST_ptr(equals = strchr(buff, '='))) {
+ TEST_info("Missing = at line %d\n", s->curr);
return 0;
+ }
*equals++ = '\0';
+ if (s->numpairs == 0)
+ s->start = s->curr;
if (!TEST_ptr(key = strip_spaces(buff))
|| !TEST_ptr(value = strip_spaces(equals))
PAIR *pp = s->pairs;
int i = s->numpairs;
int start = s->start;
+ int curr = s->curr;
for ( ; --i >= 0; pp++) {
OPENSSL_free(pp->key);
OPENSSL_free(pp->value);
}
memset(s, 0, sizeof(*s));
+ s->curr = curr;
s->start = start;
}
static int run_file_tests(int i)
{
STANZA s;
- int linesread = 0, errcnt = 0;
+ int errcnt = 0;
if (!TEST_ptr(fp = BIO_new_file(testfiles[i], "rb")))
return 0;
/* Read test file. */
set_test_title(testfiles[i]);
memset(&s, 0, sizeof(s));
- while (!BIO_eof(fp) && readstanza(&s, &linesread)) {
+ while (!BIO_eof(fp) && readstanza(&s)) {
if (s.numpairs == 0)
continue;
if (!file_test_run(&s)) {
errcnt++;
}
clearstanza(&s);
- s.start = linesread;
}
BIO_free(fp);