summaryrefslogtreecommitdiffstats
path: root/tests/test_tcp_dup2.c
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2021-02-17 10:58:29 +0100
committerAndreas Schneider <asn@samba.org>2021-03-15 08:04:58 +0100
commit181a3fa5e4c242d72d311f5baa771c680647eda7 (patch)
tree3d2200b8d94d3510c5b7d6cc1ca5caa72be59c6d /tests/test_tcp_dup2.c
parentba970e5d32cceb0750eaa71fb83da3e2eef881d5 (diff)
downloadsocket_wrapper-181a3fa5e4c242d72d311f5baa771c680647eda7.tar.gz
socket_wrapper-181a3fa5e4c242d72d311f5baa771c680647eda7.tar.xz
socket_wrapper-181a3fa5e4c242d72d311f5baa771c680647eda7.zip
swrap: wrap __close_nocancel() if available
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>
Diffstat (limited to 'tests/test_tcp_dup2.c')
-rw-r--r--tests/test_tcp_dup2.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/test_tcp_dup2.c b/tests/test_tcp_dup2.c
index fd6adc2..238b9a8 100644
--- a/tests/test_tcp_dup2.c
+++ b/tests/test_tcp_dup2.c
@@ -2,6 +2,11 @@
#include <cmocka.h>
#include <unistd.h>
+#include <errno.h>
+
+#ifdef HAVE___CLOSE_NOCANCEL
+extern int __close_nocancel(int fd);
+#endif
static int setup(void **state)
{
@@ -20,6 +25,7 @@ static int teardown(void **state)
static void test_dup2_existing_open_fd(void **state)
{
int s, dup_s;
+ int rc;
(void) state; /* unused */
@@ -34,7 +40,19 @@ static void test_dup2_existing_open_fd(void **state)
dup_s = dup2(s, s);
assert_int_equal(dup_s, s);
- close(s);
+#ifdef HAVE___CLOSE_NOCANCEL
+ rc = __close_nocancel(s);
+ assert_return_code(rc, errno);
+ rc = close(s);
+ assert_int_equal(rc, -1);
+ assert_int_equal(errno, EBADF);
+ rc = __close_nocancel(s);
+ assert_int_equal(rc, -1);
+ assert_int_equal(errno, EBADF);
+#else
+ rc = close(s);
+ assert_return_code(rc, errno);
+#endif
}
int main(void) {