api-record-expand.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "config.h"
  2. #include "../ntdb.h"
  3. #include "../private.h"
  4. #include "tap-interface.h"
  5. #include "logging.h"
  6. #include "helpapi-external-agent.h"
  7. #define MAX_SIZE 10000
  8. #define SIZE_STEP 131
  9. int main(int argc, char *argv[])
  10. {
  11. unsigned int i;
  12. struct ntdb_context *ntdb;
  13. int flags[] = { NTDB_INTERNAL, NTDB_DEFAULT, NTDB_NOMMAP,
  14. NTDB_INTERNAL|NTDB_CONVERT, NTDB_CONVERT,
  15. NTDB_NOMMAP|NTDB_CONVERT };
  16. NTDB_DATA key = ntdb_mkdata("key", 3);
  17. NTDB_DATA data;
  18. data.dptr = malloc(MAX_SIZE);
  19. memset(data.dptr, 0x24, MAX_SIZE);
  20. plan_tests(sizeof(flags) / sizeof(flags[0])
  21. * (3 + (1 + (MAX_SIZE/SIZE_STEP)) * 2) + 1);
  22. for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
  23. ntdb = ntdb_open("run-record-expand.ntdb",
  24. flags[i]|MAYBE_NOSYNC,
  25. O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
  26. ok1(ntdb);
  27. if (!ntdb)
  28. continue;
  29. data.dsize = 0;
  30. ok1(ntdb_store(ntdb, key, data, NTDB_INSERT) == 0);
  31. ok1(ntdb_check(ntdb, NULL, NULL) == 0);
  32. for (data.dsize = 0;
  33. data.dsize < MAX_SIZE;
  34. data.dsize += SIZE_STEP) {
  35. memset(data.dptr, data.dsize, data.dsize);
  36. ok1(ntdb_store(ntdb, key, data, NTDB_MODIFY) == 0);
  37. ok1(ntdb_check(ntdb, NULL, NULL) == 0);
  38. }
  39. ntdb_close(ntdb);
  40. }
  41. ok1(tap_log_messages == 0);
  42. free(data.dptr);
  43. return exit_status();
  44. }