[project @ 2001-05-01 11:46:56 by simonmar]
authorsimonmar <unknown>
Tue, 1 May 2001 11:46:56 +0000 (11:46 +0000)
committersimonmar <unknown>
Tue, 1 May 2001 11:46:56 +0000 (11:46 +0000)
Start a new directory for networking tests, and add a simple test
which starts two threads which communicate via a socket.

The socket subdirectory already contains some tests, but they're about
6 years old and don't appear to be designed to run without user
intervention.

ghc/tests/lib/Makefile
ghc/tests/lib/net/Makefile [new file with mode: 0644]
ghc/tests/lib/net/net001.hs [new file with mode: 0644]
ghc/tests/lib/net/net001.stdout [new file with mode: 0644]

index 080bedf..f273ff4 100644 (file)
@@ -1,10 +1,10 @@
 #-----------------------------------------------------------------------------
-# $Id: Makefile,v 1.4 1998/09/20 15:33:58 simonm Exp $
+# $Id: Makefile,v 1.5 2001/05/01 11:46:56 simonmar Exp $
 
 TOP = ..
 include $(TOP)/mk/boilerplate.mk
 
-SUBDIRS = should_run 
+SUBDIRS = should_run net
 
 # posix009 hangs on Linux, disabled for now --SDM
 # posix
diff --git a/ghc/tests/lib/net/Makefile b/ghc/tests/lib/net/Makefile
new file mode 100644 (file)
index 0000000..455110d
--- /dev/null
@@ -0,0 +1,12 @@
+# -----------------------------------------------------------------------------
+# $Id: Makefile,v 1.1 2001/05/01 11:46:56 simonmar Exp $
+
+TOP = ../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/should_run.mk
+
+SRC_HC_OPTS += -dcore-lint -package net -fglasgow-exts
+
+.PRECIOUS: %.o %.bin
+
+include $(TOP)/mk/target.mk
diff --git a/ghc/tests/lib/net/net001.hs b/ghc/tests/lib/net/net001.hs
new file mode 100644 (file)
index 0000000..e5621c3
--- /dev/null
@@ -0,0 +1,20 @@
+module Main where
+
+import Socket
+import Concurrent
+import IO
+
+main = do
+   forkIO server
+   yield
+   h <- connectTo "localhost" (PortNumber 22222)
+   l <- hGetLine h
+   hClose h
+   print l
+ where
+   server = do
+         s <- listenOn (PortNumber 22222)
+         (h, host, port) <- accept s
+         hPutStrLn h "hello"
+         hClose h
+
diff --git a/ghc/tests/lib/net/net001.stdout b/ghc/tests/lib/net/net001.stdout
new file mode 100644 (file)
index 0000000..3580093
--- /dev/null
@@ -0,0 +1 @@
+"hello"