summaryrefslogtreecommitdiff
path: root/tests/automated/run_continuous.py
blob: a304f4d57b9da2c34864a00e0a5c9da57b6ea264 (plain)
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
#!/usr/bin/python
import os
import sys
import time
import datetime
import ccdash

GROUP = "Continuous"
INTERVAL = 60

if __name__ == "__main__":
	if len(sys.argv)<=1 or sys.argv[1]=="-h" or sys.argv[1]=="--h" or sys.argv[1]=="/h":
		print "Usage: run_continuous.py scenario1.xml [scenario2.xml ...]"
		sys.exit(0)

	# Splice list
	scenarios = sys.argv[1:]

	# Check if scenario exists
	for scenario in scenarios:
		if not os.path.exists(scenario):
			print "Error: file " + scenario + " does not exist"
			sys.exit(1)

	# Loop foreva
	while True:
		argv = []

		# Anything changed recently?
		argv.append("ccdash.py")
		argv.append("status")
		argv.append("-w")
		argv.append("../..")
		rc = ccdash.main(argv)

		if rc==0:
			# Nothing changed
			print str(datetime.datetime.now()) + ": No update, will check again in " + str(INTERVAL) + "s.."
			time.sleep(INTERVAL)
			continue
			
		# Run each scenario
		for scenario in scenarios:
			argv = []
			argv.append("ccdash.py")
			argv.append("scenario")
			argv.append(scenario)
			argv.append("--group")
			argv.append(GROUP)
			thisrc = ccdash.main(argv)
			if rc==0 and thisrc:
				rc = thisrc

		# Sleep even if something does change
		time.sleep(INTERVAL)