2010-11-18 17:48:28 +00:00
|
|
|
{- Checks system configuration and generates SysConfig.hs. -}
|
2010-11-18 17:30:42 +00:00
|
|
|
|
|
|
|
import System.Directory
|
|
|
|
|
2011-01-20 00:02:48 +00:00
|
|
|
import TestConfig
|
2010-11-18 18:07:22 +00:00
|
|
|
|
2010-11-27 21:31:20 +00:00
|
|
|
tests :: [TestCase]
|
2010-11-18 17:30:42 +00:00
|
|
|
tests = [
|
2011-01-20 00:02:48 +00:00
|
|
|
testCp "cp_a" "-a"
|
|
|
|
, testCp "cp_p" "-p"
|
|
|
|
, testCp "cp_reflink_auto" "--reflink=auto"
|
|
|
|
, TestCase "uuid generator" $ selectCmd "uuid" ["uuid", "uuidgen"]
|
2011-02-08 23:31:27 +00:00
|
|
|
, TestCase "sha1sum" $ requireCmd "sha1sum" "sha1sum </dev/null"
|
2011-01-20 00:02:48 +00:00
|
|
|
, TestCase "xargs -0" $ requireCmd "xargs_0" "xargs -0 </dev/null"
|
|
|
|
, TestCase "rsync" $ requireCmd "rsync" "rsync --version >/dev/null"
|
2010-11-18 17:30:42 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
tmpDir :: String
|
|
|
|
tmpDir = "tmp"
|
|
|
|
|
|
|
|
testFile :: String
|
|
|
|
testFile = tmpDir ++ "/testfile"
|
|
|
|
|
2011-01-20 00:02:48 +00:00
|
|
|
testCp :: ConfigKey -> String -> TestCase
|
|
|
|
testCp k option = TestCase cmd $ testCmd k run
|
2011-01-19 22:08:50 +00:00
|
|
|
where
|
2011-01-20 00:02:48 +00:00
|
|
|
cmd = "cp " ++ option
|
|
|
|
run = cmd ++ " " ++ testFile ++ " " ++ testFile ++ ".new"
|
2010-11-18 17:30:42 +00:00
|
|
|
|
2010-11-18 18:11:18 +00:00
|
|
|
setup :: IO ()
|
|
|
|
setup = do
|
2010-11-18 17:30:42 +00:00
|
|
|
createDirectoryIfMissing True tmpDir
|
|
|
|
writeFile testFile "test file contents"
|
2010-11-18 18:11:18 +00:00
|
|
|
|
|
|
|
cleanup :: IO ()
|
|
|
|
cleanup = do
|
2010-11-18 17:30:42 +00:00
|
|
|
removeDirectoryRecursive tmpDir
|
2010-11-18 18:11:18 +00:00
|
|
|
|
|
|
|
main :: IO ()
|
|
|
|
main = do
|
|
|
|
setup
|
|
|
|
config <- runTests tests
|
2010-11-18 17:30:42 +00:00
|
|
|
writeSysConfig config
|
2010-11-18 18:11:18 +00:00
|
|
|
cleanup
|