From 6b44130571f7fb19837c73c4e413fe65831a640f Mon Sep 17 00:00:00 2001 From: gdr-ftp Date: Thu, 31 Dec 1998 22:45:35 +0000 Subject: [PATCH] ports.c: initial checkin for test re PR#102 --- lib/libc/tests/sys/ports.c | 47 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 lib/libc/tests/sys/ports.c diff --git a/lib/libc/tests/sys/ports.c b/lib/libc/tests/sys/ports.c new file mode 100644 index 0000000..1b44ab3 --- /dev/null +++ b/lib/libc/tests/sys/ports.c @@ -0,0 +1,47 @@ +/* + * This program demonstrates the problem documented in PR#102 regarding + * multiple bindings on a port. + * + * $Id: ports.c,v 1.1 1998/12/31 22:45:35 gdr-ftp Exp $ + */ + +#include +#include + +#define PORT_NAME "mytestport" + +int +main (int argc, char **argv) { + int result, port1, port2; + + printf("creating ports\n"); + if ((port1 = pcreate(2)) == -1) { + perror("first pcreate failed"); + return 1; + } + printf("port 1 is %d\n", port1); + if ((port2 = pcreate(3)) == -1) { + perror("second pcreate failed"); + return 1; + } + printf("port 2 is %d\n", port2); + + printf("binding first port: should succeed\n"); + result = pbind(port1, PORT_NAME); + if (result == -1) { + printf("bind of first port failed with code %d\n", result); + } else { + printf("bind of first port succeeded with code %d\n", result); + } + + printf("binding second port: should fail\n"); + result = pbind(port2, PORT_NAME); + if (result == -1) { + printf("bind of second port failed with code %d\n", result); + } else { + printf("bind of second port succeeded with code %d\n", result); + } + + printf("pgetport returns %d\n", pgetport(PORT_NAME)); + return 0; +}