diff options
author | Asbjørn Sloth Tønnesen <ast@fiberby.dk> | 2016-01-25 10:40:27 +0000 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-02-01 00:01:18 +0100 |
commit | c43f55f35459d0b4fcfdb5617789ccf467130423 (patch) | |
tree | 3ed22b605458cfd405a7e08573c6d32c22c55637 /tests | |
parent | a6ac89adfb5c7a6c72ed0fe5be0be48464250764 (diff) |
tests: conntrack: run testfiles in the correct order
Use scandir(3) instead of opendir(3), so that the tests are
run in the expected order, otherwise it doesn't make
sense to prefix the testfiles with a two digit number,
giving the impression that they are run in order.
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.dk>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/conntrack/test-conntrack.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/conntrack/test-conntrack.c b/tests/conntrack/test-conntrack.c index c9097b6..7ce069b 100644 --- a/tests/conntrack/test-conntrack.c +++ b/tests/conntrack/test-conntrack.c @@ -23,14 +23,16 @@ int main() { int ret, ok = 0, bad = 0, line; FILE *fp; - DIR *d; char buf[1024]; + struct dirent **dents; struct dirent *dent; char file[1024]; + int i,n; - d = opendir("testsuite"); + n = scandir("testsuite", &dents, NULL, alphasort); - while ((dent = readdir(d)) != NULL) { + for (i = 0; i < n; i++) { + dent = dents[i]; sprintf(file, "testsuite/%s", dent->d_name); @@ -88,7 +90,11 @@ int main() } fclose(fp); } - closedir(d); + + for (i = 0; i < n; i++) + free(dents[i]); + + free(dents); fprintf(stdout, "OK: %d BAD: %d\n", ok, bad); } |