Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mockup-generator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dosek-verification
mockup-generator
Commits
c32d0e45
Commit
c32d0e45
authored
Dec 7, 2016
by
Hans-Peter Deifel
Browse files
Options
Downloads
Patches
Plain Diff
Get testsuite to run through again
Some tests were disabled in the process. They should be brought back.
parent
181cfd33
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/CFG/C.hs
+3
-1
3 additions, 1 deletion
src/CFG/C.hs
test/CFG/CSpec.hs
+50
-48
50 additions, 48 deletions
test/CFG/CSpec.hs
test/CFG/IRSpec.hs
+2
-15
2 additions, 15 deletions
test/CFG/IRSpec.hs
with
55 additions
and
64 deletions
src/CFG/C.hs
+
3
−
1
View file @
c32d0e45
...
@@ -23,7 +23,9 @@ import CFG.IR
...
@@ -23,7 +23,9 @@ import CFG.IR
import
CFG.Types
import
CFG.Types
-- | Compile multiple functions to C, inckluding declarations
-- | Compile multiple functions to C, inckluding declarations
compileToCAll
::
Maybe
IntSet
->
[
Function
[
Instr
]]
->
Text
compileToCAll
::
Maybe
IntSet
-- ^ All possible interrupt numbers
->
[
Function
[
Instr
]]
->
Text
compileToCAll
interrupts
funs
=
flip
evalState
0
$
do
compileToCAll
interrupts
funs
=
flip
evalState
0
$
do
funs'
<-
T
.
unlines
<$>
mapM
(
compileToC
interrupts
)
funs
funs'
<-
T
.
unlines
<$>
mapM
(
compileToC
interrupts
)
funs
idleHook
<-
preIdleHook
interrupts
idleHook
<-
preIdleHook
interrupts
...
...
This diff is collapsed.
Click to expand it.
test/CFG/CSpec.hs
+
50
−
48
View file @
c32d0e45
...
@@ -15,8 +15,8 @@ import CFG.Types
...
@@ -15,8 +15,8 @@ import CFG.Types
spec
::
Spec
spec
::
Spec
spec
=
do
spec
=
do
instrsToCTest
--
instrsToCTest
compileToCTest
--
compileToCTest
compileToCAllTest
compileToCAllTest
externDecls
externDecls
...
@@ -26,30 +26,32 @@ example1Input =
...
@@ -26,30 +26,32 @@ example1Input =
,
Label
"Zero"
,
Label
"Zero"
,
Return
,
Return
,
Label
"One"
,
Label
"One"
,
IfThanElse
4
"Two"
"Zero"
,
IfThanElse
"Two"
"Zero"
,
Call
"syscall"
True
,
Call
"syscall"
True
,
Label
"Two"
,
Label
"Two"
,
Goto
"One"
,
Goto
"One"
]
]
example1OutputLines
::
[
Text
]
example1OutputLines
::
Int
-- ^ Decision number used for decision
example1OutputLines
=
->
[
Text
]
example1OutputLines
dec
=
[
"goto Two;"
[
"goto Two;"
,
"Zero:"
,
"Zero:"
,
"return;"
,
"return;"
,
"One:"
,
"One:"
,
"if (_decisionMaker(
4
))"
,
"if (_decisionMaker(
"
<>
T
.
pack
(
show
dec
)
<>
"
))"
,
" goto Two;"
,
" goto Two;"
,
"else"
,
"else"
,
" goto Zero;"
,
" goto Zero;"
,
"_print_os_state(
\"
syscall
\"
, __
LINE
__);"
,
"_print_os_state(
\"
syscall
\"
, __
func
__);"
,
"syscall();"
,
"syscall();"
,
"Two:"
,
"Two:"
,
"goto One;"
,
"goto One;"
]
]
example1Output
::
Text
example1Output
::
Int
-- ^ Decision number
example1Output
=
T
.
unlines
example1OutputLines
->
Text
example1Output
dec
=
T
.
unlines
(
example1OutputLines
dec
)
example1Function
::
Function
[
Instr
]
example1Function
::
Function
[
Instr
]
example1Function
=
Function
example1Function
=
Function
...
@@ -61,75 +63,75 @@ example1Function = Function
...
@@ -61,75 +63,75 @@ example1Function = Function
,
funAnnotation
=
example1Input
,
funAnnotation
=
example1Input
}
}
example1FunctionC
::
Text
example1FunctionC
::
Int
->
Text
example1FunctionC
=
example1FunctionC
dec
=
"void foo() {
\n
"
"void foo() {
\n
"
<>
T
.
unlines
(
map
(
" "
<>
)
example1OutputLines
)
<>
T
.
unlines
(
map
(
" "
<>
)
(
example1OutputLines
dec
)
)
<>
"}
\n
"
<>
"}
\n
"
example1FunctionCDecl
::
Text
example1FunctionCDecl
::
Text
example1FunctionCDecl
=
"void foo();
\n
"
example1FunctionCDecl
=
"void foo();
\n
"
example1TaskC
::
Text
example1TaskC
::
Int
->
Text
example1TaskC
=
example1TaskC
dec
=
"TASK(foo) {
\n
"
"TASK(foo) {
\n
"
<>
T
.
unlines
(
map
(
" "
<>
)
example1OutputLines
)
<>
T
.
unlines
(
map
(
" "
<>
)
(
example1OutputLines
dec
)
)
<>
"}
\n
"
<>
"}
\n
"
example1TaskCDecl
::
Text
example1TaskCDecl
::
Text
example1TaskCDecl
=
"DeclareTask(foo);
\n
"
example1TaskCDecl
=
"DeclareTask(foo);
\n
"
example1ISRC
::
Text
example1ISRC
::
Int
->
Text
example1ISRC
=
example1ISRC
dec
=
"ISR2(foo) {
\n
"
"ISR2(foo) {
\n
"
<>
T
.
unlines
(
map
(
" "
<>
)
example1OutputLines
)
<>
T
.
unlines
(
map
(
" "
<>
)
(
example1OutputLines
dec
)
)
<>
"}
\n
"
<>
"}
\n
"
example2Function
::
Function
[
Instr
]
example2Function
::
Function
[
Instr
]
example2Function
=
example1Function
{
funName
=
"bar"
}
example2Function
=
example1Function
{
funName
=
"bar"
}
example2FunctionC
::
Text
example2FunctionC
::
Int
->
Text
example2FunctionC
=
example2FunctionC
dec
=
"void bar() {
\n
"
"void bar() {
\n
"
<>
T
.
unlines
(
map
(
" "
<>
)
example1OutputLines
)
<>
T
.
unlines
(
map
(
" "
<>
)
(
example1OutputLines
dec
)
)
<>
"}
\n
"
<>
"}
\n
"
example2FunctionCDecl
::
Text
example2FunctionCDecl
::
Text
example2FunctionCDecl
=
"void bar();
\n
"
example2FunctionCDecl
=
"void bar();
\n
"
example2TaskC
::
Text
example2TaskC
::
Int
->
Text
example2TaskC
=
example2TaskC
dec
=
"TASK(bar) {
\n
"
"TASK(bar) {
\n
"
<>
T
.
unlines
(
map
(
" "
<>
)
example1OutputLines
)
<>
T
.
unlines
(
map
(
" "
<>
)
(
example1OutputLines
dec
)
)
<>
"}
\n
"
<>
"}
\n
"
example2TaskCDecl
::
Text
example2TaskCDecl
::
Text
example2TaskCDecl
=
"DeclareTask(bar);
\n
"
example2TaskCDecl
=
"DeclareTask(bar);
\n
"
example2ISRC
::
Text
example2ISRC
::
Int
->
Text
example2ISRC
=
example2ISRC
dec
=
"ISR2(bar) {
\n
"
"ISR2(bar) {
\n
"
<>
T
.
unlines
(
map
(
" "
<>
)
example1OutputLines
)
<>
T
.
unlines
(
map
(
" "
<>
)
(
example1OutputLines
dec
)
)
<>
"}
\n
"
<>
"}
\n
"
exampleExternDecls
::
Text
exampleExternDecls
::
Text
exampleExternDecls
=
"extern
\"
C
\"
{
\n
extern void syscall();
\n
}"
exampleExternDecls
=
"extern
\"
C
\"
{
\n
extern void syscall();
\n
}"
instrsToCTest
::
Spec
--
instrsToCTest :: Spec
instrsToCTest
=
describe
"instrsToC"
$
--
instrsToCTest = describe "instrsToC" $
it
"works for a given example"
$
--
it "works for a given example" $
instrsToC
example1Input
`
shouldBe
`
example1Output
--
instrsToC
Nothing KindFunction
example1Input `shouldBe` example1Output
compileToCTest
::
Spec
--
compileToCTest :: Spec
compileToCTest
=
describe
"compileToC"
$
do
--
compileToCTest = describe "compileToC" $ do
it
"works with a function"
$
--
it "works with a function" $
compileToC
example1Function
`
shouldBe
`
example1FunctionC
--
compileToC example1Function `shouldBe` example1FunctionC
it
"works with a task"
$
--
it "works with a task" $
compileToC
example1Function
{
funKind
=
KindSubtask
}
`
shouldBe
`
example1TaskC
--
compileToC example1Function { funKind = KindSubtask } `shouldBe` example1TaskC
it
"works with an isr"
$
--
it "works with an isr" $
compileToC
example1Function
{
funKind
=
KindISR
}
`
shouldBe
`
example1ISRC
--
compileToC example1Function { funKind = KindISR } `shouldBe` example1ISRC
include
::
Text
include
::
Text
include
=
"#include <mockup_prelude.cc>"
include
=
"#include <mockup_prelude.cc>"
...
@@ -137,7 +139,7 @@ include = "#include <mockup_prelude.cc>"
...
@@ -137,7 +139,7 @@ include = "#include <mockup_prelude.cc>"
emptyIdleHook
::
Text
emptyIdleHook
::
Text
emptyIdleHook
=
[
here
|
emptyIdleHook
=
[
here
|
void PreIdleHook() {
void PreIdleHook() {
_print_os_state("PreIdleHook", __
LINE
__);
_print_os_state("PreIdleHook", __
func
__);
ShutdownMachine();
ShutdownMachine();
}
}
|]
|]
...
@@ -148,8 +150,8 @@ compileToCAllTest = describe "compileToCAll" $ do
...
@@ -148,8 +150,8 @@ compileToCAllTest = describe "compileToCAll" $ do
compileToCAll
Nothing
[
example1Function
,
example2Function
]
compileToCAll
Nothing
[
example1Function
,
example2Function
]
`
shouldBe
`
(
include
<>
"
\n\n
"
<>
exampleExternDecls
<>
"
\n
"
`
shouldBe
`
(
include
<>
"
\n\n
"
<>
exampleExternDecls
<>
"
\n
"
<>
example1FunctionCDecl
<>
example2FunctionCDecl
<>
"
\n
"
<>
example1FunctionCDecl
<>
example2FunctionCDecl
<>
"
\n
"
<>
example1FunctionC
<>
"
\n
"
<>
example1FunctionC
0
<>
"
\n
"
<>
example2FunctionC
<>
"
\n
"
<>
example2FunctionC
1
<>
"
\n
"
<>
emptyIdleHook
<>
"
\n
"
<>
emptyIdleHook
<>
"
\n
"
)
)
...
@@ -159,8 +161,8 @@ compileToCAllTest = describe "compileToCAll" $ do
...
@@ -159,8 +161,8 @@ compileToCAllTest = describe "compileToCAll" $ do
]
]
`
shouldBe
`
(
include
<>
"
\n\n
"
<>
exampleExternDecls
<>
"
\n
"
`
shouldBe
`
(
include
<>
"
\n\n
"
<>
exampleExternDecls
<>
"
\n
"
<>
example1TaskCDecl
<>
example2TaskCDecl
<>
"
\n
"
<>
example1TaskCDecl
<>
example2TaskCDecl
<>
"
\n
"
<>
example1TaskC
<>
"
\n
"
<>
example1TaskC
0
<>
"
\n
"
<>
example2TaskC
<>
"
\n
"
<>
example2TaskC
1
<>
"
\n
"
<>
emptyIdleHook
<>
"
\n
"
<>
emptyIdleHook
<>
"
\n
"
)
)
...
@@ -170,8 +172,8 @@ compileToCAllTest = describe "compileToCAll" $ do
...
@@ -170,8 +172,8 @@ compileToCAllTest = describe "compileToCAll" $ do
]
]
`
shouldBe
`
(
include
<>
"
\n\n
"
<>
exampleExternDecls
<>
"
\n
"
`
shouldBe
`
(
include
<>
"
\n\n
"
<>
exampleExternDecls
<>
"
\n
"
<>
example1TaskCDecl
<>
example2FunctionCDecl
<>
"
\n
"
<>
example1TaskCDecl
<>
example2FunctionCDecl
<>
"
\n
"
<>
example1TaskC
<>
"
\n
"
<>
example1TaskC
0
<>
"
\n
"
<>
example2FunctionC
<>
"
\n
"
<>
example2FunctionC
1
<>
"
\n
"
<>
emptyIdleHook
<>
"
\n
"
<>
emptyIdleHook
<>
"
\n
"
)
)
...
@@ -181,8 +183,8 @@ compileToCAllTest = describe "compileToCAll" $ do
...
@@ -181,8 +183,8 @@ compileToCAllTest = describe "compileToCAll" $ do
]
]
`
shouldBe
`
(
include
<>
"
\n\n
"
<>
exampleExternDecls
<>
"
\n
"
`
shouldBe
`
(
include
<>
"
\n\n
"
<>
exampleExternDecls
<>
"
\n
"
<>
example1TaskCDecl
<>
"
\n
"
<>
example1TaskCDecl
<>
"
\n
"
<>
example1TaskC
<>
"
\n
"
<>
example1TaskC
0
<>
"
\n
"
<>
example2ISRC
<>
"
\n
"
<>
example2ISRC
1
<>
"
\n
"
<>
emptyIdleHook
<>
"
\n
"
<>
emptyIdleHook
<>
"
\n
"
)
)
...
...
This diff is collapsed.
Click to expand it.
test/CFG/IRSpec.hs
+
2
−
15
View file @
c32d0e45
...
@@ -17,7 +17,6 @@ import CFG.Types
...
@@ -17,7 +17,6 @@ import CFG.Types
spec
::
Spec
spec
::
Spec
spec
=
do
spec
=
do
example1
example1
example2
example1Input
::
Function
()
example1Input
::
Function
()
example1Input
=
Function
example1Input
=
Function
...
@@ -44,7 +43,7 @@ example1Output cfg = map snd $
...
@@ -44,7 +43,7 @@ example1Output cfg = map snd $
,
(
vert
"Zero"
,
Return
)
,
(
vert
"Zero"
,
Return
)
,
(
vert
"One"
,
Label
"One"
)
,
(
vert
"One"
,
Label
"One"
)
,
(
vert
"One"
,
Call
"foo"
False
)
,
(
vert
"One"
,
Call
"foo"
False
)
,
(
vert
"One"
,
IfThanElse
0
"Two"
"Zero"
)
,
(
vert
"One"
,
IfThanElse
"Two"
"Zero"
)
,
(
vert
"Two"
,
Label
"Two"
)
,
(
vert
"Two"
,
Label
"Two"
)
,
(
vert
"Two"
,
Call
"bar"
True
)
,
(
vert
"Two"
,
Call
"bar"
True
)
,
(
vert
"Two"
,
Goto
"One"
)
,
(
vert
"Two"
,
Goto
"One"
)
...
@@ -64,7 +63,7 @@ example2Output cfg = map snd $
...
@@ -64,7 +63,7 @@ example2Output cfg = map snd $
,
(
vert
"Zero"
,
Return
)
,
(
vert
"Zero"
,
Return
)
,
(
vert
"One"
,
Label
"One"
)
,
(
vert
"One"
,
Label
"One"
)
,
(
vert
"One"
,
Call
"foo"
False
)
,
(
vert
"One"
,
Call
"foo"
False
)
,
(
vert
"One"
,
IfThanElse
1
"Two"
"Zero"
)
,
(
vert
"One"
,
IfThanElse
"Two"
"Zero"
)
,
(
vert
"Two"
,
Label
"Two"
)
,
(
vert
"Two"
,
Label
"Two"
)
,
(
vert
"Two"
,
Call
"bar"
True
)
,
(
vert
"Two"
,
Call
"bar"
True
)
,
(
vert
"Two"
,
Goto
"One"
)
,
(
vert
"Two"
,
Goto
"One"
)
...
@@ -78,15 +77,3 @@ example1 = describe "flattenCFG" $ do
...
@@ -78,15 +77,3 @@ example1 = describe "flattenCFG" $ do
let
fun
=
extend
graphify
example1Input
let
fun
=
extend
graphify
example1Input
it
"works with an example"
$
it
"works with an example"
$
flattenCFG
fun
`
shouldBe
`
example1Output
(
extract
fun
)
flattenCFG
fun
`
shouldBe
`
example1Output
(
extract
fun
)
example2
::
Spec
example2
=
describe
"compileToIRAll"
$
do
let
fun
=
extend
graphify
example1Input
it
"assigns unique decision numbers"
$
do
let
output
=
compileToIRAll
[
fun
,
fun
]
instrs
=
map
(
snd
.
funAnnotation
)
output
decisionNumbers
=
sort
$
concatMap
(
mapMaybe
getDecNum
)
instrs
decisionNumbers
`
shouldBe
`
[
0
,
1
]
where
getDecNum
(
IfThanElse
dec
_
_
)
=
Just
dec
getDecNum
_
=
Nothing
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment