driver.c revision 5f6f061e40e5ec48dd42d3329bfe9d56730efe56
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff/*
4a73cf8ee07ae396be20231ac252a24830f3c801Bob Halley * Copyright (C) 2000 Internet Software Consortium.
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff *
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * Permission to use, copy, modify, and distribute this software for any
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * purpose with or without fee is hereby granted, provided that the above
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * copyright notice and this permission notice appear in all copies.
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff *
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * SOFTWARE.
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff */
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff/* $Id: driver.c,v 1.2 2000/06/16 23:38:42 explorer Exp $ */
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff#include <isc/string.h>
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff#include <isc/util.h>
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff#include <stdlib.h>
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff#include <stdio.h>
86944a4c8002e80ae9b6eb5a5e29b797879be45fMichael Graff#include <time.h>
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff#include "driver.h"
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff#include "testsuite.h"
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff#define NTESTS (sizeof(tests) / sizeof(test_t))
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff
910df98b0efcbe8380b952887f4071051cc39a25Michael Graffconst char *gettime(void);
910df98b0efcbe8380b952887f4071051cc39a25Michael Graffconst char *test_result_totext(test_result_t);
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff/*
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * Not thread safe.
e45d323a2a0f4ca08d4b139546e60a5fa7bd3f0cMichael Graff */
fd15c8e32ed0c1cfd3ed737858a81966e7fbaeacAndreas Gustafssonconst char *
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graffgettime(void) {
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff static char now[512];
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff time_t t;
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff (void)time(&t);
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff strftime(now, sizeof(now) - 1,
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff "%A %d %B %H:%M:%S %Y",
c803787146cadcb2d7e10cbf4491f3be513dfa1aMichael Graff localtime(&t));
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff return (now);
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff}
2bcb48cfcae36398454c98e40c563e2cde748e07Michael Graff
2bcb48cfcae36398454c98e40c563e2cde748e07Michael Graffconst char *
3ac63b472022ff92691d1fe69ac715a729671965Michael Grafftest_result_totext(test_result_t result) {
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff const char *s;
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff switch (result) {
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff case PASSED:
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff s = "PASS";
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff break;
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff case FAILED:
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff s = "FAIL";
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff break;
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff case UNTESTED:
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff s = "UNTESTED";
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff break;
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff case UNKNOWN:
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff default:
86944a4c8002e80ae9b6eb5a5e29b797879be45fMichael Graff s = "UNKNOWN";
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff break;
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff }
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff return (s);
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff}
fc4fe6e5e61dbc916707ab2e071ffd22aef9de7fMichael Graff
fc4fe6e5e61dbc916707ab2e071ffd22aef9de7fMichael Graffint
86944a4c8002e80ae9b6eb5a5e29b797879be45fMichael Graffmain(int argc, char **argv) {
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff test_t *test;
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff test_result_t result;
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff unsigned int n_failed;
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff unsigned int testno;
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff UNUSED(argc);
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff UNUSED(argv);
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff printf("S:%s:%s\n", SUITENAME, gettime());
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff n_failed = 0;
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff for (testno = 0 ; testno < NTESTS ; testno++) {
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff test = &tests[testno];
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff printf("T:%s:%u:A\n", test->tag, testno + 1);
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff printf("A:%s\n", test->description);
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff result = test->func();
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff printf("R:%s\n", test_result_totext(result));
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff if (result != PASSED)
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff n_failed++;
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff }
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff printf("E:%s:%s\n", SUITENAME, gettime());
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff if (n_failed > 0)
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff exit(1);
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff else
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff exit(0);
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff}
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff