summaryrefslogtreecommitdiff
path: root/testing/hstox/toxcore-sut.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testing/hstox/toxcore-sut.hs')
-rw-r--r--testing/hstox/toxcore-sut.hs31
1 files changed, 31 insertions, 0 deletions
diff --git a/testing/hstox/toxcore-sut.hs b/testing/hstox/toxcore-sut.hs
new file mode 100644
index 00000000..73bdb702
--- /dev/null
+++ b/testing/hstox/toxcore-sut.hs
@@ -0,0 +1,31 @@
1module Main (main) where
2
3import Control.Concurrent (threadDelay)
4import System.Environment (getArgs, withArgs)
5import System.Process (createProcess, proc, terminateProcess)
6
7import Network.Tox.Testing (serve)
8import qualified ToxTestSuite
9
10
11foreign import ccall test_main :: IO ()
12
13
14main :: IO ()
15main = do
16 args <- getArgs
17 case args of
18 ["--sut"] -> test_main
19 self : testArgs -> do
20 -- Start a toxcore SUT (System Under Test) process that will listen on
21 -- port 1234. We call ourselves here, so the branch above is taken.
22 (_, _, _, sut) <- createProcess $ proc self ["--sut"]
23 -- 100ms delay to give the SUT time to set up its socket before we try to
24 -- build connections in the test runner.
25 threadDelay $ 100 * 1000
26 -- ToxTestSuite (the test runner) makes connections to port 1234 to
27 -- communicate with the SUT.
28 withArgs (["--print-cpu-time", "--color"] ++ testArgs) ToxTestSuite.main
29 terminateProcess sut
30 _ ->
31 fail "Usage: toxcore-sut <path-to-toxcore-sut> [test-args...]"