-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_simulate.py
75 lines (68 loc) · 2.1 KB
/
test_simulate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Copyright (C) 2020 TU Dresden
# Licensed under the ISC license (see LICENSE.txt)
#
# Authors: Christian Menard
import subprocess
def test_tgff_simulate(datadir):
res = subprocess.run(
[
"mocasin",
"simulate",
"platform=generic_bus",
"graph=tgff_reader",
"trace=tgff_reader",
"mapper=default",
"tgff.file=auto-indust-cords.tgff",
"tgff.directory=tgff/e3s-0.9",
],
cwd=datadir,
check=True,
stdout=subprocess.PIPE,
)
found_line = False
stdout = res.stdout.decode()
for line in stdout.split("\n"):
if line.startswith("Total simulated time: "):
time = line[22:]
assert time == "524.0033275 ms"
found_line = True
assert found_line
def test_sdf3_simulate(datadir):
res = subprocess.run(
[
"mocasin",
"simulate",
"platform=odroid",
"graph=sdf3_reader",
"trace=sdf3_reader",
"mapper=static_cfs",
"sdf3.file=sdf3/medium_cyclic.xml",
],
cwd=datadir,
check=True,
stdout=subprocess.PIPE,
)
found_flags = 0x0
stdout = res.stdout.decode()
for line in stdout.split("\n"):
if line.startswith("Total simulated time: "):
value = line[22:]
assert value == "24.898274381 ms"
found_flags |= 0x1
if line.startswith("Total energy consumption: "):
value = line[26:]
assert value == "76.127015440 mJ"
found_flags |= 0x2
if line.startswith(" --- static energy: "):
value = line[26:]
assert value == "54.370361766 mJ"
found_flags |= 0x4
if line.startswith(" --- dynamic energy: "):
value = line[26:]
assert value == "21.756653674 mJ"
found_flags |= 0x8
if line.startswith("Average power: "):
value = line[15:]
assert value == "3.057522 W"
found_flags |= 0x10
assert found_flags == 0x1F