Skip to content

Commit f408738

Browse files
committed
Handling end of continous burst mode properly with a SIGTERM signal
1 parent 8ff988b commit f408738

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

trex-container-app/app/scripts/run-trex

+12-4
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,18 @@ class STLS1_Wrapper(object):
113113
def signal_handler(self, sig, frame):
114114
log.info('You pressed Ctrl+C!')
115115
trexstats.force_exit = True
116-
self.client.reset(ports = self.ports)
117-
self.force_exit = True
118-
clog.force_exit = True
119-
116+
try:
117+
if self.duration == -1:
118+
stats = self.client.get_stats()
119+
warnings = self.client.get_warnings()
120+
passed = trexstats.completed_stats(stats, warnings, self.port_a, self.port_b, self.profile, self.rate, self.duration)
121+
except STLError as e:
122+
passed = False
123+
log.info(e)
124+
finally:
125+
self.client.reset(ports = self.ports)
126+
self.force_exit = True
127+
clog.force_exit = True
120128

121129
def main():
122130
# run the tests

trex-container-app/app/scripts/run-trex-direct

+12-3
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,18 @@ class STLS1(object):
204204
def signal_handler(self, sig, frame):
205205
log.info('You pressed Ctrl+C!')
206206
time.sleep(6)
207-
self.force_exit = True
208-
clog.force_exit = True
209-
sys.exit(0)
207+
try:
208+
if self.duration == -1:
209+
stats = self.client.get_stats()
210+
warnings = self.client.get_warnings()
211+
passed = trexstats.completed_stats(stats, warnings, self.port_a, self.port_b, self.profile, self.rate, self.duration)
212+
except STLError as e:
213+
passed = False
214+
log.info(e)
215+
finally:
216+
self.force_exit = True
217+
clog.force_exit = True
218+
sys.exit(0)
210219

211220

212221
def main():

0 commit comments

Comments
 (0)