tests/openat.c: use errno2name
diff --git a/tests/openat.c b/tests/openat.c
index f769f6e..e7f9fbe 100644
--- a/tests/openat.c
+++ b/tests/openat.c
@@ -39,29 +39,20 @@
main(void)
{
static const char sample[] = "openat.sample";
- int fd;
-
- fd = syscall(__NR_openat, -100, sample, O_RDONLY|O_CREAT, 0400);
+ int fd = syscall(__NR_openat, -100, sample, O_RDONLY|O_CREAT, 0400);
if (fd == -1) {
- if (errno == ENOSYS) {
- printf("openat(AT_FDCWD, \"%s\", O_RDONLY|O_CREAT"
- ", 0400) = -1 ENOSYS (%m)\n", sample);
- } else {
- perror_msg_and_fail("openat");
- }
+ printf("openat(AT_FDCWD, \"%s\", O_RDONLY|O_CREAT, 0400)"
+ " = -1 %s (%m)\n", sample, errno2name());
} else {
- printf("openat(AT_FDCWD, \"%s\", O_RDONLY|O_CREAT"
- ", 0400) = %d\n", sample, fd);
+ printf("openat(AT_FDCWD, \"%s\", O_RDONLY|O_CREAT, 0400)"
+ " = %d\n", sample, fd);
close(fd);
if (unlink(sample) == -1)
perror_msg_and_fail("unlink");
+
fd = syscall(__NR_openat, -100, sample, O_RDONLY);
- if (fd == -1 && errno == ENOENT) {
- printf("openat(AT_FDCWD, \"%s\", O_RDONLY) = %d ENOENT"
- " (%m)\n", sample, fd);
- } else {
- perror_msg_and_fail("openat");
- }
+ printf("openat(AT_FDCWD, \"%s\", O_RDONLY) = %d %s (%m)\n",
+ sample, fd, errno2name());
}
puts("+++ exited with 0 +++");