~ubuntu-branches/ubuntu/utopic/tdb/utopic-proposed

« back to all changes in this revision

Viewing changes to test/run-rwlock-check.c

  • Committer: Package Import Robot
  • Author(s): Andrew Bartlett
  • Date: 2013-02-12 20:43:55 UTC
  • mfrom: (1.4.6)
  • mto: (1.4.7) (3.3.7 experimental)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: package-import@ubuntu.com-20130212204355-6q6jvxshtoie7ex5
ImportĀ upstreamĀ versionĀ 1.2.11

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "../common/tdb_private.h"
 
2
#include "../common/io.c"
 
3
#include "../common/tdb.c"
 
4
#include "../common/lock.c"
 
5
#include "../common/freelist.c"
 
6
#include "../common/traverse.c"
 
7
#include "../common/transaction.c"
 
8
#include "../common/error.c"
 
9
#include "../common/open.c"
 
10
#include "../common/check.c"
 
11
#include "../common/hash.c"
 
12
#include "tap-interface.h"
 
13
#include <stdlib.h>
 
14
 
 
15
static void log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...)
 
16
{
 
17
        unsigned int *count = tdb_get_logging_private(tdb);
 
18
        if (strstr(fmt, "spinlocks"))
 
19
                (*count)++;
 
20
}
 
21
 
 
22
/* The code should barf on TDBs created with rwlocks. */
 
23
int main(int argc, char *argv[])
 
24
{
 
25
        struct tdb_context *tdb;
 
26
        unsigned int log_count;
 
27
        struct tdb_logging_context log_ctx = { log_fn, &log_count };
 
28
 
 
29
        plan_tests(4);
 
30
 
 
31
        /* We should fail to open rwlock-using tdbs of either endian. */
 
32
        log_count = 0;
 
33
        tdb = tdb_open_ex("test/rwlock-le.tdb", 0, 0, O_RDWR, 0,
 
34
                          &log_ctx, NULL);
 
35
        ok1(!tdb);
 
36
        ok1(log_count == 1);
 
37
 
 
38
        log_count = 0;
 
39
        tdb = tdb_open_ex("test/rwlock-be.tdb", 0, 0, O_RDWR, 0,
 
40
                          &log_ctx, NULL);
 
41
        ok1(!tdb);
 
42
        ok1(log_count == 1);
 
43
 
 
44
        return exit_status();
 
45
}