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
be1d6120
Commit
be1d6120
authored
Mar 01, 2011
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tdb2: failtest on tdb_store
Increase from: 1985 of 2553 lines covered to: 2018 of 2552 lines covered
parent
2c137288
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
16 deletions
+48
-16
ccan/tdb2/test/run-10-simple-store.c
ccan/tdb2/test/run-10-simple-store.c
+48
-16
No files found.
ccan/tdb2/test/run-10-simple-store.c
View file @
be1d6120
#include <ccan/failtest/failtest_override.h>
#include <ccan/tdb2/tdb.c>
#include <ccan/tdb2/tdb.c>
#include <ccan/tdb2/free.c>
#include <ccan/tdb2/free.c>
#include <ccan/tdb2/lock.c>
#include <ccan/tdb2/lock.c>
...
@@ -6,7 +7,20 @@
...
@@ -6,7 +7,20 @@
#include <ccan/tdb2/transaction.c>
#include <ccan/tdb2/transaction.c>
#include <ccan/tdb2/check.c>
#include <ccan/tdb2/check.c>
#include <ccan/tap/tap.h>
#include <ccan/tap/tap.h>
#include <ccan/failtest/failtest.h>
#include "logging.h"
#include "logging.h"
#include "failtest_helper.h"
static
bool
failtest_suppress
=
false
;
/* Don't need to test everything here, just want expand testing. */
static
enum
failtest_result
suppress_failure
(
struct
failtest_call
*
history
,
unsigned
num
)
{
if
(
failtest_suppress
)
return
FAIL_DONT_FAIL
;
return
block_repeat_failures
(
history
,
num
);
}
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
...
@@ -18,26 +32,44 @@ int main(int argc, char *argv[])
...
@@ -18,26 +32,44 @@ int main(int argc, char *argv[])
struct
tdb_data
key
=
{
(
unsigned
char
*
)
"key"
,
3
};
struct
tdb_data
key
=
{
(
unsigned
char
*
)
"key"
,
3
};
struct
tdb_data
data
=
{
(
unsigned
char
*
)
"data"
,
4
};
struct
tdb_data
data
=
{
(
unsigned
char
*
)
"data"
,
4
};
failtest_init
(
argc
,
argv
);
failtest_hook
=
suppress_failure
;
failtest_exit_check
=
exit_check_log
;
failtest_suppress
=
true
;
plan_tests
(
sizeof
(
flags
)
/
sizeof
(
flags
[
0
])
*
7
+
1
);
plan_tests
(
sizeof
(
flags
)
/
sizeof
(
flags
[
0
])
*
7
+
1
);
for
(
i
=
0
;
i
<
sizeof
(
flags
)
/
sizeof
(
flags
[
0
]);
i
++
)
{
for
(
i
=
0
;
i
<
sizeof
(
flags
)
/
sizeof
(
flags
[
0
]);
i
++
)
{
tdb
=
tdb_open
(
"run-10-simple-store.tdb"
,
flags
[
i
],
tdb
=
tdb_open
(
"run-10-simple-store.tdb"
,
flags
[
i
],
O_RDWR
|
O_CREAT
|
O_TRUNC
,
0600
,
&
tap_log_attr
);
O_RDWR
|
O_CREAT
|
O_TRUNC
,
0600
,
&
tap_log_attr
);
ok1
(
tdb
);
if
(
!
ok1
(
tdb
))
if
(
tdb
)
{
break
;
/* Modify should fail. */
/* Modify should fail. */
ok1
(
tdb_store
(
tdb
,
key
,
data
,
TDB_MODIFY
)
failtest_suppress
=
false
;
==
TDB_ERR_NOEXIST
);
if
(
!
ok1
(
tdb_store
(
tdb
,
key
,
data
,
TDB_MODIFY
)
ok1
(
tdb_check
(
tdb
,
NULL
,
NULL
)
==
0
);
==
TDB_ERR_NOEXIST
))
/* Insert should succeed. */
goto
fail
;
ok1
(
tdb_store
(
tdb
,
key
,
data
,
TDB_INSERT
)
==
0
);
failtest_suppress
=
true
;
ok1
(
tdb_check
(
tdb
,
NULL
,
NULL
)
==
0
);
ok1
(
tdb_check
(
tdb
,
NULL
,
NULL
)
==
0
);
/* Second insert should fail. */
/* Insert should succeed. */
ok1
(
tdb_store
(
tdb
,
key
,
data
,
TDB_INSERT
)
failtest_suppress
=
false
;
==
TDB_ERR_EXISTS
);
if
(
!
ok1
(
tdb_store
(
tdb
,
key
,
data
,
TDB_INSERT
)
==
0
))
ok1
(
tdb_check
(
tdb
,
NULL
,
NULL
)
==
0
);
goto
fail
;
tdb_close
(
tdb
);
failtest_suppress
=
true
;
}
ok1
(
tdb_check
(
tdb
,
NULL
,
NULL
)
==
0
);
/* Second insert should fail. */
failtest_suppress
=
false
;
if
(
!
ok1
(
tdb_store
(
tdb
,
key
,
data
,
TDB_INSERT
)
==
TDB_ERR_EXISTS
))
goto
fail
;
failtest_suppress
=
true
;
ok1
(
tdb_check
(
tdb
,
NULL
,
NULL
)
==
0
);
tdb_close
(
tdb
);
}
}
ok1
(
tap_log_messages
==
0
);
ok1
(
tap_log_messages
==
0
);
return
exit_status
();
failtest_exit
(
exit_status
());
fail:
failtest_suppress
=
true
;
tdb_close
(
tdb
);
failtest_exit
(
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