Commit 47981332 authored by Rusty Russell's avatar Rusty Russell

failtest: don't insert spurious failures if open would fail anyway.

open fails in fairly normal cases; don't double execution time for this!
parent fb9514a5
...@@ -588,12 +588,17 @@ int failtest_open(const char *pathname, ...@@ -588,12 +588,17 @@ int failtest_open(const char *pathname,
/* Avoid memory leak! */ /* Avoid memory leak! */
if (p == &unrecorded_call) if (p == &unrecorded_call)
free((char *)call.pathname); free((char *)call.pathname);
if (should_fail(p)) { p->u.open.ret = open(pathname, call.flags, call.mode);
if (!failpath && p->u.open.ret == -1) {
p->fail = false;
p->error = errno;
} else if (should_fail(p)) {
close(p->u.open.ret);
p->u.open.ret = -1; p->u.open.ret = -1;
/* FIXME: Play with error codes? */ /* FIXME: Play with error codes? */
p->error = EACCES; p->error = EACCES;
} else { } else {
p->u.open.ret = open(pathname, call.flags, call.mode);
set_cleanup(p, cleanup_open, struct open_call); set_cleanup(p, cleanup_open, struct open_call);
} }
errno = p->error; errno = p->error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment