static void wiki_exit() { /* Now shutdown everything */ if (wiki->errorfd) { fclose(wiki->errorfd); } if (wiki->accessfd) { fclose(wiki->accessfd); } svr_del(server); cfg_del(wiki->cfg); }
int run_suite(const char *cfgname, const char *csvname, int testnums[], int tlen) { struct cfg *cfg; FILE *csv; unsigned char buf[4096], *row[32]; int tnum, ti, ret, flags; if ((cfg = cfg_new(NULL)) == NULL || cfg_load(cfg, cfgname)) { AMSG(": %s", cfgname); return -1; } if ((csv = fopen(csvname, "r")) == NULL) { PMNF(errno, ": %s", csvname); return -1; } while ((ret = csv_row_fread(csv, buf, 4096, row, 32, ',', CSV_TRIM | CSV_QUOTES)) > 0) { if ((flags = strtol(row[1], NULL, 10)) == LONG_MIN || flags == LONG_MAX) { PMNF(errno, ": Invalid test flags: %s", row[1]); return -1; } if (flags == 0) { continue; } if ((tnum = strtol(row[0], NULL, 10)) == LONG_MIN || tnum == LONG_MAX) { PMNF(errno, ": Invalid test number: %s", row[0]); return -1; } if (tlen) { for (ti = 0; ti < tlen; ti++) { if (tnum == testnums[ti]) { break; } } if (ti == tlen) { continue; } } for (ti = 0; test_tbl[ti].test; ti++) { if (tnum == test_tbl[ti].num) { break; } } if (test_tbl[ti].test == NULL) { PMSG("Test not found: %d", tnum); return -1; } errno = 0; fprintf(stderr, "%d:%s: ", tnum, row[2]); fflush(stderr); if (test_tbl[ti].test(flags > 1 ? flags : 0, cfg, (char **)row + 4) == 0) { fprintf(stderr, "pass\n"); } else { MMSG("%d failed", tnum); } } fclose(csv); cfg_del(cfg); return ret; }