summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bench/Main.hs7
-rw-r--r--krpc.cabal24
-rw-r--r--tests/Client.hs53
3 files changed, 62 insertions, 22 deletions
diff --git a/bench/Main.hs b/bench/Main.hs
index 87d39f14..f9650d97 100644
--- a/bench/Main.hs
+++ b/bench/Main.hs
@@ -19,4 +19,9 @@ main = defaultMain $ map (mkbench 1) [1, 10, 100, 1000, 32 * 1024]
19 ++ map (mkbench 10) [1, 10, 100, 1000] 19 ++ map (mkbench 10) [1, 10, 100, 1000]
20 where 20 where
21 mkbench r n = bench (show r ++ "/" ++ show n) $ nfIO $ 21 mkbench r n = bench (show r ++ "/" ++ show n) $ nfIO $
22 replicateM r $ call addr echo (B.replicate n 0) \ No newline at end of file 22 replicateM r $ call addr echo (B.replicate n 0)
23
24{-
25 forM_ [1..] $ const $ do
26 async addr myconcat (replicate 100 [1..10])
27-}
diff --git a/krpc.cabal b/krpc.cabal
index b9bd0f1a..bb3fdea6 100644
--- a/krpc.cabal
+++ b/krpc.cabal
@@ -42,18 +42,28 @@ library
42 42
43 43
44 44
45 45test-suite test-client
46executable exsample-client 46 type: exitcode-stdio-1.0
47 main-is: Client.hs 47 main-is: Client.hs
48 other-modules: Shared 48 other-modules: Shared
49 build-depends: base == 4.*, krpc, bytestring 49 build-depends: base == 4.*
50 hs-source-dirs: examples 50 , bytestring
51 , krpc
52
53 , HUnit
54 , test-framework
55 , test-framework-hunit
51 56
52executable exsample-server 57 hs-source-dirs: tests
58
59executable test-server
53 main-is: Server.hs 60 main-is: Server.hs
54 other-modules: Shared 61 other-modules: Shared
55 build-depends: base == 4.*, krpc, bytestring 62 build-depends: base == 4.*
56 hs-source-dirs: examples 63 , bytestring
64 , krpc
65
66 hs-source-dirs: tests
57 67
58 68
59 69
diff --git a/tests/Client.hs b/tests/Client.hs
index ec86639e..c2ac6d01 100644
--- a/tests/Client.hs
+++ b/tests/Client.hs
@@ -3,6 +3,11 @@ module Main (main) where
3 3
4import qualified Data.ByteString as B 4import qualified Data.ByteString as B
5import System.Environment 5import System.Environment
6
7import Test.HUnit hiding (Test)
8import Test.Framework
9import Test.Framework.Providers.HUnit
10
6import Remote.KRPC 11import Remote.KRPC
7import Shared 12import Shared
8 13
@@ -11,17 +16,37 @@ addr :: RemoteAddr
11addr = (0, 6000) 16addr = (0, 6000)
12 17
13main :: IO () 18main :: IO ()
14main = do 19main = defaultMain tests
15 print =<< call addr unitM () 20
16 print =<< call addr echoM 0 21(==?) :: (Eq a, Show a) => a -> IO a -> Assertion
17 call addr reverseM [1..1000] 22expected ==? action = do
18 print =<< call addr swapM (0, 1) 23 actual <- action
19 print =<< call addr shiftR ((), 1, [2..10]) 24 expected @=? actual
20 let bs = B.replicate (32 * 1024) 0 25
21 bs' <- call addr echoBytes bs 26tests :: [Test]
22 print (bs == bs') 27tests =
23 28 [ testCase "unit" $
24{- 29 () ==? call addr unitM ()
25 forM_ [1..] $ const $ do 30
26 async addr myconcat (replicate 100 [1..10]) 31 , testCase "echo int" $
27-} 32 1234 ==? call addr echoM 1234
33
34 , testCase "reverse 1..100" $
35 reverse [1..100] ==? call addr reverseM [1..100]
36
37 , testCase "reverse empty list" $
38 reverse [] ==? call addr reverseM []
39
40 , testCase "reverse singleton list" $
41 reverse [1] ==? call addr reverseM [1]
42
43 , testCase "swap pair" $
44 (1, 0) ==? call addr swapM (0, 1)
45
46 , testCase "shift triple" $
47 ([2..10], (), 1) ==? call addr shiftR ((), 1, [2..10])
48
49 , testCase "echo bytestring" $
50 let bs = B.replicate 400 0 in
51 bs ==? call addr echoBytes bs
52 ]