def main():

    parser = argparse.ArgumentParser()
    parser.add_argument("-t", "--target-ip", dest="ip", help="The IP address of the target machine. Use this to \
            overwrite the value determined from TEST_TARGET_IP at build time")
    parser.add_argument("-s", "--server-ip", dest="server_ip", help="The IP address of this machine. Use this to \
            overwrite the value determined from TEST_SERVER_IP at build time.")
    parser.add_argument("-d", "--deploy-dir", dest="deploy_dir", help="Full path to the package feeds, that this \
            the contents of what used to be DEPLOY_DIR on the build machine. If not specified it will use the value \
            specified in the json if that directory actually exists or it will error out.")
    parser.add_argument("-l", "--log-dir", dest="log_dir", help="This sets the path for TEST_LOG_DIR. If not specified \
            the current dir is used. This is used for usually creating a ssh log file and a scp test file.")
    parser.add_argument("json", help="The json file exported by the build system", default="testdata.json", nargs='?')

    args = parser.parse_args()

    with open(args.json, "r") as f:
        loaded = json.load(f)

    if args.ip:
        loaded["target"]["ip"] = args.ip
    if args.server_ip:
        loaded["target"]["server_ip"] = args.server_ip

    d = MyDataDict()
    for key in loaded["d"].keys():
        d[key] = loaded["d"][key]

    if args.log_dir:
        d["TEST_LOG_DIR"] = args.log_dir
    else:
        d["TEST_LOG_DIR"] = os.path.abspath(os.path.dirname(__file__))
    if args.deploy_dir:
        d["DEPLOY_DIR"] = args.deploy_dir
    else:
        if not os.path.isdir(d["DEPLOY_DIR"]):
            print("WARNING: The path to DEPLOY_DIR does not exist: %s" % d["DEPLOY_DIR"])


    target = FakeTarget(d)
    for key in loaded["target"].keys():
        setattr(target, key, loaded["target"][key])

    host_dumper = get_host_dumper(d)
    host_dumper.parent_dir = loaded["host_dumper"]["parent_dir"]
    host_dumper.cmds = loaded["host_dumper"]["cmds"]

    tc = TestContext()
    setattr(tc, "d", d)
    setattr(tc, "target", target)
    setattr(tc, "host_dumper", host_dumper)
    for key in loaded.keys():
        if key != "d" and key != "target" and key != "host_dumper":
            setattr(tc, key, loaded[key])

    target.exportStart()
    runTests(tc)

    return 0
def main():

    parser = argparse.ArgumentParser()
    parser.add_argument("-t", "--target-ip", dest="ip", help="The IP address of the target machine. Use this to \
            overwrite the value determined from TEST_TARGET_IP at build time")
    parser.add_argument("-s", "--server-ip", dest="server_ip", help="The IP address of this machine. Use this to \
            overwrite the value determined from TEST_SERVER_IP at build time.")
    parser.add_argument("-d", "--deploy-dir", dest="deploy_dir", help="Full path to the package feeds, that this \
            the contents of what used to be DEPLOY_DIR on the build machine. If not specified it will use the value \
            specified in the json if that directory actually exists or it will error out.")
    parser.add_argument("-l", "--log-dir", dest="log_dir", help="This sets the path for TEST_LOG_DIR. If not specified \
            the current dir is used. This is used for usually creating a ssh log file and a scp test file.")
    parser.add_argument("json", help="The json file exported by the build system", default="testdata.json", nargs='?')

    args = parser.parse_args()

    with open(args.json, "r") as f:
        loaded = json.load(f)

    if args.ip:
        loaded["target"]["ip"] = args.ip
    if args.server_ip:
        loaded["target"]["server_ip"] = args.server_ip

    d = MyDataDict()
    for key in loaded["d"].keys():
        d[key] = loaded["d"][key]

    if args.log_dir:
        d["TEST_LOG_DIR"] = args.log_dir
    else:
        d["TEST_LOG_DIR"] = os.path.abspath(os.path.dirname(__file__))
    if args.deploy_dir:
        d["DEPLOY_DIR"] = args.deploy_dir
    else:
        if not os.path.isdir(d["DEPLOY_DIR"]):
            print("WARNING: The path to DEPLOY_DIR does not exist: %s" % d["DEPLOY_DIR"])


    target = FakeTarget(d)
    for key in loaded["target"].keys():
        setattr(target, key, loaded["target"][key])

    host_dumper = get_host_dumper(d)
    host_dumper.parent_dir = loaded["host_dumper"]["parent_dir"]
    host_dumper.cmds = loaded["host_dumper"]["cmds"]

    tc = TestContext()
    setattr(tc, "d", d)
    setattr(tc, "target", target)
    setattr(tc, "host_dumper", host_dumper)
    for key in loaded.keys():
        if key != "d" and key != "target" and key != "host_dumper":
            setattr(tc, key, loaded[key])

    target.exportStart()
    runTests(tc)

    return 0
Esempio n. 3
0
def main():

    usage = "usage: %prog [options] <json file>"
    parser = OptionParser(usage=usage)
    parser.add_option("-t", "--target-ip", dest="ip", help="The IP address of the target machine. Use this to \
            overwrite the value determined from TEST_TARGET_IP at build time")
    parser.add_option("-s", "--server-ip", dest="server_ip", help="The IP address of this machine. Use this to \
            overwrite the value determined from TEST_SERVER_IP at build time.")
    parser.add_option("-d", "--deploy-dir", dest="deploy_dir", help="Full path to the package feeds, that this \
            the contents of what used to be DEPLOY_DIR on the build machine. If not specified it will use the value \
            specified in the json if that directory actually exists or it will error out.")
    parser.add_option("-l", "--log-dir", dest="log_dir", help="This sets the path for TEST_LOG_DIR. If not specified \
            the current dir is used. This is used for usually creating a ssh log file and a scp test file.")

    (options, args) = parser.parse_args()
    if len(args) != 1:
        parser.error("Incorrect number of arguments. The one and only argument should be a json file exported by the build system")

    with open(args[0], "r") as f:
        loaded = json.load(f)

    if options.ip:
        loaded["target"]["ip"] = options.ip
    if options.server_ip:
        loaded["target"]["server_ip"] = options.server_ip

    d = MyDataDict()
    for key in loaded["d"].keys():
        d[key] = loaded["d"][key]

    if options.log_dir:
        d["TEST_LOG_DIR"] = options.log_dir
    else:
        d["TEST_LOG_DIR"] = os.path.abspath(os.path.dirname(__file__))
    if options.deploy_dir:
        d["DEPLOY_DIR"] = options.deploy_dir
    else:
        if not os.path.isdir(d["DEPLOY_DIR"]):
            raise Exception("The path to DEPLOY_DIR does not exists: %s" % d["DEPLOY_DIR"])


    target = FakeTarget(d)
    for key in loaded["target"].keys():
        setattr(target, key, loaded["target"][key])

    host_dumper = get_host_dumper(d)
    host_dumper.parent_dir = loaded["host_dumper"]["parent_dir"]
    host_dumper.cmds = loaded["host_dumper"]["cmds"]

    tc = TestContext()
    setattr(tc, "d", d)
    setattr(tc, "target", target)
    setattr(tc, "host_dumper", host_dumper)
    for key in loaded.keys():
        if key != "d" and key != "target" and key != "host_dumper":
            setattr(tc, key, loaded[key])

    target.exportStart()
    runTests(tc)

    return 0
Esempio n. 4
0
def main():

    usage = "usage: %prog [options] <json file>"
    parser = OptionParser(usage=usage)
    parser.add_option("-t",
                      "--target-ip",
                      dest="ip",
                      help="The IP address of the target machine. Use this to \
            overwrite the value determined from TEST_TARGET_IP at build time")
    parser.add_option("-s",
                      "--server-ip",
                      dest="server_ip",
                      help="The IP address of this machine. Use this to \
            overwrite the value determined from TEST_SERVER_IP at build time.")
    parser.add_option("-d",
                      "--deploy-dir",
                      dest="deploy_dir",
                      help="Full path to the package feeds, that this \
            the contents of what used to be DEPLOY_DIR on the build machine. If not specified it will use the value \
            specified in the json if that directory actually exists or it will error out."
                      )
    parser.add_option(
        "-l",
        "--log-dir",
        dest="log_dir",
        help="This sets the path for TEST_LOG_DIR. If not specified \
            the current dir is used. This is used for usually creating a ssh log file and a scp test file."
    )

    (options, args) = parser.parse_args()
    if len(args) != 1:
        parser.error(
            "Incorrect number of arguments. The one and only argument should be a json file exported by the build system"
        )

    with open(args[0], "r") as f:
        loaded = json.load(f)

    if options.ip:
        loaded["target"]["ip"] = options.ip
    if options.server_ip:
        loaded["target"]["server_ip"] = options.server_ip

    d = MyDataDict()
    for key in loaded["d"].keys():
        d[key] = loaded["d"][key]

    if options.log_dir:
        d["TEST_LOG_DIR"] = options.log_dir
    else:
        d["TEST_LOG_DIR"] = os.path.abspath(os.path.dirname(__file__))
    if options.deploy_dir:
        d["DEPLOY_DIR"] = options.deploy_dir
    else:
        if not os.path.isdir(d["DEPLOY_DIR"]):
            raise Exception("The path to DEPLOY_DIR does not exists: %s" %
                            d["DEPLOY_DIR"])

    target = FakeTarget(d)
    for key in loaded["target"].keys():
        setattr(target, key, loaded["target"][key])

    host_dumper = get_host_dumper(d)
    host_dumper.parent_dir = loaded["host_dumper"]["parent_dir"]
    host_dumper.cmds = loaded["host_dumper"]["cmds"]

    tc = TestContext()
    setattr(tc, "d", d)
    setattr(tc, "target", target)
    setattr(tc, "host_dumper", host_dumper)
    for key in loaded.keys():
        if key != "d" and key != "target" and key != "host_dumper":
            setattr(tc, key, loaded[key])

    target.exportStart()
    runTests(tc)

    return 0