summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* swrap: wrap __close_nocancel() if availableStefan Metzmacher2021-03-151-1/+19
| | | | | | | | | | | While it's no possible to inject swrap__close_nocancel() into libc.so.6 directly, because it's no weak symbol, it seems to be possible to inject it to other glibc libraries like libpthread.so.0, which is better than nothing. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14640 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: export a public socket_wrapper_indicate_no_inet_fd() helper functionStefan Metzmacher2021-03-151-0/+31
| | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=14640 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: introduce a socket_wrapper_noop.so and socket_wrapper.h to provide ↵Stefan Metzmacher2021-03-152-1/+80
| | | | | | | | | | | | noop stubs Applications with the need to call socket_wrapper_enabled() should link against -lsocket_wrapper_noop in order to resolve the symbol at link time. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14640 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* test_echo_tcp_sendmsg_recvmsg_fd: add test_tcp_sendmsg_recvmsg_fd_mixed() testsStefan Metzmacher2021-02-081-0/+165
| | | | | | Here we mix sockets and other valid file descriptors. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* test_echo_tcp_sendmsg_recvmsg_fd: add ↵Stefan Metzmacher2021-02-081-0/+82
| | | | | | test_tcp_sendmsg_recvmsg_fd_different() tests Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* test_echo_tcp_sendmsg_recvmsg_fd: also test passing the same socket up to 6 ↵Stefan Metzmacher2021-02-081-1/+46
| | | | | | | | | | | times Note SWRAP_MAX_PASSED_FDS is currently 6. This test demonstrates that even 64-bit systems required commit: "swrap: fix fd-passing without 4 padding bytes" Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* test_echo_tcp_sendmsg_recvmsg_fd: split out test_tcp_sendmsg_recvmsg_fd_same()Stefan Metzmacher2021-02-081-4/+16
| | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* test_echo_tcp_sendmsg_recvmsg_fd: split out test_tcp_sendmsg_recvmsg_fd_array()Stefan Metzmacher2021-02-081-53/+145
| | | | | | | This will allow us to test more combinations in order to get better coverage. For now we just test a single fd. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* tests/echo_srv: allow more than once tcp connection at a timeStefan Metzmacher2021-02-081-1/+1
| | | | | | | We should not wait for the last connection to disconnect, there would not be any reason to use fork at all. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* tests/echo_srv: make the main server logic resilient to ECONNABORTED from ↵Stefan Metzmacher2021-02-051-0/+3
| | | | | | | | | | | | | accept() That should fix a race where the connect() directly followed by close() in test_thread_echo_tcp_connect will cause the echo_srv to terminate early, which results in connect() returning ECONNREFUSED in for other threads. This mainly happens on FreeBSD, but it can also happen on Linux. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* swrap: add basic support for fd-passing via SCM_RIGHTSStefan Metzmacher2021-02-021-4/+0
| | | | | | | | | | | | | | | | | | | | | | We only allow passing up to 6 fds in a single sendmsg call, in order to keep the logic simple. That's more than enough for Samba's use of fd-passing, there we only pass a single fd and the fd will be closed in the sender on success. It means it's ok to keep the socket_info.io.pck_{snd,rcv} fields per process and the PCAP generation will still work as expected. If these constraints turn out to be a problem for other applications, we need to change to a more complex design and move the socket_info array into a shared memory file and use shared robust mutexes. But for now we just want to support multi-channel testing in Samba. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11899 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* tests: Add test for socket_wrapper fd-passing supportAnoop C S2021-02-022-1/+193
| | | | | Signed-off-by: Anoop C S <anoopcs@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* gitlab-ci: Add job for ThreadSanitizerAndreas Schneider2021-01-291-0/+9
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* socket_wrapper.c/tests: fall back to pragma init/fini for ↵Björn Jacke2020-11-041-1/+4
| | | | | | constructor/destructor if possible Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* test_echo_tcp_socket_options.c: add tests for TCP_INFOStefan Metzmacher2020-06-222-0/+82
| | | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> (cherry picked from commit a37c0175492fb1b35257b785c71dea4e4f6d4750)
* Revert "test_echo_tcp_socket_options.c: add tests for TCP_INFO"Stefan Metzmacher2020-06-192-82/+0
| | | | | | | | This reverts commit a37c0175492fb1b35257b785c71dea4e4f6d4750. This got merged automatically by gitlab without review. Signed-off-by: Stefan Metzmacher <metze@samba.org>
* test_echo_tcp_socket_options.c: add tests for TCP_INFOStefan Metzmacher2020-06-192-0/+82
| | | | Signed-off-by: Stefan Metzmacher <metze@samba.org>
* tests: do not truncate pid to 16 bitsMike Gilbert2020-05-141-6/+4
| | | | | | | | | | On Linux, pid_t is a 32-bit type, and the kernel permits pids up to 22 bits in length. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14373 Signed-off-by: Mike Gilbert <floppym@gentoo.org> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* tests: Fix a compile warning on UbuntuAndreas Schneider2020-03-241-1/+3
| | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tests: Fix a coverty warning in echo_srvAndreas Schneider2020-03-231-1/+3
| | | | | | CID #288875 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tests: Fix typo in echo_srv helpAndreas Schneider2019-03-211-1/+1
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* cmake: Disable deep binding for helgrindAndreas Schneider2019-02-121-1/+1
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* tests: Enable threaded test cases on FreeBSDAnoop C S2018-11-121-12/+0
| | | | | | | | | It was previously judged as a bug which now turned to be due to wrong backlog count set in echo_srv while listening on socket. Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* tests: Increase backlog count for listen() in echo_srvAnoop C S2018-11-121-1/+1
| | | | | | Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* tests: Protect IPv6 in st_echo_tcp_get_peer_sock_nameAndreas Schneider2018-11-071-0/+15
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* cmake: Set LINK_FLAGS for echo_srvAndreas Schneider2018-11-071-0/+5
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* tests: Disable failing tests as on FreeBSDAndreas Schneider2018-11-061-0/+12
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* tests: Protect IPv6 function in setup_echo_srv_tcp_ipv6Andreas Schneider2018-11-061-0/+2
| | | | | | | Fixes the build on OmniOS. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* tests: Protect IPv6 case in echo_srvAndreas Schneider2018-11-061-0/+6
| | | | | | | This fixes the build on OmniOS. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* cmake: Don't use string PREPENDAndreas Schneider2018-10-301-2/+2
| | | | | | | This is only supported in cmake >= 3.10. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* tests: Init in_addr only once in test_tcp_socket_overwriteAndreas Schneider2018-10-231-7/+3
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* tests: Return an error if setenv() fails in test_max_socketsAndreas Schneider2018-10-231-1/+1
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* tests: Check the correct return code in test_thread_echo_tcp_write_readAndreas Schneider2018-10-231-1/+1
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* tests: Check return code of connect in test_thread_echo_tcp_sendmsg_recvmsgAndreas Schneider2018-10-231-0/+2
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* tests: Check the return code of connect in test_echo_udp_sendmsg_recvmsgAndreas Schneider2018-10-231-0/+3
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* tests: Check return code of connnect in test_echo_tcp_sendmsg_recvmsgAndreas Schneider2018-10-231-0/+3
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* echo_srv: Check for a valid pidfile pointerAndreas Schneider2018-10-231-1/+1
| | | | | Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* echo_srv: Only use 128K as buffer size instead of 4MBAndreas Schneider2018-10-231-1/+1
| | | | | | | This produced errors built with clang. Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* torture: Wait longer for echo_srv startupAndreas Schneider2018-10-231-2/+2
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* echo_srv: Do not close bogus file descriptorsAndreas Schneider2018-10-231-4/+2
| | | | | | | | | | | | | | ==1564== Warning: invalid file descriptor 1048564 in syscall close() ==1564== at 0x4D18534: close (in /lib64/libc-2.27.so) ==1564== by 0x4046A74: libc_close (socket_wrapper.c:760) ==1564== by 0x405105C: swrap_close (socket_wrapper.c:5933) ==1564== by 0x40511F5: close (socket_wrapper.c:5979) ==1564== by 0x401679: become_daemon (echo_srv.c:202) ==1564== by 0x402D44: main (echo_srv.c:896) ==1563== Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* tests: Use assert_return_code() to get errnoAndreas Schneider2018-10-231-8/+8
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* tests: Avoid -Wcast-align warningAnoop C S2018-10-231-28/+18
| | | | | | | | | | | | | | | warning: cast from 'struct sockaddr *' to 'struct sockaddr_in *' increases required alignment from 2 to 4 [-Wcast-align] struct sockaddr_in *sinp = (struct sockaddr_in *)to; ^~~~~~~~~~~~~~~~~~~~~~~~ Above warning can be avoided by making use of sockaddr_in available within torture_address from the caller of echo_udp_recv_from_to(). Following that sa_socklen from torture_address can be used instead of passing sa_socklen explicitly to echo_udp_recv_from_to(). Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* tests: Fix -Wformat gcc warningAnoop C S2018-10-231-1/+1
| | | | | | | | | test_fork_thread_deadlock.c:48:25: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘pid_t {aka long int}’ [-Wformat=] Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* cmake: Update AddCMockaTestAndreas Schneider2018-10-231-42/+41
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* cmake: Support running the tests with AddressSanitizerAndreas Schneider2018-10-231-1/+27
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* cmake: Improve checks for compiler flagsAndreas Schneider2018-10-231-0/+14
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* cmake: Suppress helgrind race condition warning we created on purposeAndreas Schneider2018-10-232-1/+12
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* cmake: Create an error if helgrind finds a bugAndreas Schneider2018-10-231-1/+1
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* cmake: Write helgrind logs to stderr so we can see themAndreas Schneider2018-10-231-2/+2
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* tests: Update valgrind suppression fileAndreas Schneider2018-08-171-1/+9
| | | | | Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>