s3: use generate_random_password() instead of generate_random_str()
[Samba/gebeck_regimport.git] / lib / ntdb / test / api-record-expand.c
blob8786fc7e5c4c8f8603e18d608f2a33cf79ab23da
1 #include "config.h"
2 #include "ntdb.h"
3 #include "tap-interface.h"
4 #include <sys/types.h>
5 #include <sys/stat.h>
6 #include <fcntl.h>
7 #include <stdlib.h>
8 #include "logging.h"
10 #define MAX_SIZE 10000
11 #define SIZE_STEP 131
13 int main(int argc, char *argv[])
15 unsigned int i;
16 struct ntdb_context *ntdb;
17 int flags[] = { NTDB_INTERNAL, NTDB_DEFAULT, NTDB_NOMMAP,
18 NTDB_INTERNAL|NTDB_CONVERT, NTDB_CONVERT,
19 NTDB_NOMMAP|NTDB_CONVERT };
20 NTDB_DATA key = ntdb_mkdata("key", 3);
21 NTDB_DATA data;
23 data.dptr = malloc(MAX_SIZE);
24 memset(data.dptr, 0x24, MAX_SIZE);
26 plan_tests(sizeof(flags) / sizeof(flags[0])
27 * (3 + (1 + (MAX_SIZE/SIZE_STEP)) * 2) + 1);
28 for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
29 ntdb = ntdb_open("run-record-expand.ntdb",
30 flags[i]|MAYBE_NOSYNC,
31 O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
32 ok1(ntdb);
33 if (!ntdb)
34 continue;
36 data.dsize = 0;
37 ok1(ntdb_store(ntdb, key, data, NTDB_INSERT) == 0);
38 ok1(ntdb_check(ntdb, NULL, NULL) == 0);
39 for (data.dsize = 0;
40 data.dsize < MAX_SIZE;
41 data.dsize += SIZE_STEP) {
42 memset(data.dptr, data.dsize, data.dsize);
43 ok1(ntdb_store(ntdb, key, data, NTDB_MODIFY) == 0);
44 ok1(ntdb_check(ntdb, NULL, NULL) == 0);
46 ntdb_close(ntdb);
48 ok1(tap_log_messages == 0);
49 free(data.dptr);
51 return exit_status();