test.c 1.1 KB

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