Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
75281499
Commit
75281499
authored
Dec 20, 2011
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tdb: test exponential recovery expansion problem.
parent
3d45cf27
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
0 deletions
+78
-0
ccan/tdb/test/run-transaction-expand.c
ccan/tdb/test/run-transaction-expand.c
+78
-0
No files found.
ccan/tdb/test/run-transaction-expand.c
0 → 100644
View file @
75281499
/* We need this otherwise fcntl locking fails. */
#define _FILE_OFFSET_BITS 64
#define _XOPEN_SOURCE 500
#include <ccan/tdb/tdb_private.h>
/* Speed up the tests: setting TDB_NOSYNC removed recovery altogether. */
static
inline
int
fake_fsync
(
int
fd
)
{
return
0
;
}
#define fsync fake_fsync
#ifdef MS_SYNC
static
inline
int
fake_msync
(
void
*
addr
,
size_t
length
,
int
flags
)
{
return
0
;
}
#define msync fake_msync
#endif
#include <ccan/tdb/tdb.h>
#include <ccan/tdb/io.c>
#include <ccan/tdb/tdb.c>
#include <ccan/tdb/lock.c>
#include <ccan/tdb/freelist.c>
#include <ccan/tdb/traverse.c>
#include <ccan/tdb/transaction.c>
#include <ccan/tdb/error.c>
#include <ccan/tdb/open.c>
#include <ccan/tdb/check.c>
#include <ccan/tdb/hash.c>
#include <ccan/tap/tap.h>
#include <stdlib.h>
#include <err.h>
#include "logging.h"
static
void
write_record
(
struct
tdb_context
*
tdb
,
size_t
extra_len
,
TDB_DATA
*
data
)
{
TDB_DATA
key
;
key
.
dsize
=
strlen
(
"hi"
);
key
.
dptr
=
(
void
*
)
"hi"
;
data
->
dptr
=
realloc
(
data
->
dptr
,
data
->
dsize
+
extra_len
);
memset
(
data
->
dptr
+
data
->
dsize
,
'x'
,
extra_len
);
data
->
dsize
+=
extra_len
;
tdb_transaction_start
(
tdb
);
tdb_store
(
tdb
,
key
,
*
data
,
TDB_REPLACE
);
tdb_transaction_commit
(
tdb
);
diag
(
"TDB size = %zu"
,
(
size_t
)
tdb
->
map_size
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
struct
tdb_context
*
tdb
;
size_t
i
;
TDB_DATA
data
;
plan_tests
(
2
);
tdb
=
tdb_open_ex
(
"run-transaction-expand.tdb"
,
1024
,
TDB_CLEAR_IF_FIRST
,
O_CREAT
|
O_TRUNC
|
O_RDWR
,
0600
,
&
taplogctx
,
NULL
);
ok1
(
tdb
);
data
.
dsize
=
0
;
data
.
dptr
=
NULL
;
/* Simulate a slowly growing record. */
for
(
i
=
0
;
i
<
1000
;
i
++
)
write_record
(
tdb
,
getpagesize
(),
&
data
);
/* We should only be about 3 times larger than largest record. */
ok1
(
tdb
->
map_size
<
3
*
i
*
getpagesize
());
tdb_close
(
tdb
);
free
(
data
.
dptr
);
return
exit_status
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment