-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautotest.py
201 lines (174 loc) · 6.49 KB
/
autotest.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# Copyright (C) 2017-2022 Battelle Memorial Institute
# file: autotest.py
"""Runs the set of TESP test cases, excluding the longer FNCS cases
MATPOWER/MOST example must be run after manual installation of Octave and MATPOWER
"""
import os
import sys
import stat
import shutil
import subprocess
from tesp_support.run_test_case import RunTestCase
from tesp_support.run_test_case import InitializeTestCaseReports
from tesp_support.run_test_case import GetTestCaseReports
if sys.platform == 'win32':
pycall = 'python'
else:
pycall = 'python3'
def loadshed_test():
# FNCS loadshed examples
print('== Prepare: loadshed examples', flush=True)
if bTryHELICS:
os.chdir('./examples/capabilities/loadshed')
p1 = subprocess.Popen('./clean.sh', shell=True)
p1.wait()
RunTestCase('runhpy.sh', 'Loadshed HELICS ns-3')
RunTestCase('runhpy0.sh', 'Loadshed HELICS Python')
RunTestCase('runhjava.sh', 'Loadshed HELICS Java')
else:
os.chdir('./examples/capabilities/loadshedf')
p1 = subprocess.Popen('./clean.sh', shell=True)
p1.wait()
RunTestCase('run.sh', 'Loadshed FNCS Python')
RunTestCase('runjava.sh', 'Loadshed FNCS Java')
os.chdir(basePath)
def weatherAgent_test():
# weatherAgent example
print('== Prepare: weatherAgent examples', flush=True)
os.chdir('./examples/capabilities/weatherAgent')
p1 = subprocess.Popen('./clean.sh', shell=True)
p1.wait()
if bTryHELICS:
RunTestCase('runh.sh', 'Weather Agent HELICS')
else:
RunTestCase('run.sh', 'Weather Agent FNCS')
os.chdir(basePath)
def PYPOWER_test():
# PYPOWER example
print('== Prepare: PYPOWER examples', flush=True)
os.chdir('./examples/capabilities/pypower')
p1 = subprocess.Popen('./clean.sh', shell=True)
p1.wait()
if bTryHELICS:
RunTestCase('runhpp.sh', 'PYPOWER HELICS')
else:
RunTestCase('runpp.sh', 'PYPOWER FNCS')
os.chdir(basePath)
def EnergyPlus_test():
# EnergyPlus examples
print('== Prepare: EnergyPlus examples', flush=True)
os.chdir('./examples/capabilities/energyplus')
p1 = subprocess.Popen('./clean.sh', shell=True)
p1.wait()
# p1 = subprocess.Popen ('./run_baselines.sh', shell=True)
# p1.wait()
# p1 = subprocess.Popen ('./make_all_ems.sh', shell=True)
# p1.wait()
if bTryHELICS:
RunTestCase('runh.sh', 'EnergyPlus HELICS EMS')
# RunTestCase ('batch_ems_case.sh', 'EnergyPlus Batch EMS')
else:
RunTestCase('run.sh', 'EnergyPlus FNCS IDF')
RunTestCase('run2.sh', 'EnergyPlus FNCS EMS')
os.chdir(basePath)
def TE30_test():
# TE30 example
print('== Prepare: TE30 examples', flush=True)
os.chdir('./examples/capabilities/te30')
p1 = subprocess.Popen('./clean.sh', shell=True)
p1.wait()
p1 = subprocess.Popen(pycall + ' prepare_case.py', shell=True)
p1.wait()
if bTryHELICS:
RunTestCase('runh.sh', 'TE30 HELICS Market')
RunTestCase('runh0.sh', 'TE30 HELICS No Market')
else:
RunTestCase('run.sh', 'TE30 FNCS Market')
RunTestCase('run0.sh', 'TE30 FNCS No Market')
os.chdir(basePath)
def make_comm_base_test():
# make_comm_base, next three cases
print('== Prepare: Nocomm_Base examples', flush=True)
os.chdir('./examples/capabilities/comm')
p1 = subprocess.Popen(pycall + ' make_comm_base.py', shell=True)
p1.wait()
# generated Nocomm_Base example
os.chdir('Nocomm_Base')
if bTryHELICS:
st = os.stat('runh.sh')
os.chmod('runh.sh', st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
RunTestCase('runh.sh', 'Nocomm Base HELICS')
else:
st = os.stat('run.sh')
os.chmod('run.sh', st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
RunTestCase('run.sh', 'Nocomm Base FNCS')
os.chdir(basePath)
# generated Eplus_Restaurant example
os.chdir('./examples/capabilities/comm/Eplus_Restaurant')
if bTryHELICS:
st = os.stat('runh.sh')
os.chmod('runh.sh', st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
RunTestCase('runh.sh', 'Eplus Restaurant HELICS')
else:
st = os.stat('run.sh')
os.chmod('run.sh', st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
RunTestCase('run.sh', 'Eplus Restaurant FNCS')
os.chdir(basePath)
# generated SGIP1c example
os.chdir('./examples/capabilities/comm/SGIP1c')
if bTryHELICS:
st = os.stat('runh.sh')
os.chmod('runh.sh', st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
RunTestCase('runh.sh', 'SGIP1c HELICS')
else:
st = os.stat('run.sh')
os.chmod('run.sh', st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
RunTestCase('run.sh', 'SGIP1c FNCS')
os.chdir(basePath)
def make_comm_eplus_test():
# make_comm_eplus
# generated Nocomm_Base example
print('== Prepare: Eplus with comm example', flush=True)
os.chdir('./examples/capabilities/comm')
p1 = subprocess.Popen(pycall + ' make_comm_eplus.py', shell=True)
p1.wait()
os.chdir('Eplus_Comm')
st = os.stat('run.sh')
os.chmod('run.sh', st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
RunTestCase('run.sh', 'EPLus comm HELICS')
os.chdir(basePath)
def combine_feeders_test():
# generated CombinedCase example
print('== Prepare: CombinedCase example', flush=True)
os.chdir('./examples/capabilities/comm')
p1 = subprocess.Popen(pycall + ' combine_feeders.py', shell=True)
p1.wait()
shutil.copy('runcombined.sh', 'CombinedCase')
shutil.copy('runcombinedh.sh', 'CombinedCase')
os.chdir('CombinedCase')
if bTryHELICS:
st = os.stat('runcombinedh.sh')
os.chmod('runcombinedh.sh', st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
RunTestCase('runcombinedh.sh', '4 Feeders HELICS')
else:
st = os.stat('runcombined.sh')
os.chmod('runcombined.sh', st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
RunTestCase('runcombined.sh', '4 Feeders FNCS')
os.chdir(basePath)
def block(call):
print('\n<!--', flush=True)
call()
print('--!>', flush=True)
if __name__ == '__main__':
InitializeTestCaseReports()
basePath = os.getcwd()
bTryHELICS = True
block(loadshed_test)
block(weatherAgent_test)
block(PYPOWER_test)
block(EnergyPlus_test)
block(TE30_test)
block(make_comm_base_test)
block(make_comm_eplus_test)
block(combine_feeders_test)
print(GetTestCaseReports())