~ubuntu-branches/debian/lenny/tdb/lenny

« back to all changes in this revision

Viewing changes to tdbtorture.c

  • Committer: Bazaar Package Importer
  • Author(s): Marek Habersack
  • Date: 2005-05-04 11:11:22 UTC
  • mfrom: (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050504111122-7vpgb6zbq9zzc34t
Tags: 1.0.6-13
* Closes: #307214: ctrlproxy: FTBFS: /usr/include/tdb.h:150: error:
  parse error before '*' token
* Thanks to Wilmer van der Gaast <lintux@debian.org> for providing
  the patch to fix the above issue.
* Closes: #290211: Improper copyright file
* Closes: #262490: tdb_1.0.6-8_mips: FTBFS: opcode not supported on
  this processor: mips1. Spinlocks are not used on mips.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
#include <unistd.h>
6
6
#include <string.h>
7
7
#include <fcntl.h>
 
8
#include <signal.h>
8
9
#include <stdarg.h>
9
10
#include <sys/mman.h>
10
11
#include <sys/stat.h>
21
22
#define REOPEN_PROB 30
22
23
#define DELETE_PROB 8
23
24
#define STORE_PROB 4
 
25
#define APPEND_PROB 6
24
26
#define LOCKSTORE_PROB 0
25
27
#define TRAVERSE_PROB 20
26
28
#define CULL_PROB 100
67
69
        return buf;
68
70
}
69
71
 
70
 
static int cull_traverse(TDB_CONTEXT *db, TDB_DATA key, TDB_DATA dbuf,
 
72
static int cull_traverse(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf,
71
73
                         void *state)
72
74
{
73
75
        if (random() % CULL_PROB == 0) {
74
 
                tdb_delete(db, key);
 
76
                tdb_delete(tdb, key);
75
77
        }
76
78
        return 0;
77
79
}
122
124
        }
123
125
#endif
124
126
 
 
127
#if APPEND_PROB
 
128
        if (random() % APPEND_PROB == 0) {
 
129
                if (tdb_append(db, key, data) != 0) {
 
130
                        fatal("tdb_append failed");
 
131
                }
 
132
                goto next;
 
133
        }
 
134
#endif
 
135
 
125
136
#if LOCKSTORE_PROB
126
137
        if (random() % LOCKSTORE_PROB == 0) {
127
138
                tdb_chainlock(db, lockkey);
151
162
        free(s);
152
163
}
153
164
 
154
 
static int traverse_fn(TDB_CONTEXT *db, TDB_DATA key, TDB_DATA dbuf,
 
165
static int traverse_fn(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf,
155
166
                       void *state)
156
167
{
157
 
        tdb_delete(db, key);
 
168
        tdb_delete(tdb, key);
158
169
        return 0;
159
170
}
160
171