diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2025-07-05 18:15:06 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2025-07-06 13:03:19 +0200 |
commit | 28a93e24f6a33a8254c16c31961d523c71bdb1d2 (patch) | |
tree | dfd54319c67c031cadf3398dc93ac648dc7e90be /src/Run.hs | |
parent | 8e4bacb750d6b3657e5e8c72a8f30f14455812e5 (diff) |
Recursively bind and set to read-only all the host filesystems and
bind-mount as read-write only the test dir. Provide new writable tmpfs
under /tmp.
Changelog: Make host filesystems read-only for the test process (except for test dir)
Diffstat (limited to 'src/Run.hs')
-rw-r--r-- | src/Run.hs | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -39,6 +39,7 @@ import Output import Parser import Process import Run.Monad +import Sandbox import Script.Expr import Script.Module import Script.Object @@ -102,11 +103,21 @@ runTest out opts gdefs test = do oldHandler <- installHandler processStatusChanged (CatchInfo sigHandler) Nothing resetOutputTime out - ( res, [] ) <- runWriterT $ runExceptT $ flip runReaderT (tenv, tstate) $ fromTestRun $ do - withInternet $ \_ -> do - runStep =<< eval (testSteps test) - when (optWait opts) $ do - void $ outPromptGetLine $ "Test '" <> testName test <> "' completed, waiting..." + testRunResult <- newEmptyMVar + + void $ forkOS $ do + isolateFilesystem testDir >>= \case + True -> do + tres <- runWriterT $ runExceptT $ flip runReaderT (tenv, tstate) $ fromTestRun $ do + withInternet $ \_ -> do + runStep =<< eval (testSteps test) + when (optWait opts) $ do + void $ outPromptGetLine $ "Test '" <> testName test <> "' completed, waiting..." + putMVar testRunResult tres + _ -> do + putMVar testRunResult ( Left Failed, [] ) + + ( res, [] ) <- takeMVar testRunResult void $ installHandler processStatusChanged oldHandler Nothing |