From b36a65e5cadc201eb840e2b7716ae878e5c3533f Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Mon, 13 Mar 2017 10:20:05 -0300 Subject: Fix test-errno issues This patch fixes multiple issues of test-errno.c (9a56f8718341): - Rename Linux test-errno.c to test-errno-linux.c to avoid build the same source for both tests. - Add a mlock check for 32 bits build running on 64 bits kernels. Althuough man pages states that mlock fails with EINVAL if final address overflows, kernels does not return it for aforementioned condition (it returns ENOMEM instead). Although it seems to be a kernel issue for compat syscall handling, I think it is worth to still check syscall return and document the behavior. - Initialize option lenght for setsockopt check. - Change open test from EINVAL to EISDIR. Checked on x86_64-linux-gnu and i686-linux-gnu (running on 64 bits kernel). * posix/test-errno.c (do_test): Initialize setsockopt optlen. * sysdeps/unix/sysv/linux/test-errno.c: Move to ... * sysdeps/unix/sysv/linux/test-errno-linux.c: ... here. (test_wrp_rv): Fix format. (test_wrp_rv2): New macro. (do_test): Handle mlock return on 64 bits kernels with 32 bits binaries. --- posix/test-errno.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'posix/test-errno.c') diff --git a/posix/test-errno.c b/posix/test-errno.c index 98df344..c2bfd8a 100644 --- a/posix/test-errno.c +++ b/posix/test-errno.c @@ -131,7 +131,7 @@ do_test (void) fails |= test_wrp (EINVAL, mprotect, (void *) -1, pagesize, -1); fails |= test_wrp (EINVAL, msync, (void *) -1, pagesize, -1); fails |= test_wrp (EINVAL, munmap, (void *) -1, 0); - fails |= test_wrp (EINVAL, open, "/bin/sh", -1, 0); + fails |= test_wrp (EISDIR, open, "/bin", EISDIR, O_WRONLY); fails |= test_wrp (EBADF, read, -1, buf, 1); fails |= test_wrp (EINVAL, readlink, "/", buf, -1); fails |= test_wrp (EBADF, readv, -1, iov, 1); @@ -142,7 +142,7 @@ do_test (void) fails |= test_wrp (EBADF, send, -1, buf, 1, 0); fails |= test_wrp (EBADF, sendmsg, -1, &msg, 0); fails |= test_wrp (EBADF, sendto, -1, buf, 1, 0, &sa, sl); - fails |= test_wrp (EBADF, setsockopt, -1, 0, 0, buf, sl); + fails |= test_wrp (EBADF, setsockopt, -1, 0, 0, buf, sizeof (*buf)); fails |= test_wrp (EBADF, shutdown, -1, SHUT_RD); fails |= test_wrp (EBADF, write, -1, "Hello", sizeof ("Hello") ); fails |= test_wrp (EBADF, writev, -1, iov, 1 ); -- cgit v1.1