summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Williams <neil.williams@linaro.org>2016-09-20 10:05:56 +0100
committerNeil Williams <neil.williams@linaro.org>2016-09-20 10:05:56 +0100
commitf8f3de2f0cbc252fc9adfb1b21a7ea681f53e624 (patch)
tree2fd84c764be2bb7566a3f1af2e0db46034af5359
parent7425968d1628a56aae325c4adc319e5b50b74011 (diff)
add a script to validate V2 device configuration
Change-Id: Ie28a168c6591bb241982a6b68d5bbfb54082129e
-rw-r--r--unit-tests/lava/valid-device.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/unit-tests/lava/valid-device.py b/unit-tests/lava/valid-device.py
new file mode 100644
index 0000000..3984509
--- /dev/null
+++ b/unit-tests/lava/valid-device.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# valid-device.py
+#
+# Copyright 2016 Neil Williams <codehelp@debian.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+#
+#
+
+import yaml
+import argparse
+import xmlrpclib
+import subprocess
+
+
+def testcase(hostname, result):
+ subprocess.Popen(["lava-test-case", "%s-validity" % hostname, "--result", result])
+ return 0
+
+
+def main():
+ parser = argparse.ArgumentParser(description='lava test case device helper')
+ parser.add_argument(
+ '--instance', type=str, required=True,
+ help='Name of the instance to check')
+ parser.add_argument(
+ '--hostname', default=None, type=str,
+ help='Device to check (all pipeline devices if not used)')
+ args = parser.parse_args()
+
+ connection = xmlrpclib.ServerProxy("http://%s//RPC2" % args.instance)
+ if args.hostname:
+ data = connection.scheduler.validate_pipeline_devices(args.hostname)
+ else:
+ data = connection.scheduler.validate_pipeline_devices()
+ devices = data.data.split('\n')
+ for device in devices:
+ if not device:
+ continue
+ key = device.split(':')[0]
+ print("Checked %s: %s" % (key, device))
+ if 'Valid' in device:
+ testcase(key, 'pass')
+ else:
+ testcase(key, 'fail')
+ print(device)
+
+if __name__ == '__main__':
+ main()
+ main()