Example #1
0
    def test_binary_flash(self, tdev):
        """Creates a binary image from the hex image and tries to flash the
        device.

        Checks two test cases:
        1) fails when trying to flash binary image with
            'bin' bool set to False;
        2) passes when trying to flash binary image with
            'bin' bool set to True;
        """
        # Basic Binary Test
        cmd = get_cmd_with_device_params(tdev)

        cmd.extend(["flash", "\"%s\"" % tdev['binary-image'], "--bin"])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)

        # Flashing binary without specifying binary=True
        with pytest.raises(subprocess.CalledProcessError):
            cmd = get_cmd_with_device_params(tdev)

            cmd.extend(["flash", "\"%s\"" % tdev['binary-image']])
            cmd_str = " ".join(cmd)

            subprocess.check_call(cmd_str, shell=True)

        # Flashing hex image with specifying binary image = True
        with pytest.raises(subprocess.CalledProcessError):
            cmd = get_cmd_with_device_params(tdev)

            cmd.extend(["flash", "\"%s\"" % tdev['hex-image'], "--bin"])
            cmd_str = " ".join(cmd)

            subprocess.check_call(cmd_str, shell=True)
Example #2
0
    def test_binary_verify(self, device):
        """Creates a binary image from the hex image and tries to flash the
        device.

        Checks two test cases:
        1) fails when trying to flash binary image with
            'bin' bool set to False;
        2) passes when trying to flash binary image with
            'bin' bool set to True;
        """
        # Ensure image is a hex file
        assert device['image'].endswith(".hex")
        hex_path = device['image']
        bin_path = hex_path[:-3] + "bin"

        # Convert .hex image to .bin
        intelhex.hex2bin(hex_path, bin_path)

        # Basic Binary Flash
        cmd = get_cmd_with_device_params(device)

        cmd.extend(["flash", "\"%s\"" % bin_path, "--bin"])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)

        # Basic Binary Verify
        cmd = get_cmd_with_device_params(device)

        cmd.extend(["verify", "\"%s\"" % bin_path, "--bin"])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)

        # Verifying binary without specifying binary=True
        cmd = get_cmd_with_device_params(device)

        cmd.extend(["verify", "\"%s\"" % bin_path])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)

        # Verify hex image with specifying binary image = True
        with pytest.raises(subprocess.CalledProcessError):
            cmd = get_cmd_with_device_params(device)

            cmd.extend(["verify", "\"%s\"" % hex_path, "--bin"])
            cmd_str = " ".join(cmd)

            subprocess.check_call(cmd_str, shell=True)
Example #3
0
    def test_basic_xds110_list(self, tdev, tenv):
        """Tests xds110_list returns list of all connected devices"""
        cmd = get_cmd_with_device_params(tdev)

        cmd.extend(["xds110-list"])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)
Example #4
0
    def test_basic_xds110_reset(self, tdev):
        """Tests simple xds110_reset on each device in devices.cfg"""
        cmd = get_cmd_with_device_params(tdev)

        cmd.extend(["xds110-reset"])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)
Example #5
0
    def test_basic_get_option(self, device):
        """Tests basic get_option function"""
        cmd = get_cmd_with_device_params(device)

        cmd.extend(["options-get", "\"%s\"" % "ResetOnRestart"])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)
Example #6
0
    def test_basic_xds110_upgrade(self, device):
        """Tests simple xds110_upgrade on each device in devices.cfg"""
        cmd = get_cmd_with_device_params(device)

        cmd.extend(["xds110-upgrade"])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)
Example #7
0
    def test_list_options(self, device):
        """Tests all options returned in list are valid"""
        cmd = get_cmd_with_device_params(device)

        cmd.extend(["options-list"])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)
Example #8
0
    def test_basic_get_option(self, tdev):
        """Tests basic get_option function"""
        cmd = get_cmd_with_device_params(tdev)

        cmd.extend(["options-get", "\"%s\"" % tdev['option']])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)
Example #9
0
    def test_basic_verify(self, tdev):
        """Tests simple flash on each device in devices.cfg"""
        cmd = get_cmd_with_device_params(tdev)

        # First Flash image
        cmd.extend(["flash", "\"%s\"" % tdev["hex-image"]])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)

        # Then Verify image
        cmd = get_cmd_with_device_params(tdev)

        cmd.extend(["verify", "\"%s\"" % tdev["hex-image"]])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)
Example #10
0
    def test_basic_memory_read_multiple_bytes(self, device):
        """Tests simple memory read of multiple bytes"""
        NUM_BYTES = "4"
        cmd = get_cmd_with_device_params(device)

        cmd.extend(["memory-read", "\"%s\"" % ADDRESS, "-n", NUM_BYTES])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)
Example #11
0
    def test_basic_flash(self, device):
        """Tests simple flash on each device in devices.cfg"""

        cmd = get_cmd_with_device_params(device)

        cmd.extend(["flash", "\"%s\"" % device["image"]])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)
Example #12
0
    def test_get_invalid_option(self, device):
        """Tests get_option throws error when invalid option id provided"""
        cmd = get_cmd_with_device_params(device)

        cmd.extend(["options-get", "\"%s\"" % "InvalidOption"])
        cmd_str = " ".join(cmd)

        with pytest.raises(subprocess.CalledProcessError):
            subprocess.check_call(cmd_str, shell=True)
Example #13
0
    def test_basic_erase(self, tdev):
        """Tests simple erase on each device in devices.cfg"""

        cmd = get_cmd_with_device_params(tdev)

        cmd.append("erase")
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)
Example #14
0
    def test_basic_register_read(self, device):
        """Tests simple register read"""
        REGNAME = "PC"

        cmd = get_cmd_with_device_params(device)

        cmd.extend(["register-read", "\"%s\"" % REGNAME])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)
Example #15
0
    def test_basic_expression(self, tdev):
        """Runs a simple gel command"""
        EXPRESSION = tdev['expression-name']

        cmd = get_cmd_with_device_params(tdev)

        cmd.extend(["evaluate", "\"%s\"" % EXPRESSION])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)
Example #16
0
    def test_basic_expression(self, device):
        """Runs a simple gel command"""
        EXPRESSION = "MassErase();"

        cmd = get_cmd_with_device_params(device)

        cmd.extend(["evaluate", "\"%s\"" % EXPRESSION])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)
Example #17
0
    def test_list_single_option(self, device):
        """Tests listing of one specified option"""
        option_to_test = "DeviceInfoRevision"

        cmd = get_cmd_with_device_params(device)

        cmd.extend(["options-list", "\"%s\"" % option_to_test])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)
Example #18
0
    def test_invalid_expression_format(self, tdev):
        """Tries using expression command with invalid C syntax"""

        EXPRESSION = "var i = 0"
        cmd = get_cmd_with_device_params(tdev)

        cmd.extend(["evaluate", "\"%s\"" % EXPRESSION])
        cmd_str = " ".join(cmd)

        with pytest.raises(subprocess.CalledProcessError):
            subprocess.check_call(cmd_str, shell=True)
Example #19
0
    def test_list_single_nonexistant_option(self, device):
        """Tests listing of specified option that does not exist"""
        option_to_test = "InvalidOption"

        cmd = get_cmd_with_device_params(device)

        cmd.extend(["options-list", "\"%s\"" % option_to_test])
        cmd_str = " ".join(cmd)

        with pytest.raises(subprocess.CalledProcessError):
            subprocess.check_call(cmd_str, shell=True)
Example #20
0
    def test_basic_register_write(self, device):
        """Tests simple register write"""
        REGNAME = "R1"
        VALUE = "0xBEEF"

        cmd = get_cmd_with_device_params(device)

        cmd.extend(["register-write", "\"%s\"" % REGNAME, VALUE])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)
Example #21
0
    def test_get_option_invalid_preop(self, device):
        """Tests get_option raises error when invalid preop provided"""
        cmd = get_cmd_with_device_params(device)

        cmd.extend([
            "options-get",
            "\"%s\"" % "DeviceInfoRevision", "-op", "InvalidPreOp"
        ])
        cmd_str = " ".join(cmd)

        with pytest.raises(subprocess.CalledProcessError):
            subprocess.check_call(cmd_str, shell=True)
Example #22
0
    def test_basic_xds110_reset_fail(self, device):
        """Tests xds110_reset fails when garbage serno used"""
        old_serno = device['serno']
        device['serno'] = "GARBAGE"
        cmd = get_cmd_with_device_params(device)

        cmd.extend(["xds110-reset"])
        cmd_str = " ".join(cmd)

        with pytest.raises(subprocess.CalledProcessError):
            subprocess.check_call(cmd_str, shell=True)
        device['serno'] = old_serno
Example #23
0
    def test_invalid_register_read(self, device):
        """Tests an Error is raised when trying to access invalid register for
        register read"""
        INVALID_REGNAME = "INVALIDREGNAME"

        with pytest.raises(subprocess.CalledProcessError):
            cmd = get_cmd_with_device_params(device)

            cmd.extend(["register-read", "\"%s\"" % INVALID_REGNAME])
            cmd_str = " ".join(cmd)

            subprocess.check_call(cmd_str, shell=True)
Example #24
0
    def test_basic_xds110_upgrade_fail(self, tdev):
        """Tests xds110_upgrade fails when garbage serno used"""
        old_serno = tdev['serno']
        tdev['serno'] = "GARBAGE"
        cmd = get_cmd_with_device_params(tdev)

        cmd.extend(["xds110-upgrade"])
        cmd_str = " ".join(cmd)

        with pytest.raises(subprocess.CalledProcessError):
            subprocess.check_call(cmd_str, shell=True)
        tdev['serno'] = old_serno
Example #25
0
    def test_invalid_register_write(self, tdev):
        """Tests an Error is raised when trying to access invalid register for
        register write"""
        INVALID_REGNAME = "PC"
        VALUE = "0xFFFFFF"

        with pytest.raises(subprocess.CalledProcessError):
            cmd = get_cmd_with_device_params(tdev)

            cmd.extend(["register-write", "\"%s\"" % INVALID_REGNAME, VALUE])
            cmd_str = " ".join(cmd)

            subprocess.check_call(cmd_str, shell=True)
Example #26
0
    def test_basic_memory_write(self, device):
        """Tests simple memory write"""
        WRITE_ADDRESS = "0x20000000"
        WRITE_DATA = "0x11 0x22 0x33"
        cmd = get_cmd_with_device_params(device)

        cmd.extend(
            ["memory-write",
             "\"%s\"" % WRITE_ADDRESS, "-d", WRITE_DATA])

        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)
Example #27
0
    def test_invalid_address_memory_read(self, device):
        """Tests an Error is raised when trying to access invalid memory for
        memory read"""
        INVALID_ADDRESS = "0xFFFFFFFF"
        NUM_BYTES = "4"

        with pytest.raises(subprocess.CalledProcessError):
            cmd = get_cmd_with_device_params(device)

            cmd.extend(
                ["memory-read",
                 "\"%s\"" % INVALID_ADDRESS, "-n", NUM_BYTES])
            cmd_str = " ".join(cmd)

            subprocess.check_call(cmd_str, shell=True)
Example #28
0
    def test_get_option_with_preop(self, device):
        """Tests get_option with a preop"""
        if 'ieee' not in device.keys():
            pytest.skip(
                "No IEEE Address provided in setup.cfg for this device")

        cmd = get_cmd_with_device_params(device)

        cmd.extend([
            "options-get",
            "\"%s\"" % "DeviceIeeePrimary", "-op", "\"ReadPriIeee\""
        ])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)
Example #29
0
    def test_get_option_with_preop(self, tdev):
        """Tests get_option with a preop"""
        if 'preop' not in tdev.keys():
            pytest.skip("No preop provided for device")

        cmd = get_cmd_with_device_params(tdev)

        cmd.extend([
            "options-get",
            "\"%s\"" % tdev['preop-option'], "-op",
            "\"%s\"" % tdev['preop']
        ])
        cmd_str = " ".join(cmd)

        subprocess.check_call(cmd_str, shell=True)
Example #30
0
    def test_invalid_address_memory_write(self, device):
        """Tests an Error is raised when trying to access invalid memory for
        memory write"""
        INVALID_ADDRESS = "0x10000000"
        WRITE_DATA = "0x11 0x22 0x33"

        with pytest.raises(subprocess.CalledProcessError):
            cmd = get_cmd_with_device_params(device)

            cmd.extend(
                ["memory-write",
                 "\"%s\"" % INVALID_ADDRESS, "-d", WRITE_DATA])
            cmd_str = " ".join(cmd)

            subprocess.check_call(cmd_str, shell=True)