summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/tdb/test/external-agent.c12
-rw-r--r--lib/tdb/test/run-corrupt.c12
-rw-r--r--lib/tdb/test/run-die-during-transaction.c16
-rw-r--r--lib/tdb/test/run-nested-traverse.c2
-rw-r--r--lib/tdb/test/run-open-during-transaction.c2
-rw-r--r--lib/tdb/test/run-traverse-in-transaction.c2
-rw-r--r--lib/tdb/test/tap-interface.h5
7 files changed, 28 insertions, 23 deletions
diff --git a/lib/tdb/test/external-agent.c b/lib/tdb/test/external-agent.c
index 139de76f9a..8140e70ead 100644
--- a/lib/tdb/test/external-agent.c
+++ b/lib/tdb/test/external-agent.c
@@ -108,12 +108,16 @@ struct agent *prepare_external_agent(void)
int command[2], response[2];
char name[1+PATH_MAX];
- if (pipe(command) != 0 || pipe(response) != 0)
- return NULL;
+ if (pipe(command) != 0 || pipe(response) != 0) {
+ fprintf(stderr, "pipe failed: %s\n", strerror(errno));
+ exit(1);
+ }
pid = fork();
- if (pid < 0)
- return NULL;
+ if (pid < 0) {
+ fprintf(stderr, "fork failed: %s\n", strerror(errno));
+ exit(1);
+ }
if (pid != 0) {
struct agent *agent = malloc(sizeof(*agent));
diff --git a/lib/tdb/test/run-corrupt.c b/lib/tdb/test/run-corrupt.c
index 584f789bf8..1a3c769183 100644
--- a/lib/tdb/test/run-corrupt.c
+++ b/lib/tdb/test/run-corrupt.c
@@ -41,11 +41,15 @@ static void tdb_flip_bit(struct tdb_context *tdb, unsigned int bit)
((unsigned char *)tdb->map_ptr)[off] ^= mask;
else {
unsigned char c;
- if (pread(tdb->fd, &c, 1, off) != 1)
- err(1, "pread");
+ if (pread(tdb->fd, &c, 1, off) != 1) {
+ fprintf(stderr, "pread: %s\n", strerror(errno));
+ exit(1);
+ }
c ^= mask;
- if (pwrite(tdb->fd, &c, 1, off) != 1)
- err(1, "pwrite");
+ if (pwrite(tdb->fd, &c, 1, off) != 1) {
+ fprintf(stderr, "pwrite: %s\n", strerror(errno));
+ exit(1);
+ }
}
}
diff --git a/lib/tdb/test/run-die-during-transaction.c b/lib/tdb/test/run-die-during-transaction.c
index 19c9dbebf9..6e3a70d4ae 100644
--- a/lib/tdb/test/run-die-during-transaction.c
+++ b/lib/tdb/test/run-die-during-transaction.c
@@ -164,12 +164,18 @@ reset:
key.dsize--;
ret = external_agent_operation(agent, OPEN, TEST_DBNAME);
- if (ret != SUCCESS)
- errx(1, "Agent failed to open: %s", agent_return_name(ret));
+ if (ret != SUCCESS) {
+ fprintf(stderr, "Agent failed to open: %s\n",
+ agent_return_name(ret));
+ exit(1);
+ }
ret = external_agent_operation(agent, FETCH, KEY_STRING);
- if (ret != SUCCESS)
- errx(1, "Agent failed find key: %s", agent_return_name(ret));
+ if (ret != SUCCESS) {
+ fprintf(stderr, "Agent failed find key: %s\n",
+ agent_return_name(ret));
+ exit(1);
+ }
in_transaction = true;
if (tdb_transaction_start(tdb) != 0)
@@ -215,8 +221,6 @@ int main(int argc, char *argv[])
unlock_callback = maybe_die;
agent = prepare_external_agent();
- if (!agent)
- err(1, "preparing agent");
for (i = 0; i < sizeof(ops)/sizeof(ops[0]); i++) {
diag("Testing %s after death", operation_name(ops[i]));
diff --git a/lib/tdb/test/run-nested-traverse.c b/lib/tdb/test/run-nested-traverse.c
index 86f2913455..37d57c0125 100644
--- a/lib/tdb/test/run-nested-traverse.c
+++ b/lib/tdb/test/run-nested-traverse.c
@@ -62,8 +62,6 @@ int main(int argc, char *argv[])
plan_tests(17);
agent = prepare_external_agent();
- if (!agent)
- err(1, "preparing agent");
tdb = tdb_open_ex("run-nested-traverse.tdb", 1024, TDB_CLEAR_IF_FIRST,
O_CREAT|O_TRUNC|O_RDWR, 0600, &taplogctx, NULL);
diff --git a/lib/tdb/test/run-open-during-transaction.c b/lib/tdb/test/run-open-during-transaction.c
index d46b216ccd..a825e6269d 100644
--- a/lib/tdb/test/run-open-during-transaction.c
+++ b/lib/tdb/test/run-open-during-transaction.c
@@ -149,8 +149,6 @@ int main(int argc, char *argv[])
plan_tests(20);
agent = prepare_external_agent();
- if (!agent)
- err(1, "preparing agent");
unlock_callback = after_unlock;
for (i = 0; i < sizeof(flags)/sizeof(flags[0]); i++) {
diff --git a/lib/tdb/test/run-traverse-in-transaction.c b/lib/tdb/test/run-traverse-in-transaction.c
index 7813a6ce9a..bcdc3545cd 100644
--- a/lib/tdb/test/run-traverse-in-transaction.c
+++ b/lib/tdb/test/run-traverse-in-transaction.c
@@ -47,8 +47,6 @@ int main(int argc, char *argv[])
plan_tests(13);
agent = prepare_external_agent();
- if (!agent)
- err(1, "preparing agent");
tdb = tdb_open_ex("run-traverse-in-transaction.tdb",
1024, TDB_CLEAR_IF_FIRST, O_CREAT|O_TRUNC|O_RDWR,
diff --git a/lib/tdb/test/tap-interface.h b/lib/tdb/test/tap-interface.h
index 12d5f942b7..d9ed6e84ea 100644
--- a/lib/tdb/test/tap-interface.h
+++ b/lib/tdb/test/tap-interface.h
@@ -22,7 +22,6 @@
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
-#include <err.h>
#ifndef __location__
#define __TAP_STRING_LINE1__(s) #s
@@ -32,9 +31,9 @@
#endif
#define plan_tests(num)
-#define ok(e, ...) ((e) ? (void)printf(".") : errx(1, __VA_ARGS__))
+#define ok(e, ...) do { if (e) { (void)printf("."); } else { fprintf(stderr, __VA_ARGS__); exit(1); } } while(0)
#define ok1(e) ok((e), "%s:%s", __location__, #e)
#define pass(...) printf(".")
-#define fail(...) errx(1, __VA_ARGS__)
+#define fail(...) do { fprintf(stderr, __VA_ARGS__); exit(1); } while(0)
#define diag printf
#define exit_status() 0