summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmeta/lib/oeqa/runexported.py36
1 files changed, 17 insertions, 19 deletions
diff --git a/meta/lib/oeqa/runexported.py b/meta/lib/oeqa/runexported.py
index 0daedd057e..dba0d7aec1 100755
--- a/meta/lib/oeqa/runexported.py
+++ b/meta/lib/oeqa/runexported.py
@@ -21,7 +21,7 @@
21import sys 21import sys
22import os 22import os
23import time 23import time
24from optparse import OptionParser 24import argparse
25 25
26try: 26try:
27 import simplejson as json 27 import simplejson as json
@@ -76,40 +76,38 @@ class TestContext(object):
76 76
77def main(): 77def main():
78 78
79 usage = "usage: %prog [options] <json file>" 79 parser = argparse.ArgumentParser()
80 parser = OptionParser(usage=usage) 80 parser.add_argument("-t", "--target-ip", dest="ip", help="The IP address of the target machine. Use this to \
81 parser.add_option("-t", "--target-ip", dest="ip", help="The IP address of the target machine. Use this to \
82 overwrite the value determined from TEST_TARGET_IP at build time") 81 overwrite the value determined from TEST_TARGET_IP at build time")
83 parser.add_option("-s", "--server-ip", dest="server_ip", help="The IP address of this machine. Use this to \ 82 parser.add_argument("-s", "--server-ip", dest="server_ip", help="The IP address of this machine. Use this to \
84 overwrite the value determined from TEST_SERVER_IP at build time.") 83 overwrite the value determined from TEST_SERVER_IP at build time.")
85 parser.add_option("-d", "--deploy-dir", dest="deploy_dir", help="Full path to the package feeds, that this \ 84 parser.add_argument("-d", "--deploy-dir", dest="deploy_dir", help="Full path to the package feeds, that this \
86 the contents of what used to be DEPLOY_DIR on the build machine. If not specified it will use the value \ 85 the contents of what used to be DEPLOY_DIR on the build machine. If not specified it will use the value \
87 specified in the json if that directory actually exists or it will error out.") 86 specified in the json if that directory actually exists or it will error out.")
88 parser.add_option("-l", "--log-dir", dest="log_dir", help="This sets the path for TEST_LOG_DIR. If not specified \ 87 parser.add_argument("-l", "--log-dir", dest="log_dir", help="This sets the path for TEST_LOG_DIR. If not specified \
89 the current dir is used. This is used for usually creating a ssh log file and a scp test file.") 88 the current dir is used. This is used for usually creating a ssh log file and a scp test file.")
89 parser.add_argument("json", help="The json file exported by the build system", default="testdata.json", nargs='?')
90 90
91 (options, args) = parser.parse_args() 91 args = parser.parse_args()
92 if len(args) != 1:
93 parser.error("Incorrect number of arguments. The one and only argument should be a json file exported by the build system")
94 92
95 with open(args[0], "r") as f: 93 with open(args.json, "r") as f:
96 loaded = json.load(f) 94 loaded = json.load(f)
97 95
98 if options.ip: 96 if args.ip:
99 loaded["target"]["ip"] = options.ip 97 loaded["target"]["ip"] = args.ip
100 if options.server_ip: 98 if args.server_ip:
101 loaded["target"]["server_ip"] = options.server_ip 99 loaded["target"]["server_ip"] = args.server_ip
102 100
103 d = MyDataDict() 101 d = MyDataDict()
104 for key in loaded["d"].keys(): 102 for key in loaded["d"].keys():
105 d[key] = loaded["d"][key] 103 d[key] = loaded["d"][key]
106 104
107 if options.log_dir: 105 if args.log_dir:
108 d["TEST_LOG_DIR"] = options.log_dir 106 d["TEST_LOG_DIR"] = args.log_dir
109 else: 107 else:
110 d["TEST_LOG_DIR"] = os.path.abspath(os.path.dirname(__file__)) 108 d["TEST_LOG_DIR"] = os.path.abspath(os.path.dirname(__file__))
111 if options.deploy_dir: 109 if args.deploy_dir:
112 d["DEPLOY_DIR"] = options.deploy_dir 110 d["DEPLOY_DIR"] = args.deploy_dir
113 else: 111 else:
114 if not os.path.isdir(d["DEPLOY_DIR"]): 112 if not os.path.isdir(d["DEPLOY_DIR"]):
115 print("WARNING: The path to DEPLOY_DIR does not exist: %s" % d["DEPLOY_DIR"]) 113 print("WARNING: The path to DEPLOY_DIR does not exist: %s" % d["DEPLOY_DIR"])