2023-06-22 00:06:53 +01:00
|
|
|
#!/usr/bin/env python3
|
2016-04-28 17:46:00 +03:00
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
|
|
|
actions = set(['pre-dump', 'pre-restore', 'post-dump', 'setup-namespaces', \
|
2019-09-07 15:46:22 +03:00
|
|
|
'post-setup-namespaces', 'post-restore', 'post-resume', \
|
|
|
|
'network-lock', 'network-unlock' ])
|
2016-04-28 17:46:00 +03:00
|
|
|
errors = []
|
|
|
|
af = os.path.dirname(os.path.abspath(__file__)) + '/actions_called.txt'
|
|
|
|
|
|
|
|
for act in open(af):
|
2019-09-07 15:46:22 +03:00
|
|
|
act = act.strip().split()
|
|
|
|
act.append('EMPTY')
|
|
|
|
act.append('EMPTY')
|
2016-04-28 17:46:00 +03:00
|
|
|
|
2019-09-07 15:46:22 +03:00
|
|
|
if act[0] == 'EMPTY':
|
|
|
|
raise Exception("Error in test, bogus actions line")
|
2016-04-28 17:46:00 +03:00
|
|
|
|
2019-09-07 15:46:22 +03:00
|
|
|
if act[1] == 'EMPTY':
|
|
|
|
errors.append('Action %s misses CRTOOLS_IMAGE_DIR' % act[0])
|
2016-04-28 17:46:00 +03:00
|
|
|
|
2019-09-07 15:46:22 +03:00
|
|
|
if act[0] in ('post-dump', 'setup-namespaces', 'post-setup-namespaces', \
|
|
|
|
'post-restore', 'post-resume', 'network-lock', 'network-unlock'):
|
|
|
|
if act[2] == 'EMPTY':
|
|
|
|
errors.append('Action %s misses CRTOOLS_INIT_PID' % act[0])
|
|
|
|
elif not act[2].isdigit() or int(act[2]) == 0:
|
|
|
|
errors.append('Action %s PID is not number (%s)' %
|
|
|
|
(act[0], act[2]))
|
2016-04-28 17:46:00 +03:00
|
|
|
|
2019-09-07 15:46:22 +03:00
|
|
|
actions -= set([act[0]])
|
2016-04-28 17:46:00 +03:00
|
|
|
|
|
|
|
if actions:
|
2019-09-07 15:46:22 +03:00
|
|
|
errors.append('Not all actions called: %r' % actions)
|
2016-04-28 17:46:00 +03:00
|
|
|
|
|
|
|
if errors:
|
2019-09-07 15:46:22 +03:00
|
|
|
for x in errors:
|
|
|
|
print(x)
|
|
|
|
sys.exit(1)
|
2016-04-28 17:46:00 +03:00
|
|
|
|
2018-09-23 15:31:52 +01:00
|
|
|
print('PASS')
|