From 10c619adb94208b801cc549ec3d3ede2efb4a2dc Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 22 Apr 2021 17:36:05 -0700 Subject: [PATCH] test/zdtm: pr_err / pr_perror fixes 1. Use pr_perror where errno needs to be shown. 2. Use pr_err in cases where errno is not set by the previous failed call. 3. Make sure pr_err's first argument do not have \n. 4. While at it, fix some error messages. Signed-off-by: Kir Kolyshkin --- test/zdtm/lib/tcp.c | 4 +-- test/zdtm/lib/zdtmtst.h | 2 +- test/zdtm/static/autofs.c | 6 ++-- test/zdtm/static/cgroup_stray.c | 4 +-- test/zdtm/static/cgroupns.c | 6 ++-- test/zdtm/static/criu-rtc.c | 2 +- test/zdtm/static/epoll.c | 4 +-- test/zdtm/static/file_locks01.c | 4 +-- test/zdtm/static/inotify02.c | 10 +++---- test/zdtm/static/maps01.c | 8 ++--- test/zdtm/static/netns_sub_veth.c | 2 +- test/zdtm/static/opath_file.c | 2 +- test/zdtm/static/socket-tcp-close-wait.c | 16 +++++----- test/zdtm/static/socket-tcp-close0.c | 2 +- test/zdtm/static/socket-tcp-closed.c | 4 +-- test/zdtm/static/socket-tcp-closing.c | 38 ++++++++++++------------ test/zdtm/static/socket-tcp-fin-wait1.c | 38 ++++++++++++------------ test/zdtm/static/socket-tcp-unconn.c | 2 +- test/zdtm/static/socket_udp_shutdown.c | 20 ++++++------- test/zdtm/static/tempfs_overmounted.c | 2 +- test/zdtm/static/tempfs_overmounted01.c | 4 +-- test/zdtm/static/vdso-proxy.c | 8 ++--- test/zdtm/static/vfork00.c | 2 +- test/zdtm/static/zombie_leader.c | 2 +- test/zdtm/transition/maps008.c | 4 +-- 25 files changed, 98 insertions(+), 98 deletions(-) diff --git a/test/zdtm/lib/tcp.c b/test/zdtm/lib/tcp.c index 03862b24c..623994bf8 100644 --- a/test/zdtm/lib/tcp.c +++ b/test/zdtm/lib/tcp.c @@ -43,13 +43,13 @@ int tcp_init_server_with_opts(int family, int *port, struct zdtm_tcp_opts *opts) if (opts->reuseport && setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(int)) == -1) { - pr_perror(""); + pr_perror("setsockopt(SO_REUSEPORT) failed"); return -1; } if (opts->reuseaddr && setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) { - pr_perror("setsockopt() error"); + pr_perror("setsockopt(SO_REUSEATTR) failed"); return -1; } diff --git a/test/zdtm/lib/zdtmtst.h b/test/zdtm/lib/zdtmtst.h index b5714ce7b..ec6c110a2 100644 --- a/test/zdtm/lib/zdtmtst.h +++ b/test/zdtm/lib/zdtmtst.h @@ -114,7 +114,7 @@ extern int write_pidfile(int pid); #define __stringify(x) __stringify_1(x) /* - * Macro to define stack alignment. + * Macro to define stack alignment. * aarch64 requires stack to be aligned to 16 bytes. */ #define __stack_aligned__ __attribute__((aligned(16))) diff --git a/test/zdtm/static/autofs.c b/test/zdtm/static/autofs.c index b6d0170fe..6d261677b 100644 --- a/test/zdtm/static/autofs.c +++ b/test/zdtm/static/autofs.c @@ -437,11 +437,11 @@ static int automountd_serve(const char *mountpoint, struct autofs_params *p, res = autofs_mount_direct(mountpoint, v5_packet); break; case autofs_ptype_expire_indirect: - pr_err("%d: expire request for indirect mount %s?", + pr_err("%d: expire request for indirect mount %s?\n", getpid(), v5_packet->name); return -EINVAL; case autofs_ptype_expire_direct: - pr_err("%d: expire request for direct mount?", + pr_err("%d: expire request for direct mount?\n", getpid()); return -EINVAL; default: @@ -507,7 +507,7 @@ static int automountd(struct autofs_params *p, int control_fd) autofs_path = xsprintf("%s/%s", dirname, p->mountpoint); if (!autofs_path) { - pr_err("failed to allocate autofs path"); + pr_err("failed to allocate autofs path\n"); goto err; } diff --git a/test/zdtm/static/cgroup_stray.c b/test/zdtm/static/cgroup_stray.c index dc68ee6e5..a068378ec 100644 --- a/test/zdtm/static/cgroup_stray.c +++ b/test/zdtm/static/cgroup_stray.c @@ -97,7 +97,7 @@ static bool pid_in_cgroup(pid_t pid, const char *controller, const char *path) { /* skip hierarchy no. */ pos = strstr(buf, ":"); if (!pos) { - pr_err("invalid /proc/pid/cgroups file"); + pr_err("invalid /proc/pid/cgroups file\n"); goto out; } pos++; @@ -105,7 +105,7 @@ static bool pid_in_cgroup(pid_t pid, const char *controller, const char *path) { pos = strstr(pos, ":"); if (!pos) { - pr_err("invalid /proc/pid/cgroups file"); + pr_err("invalid /proc/pid/cgroups file\n"); goto out; } diff --git a/test/zdtm/static/cgroupns.c b/test/zdtm/static/cgroupns.c index 7459af138..68b86b44b 100644 --- a/test/zdtm/static/cgroupns.c +++ b/test/zdtm/static/cgroupns.c @@ -95,7 +95,7 @@ static bool pid_in_cgroup(pid_t pid, const char *controller, const char *path) { /* skip hierarchy no. */ pos = strstr(buf, ":"); if (!pos) { - pr_err("invalid /proc/pid/cgroups file"); + pr_err("invalid /proc/pid/cgroups file\n"); goto out; } pos++; @@ -103,7 +103,7 @@ static bool pid_in_cgroup(pid_t pid, const char *controller, const char *path) { pos = strstr(pos, ":"); if (!pos) { - pr_err("invalid /proc/pid/cgroups file"); + pr_err("invalid /proc/pid/cgroups file\n"); goto out; } @@ -190,7 +190,7 @@ int main(int argc, char **argv) } if (pid != waitpid(pid, &status, 0)) { - pr_err("wrong pid"); + pr_perror("wrong pid"); goto out; } diff --git a/test/zdtm/static/criu-rtc.c b/test/zdtm/static/criu-rtc.c index 8588f9f52..8ffb0cd08 100644 --- a/test/zdtm/static/criu-rtc.c +++ b/test/zdtm/static/criu-rtc.c @@ -96,7 +96,7 @@ int cr_plugin_restore_file(int id) e = criu_rtc__unpack(NULL, len, buf); if (e == NULL) { - pr_err("Unable to parse the RTC message %#x", id); + pr_err("Unable to parse the RTC message %#x\n", id); return -1; } diff --git a/test/zdtm/static/epoll.c b/test/zdtm/static/epoll.c index ed2609a07..5acb54094 100644 --- a/test/zdtm/static/epoll.c +++ b/test/zdtm/static/epoll.c @@ -52,7 +52,7 @@ int main(int argc, char *argv[]) for (i = 0; i < ARRAY_SIZE(pipes); i++) { if (pipe(pipes[i].pipefd)) { - pr_err("Can't create pipe %d\n", i); + pr_perror("Can't create pipe %d", i); exit(1); } @@ -61,7 +61,7 @@ int main(int argc, char *argv[]) nfd = dup2(pipes[i].pipefd[0], i + 700); if (nfd < 0) { - pr_err("dup2"); + pr_perror("dup2"); exit(1); } close(pipes[i].pipefd[0]); diff --git a/test/zdtm/static/file_locks01.c b/test/zdtm/static/file_locks01.c index c08c40b51..a57a5b61b 100644 --- a/test/zdtm/static/file_locks01.c +++ b/test/zdtm/static/file_locks01.c @@ -96,7 +96,7 @@ static int check_file_lock(int fd, char *expected_type, snprintf(path, sizeof(path), "/proc/self/fdinfo/%d", fd); fp_locks = fopen(path, "r"); if (!fp_locks) { - pr_err("Can't open %s\n", path); + pr_perror("Can't open %s", path); return -1; } @@ -113,7 +113,7 @@ static int check_file_lock(int fd, char *expected_type, fl_flag, fl_type, fl_option, &fl_owner, &maj, &min, &i_no); if (num < 7) { - pr_perror("Invalid lock info."); + pr_err("Invalid lock info\n"); break; } diff --git a/test/zdtm/static/inotify02.c b/test/zdtm/static/inotify02.c index b1b75d2e1..bedfefac9 100644 --- a/test/zdtm/static/inotify02.c +++ b/test/zdtm/static/inotify02.c @@ -34,7 +34,7 @@ static int num_of_handles(int fd) snprintf(path, sizeof(path), "/proc/self/fdinfo/%d", fd); f = fopen(path, "r"); if (!f) { - pr_err("Can't open %s", path); + pr_perror("Can't open %s", path); return -1; } @@ -59,13 +59,13 @@ int main (int argc, char *argv[]) test_init(argc, argv); if (mkdir(dirname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)) { - pr_err("Can't create directory %s", dirname); + pr_perror("Can't create directory %s", dirname); exit(1); } fd = inotify_init1(IN_NONBLOCK); if (fd < 0) { - pr_err("inotify_init failed"); + pr_perror("inotify_init failed"); exit(1); } @@ -73,12 +73,12 @@ int main (int argc, char *argv[]) snprintf(temp[i], sizeof(temp[0]), "d.%03d", i); snprintf(path, sizeof(path), "%s/%s", dirname, temp[i]); if (mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)) { - pr_err("Can't create %s", path); + pr_perror("Can't create %s", path); exit(1); } if (inotify_add_watch(fd, path, mask) < 0) { - pr_err("inotify_add_watch failed on %s", path); + pr_perror("inotify_add_watch failed on %s", path); exit(1); } } diff --git a/test/zdtm/static/maps01.c b/test/zdtm/static/maps01.c index 119d7a6a4..2bb465a25 100644 --- a/test/zdtm/static/maps01.c +++ b/test/zdtm/static/maps01.c @@ -36,7 +36,7 @@ int main(int argc, char ** argv) MAP_SHARED | MAP_ANONYMOUS, -1, 0); if (m == MAP_FAILED) { - pr_err("Failed to mmap %lu Mb shared anonymous R/W memory\n", + pr_perror("Failed to mmap %lu Mb shared anonymous R/W memory", MEM_SIZE >> 20); goto err; } @@ -45,14 +45,14 @@ int main(int argc, char ** argv) MAP_SHARED | MAP_ANONYMOUS, -1, 0); if (p == MAP_FAILED) { - pr_err("Failed to mmap %ld Mb shared anonymous R/W memory\n", + pr_perror("Failed to mmap %ld Mb shared anonymous R/W memory", MEM_SIZE >> 20); goto err; } p2 = mmap(NULL, MEM_OFFSET, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (p2 == MAP_FAILED) { - pr_err("Failed to mmap %lu Mb anonymous memory\n", + pr_perror("Failed to mmap %lu Mb anonymous memory", MEM_OFFSET >> 20); goto err; } @@ -67,7 +67,7 @@ int main(int argc, char ** argv) p3 = mmap(NULL, MEM_OFFSET3, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (p3 == MAP_FAILED) { - pr_err("Failed to mmap %lu Mb anonymous R/W memory\n", + pr_perror("Failed to mmap %lu Mb anonymous R/W memory", MEM_OFFSET3 >> 20); goto err; } diff --git a/test/zdtm/static/netns_sub_veth.c b/test/zdtm/static/netns_sub_veth.c index eedbb15c3..c0a71b337 100644 --- a/test/zdtm/static/netns_sub_veth.c +++ b/test/zdtm/static/netns_sub_veth.c @@ -67,7 +67,7 @@ int main(int argc, char **argv) ret = nl_connect(sk, NETLINK_ROUTE); if (ret < 0) { nl_socket_free(sk); - pr_err("Unable to connect socket: %s", nl_geterror(ret)); + pr_err("Unable to connect socket: %s\n", nl_geterror(ret)); return -1; } diff --git a/test/zdtm/static/opath_file.c b/test/zdtm/static/opath_file.c index 943f4eddb..40e5987c3 100644 --- a/test/zdtm/static/opath_file.c +++ b/test/zdtm/static/opath_file.c @@ -37,7 +37,7 @@ static int parse_self_fdinfo(int fd, struct fdinfo *fi) while (fgets(line, sizeof(line), file)) { if (fdinfo_field(line, "flags")) { if (sscanf(line, "%*s %llo", &val) != 1) { - pr_err("failed to read flags: %s", line); + pr_err("failed to read flags: %s\n", line); goto fail; } pr_debug("Open flags = %llu\n", val); diff --git a/test/zdtm/static/socket-tcp-close-wait.c b/test/zdtm/static/socket-tcp-close-wait.c index 3608e6b37..152dcf31f 100644 --- a/test/zdtm/static/socket-tcp-close-wait.c +++ b/test/zdtm/static/socket-tcp-close-wait.c @@ -37,11 +37,11 @@ int fill_sock_buf(int fd) flags = fcntl(fd, F_GETFL, 0); if (flags == -1) { - pr_err("Can't get flags"); + pr_perror("Can't get flags"); return -1; } if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) { - pr_err("Can't set flags"); + pr_perror("Can't set flags"); return -1; } @@ -52,14 +52,14 @@ int fill_sock_buf(int fd) if (ret == -1) { if (errno == EAGAIN) break; - pr_err("write"); + pr_perror("write"); return -1; } size += ret; } if (fcntl(fd, F_SETFL, flags) == -1) { - pr_err("Can't set flags"); + pr_perror("Can't set flags"); return -1; } @@ -77,7 +77,7 @@ static int clean_sk_buf(int fd) while (1) { ret = read(fd, buf, sizeof(buf)); if (ret == -1) { - pr_err("read"); + pr_perror("read"); return -11; } @@ -192,7 +192,7 @@ int main(int argc, char **argv) test_init(argc, argv); if ((fd_s = tcp_init_server(ZDTM_SRV_FAMILY, &port)) < 0) { - pr_err("initializing server failed"); + pr_err("initializing server failed\n"); return 1; } @@ -208,13 +208,13 @@ int main(int argc, char **argv) */ fd = tcp_accept_server(fd_s); if (fd < 0) { - pr_err("can't accept client connection"); + pr_err("can't accept client connection\n"); return 1; } ctl_fd = tcp_accept_server(fd_s); if (ctl_fd < 0) { - pr_err("can't accept client connection"); + pr_err("can't accept client connection\n"); return 1; } diff --git a/test/zdtm/static/socket-tcp-close0.c b/test/zdtm/static/socket-tcp-close0.c index 367e40473..270965cbd 100644 --- a/test/zdtm/static/socket-tcp-close0.c +++ b/test/zdtm/static/socket-tcp-close0.c @@ -28,7 +28,7 @@ static int check_socket_closed(int sk) pr_perror("Can't get socket state"); return -1; } else if (info.tcpi_state != TCP_CLOSE) { - pr_err("Invalid socket state (%i)", (int)info.tcpi_state); + pr_err("Invalid socket state (%i)\n", (int)info.tcpi_state); return -1; } diff --git a/test/zdtm/static/socket-tcp-closed.c b/test/zdtm/static/socket-tcp-closed.c index a51f9b96d..e8fc25c56 100644 --- a/test/zdtm/static/socket-tcp-closed.c +++ b/test/zdtm/static/socket-tcp-closed.c @@ -128,7 +128,7 @@ int main(int argc, char **argv) return 1; } if (memcmp(&addr, &dst_addr, aux)) { - pr_err("A destination address mismatch"); + pr_err("A destination address mismatch\n"); return 1; } @@ -137,7 +137,7 @@ int main(int argc, char **argv) return 1; } if (memcmp(&addr, &src_addr, aux)) { - pr_err("A source address mismatch"); + pr_err("A source address mismatch\n"); return 1; } diff --git a/test/zdtm/static/socket-tcp-closing.c b/test/zdtm/static/socket-tcp-closing.c index 83b21e8ad..84ff6be9d 100644 --- a/test/zdtm/static/socket-tcp-closing.c +++ b/test/zdtm/static/socket-tcp-closing.c @@ -37,11 +37,11 @@ int fill_sock_buf(int fd) flags = fcntl(fd, F_GETFL, 0); if (flags == -1) { - pr_err("Can't get flags"); + pr_perror("Can't get flags"); return -1; } if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) { - pr_err("Can't set flags"); + pr_perror("Can't set flags"); return -1; } @@ -52,14 +52,14 @@ int fill_sock_buf(int fd) if (ret == -1) { if (errno == EAGAIN) break; - pr_err("write"); + pr_perror("write"); return -1; } size += ret; } if (fcntl(fd, F_SETFL, flags) == -1) { - pr_err("Can't set flags"); + pr_perror("Can't set flags"); return -1; } @@ -77,7 +77,7 @@ static int clean_sk_buf(int fd) while (1) { ret = read(fd, buf, sizeof(buf)); if (ret == -1) { - pr_err("read"); + pr_perror("read"); return -11; } @@ -104,13 +104,13 @@ int main(int argc, char **argv) test_init(argc, argv); if (pipe(pfd)) { - pr_err("pipe() failed"); + pr_perror("pipe() failed"); return 1; } extpid = fork(); if (extpid < 0) { - pr_err("fork() failed"); + pr_perror("fork() failed"); return 1; } else if (extpid == 0) { int size = 0; @@ -121,7 +121,7 @@ int main(int argc, char **argv) close(pfd[1]); if (read(pfd[0], &port, sizeof(port)) != sizeof(port)) { - pr_err("Can't read port\n"); + pr_perror("Can't read port"); return 1; } @@ -138,17 +138,17 @@ int main(int argc, char **argv) return 1; if (shutdown(fd, SHUT_WR) == -1) { - pr_err("shutdown"); + pr_perror("shutdown"); return 1; } if (write(ctl_fd, &size, sizeof(size)) != sizeof(size)) { - pr_err("write"); + pr_perror("write"); return 1; } if (read(ctl_fd, &c, 1) != 0) { - pr_err("read"); + pr_perror("read"); return 1; } @@ -166,13 +166,13 @@ int main(int argc, char **argv) test_init(argc, argv); if ((fd_s = tcp_init_server(ZDTM_SRV_FAMILY, &port)) < 0) { - pr_err("initializing server failed"); + pr_err("initializing server failed\n"); return 1; } close(pfd[0]); if (write(pfd[1], &port, sizeof(port)) != sizeof(port)) { - pr_err("Can't send port"); + pr_perror("Can't send port"); return 1; } close(pfd[1]); @@ -182,13 +182,13 @@ int main(int argc, char **argv) */ fd = tcp_accept_server(fd_s); if (fd < 0) { - pr_err("can't accept client connection %m"); + pr_err("can't accept client connection\n"); return 1; } ctl_fd = tcp_accept_server(fd_s); if (ctl_fd < 0) { - pr_err("can't accept client connection %m"); + pr_err("can't accept client connection\n"); return 1; } @@ -197,12 +197,12 @@ int main(int argc, char **argv) return 1; if (shutdown(fd, SHUT_WR) == -1) { - pr_err("shutdown"); + pr_perror("shutdown"); return 1; } if (read(ctl_fd, &ret, sizeof(ret)) != sizeof(ret)) { - pr_err("read"); + pr_perror("read"); return 1; } @@ -224,12 +224,12 @@ int main(int argc, char **argv) } if (shutdown(ctl_fd, SHUT_WR) == -1) { - pr_err("shutdown"); + pr_perror("shutdown"); return 1; } if (read(ctl_fd, &ret, sizeof(ret)) != sizeof(ret)) { - pr_err("read"); + pr_perror("read"); return 1; } diff --git a/test/zdtm/static/socket-tcp-fin-wait1.c b/test/zdtm/static/socket-tcp-fin-wait1.c index 1264a5959..4bc7b3238 100644 --- a/test/zdtm/static/socket-tcp-fin-wait1.c +++ b/test/zdtm/static/socket-tcp-fin-wait1.c @@ -38,11 +38,11 @@ int fill_sock_buf(int fd) flags = fcntl(fd, F_GETFL, 0); if (flags == -1) { - pr_err("Can't get flags"); + pr_perror("Can't get flags"); return -1; } if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1) { - pr_err("Can't set flags"); + pr_perror("Can't set flags"); return -1; } @@ -53,14 +53,14 @@ int fill_sock_buf(int fd) if (ret == -1) { if (errno == EAGAIN) break; - pr_err("write"); + pr_perror("write"); return -1; } size += ret; } if (fcntl(fd, F_SETFL, flags) == -1) { - pr_err("Can't set flags"); + pr_perror("Can't set flags"); return -1; } @@ -78,7 +78,7 @@ static int clean_sk_buf(int fd) while (1) { ret = read(fd, buf, sizeof(buf)); if (ret == -1) { - pr_err("read"); + pr_perror("read"); return -11; } @@ -106,13 +106,13 @@ int main(int argc, char **argv) test_init(argc, argv); if (pipe(pfd)) { - pr_err("pipe() failed"); + pr_perror("pipe() failed"); return 1; } extpid = fork(); if (extpid < 0) { - pr_err("fork() failed"); + pr_perror("fork() failed"); return 1; } else if (extpid == 0) { int size = 0; @@ -123,7 +123,7 @@ int main(int argc, char **argv) close(pfd[1]); if (read(pfd[0], &port, sizeof(port)) != sizeof(port)) { - pr_err("Can't read port\n"); + pr_perror("Can't read port"); return 1; } @@ -137,17 +137,17 @@ int main(int argc, char **argv) return 1; if (read(ctl_fd, &c, 1) != 0) { - pr_err("read"); + pr_perror("read"); return 1; } if (write(fd, &TEST_MSG[2], sizeof(TEST_MSG) - 2) != sizeof(TEST_MSG) - 2) { - pr_err("write"); + pr_perror("write"); return 1; } if (shutdown(fd, SHUT_WR) == -1) { - pr_err("shutdown"); + pr_perror("shutdown"); return 1; } @@ -165,13 +165,13 @@ int main(int argc, char **argv) test_init(argc, argv); if ((fd_s = tcp_init_server(ZDTM_SRV_FAMILY, &port)) < 0) { - pr_err("initializing server failed"); + pr_err("initializing server failed\n"); return 1; } close(pfd[0]); if (write(pfd[1], &port, sizeof(port)) != sizeof(port)) { - pr_err("Can't send port"); + pr_perror("Can't send port"); return 1; } close(pfd[1]); @@ -181,13 +181,13 @@ int main(int argc, char **argv) */ fd = tcp_accept_server(fd_s); if (fd < 0) { - pr_err("can't accept client connection %m"); + pr_err("can't accept client connection\n"); return 1; } ctl_fd = tcp_accept_server(fd_s); if (ctl_fd < 0) { - pr_err("can't accept client connection %m"); + pr_err("can't accept client connection\n"); return 1; } @@ -198,7 +198,7 @@ int main(int argc, char **argv) #endif if (shutdown(fd, SHUT_WR) == -1) { - pr_err("shutdown"); + pr_perror("shutdown"); return 1; } @@ -207,18 +207,18 @@ int main(int argc, char **argv) test_waitsig(); if (shutdown(ctl_fd, SHUT_WR) == -1) { - pr_err("shutdown"); + pr_perror("shutdown"); return 1; } if (recv(fd, buf, sizeof(buf), MSG_WAITALL) != sizeof(TEST_MSG) || strncmp(buf, TEST_MSG, sizeof(TEST_MSG))) { - pr_err("read"); + pr_perror("recv: expected %s, got %s", TEST_MSG, buf); return 1; } if (read(ctl_fd, &ret, sizeof(ret)) != sizeof(ret)) { - pr_err("read"); + pr_perror("read"); return 1; } diff --git a/test/zdtm/static/socket-tcp-unconn.c b/test/zdtm/static/socket-tcp-unconn.c index e943b7c7a..1b3e1a660 100644 --- a/test/zdtm/static/socket-tcp-unconn.c +++ b/test/zdtm/static/socket-tcp-unconn.c @@ -86,7 +86,7 @@ int main(int argc, char **argv) return 1; } if (memcmp(&addr, &src_addr, aux)) { - pr_err("A source address mismatch"); + pr_err("A source address mismatch\n"); return 1; } diff --git a/test/zdtm/static/socket_udp_shutdown.c b/test/zdtm/static/socket_udp_shutdown.c index ae148c5fa..5d65348ea 100644 --- a/test/zdtm/static/socket_udp_shutdown.c +++ b/test/zdtm/static/socket_udp_shutdown.c @@ -31,7 +31,7 @@ int main(int argc, char **argv) sk1 = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); sk2 = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); if (sk1 < 0 || sk2 < 0) { - pr_err("Can't create socket"); + pr_perror("Can't create socket"); exit(1); return 1; } @@ -49,19 +49,19 @@ int main(int argc, char **argv) if (bind(sk1, (struct sockaddr *)&addr1, len) < 0 || bind(sk2, (struct sockaddr *)&addr2, len) < 0) { - pr_err("Can't bind socket"); + pr_perror("Can't bind socket"); return 1; } if (connect(sk1, (struct sockaddr *)&addr2, len) || connect(sk2, (struct sockaddr *)&addr1, len)) { - pr_err("Can't connect"); + pr_perror("Can't connect"); return 1; } if (shutdown(sk1, SHUT_WR) || shutdown(sk2, SHUT_RD)) { - pr_err("Can't shutdown\n"); + pr_perror("Can't shutdown"); return 1; } @@ -75,17 +75,17 @@ int main(int argc, char **argv) ret = recvfrom(sk1, buf, sizeof(buf), 0, (struct sockaddr *)&addr, &len); if (ret <= 0) { - pr_err("Can't receive data"); + pr_perror("Can't receive data"); return 1; } if (len != sizeof(struct sockaddr_in) || memcmp(&addr2, &addr, len)) { - pr_err("Data received from wrong peer"); + pr_err("Data received from wrong peer\n"); return 1; } if (ret != sizeof(MSG1) || memcmp(buf, MSG1, ret)) { - pr_err("Wrong message received"); + pr_err("Wrong message received\n"); return 1; } @@ -102,17 +102,17 @@ int main(int argc, char **argv) ret = recvfrom(sk1, buf, sizeof(buf), 0, (struct sockaddr *)&addr, &len); if (ret <= 0) { - pr_err("Can't receive data"); + pr_perror("Can't receive data"); return 1; } if (len != sizeof(struct sockaddr_in) || memcmp(&addr2, &addr, len)) { - pr_err("Data received from wrong peer"); + pr_err("Data received from wrong peer\n"); return 1; } if (ret != sizeof(MSG1) || memcmp(buf, MSG1, ret)) { - pr_err("Wrong message received"); + pr_err("Wrong message received\n"); return 1; } diff --git a/test/zdtm/static/tempfs_overmounted.c b/test/zdtm/static/tempfs_overmounted.c index 29eca00f4..ed329bf99 100644 --- a/test/zdtm/static/tempfs_overmounted.c +++ b/test/zdtm/static/tempfs_overmounted.c @@ -59,7 +59,7 @@ int main(int argc, char **argv) test_waitsig(); if (umount("a/b") || umount("a") || umount("a") || umount("a/b/c") || umount("a/b") || umount("a/b")) { - pr_err("umount"); + pr_perror("umount"); return 1; } diff --git a/test/zdtm/static/tempfs_overmounted01.c b/test/zdtm/static/tempfs_overmounted01.c index e868b184c..5a7250903 100644 --- a/test/zdtm/static/tempfs_overmounted01.c +++ b/test/zdtm/static/tempfs_overmounted01.c @@ -34,11 +34,11 @@ int main(int argc, char **argv) } if (pid == 0) { if (mount("zdtm", dirname, "tmpfs", 0, "") < 0) { - pr_err("Can't mount tmpfs"); + pr_perror("Can't mount tmpfs"); return 1; } if (chdir(dirname)) { - pr_err("chdir"); + pr_perror("chdir"); return 1; } diff --git a/test/zdtm/static/vdso-proxy.c b/test/zdtm/static/vdso-proxy.c index 2946eb790..f5ff21bd9 100644 --- a/test/zdtm/static/vdso-proxy.c +++ b/test/zdtm/static/vdso-proxy.c @@ -42,7 +42,7 @@ static int parse_maps(struct vm_area *vmas) maps = fopen("/proc/self/maps", "r"); if (maps == NULL) { - pr_err("Failed to open maps file: %m\n"); + pr_perror("Failed to open maps file"); return -1; } @@ -74,7 +74,7 @@ static int parse_maps(struct vm_area *vmas) } if (fclose(maps)) { - pr_err("Failed to close maps file: %m\n"); + pr_perror("Failed to close maps file"); return -1; } @@ -141,7 +141,7 @@ int main(int argc, char *argv[]) test_msg("[NOTE]\tMappings before:\n"); nr_before = parse_maps(vmas_before); if (nr_before < 0) { - pr_perror("Failed to parse maps"); + pr_err("Failed to parse maps\n"); return -1; } @@ -151,7 +151,7 @@ int main(int argc, char *argv[]) test_msg("[NOTE]\tMappings after:\n"); nr_after = parse_maps(vmas_after); if (nr_after < 0) { - pr_perror("Failed to parse maps"); + pr_err("Failed to parse maps\n"); return -1; } diff --git a/test/zdtm/static/vfork00.c b/test/zdtm/static/vfork00.c index 0f8ef0666..6abc5c6ac 100644 --- a/test/zdtm/static/vfork00.c +++ b/test/zdtm/static/vfork00.c @@ -23,7 +23,7 @@ int main(int argc, char ** argv) * in the child */ pid = fork(); if (pid < 0) { - pr_err("fork failed: %m"); + pr_perror("fork failed"); exit(1); } diff --git a/test/zdtm/static/zombie_leader.c b/test/zdtm/static/zombie_leader.c index d94b2af04..1928687cd 100644 --- a/test/zdtm/static/zombie_leader.c +++ b/test/zdtm/static/zombie_leader.c @@ -62,7 +62,7 @@ int main(int argc, char **argv) } if (!*cpid) { - pr_err("Don't know grand child's pid"); + pr_err("Don't know grand child's pid\n"); goto err; } diff --git a/test/zdtm/transition/maps008.c b/test/zdtm/transition/maps008.c index 7ed7c10a5..851814c11 100644 --- a/test/zdtm/transition/maps008.c +++ b/test/zdtm/transition/maps008.c @@ -109,7 +109,7 @@ static void check_mem_eq(void *addr1, size_t size1, void *addr2, size_t size2) static void xmunmap(void *map, size_t size) { if (munmap(map, size)) { - pr_err("xmunmap"); + pr_perror("xmunmap"); exit(1); } } @@ -507,7 +507,7 @@ int main(int argc, char **argv) }; if (atexit(kill_pstree_from_root)) { - pr_err("Can't setup atexit cleanup func"); + pr_err("Can't setup atexit cleanup func\n"); exit(1); } return proc1_func();