Loading test/bntest.c +14 −8 Original line number Original line Diff line number Diff line Loading @@ -49,7 +49,8 @@ typedef struct pair_st { } PAIR; } PAIR; typedef struct stanza_st { typedef struct stanza_st { int start; int curr; /* Current line in file */ int start; /* Line where test starts */ int numpairs; int numpairs; PAIR pairs[MAXPAIRS]; PAIR pairs[MAXPAIRS]; } STANZA; } STANZA; Loading Loading @@ -2005,16 +2006,16 @@ static char *strip_spaces(char *p) /* /* * Read next test stanza; return 1 if found, 0 on EOF or error. * 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; PAIR *pp = s->pairs; char *p, *equals, *key, *value; char *p, *equals, *key, *value; char buff[1024]; char buff[1024]; while (BIO_gets(fp, buff, sizeof(buff))) { while (BIO_gets(fp, buff, sizeof(buff))) { (*linesread)++; s->curr++; if (!TEST_ptr(p = strchr(buff, '\n'))) { 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; return 0; } } *p = '\0'; *p = '\0'; Loading @@ -2027,9 +2028,13 @@ static int readstanza(STANZA *s, int *linesread) if (buff[0] == '#') if (buff[0] == '#') continue; continue; if (!TEST_ptr(equals = strchr(buff, '='))) if (!TEST_ptr(equals = strchr(buff, '='))) { TEST_info("Missing = at line %d\n", s->curr); return 0; return 0; } *equals++ = '\0'; *equals++ = '\0'; if (s->numpairs == 0) s->start = s->curr; if (!TEST_ptr(key = strip_spaces(buff)) if (!TEST_ptr(key = strip_spaces(buff)) || !TEST_ptr(value = strip_spaces(equals)) || !TEST_ptr(value = strip_spaces(equals)) Loading @@ -2049,12 +2054,14 @@ static void clearstanza(STANZA *s) PAIR *pp = s->pairs; PAIR *pp = s->pairs; int i = s->numpairs; int i = s->numpairs; int start = s->start; int start = s->start; int curr = s->curr; for ( ; --i >= 0; pp++) { for ( ; --i >= 0; pp++) { OPENSSL_free(pp->key); OPENSSL_free(pp->key); OPENSSL_free(pp->value); OPENSSL_free(pp->value); } } memset(s, 0, sizeof(*s)); memset(s, 0, sizeof(*s)); s->curr = curr; s->start = start; s->start = start; } } Loading Loading @@ -2094,7 +2101,7 @@ static char * const *testfiles; static int run_file_tests(int i) static int run_file_tests(int i) { { STANZA s; STANZA s; int linesread = 0, errcnt = 0; int errcnt = 0; if (!TEST_ptr(fp = BIO_new_file(testfiles[i], "rb"))) if (!TEST_ptr(fp = BIO_new_file(testfiles[i], "rb"))) return 0; return 0; Loading @@ -2102,14 +2109,13 @@ static int run_file_tests(int i) /* Read test file. */ /* Read test file. */ set_test_title(testfiles[i]); set_test_title(testfiles[i]); memset(&s, 0, sizeof(s)); memset(&s, 0, sizeof(s)); while (!BIO_eof(fp) && readstanza(&s, &linesread)) { while (!BIO_eof(fp) && readstanza(&s)) { if (s.numpairs == 0) if (s.numpairs == 0) continue; continue; if (!file_test_run(&s)) { if (!file_test_run(&s)) { errcnt++; errcnt++; } } clearstanza(&s); clearstanza(&s); s.start = linesread; } } BIO_free(fp); BIO_free(fp); Loading Loading
test/bntest.c +14 −8 Original line number Original line Diff line number Diff line Loading @@ -49,7 +49,8 @@ typedef struct pair_st { } PAIR; } PAIR; typedef struct stanza_st { typedef struct stanza_st { int start; int curr; /* Current line in file */ int start; /* Line where test starts */ int numpairs; int numpairs; PAIR pairs[MAXPAIRS]; PAIR pairs[MAXPAIRS]; } STANZA; } STANZA; Loading Loading @@ -2005,16 +2006,16 @@ static char *strip_spaces(char *p) /* /* * Read next test stanza; return 1 if found, 0 on EOF or error. * 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; PAIR *pp = s->pairs; char *p, *equals, *key, *value; char *p, *equals, *key, *value; char buff[1024]; char buff[1024]; while (BIO_gets(fp, buff, sizeof(buff))) { while (BIO_gets(fp, buff, sizeof(buff))) { (*linesread)++; s->curr++; if (!TEST_ptr(p = strchr(buff, '\n'))) { 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; return 0; } } *p = '\0'; *p = '\0'; Loading @@ -2027,9 +2028,13 @@ static int readstanza(STANZA *s, int *linesread) if (buff[0] == '#') if (buff[0] == '#') continue; continue; if (!TEST_ptr(equals = strchr(buff, '='))) if (!TEST_ptr(equals = strchr(buff, '='))) { TEST_info("Missing = at line %d\n", s->curr); return 0; return 0; } *equals++ = '\0'; *equals++ = '\0'; if (s->numpairs == 0) s->start = s->curr; if (!TEST_ptr(key = strip_spaces(buff)) if (!TEST_ptr(key = strip_spaces(buff)) || !TEST_ptr(value = strip_spaces(equals)) || !TEST_ptr(value = strip_spaces(equals)) Loading @@ -2049,12 +2054,14 @@ static void clearstanza(STANZA *s) PAIR *pp = s->pairs; PAIR *pp = s->pairs; int i = s->numpairs; int i = s->numpairs; int start = s->start; int start = s->start; int curr = s->curr; for ( ; --i >= 0; pp++) { for ( ; --i >= 0; pp++) { OPENSSL_free(pp->key); OPENSSL_free(pp->key); OPENSSL_free(pp->value); OPENSSL_free(pp->value); } } memset(s, 0, sizeof(*s)); memset(s, 0, sizeof(*s)); s->curr = curr; s->start = start; s->start = start; } } Loading Loading @@ -2094,7 +2101,7 @@ static char * const *testfiles; static int run_file_tests(int i) static int run_file_tests(int i) { { STANZA s; STANZA s; int linesread = 0, errcnt = 0; int errcnt = 0; if (!TEST_ptr(fp = BIO_new_file(testfiles[i], "rb"))) if (!TEST_ptr(fp = BIO_new_file(testfiles[i], "rb"))) return 0; return 0; Loading @@ -2102,14 +2109,13 @@ static int run_file_tests(int i) /* Read test file. */ /* Read test file. */ set_test_title(testfiles[i]); set_test_title(testfiles[i]); memset(&s, 0, sizeof(s)); memset(&s, 0, sizeof(s)); while (!BIO_eof(fp) && readstanza(&s, &linesread)) { while (!BIO_eof(fp) && readstanza(&s)) { if (s.numpairs == 0) if (s.numpairs == 0) continue; continue; if (!file_test_run(&s)) { if (!file_test_run(&s)) { errcnt++; errcnt++; } } clearstanza(&s); clearstanza(&s); s.start = linesread; } } BIO_free(fp); BIO_free(fp); Loading