Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
tapasco
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
52
Issues
52
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tapasco
tapasco
Commits
e3f219c0
Commit
e3f219c0
authored
May 17, 2019
by
Lukas Sommer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parse port information from report file written during evaluation;
parent
0464ed0b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
3 deletions
+65
-3
report-examples/correct-port.rpt
report-examples/correct-port.rpt
+3
-0
src/main/scala/tapasco/reports/PortReport.scala
src/main/scala/tapasco/reports/PortReport.scala
+34
-3
src/test/scala/tapasco/reports/PortReportSpec.scala
src/test/scala/tapasco/reports/PortReportSpec.scala
+28
-0
No files found.
report-examples/correct-port.rpt
0 → 100644
View file @
e3f219c0
AXI_MASTER_PORTS 42
AXI_SLAVE_PORTS 25
src/main/scala/tapasco/reports/PortReport.scala
View file @
e3f219c0
...
...
@@ -2,11 +2,42 @@ package de.tu_darmstadt.cs.esa.tapasco.reports
import
java.nio.file.Path
final
case
class
PortReport
(
override
val
file
:
Path
,
numSlaves
:
Int
)
extends
Report
(
file
)
import
de.tu_darmstadt.cs.esa.tapasco.util.SequenceMatcher
import
scala.io.Source
final
case
class
PortReport
(
override
val
file
:
Path
,
numMasters
:
Int
,
numSlaves
:
Int
)
extends
Report
(
file
)
object
PortReport
{
private
[
this
]
val
logger
=
de
.
tu_darmstadt
.
cs
.
esa
.
tapasco
.
Logging
.
logger
(
this
.
getClass
)
def
apply
(
pr
:
Path
)
:
Option
[
PortReport
]
=
extract
(
pr
)
private
def
masterPortMatcher
:
SequenceMatcher
[
Int
]
=
new
SequenceMatcher
[
Int
](
"""AXI_MASTER_PORTS\s+(\d+)"""
.
r
)(
true
,
ms
=>
ms
.
head
.
group
(
1
).
toInt
)
private
def
slavePortMatcher
:
SequenceMatcher
[
Int
]
=
new
SequenceMatcher
[
Int
](
"""AXI_SLAVE_PORTS\s+(\d+)"""
.
r
)(
true
,
ms
=>
ms
.
head
.
group
(
1
).
toInt
)
def
apply
(
pr
:
Path
)
:
Option
[
PortReport
]
=
Some
(
PortReport
(
pr
,
42
))
// TODO Actually parse report after it was filled by the TCL script.
private
def
extract
(
pr
:
Path
)
:
Option
[
PortReport
]
=
try
{
val
numMasters
=
masterPortMatcher
val
numSlaves
=
slavePortMatcher
val
source
=
Source
.
fromFile
(
pr
.
toString
)
source
.
getLines
foreach
{
line
=>
numMasters
.
update
(
line
)
numSlaves
.
update
(
line
)
}
if
(
numMasters
.
matched
&&
numSlaves
.
matched
){
Some
(
PortReport
(
pr
,
numMasters
.
result
.
get
,
numSlaves
.
result
.
get
))
}
else
{
None
}
}
catch
{
case
e
:
Exception
=>
logger
.
warn
(
"Could not extract port information from %s: %s"
.
format
(
pr
,
e
))
None
}
}
src/test/scala/tapasco/reports/PortReportSpec.scala
0 → 100644
View file @
e3f219c0
package
de.tu_darmstadt.cs.esa.tapasco.reports
import
java.nio.file.Paths
import
org.scalatest.
{
FlatSpec
,
Matchers
}
class
PortReportSpec
extends
FlatSpec
with
Matchers
{
val
reportPath
=
Paths
.
get
(
"report-examples"
).
toAbsolutePath
"A missing PortReport file"
should
"result in None"
in
{
PortReport
(
reportPath
.
resolve
(
"missing.rpt"
))
shouldBe
empty
}
"An invalid PortReport file"
should
"result in None"
in
{
PortReport
(
reportPath
.
resolve
(
"correct-timing.rpt"
))
shouldBe
empty
}
"A correct PortReport file"
should
"be parsed to Some(PortReport)"
in
{
PortReport
(
reportPath
.
resolve
(
"correct-port.rpt"
))
should
not
be
empty
}
"A correct PortReport file"
should
"be parsed correctly"
in
{
val
pr
=
PortReport
(
reportPath
.
resolve
(
"correct-port.rpt"
))
pr
should
not
be
empty
pr
.
get
.
numMasters
shouldBe
42
pr
.
get
.
numSlaves
shouldBe
25
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment