test.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include <time.h>
  2. #include "test_term.c"
  3. #include "test_namespace.c"
  4. #include "test_codec_nt.c"
  5. #include "test_store.c"
  6. #include "test_graph.c"
  7. #define TEST_STORE_PATH TMPDIR "/lsup_test_mdb"
  8. int main(int argc, char **argv) {
  9. // Set env variable to test path.
  10. putenv ("LSUP_MDB_STORE_PATH=" TEST_STORE_PATH);
  11. // Clear out database from previous test.
  12. rm_r (TEST_STORE_PATH);
  13. clock_t start, end;
  14. double wallclock;
  15. start = clock();
  16. int rc = LSUP_init();
  17. if (rc != LSUP_OK) return rc;
  18. if (
  19. term_tests() ||
  20. namespace_tests() ||
  21. store_tests() ||
  22. graph_tests() ||
  23. codec_nt_tests() ||
  24. 0
  25. ) {
  26. log_error ("Test failed.");
  27. rc = -1;
  28. } else {
  29. log_info ("");
  30. log_info ("********************");
  31. log_info ("* ALL TESTS PASSED *");
  32. log_info ("********************");
  33. rc = 0;
  34. }
  35. end = clock();
  36. wallclock = (end - start) * 1000 / CLOCKS_PER_SEC;
  37. log_info ("");
  38. log_info ("Run %d tests in %lu ms.", tests_run, (size_t) wallclock);
  39. return rc;
  40. }