Skip to content

Commit

Permalink
test: make the initial copy file error messages more sensible
Browse files Browse the repository at this point in the history
This is most likely the first error message a developer encounters when
running the test suite and the /run/udev/rules.d directory already exists.
Make it more meaningful than the current generic integer comparison failure.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
  • Loading branch information
whot committed May 14, 2017
1 parent 2c818ec commit 695facc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/litest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1132,15 +1132,21 @@ litest_copy_file(const char *dest, const char *src, const char *header)
litest_assert(file->path);

out = open(dest, O_CREAT|O_WRONLY, 0644);
litest_assert_int_gt(out, -1);
if (out == -1)
litest_abort_msg("Failed to write to file %s (%s)\n",
dest,
strerror(errno));

if (header) {
length = strlen(header);
litest_assert_int_eq(write(out, header, length), length);
}

in = open(src, O_RDONLY);
litest_assert_int_gt(in, -1);
if (in == -1)
litest_abort_msg("Failed to open file %s (%s)\n",
src,
strerror(errno));
/* lazy, just check for error and empty file copy */
litest_assert_int_gt(sendfile(out, in, NULL, 40960), 0);
close(out);
Expand Down

0 comments on commit 695facc

Please sign in to comment.