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
ab3df365
Commit
ab3df365
authored
Dec 23, 2010
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tdb: add test for tdb_summary
parent
d6b00a71
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
0 deletions
+65
-0
ccan/tdb/test/run-summary.c
ccan/tdb/test/run-summary.c
+65
-0
No files found.
ccan/tdb/test/run-summary.c
0 → 100644
View file @
ab3df365
#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/tdb/summary.c>
#include <ccan/tap/tap.h>
#include <stdlib.h>
#include <err.h>
int
main
(
int
argc
,
char
*
argv
[])
{
unsigned
int
i
,
j
;
struct
tdb_context
*
tdb
;
int
flags
[]
=
{
TDB_INTERNAL
,
TDB_DEFAULT
,
TDB_NOMMAP
,
TDB_INTERNAL
|
TDB_CONVERT
,
TDB_CONVERT
,
TDB_NOMMAP
|
TDB_CONVERT
};
TDB_DATA
key
=
{
(
unsigned
char
*
)
&
j
,
sizeof
(
j
)
};
TDB_DATA
data
=
{
(
unsigned
char
*
)
&
j
,
sizeof
(
j
)
};
char
*
summary
;
plan_tests
(
sizeof
(
flags
)
/
sizeof
(
flags
[
0
])
*
14
);
for
(
i
=
0
;
i
<
sizeof
(
flags
)
/
sizeof
(
flags
[
0
]);
i
++
)
{
tdb
=
tdb_open
(
"run-summary.tdb"
,
131
,
flags
[
i
],
O_RDWR
|
O_CREAT
|
O_TRUNC
,
0600
);
ok1
(
tdb
);
if
(
!
tdb
)
continue
;
/* Put some stuff in there. */
for
(
j
=
0
;
j
<
500
;
j
++
)
{
/* Make sure padding varies to we get some graphs! */
data
.
dsize
=
j
%
(
sizeof
(
j
)
+
1
);
if
(
tdb_store
(
tdb
,
key
,
data
,
TDB_REPLACE
)
!=
0
)
fail
(
"Storing in tdb"
);
}
summary
=
tdb_summary
(
tdb
);
diag
(
"%s"
,
summary
);
ok1
(
strstr
(
summary
,
"Size of file/data: "
));
ok1
(
strstr
(
summary
,
"Number of records: 500
\n
"
));
ok1
(
strstr
(
summary
,
"Smallest/average/largest keys: 4/4/4
\n
"
));
ok1
(
strstr
(
summary
,
"Smallest/average/largest data: 0/2/4
\n
"
));
ok1
(
strstr
(
summary
,
"Smallest/average/largest padding: "
));
ok1
(
strstr
(
summary
,
"Number of dead records: 0
\n
"
));
ok1
(
strstr
(
summary
,
"Number of free records: 1
\n
"
));
ok1
(
strstr
(
summary
,
"Smallest/average/largest free records: "
));
ok1
(
strstr
(
summary
,
"Number of hash chains: 131
\n
"
));
ok1
(
strstr
(
summary
,
"Smallest/average/largest hash chains: "
));
ok1
(
strstr
(
summary
,
"Number of uncoalesced records: 0
\n
"
));
ok1
(
strstr
(
summary
,
"Smallest/average/largest uncoalesced runs: 0/0/0
\n
"
));
ok1
(
strstr
(
summary
,
"Percentage keys/data/padding/free/dead/rechdrs&tailers/hashes: "
));
free
(
summary
);
tdb_close
(
tdb
);
}
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