diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-10-01 00:26:52 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-10-01 02:13:34 +0100 |
commit | c037100747a1a224160cb12defb600ddfe1ba927 (patch) | |
tree | 8332a7d288116b802866e1ed98d1b950425206f7 /testing/hstox/toxcore-sut.hs | |
parent | 1977d56caaff40ea9bbf6754b69bec9539a5a969 (diff) |
Import the hstox SUT interface from hstox.
We'll maintain it in the c-toxcore repo, where it belongs.
Diffstat (limited to 'testing/hstox/toxcore-sut.hs')
-rw-r--r-- | testing/hstox/toxcore-sut.hs | 31 |
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 @@ | |||
1 | module Main (main) where | ||
2 | |||
3 | import Control.Concurrent (threadDelay) | ||
4 | import System.Environment (getArgs, withArgs) | ||
5 | import System.Process (createProcess, proc, terminateProcess) | ||
6 | |||
7 | import Network.Tox.Testing (serve) | ||
8 | import qualified ToxTestSuite | ||
9 | |||
10 | |||
11 | foreign import ccall test_main :: IO () | ||
12 | |||
13 | |||
14 | main :: IO () | ||
15 | main = 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...]" | ||