erebos-tester 0.3.0 → 0.3.1
raw patch · 3 files changed
+19/−2 lines, 3 files
Files
- CHANGELOG.md +4/−0
- erebos-tester.cabal +1/−1
- src/Process.hs +14/−1
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for erebos-tester +## 0.3.1 -- 2025-03-03++* Fix executing test tool given with relative path+ ## 0.3.0 -- 2025-02-28 * User-defined functions
erebos-tester.cabal view
@@ -1,7 +1,7 @@ cabal-version: 3.0 name: erebos-tester-version: 0.3.0+version: 0.3.1 synopsis: Test framework with virtual network using Linux namespaces description: This framework is intended mainly for networking libraries/applications and
src/Process.hs view
@@ -22,7 +22,9 @@ import qualified Data.Text as T import qualified Data.Text.IO as T +import System.Directory import System.Exit+import System.FilePath import System.IO import System.IO.Error import System.Posix.Signals@@ -89,9 +91,20 @@ spawnOn :: Either Network Node -> ProcName -> Maybe Signal -> String -> TestRun Process spawnOn target pname killWith cmd = do+ -- When executing command given with relative path, turn it to absolute one,+ -- because working directory will be changed for the "ip netns exec" wrapper.+ cmd' <- liftIO $ do+ case span (/= ' ') cmd of+ ( path, rest )+ | any isPathSeparator path && isRelative path+ -> do+ path' <- makeAbsolute path+ return (path' ++ rest)+ _ -> return cmd+ let netns = either getNetns getNetns target let prefix = T.unpack $ "ip netns exec \"" <> textNetnsName netns <> "\" "- (Just hin, Just hout, Just herr, handle) <- liftIO $ createProcess (shell $ prefix ++ cmd)+ (Just hin, Just hout, Just herr, handle) <- liftIO $ createProcess (shell $ prefix ++ cmd') { std_in = CreatePipe, std_out = CreatePipe, std_err = CreatePipe , cwd = Just (either netDir nodeDir target) , env = Just [ ( "EREBOS_DIR", "." ) ]