From patchwork Fri Jun 10 15:05:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 69787 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp342520qgf; Fri, 10 Jun 2016 08:06:39 -0700 (PDT) X-Received: by 10.66.166.202 with SMTP id zi10mr2805233pab.42.1465571199259; Fri, 10 Jun 2016 08:06:39 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id o71si13527358pfi.47.2016.06.10.08.06.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Jun 2016 08:06:39 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-70436-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of libc-alpha-return-70436-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-70436-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=Eqq3JJDtNHA/9z0M6I0rD14gV+X+cKpacDcytmKBHSWfW5YhzZyoP IZ9FUtZ/0C7SmbMQepk3D4DO1EJ7x3KejOJeVZ6DTMio2ZlxlPGzeLIW3fbaPOiV xXwgFvLGSHRXcX1xfRZzsvTjyFcjd9wyqMHmML7oPEWLmWDLI6rNuQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; s=default; bh=sWZsxi9a13RzbiObHO+dBMS+IU8=; b=icC+ylfp0VDbOaHyCD/GPNUBKAgy IpBsfu+yTTZ7uG6hGGcs8n97+dX69jLvJXTe2uc1fY5KzxQ3i0tNANNEOOQPNLUv OGcxGhqP6qw+SUfLIW5s+nOeUVfna34KGPoXDwDY+IE9VNniYeF19j2v2NcJFVsC MjiwkJhTrdHGUd0= Received: (qmail 117865 invoked by alias); 10 Jun 2016 15:06:29 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 116882 invoked by uid 89); 10 Jun 2016 15:06:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=unsuccessful, xxx, shortly X-HELO: mail-yw0-f180.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=qqCl8tu8Ojdak6nvyHwf/jHwyt2BKDYw673tRBBsVO0=; b=gJXDU+N3iVGXxEt3lu+dWJdVij7VG8kCDpaB6sSV1vKvxut/7PGXRbpkrwCyStlSWl G9NEBSwWCkpfgS+HjpAiPfjUEoYlDZjd28Ay9wb44lPMr10flkohUAFK46dID1U2/dPy 0EDZtsvWc45gc7LTzRNWwJUY5wLBcrK9O1nG3BwIjNLcBXMBynVs5LVTwwsxO5uyTZFB XIKNxvS5uD8Y/VNzcsLIlHp/3hKy9GqmpGAEXmQRnZnyPBVvBTaJazuZlgOz0Rid1/ZF J7SJ1Ba4/zLZuvS+8R9KU99Y05V+A3bQboUmhDupX8LsVYNoRodAvzMfV9BIemnAADQ1 dm4w== X-Gm-Message-State: ALyK8tIXPFvslp2sjZ1tjXzbLtpz0rq3WW1eNT/DmjWArc9vghOtW4BBWkkt86S6FIkyf8TV X-Received: by 10.37.116.130 with SMTP id p124mr1200088ybc.5.1465571176440; Fri, 10 Jun 2016 08:06:16 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH] nptl: Add sendmmsg and recvmmsg cancellation tests Date: Fri, 10 Jun 2016 12:05:55 -0300 Message-Id: <1465571155-18996-1-git-send-email-adhemerval.zanella@linaro.org> This patch adds cancellation tests for both sendmmsg and recvmmsg syscalls. Tested on x86_64. I will commit it shortly if noone opposes it. * nptl/tst-cancel4.c (tf_recvmmsg): Add test. (tf_sendmmsg): Add test. --- ChangeLog | 3 + nptl/tst-cancel4.c | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+) -- 2.7.4 diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c index 60f7ead..c31d739 100644 --- a/nptl/tst-cancel4.c +++ b/nptl/tst-cancel4.c @@ -1393,6 +1393,89 @@ tf_recvmsg (void *arg) static void * +tf_recvmmsg (void *arg) +{ + struct sockaddr_un sun; + + tempfd = socket (AF_UNIX, SOCK_DGRAM, 0); + if (tempfd == -1) + { + printf ("%s: first socket call failed\n", __FUNCTION__); + exit (1); + } + + int tries = 0; + do + { + if (++tries > 10) + { + printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__); + } + + strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-5-XXXXXX"); + if (mktemp (sun.sun_path) == NULL) + { + printf ("%s: cannot generate temp file name\n", __FUNCTION__); + exit (1); + } + + sun.sun_family = AF_UNIX; + } + while (bind (tempfd, (struct sockaddr *) &sun, + offsetof (struct sockaddr_un, sun_path) + + strlen (sun.sun_path) + 1) != 0); + + tempfname = strdup (sun.sun_path); + + tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0); + if (tempfd2 == -1) + { + printf ("%s: second socket call failed\n", __FUNCTION__); + exit (1); + } + + int r = pthread_barrier_wait (&b2); + if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) + { + printf ("%s: barrier_wait failed\n", __FUNCTION__); + exit (1); + } + + if (arg != NULL) + { + r = pthread_barrier_wait (&b2); + if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) + { + printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); + exit (1); + } + } + + pthread_cleanup_push (cl, NULL); + + char mem[70]; + struct iovec iov[1]; + iov[0].iov_base = mem; + iov[0].iov_len = arg == NULL ? sizeof (mem) : 0; + + struct mmsghdr mm; + mm.msg_hdr.msg_name = &sun; + mm.msg_hdr.msg_namelen = sizeof (sun); + mm.msg_hdr.msg_iov = iov; + mm.msg_hdr.msg_iovlen = 1; + mm.msg_hdr.msg_control = NULL; + mm.msg_hdr.msg_controllen = 0; + + recvmmsg (tempfd2, &mm, 1, 0, NULL); + + pthread_cleanup_pop (0); + + printf ("%s: recvmmsg returned\n", __FUNCTION__); + + exit (1); +} + +static void * tf_open (void *arg) { if (arg == NULL) @@ -1937,6 +2020,92 @@ tf_sendmsg (void *arg) static void * +tf_sendmmsg (void *arg) +{ + if (arg == NULL) + // XXX If somebody can provide a portable test case in which sendmmsg() + // blocks we can enable this test to run in both rounds. + abort (); + + struct sockaddr_un sun; + + tempfd = socket (AF_UNIX, SOCK_DGRAM, 0); + if (tempfd == -1) + { + printf ("%s: first socket call failed\n", __FUNCTION__); + exit (1); + } + + int tries = 0; + do + { + if (++tries > 10) + { + printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__); + } + + strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-7-XXXXXX"); + if (mktemp (sun.sun_path) == NULL) + { + printf ("%s: cannot generate temp file name\n", __FUNCTION__); + exit (1); + } + + sun.sun_family = AF_UNIX; + } + while (bind (tempfd, (struct sockaddr *) &sun, + offsetof (struct sockaddr_un, sun_path) + + strlen (sun.sun_path) + 1) != 0); + tempfname = strdup (sun.sun_path); + + tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0); + if (tempfd2 == -1) + { + printf ("%s: second socket call failed\n", __FUNCTION__); + exit (1); + } + + int r = pthread_barrier_wait (&b2); + if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) + { + printf ("%s: barrier_wait failed\n", __FUNCTION__); + exit (1); + } + + r = pthread_barrier_wait (&b2); + if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD) + { + printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__); + exit (1); + } + + pthread_cleanup_push (cl, NULL); + + char mem[1]; + struct iovec iov[1]; + iov[0].iov_base = mem; + iov[0].iov_len = 1; + + struct mmsghdr mm; + mm.msg_hdr.msg_name = &sun; + mm.msg_hdr.msg_namelen = (offsetof (struct sockaddr_un, sun_path) + + strlen (sun.sun_path) + 1); + mm.msg_hdr.msg_iov = iov; + mm.msg_hdr.msg_iovlen = 1; + mm.msg_hdr.msg_control = NULL; + mm.msg_hdr.msg_controllen = 0; + + sendmmsg (tempfd2, &mm, 1, 0); + + pthread_cleanup_pop (0); + + printf ("%s: sendmmsg returned\n", __FUNCTION__); + + exit (1); +} + + +static void * tf_creat (void *arg) { if (arg == NULL) @@ -2230,6 +2399,7 @@ static struct ADD_TEST (recv, 2, 0), ADD_TEST (recvfrom, 2, 0), ADD_TEST (recvmsg, 2, 0), + ADD_TEST (recvmmsg, 2, 0), ADD_TEST (preadv, 2, 1), ADD_TEST (pwritev, 2, 1), ADD_TEST (open, 2, 1), @@ -2241,6 +2411,7 @@ static struct ADD_TEST (msync, 2, 1), ADD_TEST (sendto, 2, 1), ADD_TEST (sendmsg, 2, 1), + ADD_TEST (sendmmsg, 2, 1), ADD_TEST (creat, 2, 1), ADD_TEST (connect, 2, 1), ADD_TEST (tcdrain, 2, 1),