1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-14 19:24:43 +03:00
samba-mirror/lib/ntdb/test/api-add-remove-flags.c
Rusty Russell 0265837ee8 ntdb: respect TDB_NO_FSYNC flag for 'make test'
This reduces test time from 31 seconds to 6, on my laptop.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2012-06-22 07:35:16 +02:00

91 lines
2.1 KiB
C

#include "private.h" // for ntdb_context
#include "ntdb.h"
#include "tap-interface.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "logging.h"
int main(int argc, char *argv[])
{
unsigned int i;
struct ntdb_context *ntdb;
int flags[] = { NTDB_INTERNAL, NTDB_DEFAULT, NTDB_NOMMAP,
NTDB_INTERNAL|NTDB_CONVERT, NTDB_CONVERT,
NTDB_NOMMAP|NTDB_CONVERT };
plan_tests(87);
for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) {
ntdb = ntdb_open("run-add-remove-flags.ntdb",
flags[i]|MAYBE_NOSYNC,
O_RDWR|O_CREAT|O_TRUNC, 0600, &tap_log_attr);
ok1(ntdb);
if (!ntdb)
continue;
ok1(ntdb_get_flags(ntdb) == ntdb->flags);
tap_log_messages = 0;
ntdb_add_flag(ntdb, NTDB_NOLOCK);
if (flags[i] & NTDB_INTERNAL)
ok1(tap_log_messages == 1);
else {
ok1(tap_log_messages == 0);
ok1(ntdb_get_flags(ntdb) & NTDB_NOLOCK);
}
tap_log_messages = 0;
ntdb_add_flag(ntdb, NTDB_NOMMAP);
if (flags[i] & NTDB_INTERNAL)
ok1(tap_log_messages == 1);
else {
ok1(tap_log_messages == 0);
ok1(ntdb_get_flags(ntdb) & NTDB_NOMMAP);
ok1(ntdb->file->map_ptr == NULL);
}
tap_log_messages = 0;
ntdb_add_flag(ntdb, NTDB_NOSYNC);
if (flags[i] & NTDB_INTERNAL)
ok1(tap_log_messages == 1);
else {
ok1(tap_log_messages == 0);
ok1(ntdb_get_flags(ntdb) & NTDB_NOSYNC);
}
ok1(ntdb_get_flags(ntdb) == ntdb->flags);
tap_log_messages = 0;
ntdb_remove_flag(ntdb, NTDB_NOLOCK);
if (flags[i] & NTDB_INTERNAL)
ok1(tap_log_messages == 1);
else {
ok1(tap_log_messages == 0);
ok1(!(ntdb_get_flags(ntdb) & NTDB_NOLOCK));
}
tap_log_messages = 0;
ntdb_remove_flag(ntdb, NTDB_NOMMAP);
if (flags[i] & NTDB_INTERNAL)
ok1(tap_log_messages == 1);
else {
ok1(tap_log_messages == 0);
ok1(!(ntdb_get_flags(ntdb) & NTDB_NOMMAP));
ok1(ntdb->file->map_ptr != NULL);
}
tap_log_messages = 0;
ntdb_remove_flag(ntdb, NTDB_NOSYNC);
if (flags[i] & NTDB_INTERNAL)
ok1(tap_log_messages == 1);
else {
ok1(tap_log_messages == 0);
ok1(!(ntdb_get_flags(ntdb) & NTDB_NOSYNC));
}
ntdb_close(ntdb);
}
ok1(tap_log_messages == 0);
return exit_status();
}