test.c 1.2 KB

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