run-12-check.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "../private.h"
  2. #include <ccan/failtest/failtest_override.h>
  3. #include "ntdb-source.h"
  4. #include "tap-interface.h"
  5. #include <ccan/failtest/failtest.h>
  6. #include "logging.h"
  7. #include "failtest_helper.h"
  8. #include "helprun-external-agent.h"
  9. int main(int argc, char *argv[])
  10. {
  11. unsigned int i;
  12. struct ntdb_context *ntdb;
  13. int flags[] = { NTDB_INTERNAL,
  14. NTDB_INTERNAL|NTDB_CONVERT,
  15. NTDB_CONVERT };
  16. NTDB_DATA key = ntdb_mkdata("key", 3);
  17. NTDB_DATA data = ntdb_mkdata("data", 4);
  18. failtest_init(argc, argv);
  19. failtest_hook = block_repeat_failures;
  20. failtest_exit_check = exit_check_log;
  21. failtest_suppress = true;
  22. plan_tests(sizeof(flags) / sizeof(flags[0]) * 3 + 1);
  23. for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
  24. ntdb = ntdb_open("run-12-check.ntdb", flags[i]|MAYBE_NOSYNC,
  25. O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
  26. ok1(ntdb);
  27. ok1(ntdb_store(ntdb, key, data, NTDB_INSERT) == 0);
  28. /* This is what we really want to test: ntdb_check(). */
  29. failtest_suppress = false;
  30. if (!ok1(ntdb_check(ntdb, NULL, NULL) == 0))
  31. goto fail;
  32. failtest_suppress = true;
  33. ntdb_close(ntdb);
  34. }
  35. ok1(tap_log_messages == 0);
  36. failtest_exit(exit_status());
  37. fail:
  38. failtest_suppress = true;
  39. ntdb_close(ntdb);
  40. failtest_exit(exit_status());
  41. /*
  42. * We will never reach this but the compiler complains if we do not
  43. * return in this function.
  44. */
  45. return EFAULT;
  46. }