Exemplo n.º 1
0
def main():
    " Go, go, go! "
    args = setup_parser().parse_args()
    env = setup_env(args)
    devtest_pattern = "devtest_{p}.py".format(p=args.devtest_pattern)
    uhd_args_list = get_usrp_list("type=" + args.device_filter, env)
    if len(uhd_args_list) == 0:
        print("No devices found. Exiting.")
        exit(1)
    tests_passed = True
    for uhd_idx, uhd_info in enumerate(uhd_args_list):
        print(
            '--- Running all tests for device {dev} ({prod}, Serial: {ser}).'.
            format(dev=uhd_idx,
                   prod=uhd_info.get('product', 'USRP'),
                   ser=uhd_info.get('serial')))
        print('--- This will take some time. Better grab a cup of tea.')
        sys.stdout.flush()
        args_str = uhd_info['args']
        env['_UHD_TEST_ARGS_STR'] = args_str
        logfile_name = "log{}.log".format(
            args_str.replace('type=', '_').replace('serial=',
                                                   '_').replace(',', ''))
        resultsfile_name = "results{}.log".format(
            args_str.replace('type=', '_').replace('serial=',
                                                   '_').replace(',', ''))
        env['_UHD_TEST_LOGFILE'] = os.path.join(args.log_dir, logfile_name)
        env['_UHD_TEST_RESULTSFILE'] = os.path.join(args.log_dir,
                                                    resultsfile_name)
        env['_UHD_TEST_LOG_LEVEL'] = str(logging.INFO)
        env['_UHD_TEST_PRINT_LEVEL'] = str(logging.WARNING)
        env['_UHD_BUILD_DIR'] = str(args.build_dir)
        env['_UHD_DEVTEST_SRC_DIR'] = str(args.src_dir)
        proc = subprocess.Popen([
            "python",
            "-m",
            "unittest",
            "discover",
            "-v",
            "-s",
            args.src_dir,
            "-p",
            devtest_pattern,
        ],
                                env=env,
                                stdin=subprocess.PIPE,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.STDOUT,
                                universal_newlines=True)
        print(proc.communicate()[0])
        sys.stdout.flush()
        if proc.returncode != 0:
            tests_passed = False
    print('--- Done testing all attached devices.')
    return tests_passed
Exemplo n.º 2
0
def main():
    " Go, go, go! "
    args = setup_parser().parse_args()
    env = setup_env(args)
    devtest_pattern = "devtest_{p}.py".format(p=args.devtest_pattern)
    uhd_args_list = get_usrp_list("type=" + args.device_filter, env)
    if len(uhd_args_list) == 0:
        print("No devices found. Exiting.")
        exit(1)
    tests_passed = True
    for uhd_idx, uhd_info in enumerate(uhd_args_list):
        print('--- Running all tests for device {dev} ({prod}, Serial: {ser}).'.format(
            dev=uhd_idx,
            prod=uhd_info.get('product', 'USRP'),
            ser=uhd_info.get('serial')
        ))
        print('--- This will take some time. Better grab a cup of tea.')
        sys.stdout.flush()
        args_str = uhd_info['args']
        env['_UHD_TEST_ARGS_STR'] = args_str
        logfile_name = "log{}.log".format(
            args_str.replace('type=', '_').replace('serial=', '_').replace(',', '')
        )
        resultsfile_name = "results{}.log".format(
            args_str.replace('type=', '_').replace('serial=', '_').replace(',', '')
        )
        env['_UHD_TEST_LOGFILE'] = os.path.join(args.log_dir, logfile_name)
        env['_UHD_TEST_RESULTSFILE'] = os.path.join(args.log_dir, resultsfile_name)
        env['_UHD_TEST_LOG_LEVEL'] = str(logging.INFO)
        env['_UHD_TEST_PRINT_LEVEL'] = str(logging.WARNING)
        env['_UHD_BUILD_DIR'] = str(args.build_dir)
        env['_UHD_DEVTEST_SRC_DIR'] = str(args.src_dir)
        proc = subprocess.Popen(
            [
                "python", "-m", "unittest", "discover", "-v",
                "-s", args.src_dir,
                "-p", devtest_pattern,
            ],
            env=env,
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
            universal_newlines=True
        )
        print(proc.communicate()[0])
        sys.stdout.flush()
        if proc.returncode != 0:
            tests_passed = False
    print('--- Done testing all attached devices.')
    return tests_passed
Exemplo n.º 3
0
 def setUp(self):
     self.name = self.__class__.__name__
     self.test_id = self.id().split('.')[-1]
     self.results = {}
     self.results_file = os.getenv('_UHD_TEST_RESULTSFILE', "")
     if self.results_file and os.path.isfile(self.results_file):
         self.results = yaml.safe_load(open(self.results_file).read()) or {}
     self.args_str = os.getenv('_UHD_TEST_ARGS_STR', "")
     self.usrp_info = get_usrp_list(self.args_str)[0]
     if self.usrp_info['serial'] not in self.results:
         self.results[self.usrp_info['serial']] = {}
     if self.name not in self.results[self.usrp_info['serial']]:
         self.results[self.usrp_info['serial']][self.name] = {}
     self.setup_logger()
     self.set_up()
Exemplo n.º 4
0
 def setUp(self):
     self.name = self.__class__.__name__
     self.test_id = self.id().split('.')[-1]
     self.results = {}
     self.results_file = os.getenv('_UHD_TEST_RESULTSFILE', "")
     if self.results_file and os.path.isfile(self.results_file):
         self.results = yaml.safe_load(open(self.results_file).read()) or {}
     self.args_str = os.getenv('_UHD_TEST_ARGS_STR', "")
     self.usrp_info = get_usrp_list(self.args_str)[0]
     if not self.results.has_key(self.usrp_info['serial']):
         self.results[self.usrp_info['serial']] = {}
     if not self.results[self.usrp_info['serial']].has_key(self.name):
         self.results[self.usrp_info['serial']][self.name] = {}
     self.setup_logger()
     self.set_up()
Exemplo n.º 5
0
 def setUp(self):
     self.name = self.__class__.__name__
     self.test_id = self.id().split('.')[-1]
     self.results = {}
     self.results_file = os.getenv('_UHD_TEST_RESULTSFILE', "")
     if self.results_file and os.path.isfile(self.results_file):
         self.results = yaml.safe_load(open(self.results_file).read()) or {}
     self.args_str = os.getenv('_UHD_TEST_ARGS_STR', "")
     time.sleep(15)  # Wait for x300 devices to reclaim them
     self.usrp_info = get_usrp_list(self.args_str)[0]
     if not self.results.has_key(self.usrp_info['serial']):
         self.results[self.usrp_info['serial']] = {}
     if not self.results[self.usrp_info['serial']].has_key(self.name):
         self.results[self.usrp_info['serial']][self.name] = {}
     self.setup_logger()
     self.set_up()
Exemplo n.º 6
0
def main():
    " Go, go, go! "
    args = setup_parser().parse_args()
    env = setup_env(args)
    devtest_pattern = "devtest_{p}.py".format(p=args.devtest_pattern)
    uhd_args_list = get_usrp_list("type=" + args.device_filter, env)
    if len(uhd_args_list) == 0:
        print("No devices found. Exiting.")
        exit(1)
    tests_passed = True
    for uhd_idx, uhd_info in enumerate(uhd_args_list):
        print(
            "--- Running all tests for device {dev} ({prod}, Serial: {ser}).".format(
                dev=uhd_idx, prod=uhd_info.get("product", "USRP"), ser=uhd_info.get("serial")
            )
        )
        print("--- This will take some time. Better grab a cup of tea.")
        args_str = uhd_info["args"]
        env["_UHD_TEST_ARGS_STR"] = args_str
        logfile_name = "log{}.log".format(args_str.replace("type=", "_").replace("serial=", "_").replace(",", ""))
        resultsfile_name = "results{}.log".format(
            args_str.replace("type=", "_").replace("serial=", "_").replace(",", "")
        )
        env["_UHD_TEST_LOGFILE"] = os.path.join(args.log_dir, logfile_name)
        env["_UHD_TEST_RESULTSFILE"] = os.path.join(args.log_dir, resultsfile_name)
        env["_UHD_TEST_LOG_LEVEL"] = str(logging.INFO)
        env["_UHD_TEST_PRINT_LEVEL"] = str(logging.WARNING)
        proc = subprocess.Popen(
            ["python", "-m", "unittest", "discover", "-v", "-s", args.src_dir, "-p", devtest_pattern],
            env=env,
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
        )
        print(proc.communicate()[0])
        if proc.returncode != 0:
            tests_passed = False
    print("--- Done testing all attached devices.")
    return tests_passed
Exemplo n.º 7
0
def main():
    " Go, go, go! "
    args = setup_parser().parse_args()
    env = setup_env(args)
    devtest_pattern = "devtest_{p}.py".format(p=args.devtest_pattern)
    uhd_args_list = get_usrp_list(args.args, env)
    arg_dict = dict(arg.split('=') for arg in args.args.strip(',').split(','))
    if len(uhd_args_list) == 0:
        print("No devices found. Exiting.")
        exit(1)
    tests_passed = True
    for uhd_idx, uhd_info in enumerate(uhd_args_list):
        print('--- Running all tests for device {dev} ({prod}, Serial: {ser}).'.format(
            dev=uhd_idx,
            prod=uhd_info.get('product', 'USRP'),
            ser=uhd_info.get('serial')
        ))
        print('--- This will take some time. Better grab a cup of tea.')
        sys.stdout.flush()
        args_str = uhd_info['args']
        logfile_name = "log{}.log".format(
            args_str.replace('type=', '_').replace('serial=', '_').replace(',', '')
        )
        resultsfile_name = "results{}.log".format(
            args_str.replace('type=', '_').replace('serial=', '_').replace(',', '')
        )
        if 'addr' in arg_dict:
            args_str += ',addr={}'.format(arg_dict['addr'])
        env['_UHD_TEST_ARGS_STR'] = args_str
        env['_UHD_TEST_LOGFILE'] = os.path.join(args.log_dir, logfile_name)
        env['_UHD_TEST_RESULTSFILE'] = os.path.join(args.log_dir, resultsfile_name)
        env['_UHD_TEST_LOG_LEVEL'] = str(logging.INFO)
        env['_UHD_TEST_PRINT_LEVEL'] = str(logging.WARNING)
        env['_UHD_BUILD_DIR'] = str(args.build_dir)
        env['_UHD_DEVTEST_SRC_DIR'] = str(args.src_dir)
        if args.xml:
            if not importlib.util.find_spec("xmlrunner"):
                print("Error: XML report is requested but Python unittest-xml-reporting (aka. xmlrunner)\n" \
                      "       is not installed. Typically you can install it with:\n" \
                      "       pip3 install unittest-xml-reporting")
                sys.exit(1)
            test_module = "xmlrunner"
        else:
            test_module = "unittest"
        proc = subprocess.Popen(
            [
                args.python_interp, "-m", test_module, "discover", "-v",
                "-s", args.src_dir,
                "-p", devtest_pattern,
            ],
            env=env,
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
            universal_newlines=True
        )
        print(proc.communicate()[0])
        sys.stdout.flush()
        if proc.returncode != 0:
            tests_passed = False
    print('--- Done testing all attached devices.')
    return tests_passed