blob: b66b34fe12ea3ecc2a81a6cc8ad161256207e7bc [file] [log] [blame]
#!/usr/bin/env python
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This script verifies if the parameter is a valid autotest state file and able
# to continue running factory main controller/UI.
# Returns shell failure (exit(1)) for that case.
import sys
import pickle
def check_state(state_file):
with open(state_file, "rb") as state_handle:
state = pickle.load(state_handle)
# A typical state should be:
# {'client': {'_record_indent': 2, 'steps': [([], 'step_init', [], {})],
# 'unexpected_reboot': ('factory_Dummy.e_0', 'factory_Dummy.e_0')}}
# And the factory needs 'step_init' in client.steps.
for record in state['client']['steps']:
if 'step_init' in record:
return True
return False
def main(argv):
for state_file in argv[1:]:
try:
if check_state(state_file):
continue
raise Exception('Unknown format')
except:
sys.stderr.write("Invalid state file: %s\n" % state_file)
exit(1)
if __name__ == '__main__':
main(sys.argv)