summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-12-12 00:45:16 +0100
committerCarl Hetherington <cth@carlh.net>2020-01-08 21:56:47 +0100
commit23590dc430e4ef2351209e30a26ba04fecca2872 (patch)
treecc303d8c74e64fff8eb5a663941cac4455154ae9
parentb1589146e73ad97d3f29e9d5cafe61e5424796a4 (diff)
First version of player stress-test management script.
-rwxr-xr-xsrc/tools/stress57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/tools/stress b/src/tools/stress
new file mode 100755
index 000000000..f861753e6
--- /dev/null
+++ b/src/tools/stress
@@ -0,0 +1,57 @@
+#!/usr/bin/python3.7
+
+import argparse
+import subprocess
+import sys
+import random
+
+def hms_to_seconds(h):
+ s = h.split(':')
+ assert(1 <= len(s) and len(s) <= 3)
+ if len(s) == 1:
+ return int(h)
+ elif len(s) == 2:
+ return int(s[0]) * 60 + int(s[1])
+ elif len(s) == 3:
+ return ((int(s[0]) * 60 + int(s[1])) * 60) + int(s[2])
+
+def seek(dcp_seconds):
+ print("O %s" % args.dcp)
+ print("P")
+ test_seconds = hms_to_seconds(args.length)
+ while test_seconds > 0:
+ wait = random.randint(500, dcp_seconds * 1000)
+ # Wait some milliseconds
+ print("W %d" % wait)
+ # Seek
+ print("S %d" % random.randint(0, 4095))
+ # Make sure we're stil playing
+ print("P")
+ test_seconds -= wait / 1000
+
+def repeat(dcp_seconds):
+ print("O %s" % args.dcp)
+ test_seconds = hms_to_seconds(args.length)
+ while test_seconds > 0:
+ print("P")
+ print("W %d" % (dcp_seconds * 1000))
+ test_seconds -= dcp_seconds
+
+parser = argparse.ArgumentParser()
+parser.add_argument('-d', '--dcp', help='DCP to make a script for', required=True)
+parser.add_argument('-t', '--type', help='script type: seek - seek a lot, repeat - play back DCP over and over', required=True)
+parser.add_argument('-l', '--length', help='approximate test length in H:M:S', required=True)
+args = parser.parse_args()
+
+for l in subprocess.run(['dcpinfo', args.dcp], capture_output=True).stdout.splitlines():
+ if l.startswith(b'Total:'):
+ b = l.split(b':')
+ dcp_seconds = (int(b[1]) * 60 + int(b[2])) * 60 + int(b[3])
+if args.type == 'seek':
+ seek(dcp_seconds)
+elif args.type == 'repeat':
+ repeat(dcp_seconds)
+else:
+ print('Unknown type %s' % args.type, file=sys.stderr)
+ sys.exit(1)
+