xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: [OSSTEST PATCH 01/16] rump-test-net: New test program
Date: Fri, 7 Oct 2016 17:34:41 +0100	[thread overview]
Message-ID: <1475858096-16123-2-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1475858096-16123-1-git-send-email-ian.jackson@eu.citrix.com>

The rump kernel WOPR test is no more, so we reimplement it.  This test
program simply listens on a TCP socket and says hi when you connect to
it.  It's a portable program.  So far, this has been tested on Linux,
but not in the rump environment.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 rump-test-net.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 rump-test-net.c

diff --git a/rump-test-net.c b/rump-test-net.c
new file mode 100644
index 0000000..96dbb1c
--- /dev/null
+++ b/rump-test-net.c
@@ -0,0 +1,65 @@
+/*
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <assert.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <sys/fcntl.h>
+
+static int master;
+
+int main(int argc, const char *const *argv) {
+    struct sockaddr_in6 sin6;
+    int r;
+
+    assert(argc==2);
+
+    master = socket(AF_INET6,SOCK_STREAM,0);
+    if (master<0) { perror("socket"); exit(-1); }
+
+    int port = atoi(argv[1]);
+
+    memset(&sin6,0,sizeof(sin6));
+    sin6.sin6_family = AF_INET6;
+    sin6.sin6_port = htons(port);
+    sin6.sin6_addr = in6addr_any;
+
+    r = bind(master,(struct sockaddr*)&sin6,sizeof(sin6));
+    if (r) { perror("bind"); exit(-1); }
+
+    r = listen(master,5);
+    if (r) { perror("listen"); exit(-1); }
+
+    fprintf(stderr,"listening on %d\n",port);
+
+    int slave = -1;
+    for (;;) {
+	static const char message[] = "hello\r\n";
+	static const int messagel = sizeof(message)-1;
+
+	if (slave > 0) close(slave);
+
+	slave = accept(master,0,0);
+	if (slave < 0) { perror("accept"); continue; }
+
+	r = fcntl(slave, F_GETFL);
+	if (r < 0) { perror("F_GETFL"); continue; }
+	r = fcntl(slave, F_SETFL, r | O_NONBLOCK);
+	if (r < 0) { perror("F_SETFL"); continue; }
+
+	r = write(slave, message, messagel);
+	if (r < 0) { perror("write"); continue; }
+	else if (r != messagel) {
+	    fprintf(stderr,"write: %d (!= %d",r,messagel);
+	    continue;
+	}
+
+	r = close(slave);
+	slave = -1;
+	if (r < 0) { perror("close"); continue; }
+    }
+}
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2016-10-07 16:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-07 16:34 [OSSTEST PATCH 00/16] Fix rump kernel tests Ian Jackson
2016-10-07 16:34 ` Ian Jackson [this message]
2016-10-07 16:34 ` [OSSTEST PATCH 02/16] rump-test-net: setsockopt V6ONLY off Ian Jackson
2016-10-07 16:34 ` [OSSTEST PATCH 03/16] BuildSupport: builddirsprops: Clean up each builddir Ian Jackson
2016-10-07 16:34 ` [OSSTEST PATCH 04/16] Support guest-specific "toolstack" for guest creation Ian Jackson
2016-10-07 16:34 ` [OSSTEST PATCH 05/16] rump kernels: Provide rumprun toolstack Ian Jackson
2016-10-07 16:34 ` [OSSTEST PATCH 06/16] rump kernels: Specify toolstack for rumprun demo to be rumprun Ian Jackson
2016-10-07 16:34 ` [OSSTEST PATCH 07/16] rump kernels: ts-rumprun-bake: Do not tolerate errors Ian Jackson
2016-10-07 16:34 ` [OSSTEST PATCH 08/16] rump kernels: Provide proper DHCP instructions to rumprun Ian Jackson
2016-10-07 16:34 ` [OSSTEST PATCH 09/16] rump kernels: Provide networking test Ian Jackson
2016-10-07 16:34 ` [OSSTEST PATCH 10/16] TestSupport: guest_unprepare_disk: Make a no-op for guests with no Lvdev Ian Jackson
2016-10-07 16:34 ` [OSSTEST PATCH 11/16] rumprun: xenstorels: Better new regexps for finding output Ian Jackson
2016-10-07 16:34 ` [OSSTEST PATCH 12/16] rumprun: Disable unwanted builds Ian Jackson
2016-10-07 16:34 ` [OSSTEST PATCH 13/16] rump kernels: Adjust indentation in run-job/test-rumprun Ian Jackson
2016-10-07 16:34 ` [OSSTEST PATCH 14/16] rump kernels: Install binutils on test box Ian Jackson
2016-10-07 16:34 ` [OSSTEST PATCH 15/16] make-flight: Honour $bfi (build flight) for rump tests Ian Jackson
2016-10-07 16:34 ` [OSSTEST PATCH 16/16] rump kernels: Build with RUMP_DEV_XEN_DEBUG and filter out debug messages Ian Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1475858096-16123-2-git-send-email-ian.jackson@eu.citrix.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).