summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Main.hs30
1 files changed, 21 insertions, 9 deletions
diff --git a/tests/Main.hs b/tests/Main.hs
index 204d1656..96c599b4 100644
--- a/tests/Main.hs
+++ b/tests/Main.hs
@@ -4,10 +4,11 @@ import Control.Exception
4import Control.Monad 4import Control.Monad
5import Data.Functor 5import Data.Functor
6import Data.Maybe 6import Data.Maybe
7import System.Directory
7import System.Exit 8import System.Exit
8import System.Environment 9import System.Environment
10import System.FilePath
9import System.Process 11import System.Process
10import System.Directory
11import Text.Printf 12import Text.Printf
12import Test.Hspec 13import Test.Hspec
13 14
@@ -25,26 +26,37 @@ torrents =
25 , "testfile.torrent" 26 , "testfile.torrent"
26 ] 27 ]
27 28
29rtorrentSessionDir :: String
30rtorrentSessionDir = "rtorrent-sessiondir"
31
32sessionName :: String -- screen session name
33sessionName = "bittorrent-testsuite"
34
28clients :: [Descr] 35clients :: [Descr]
29clients = 36clients =
30 [ ("rtorrent" 37 [ ("rtorrent"
31 , \ ClientOpts {..} tfile -> printf 38 , \ ClientOpts {..} tfile -> printf
32 "rtorrent -p %i-%i -O dht=on -O dht_port=%i -O session=rtorrent-sessiondir %s" 39 "rtorrent -p %i-%i -O dht=on -O dht_port=%i -O session=%s %s"
33 (fromEnum peerPort) (fromEnum peerPort) (fromEnum nodePort) tfile 40 (fromEnum peerPort) (fromEnum peerPort) (fromEnum nodePort)
41 rtorrentSessionDir tfile
34 ) 42 )
35 ] 43 ]
36 44
37sessionName :: String -- screen session name
38sessionName = "bittorrent-testsuite"
39
40setupEnv :: EnvOpts -> IO (Maybe ()) 45setupEnv :: EnvOpts -> IO (Maybe ())
41setupEnv EnvOpts {..} 46setupEnv EnvOpts {..}
42 | Just client <- testClient 47 | Just client <- testClient
43 , Just mkCmd <- lookup client clients = do 48 , Just mkCmd <- lookup client clients = do
49 _ <- printf "Setting up %s\n" client
50
51 let torrentPath = "testfile.torrent"
52 let tmpDir = "res"
44 let runner = printf "screen -dm -S %s %s" sessionName 53 let runner = printf "screen -dm -S %s %s" sessionName
45 (mkCmd remoteOpts "testfile.torrent") 54 (mkCmd remoteOpts torrentPath)
46 dir <- getCurrentDirectory 55
47 _ <- createProcess (shell runner) { cwd = Just (dir ++ "/res") } 56 wd <- getCurrentDirectory
57 createDirectoryIfMissing True (wd </> tmpDir </> rtorrentSessionDir)
58 _ <- createProcess (shell runner) { cwd = Just (wd </> tmpDir) }
59
48 return (Just ()) 60 return (Just ())
49 61
50 | Just client <- testClient = do 62 | Just client <- testClient = do