Commit 288bbb1c authored by Valentin Reis's avatar Valentin Reis

Adds fwarn-unused-do-binds and rapl file permission mgt

parent 8b473ff2
Pipeline #5930 passed with stages
in 39 seconds
......@@ -48,4 +48,5 @@ executable argotk
-fwarn-name-shadowing
-fprint-potential-instances
-Wmissing-export-lists
-fwarn-unused-do-bind
-fwarn-incomplete-patterns
......@@ -60,27 +60,16 @@ prepareDaemon
-> PowerCap
-> Shell Instrumentation
prepareDaemon out stdErr test v powercap = do
daemonPath <- myWhich "daemon"
let confPath' = "/tmp/argo_nodeos_config"
cleanContainers confPath'
export "ARGO_NODEOS_CONFIG" (format fp confPath')
return $ case powercap of
None -> Instrumentation
(P.proc "daemon" (["--nrm_log", "./nrm_log"] ++ toOption v))
out
stdErr
test
_ -> Instrumentation
(P.proc
"sudo"
( [encodeString daemonPath, "--nrm_log", "./nrm_log"]
++ toOption v
++ toOption powercap
)
)
out
stdErr
test
return $ Instrumentation
(P.proc "daemon"
(["--nrm_log", "./nrm_log"] ++ toOption v ++ toOption powercap)
)
out
stdErr
test
where
nodeOsFailure n = do
printError ("argo_nodeos_config failed with exit code :" <> repr n)
......@@ -92,12 +81,13 @@ prepareDaemon out stdErr test v powercap = do
cleanContainers :: FilePath -> Shell ()
cleanContainers argo_nodeos_config =
verboseShell'
(format ("sudo" % fp % " --clean_config=kill_content:true")
argo_nodeos_config
)
empty >>= \case
(ExitFailure n,_,_) -> nodeOsFailure n
(ExitSuccess,_,_) -> return ()
(format ("sudo " % fp % " --clean_config=kill_content:true")
argo_nodeos_config
)
empty
>>= \case
(ExitFailure n, _, _) -> nodeOsFailure n
(ExitSuccess , _, _) -> return ()
cmdRunI
:: AppName
......@@ -175,6 +165,11 @@ runStack :: StackArgs -> Shell StackOutput
runStack sa@StackArgs {..} = do
when verbose $ liftIO $ pPrint sa
when (powercap /= None) $ do
user <- lineToText <$> single (inproc "whoami" [] empty)
chownPowercapFiles user "/sys/devices/virtual/powercap/intel-rapl/intel-rapl:0"
chownPowercapFiles user "/sys/devices/virtual/powercap/intel-rapl/intel-rapl:1"
cleanLeftovers workingDirectory
CM.mapM_ ($ coerce workingDirectory) [mktree, cd]
......@@ -237,6 +232,18 @@ runStack sa@StackArgs {..} = do
cd "../"
return r
where
chownPowercap user fn =
shell (format ("sudo chown " % s % ":" % s % " " % s) user user fn) empty
>>= \case
ExitSuccess ->
printWarning $ "changed ownership on " <> fn
ExitFailure _ ->
die $ "Couldn't change ownership on " <> fn
chownPowercapFiles user p =
chownPowercap user (p <> "/constraint_1_power_limit_uw")
<> chownPowercap user (p <> "/constraint_0_power_limit_uw")
verbose = verbosity == Verbose
procsWithTracebacks
:: [(StackI, Instrumentation)] -> Shell [(StackI, Text, Text)]
......
......@@ -79,7 +79,7 @@ newtype TextBehaviorStderr = TextBehaviorStderr TextBehavior deriving (Show, Rea
data TextBehavior =
WaitFor Text
| ExpectClean deriving (Show,Read)
data PowerCap = Fixed Int | Adaptive | None deriving (Show, Read)
data PowerCap = Fixed Int | Adaptive | None deriving (Show, Read, Eq)
class ToDaemonOption a where
toOption :: a -> [String]
......
......@@ -68,12 +68,12 @@ printWarning :: Text -> Shell ()
printSuccess :: Text -> Shell ()
printTest :: Text -> Shell ()
printInfo = printf ("Info: " % s % "\n")
printCommand = printf ("Running: " % s % "\n")
printWarning = colorShell Yellow . printf ("Warning: " % s % "\n")
printError = colorShell Red . printf ("Error: " % s % "\n")
printSuccess = colorShell Green . printf ("Success: " % s % "\n")
printTest = colorShell Green . printf ("RUNNING TEST: " % s % "\n")
printInfo = printf ("info: " % s % "\n")
printCommand = printf ("running: " % s % "\n")
printWarning = colorShell Yellow . printf ("warning: " % s % "\n")
printError = colorShell Red . printf ("error: " % s % "\n")
printSuccess = colorShell Green . printf ("success: " % s % "\n")
printTest = colorShell Green . printf ("running stack: " % s % "\n")
myWhich :: FilePath -> Shell FilePath
myWhich str = which str >>= \case
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment