Commit 3e9cc507 authored by dterei's avatar dterei
Browse files

Fix some issues with safe haskell tests

parent 895dc2fb
{-# LANGUAGE SafeImports #-}
module Check01 ( main' ) where
import safe CheckB
import safe Check01_B
main' = do
let n = mainM 1
......
{-# LANGUAGE Trustworthy #-}
module Check01_A (
trace
) where
import qualified Debug.Trace as D
import qualified Data.ByteString.Lazy.Char8 as BS
-- | Allowed declasification
trace :: String -> a -> a
trace s = D.trace $ s ++ show a3
a3 :: BS.ByteString
a3 = BS.take 3 $ BS.repeat 'a'
{-# LANGUAGE Safe #-}
-- Since Safe we require base package be trusted to compile
module Check01_B where
import Check01_A
mainM :: Int -> Int
mainM n = trace "Allowed Leak" $ n * 2
[3 of 3] Compiling Check01 ( Check01.hs, Check01.o )
module Check02 where
{-# LANGUAGE SafeImports #-}
module Check02 ( main' ) where
import CheckB
import safe Check02_B
mainN = do
main' = do
let n = mainM 1
print $ n
{-# LANGUAGE Trustworthy #-}
module Check02_A (
trace
) where
import qualified Debug.Trace as D
import qualified Data.ByteString.Lazy.Char8 as BS
-- | Allowed declasification
trace :: String -> a -> a
trace s = D.trace $ s ++ show a3
a3 :: BS.ByteString
a3 = BS.take 3 $ BS.repeat 'a'
{-# LANGUAGE Safe #-}
-- Since Safe we require base package be trusted to compile
module Check02_B where
import Check02_A
mainM :: Int -> Int
mainM n = trace "Allowed Leak" $ n * 2
{-# LANGUAGE SafeImports #-}
module Main ( main ) where
module Check03 where
import Check01
import Check03_B
main = main'
mainN = do
let n = mainM 1
print $ n
[4 of 4] Compiling Main ( Check03.hs, Check03.o )
Linking Check03 ...
[3 of 3] Compiling Check03 ( Check03.hs, Check03.o )
{-# LANGUAGE Trustworthy #-}
module Check03_A (
trace
) where
import qualified Debug.Trace as D
import qualified Data.ByteString.Lazy.Char8 as BS
-- | Allowed declasification
trace :: String -> a -> a
trace s = D.trace $ s ++ show a3
a3 :: BS.ByteString
a3 = BS.take 3 $ BS.repeat 'a'
{-# LANGUAGE Safe #-}
-- Since Safe we require base package be trusted to compile
module Check03_B where
import Check03_A
mainM :: Int -> Int
mainM n = trace "Allowed Leak" $ n * 2
{-# LANGUAGE SafeImports #-}
module Main ( main ) where
import Check04_1
main = main'
[4 of 4] Compiling Main ( Check04.hs, Check04.o )
Linking Check04 ...
{-# LANGUAGE SafeImports #-}
module Check04_1 ( main' ) where
import safe Check04_B
main' = do
let n = mainM 1
print $ n
{-# LANGUAGE Trustworthy #-}
module Check04_A (
trace
) where
import qualified Debug.Trace as D
import qualified Data.ByteString.Lazy.Char8 as BS
-- | Allowed declasification
trace :: String -> a -> a
trace s = D.trace $ s ++ show a3
a3 :: BS.ByteString
a3 = BS.take 3 $ BS.repeat 'a'
{-# LANGUAGE Safe #-}
-- Since Safe we require base package be trusted to compile
module Check04_B where
import Check04_A
mainM :: Int -> Int
mainM n = trace "Allowed Leak" $ n * 2
......@@ -8,29 +8,29 @@ test('CheckA', normal, compile, [''])
test('CheckB', normal, multimod_compile, ['CheckB', '-trust base'])
# fail as we don't trust base when compiling Check01
test('Check01_fail', normal, multi_compile_fail, ['Check01', [
('CheckA.hs', ''),
('CheckB.hs', '-trust base')
], ''])
test('Check01', normal, multi_compile_fail, ['Check01', [
('Check01_A.hs', ''),
('Check01_B.hs', '-trust base')
], ''])
# suceed this time since we trust base when we compile AND use CheckB
test('Check01_succeed', normal, multi_compile, ['Check01', [
('CheckA.hs', ''),
('CheckB.hs', '')
], '-trust base'])
test('Check02', normal, multi_compile, ['Check02', [
('Check02_A.hs', ''),
('Check02_B.hs', '')
], '-trust base'])
# suceed as while like Check01_fail we don't import CheckB as a safe
# import this time, so don't require base trusted when used.
test('Check02', normal, multi_compile, ['Check02', [
('CheckA.hs', ''),
('CheckB.hs', '-trust base')
test('Check03', normal, multi_compile, ['Check03', [
('Check03_A.hs', ''),
('Check03_B.hs', '-trust base')
], ''])
# Check a slightly larger transitive program. Check01 isn't imported
# safely by Check03 so we don't require base trused at end.
test('Check03', normal, multi_compile, ['Check03', [
('CheckA.hs', ''),
('CheckB.hs', '-trust base'),
('Check01.hs', '-trust base')
test('Check04', normal, multi_compile, ['Check04', [
('Check04_A.hs', ''),
('Check04_B.hs', '-trust base'),
('Check04_1.hs', '-trust base')
], ''])
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