def main():
    with MockSCSI(MockDevice(smc)) as s:
        r = s.initializeelementstatuswithrange(15, 3, rng=1, fast=1)
        cdb = r.cdb
        assert cdb[0] == s.device.opcodes.INITIALIZE_ELEMENT_STATUS_WITH_RANGE.value
        assert cdb[1] == 0x03
        assert scsi_ba_to_int(cdb[2:4]) == 15
        assert scsi_ba_to_int(cdb[6:8]) == 3

        cdb = r.unmarshall_cdb(cdb)
        assert cdb['opcode'] == s.device.opcodes.INITIALIZE_ELEMENT_STATUS_WITH_RANGE.value
        assert cdb['starting_element_address'] == 15
        assert cdb['number_of_elements'] == 3
        assert cdb['fast'] == 1
        assert cdb['range'] == 1

        d = InitializeElementStatusWithRange.unmarshall_cdb(InitializeElementStatusWithRange.marshall_cdb(cdb))
        assert d == cdb
예제 #2
0
    def initializeelementstatuswithrange(self, xfer, elements, **kwargs):
        """
        Returns a InitializeElementStatusWithRange Instance

        :param xfer: two byte indicating the address of the starting element
        :param elements: two byte representing a range of elements that should be initialized
        :param range = 0: a integer indicating if elements should be ignored
        :param fast = 0: a integer indicating if  elements should be scanned for media presence
        :return: a InitializeElementStatusWithRange instance
        """
        return InitializeElementStatusWithRange(self, xfer, elements, **kwargs)
def main():
    with MockSCSI(MockDevice(smc)) as s:
        r = s.initializeelementstatuswithrange(15, 3, rng=1, fast=1)
        cdb = r.cdb
        assert cdb[
            0] == s.device.opcodes.INITIALIZE_ELEMENT_STATUS_WITH_RANGE.value
        assert cdb[1] == 0x03
        assert scsi_ba_to_int(cdb[2:4]) == 15
        assert scsi_ba_to_int(cdb[6:8]) == 3

        cdb = r.unmarshall_cdb(cdb)
        assert cdb[
            'opcode'] == s.device.opcodes.INITIALIZE_ELEMENT_STATUS_WITH_RANGE.value
        assert cdb['starting_element_address'] == 15
        assert cdb['number_of_elements'] == 3
        assert cdb['fast'] == 1
        assert cdb['range'] == 1

        d = InitializeElementStatusWithRange.unmarshall_cdb(
            InitializeElementStatusWithRange.marshall_cdb(cdb))
        assert d == cdb
예제 #4
0
    def test_main(self):
        with MockSCSI(MockDevice(smc)) as s:
            r = s.initializeelementstatuswithrange(15, 3, rng=1, fast=1)
            cdb = r.cdb
            self.assertEqual(
                cdb[0],
                s.device.opcodes.INITIALIZE_ELEMENT_STATUS_WITH_RANGE.value)
            self.assertEqual(cdb[1], 0x03)
            self.assertEqual(scsi_ba_to_int(cdb[2:4]), 15)
            self.assertEqual(scsi_ba_to_int(cdb[6:8]), 3)

            cdb = r.unmarshall_cdb(cdb)
            self.assertEqual(
                cdb['opcode'],
                s.device.opcodes.INITIALIZE_ELEMENT_STATUS_WITH_RANGE.value)
            self.assertEqual(cdb['starting_element_address'], 15)
            self.assertEqual(cdb['number_of_elements'], 3)
            self.assertEqual(cdb['fast'], 1)
            self.assertEqual(cdb['range'], 1)

            d = InitializeElementStatusWithRange.unmarshall_cdb(
                InitializeElementStatusWithRange.marshall_cdb(cdb))
            self.assertEqual(d, cdb)
def main():
    dev = MockInitializeElementStatusWithRange()
    dev.opcodes = smc
    s = SCSI(dev)
    # we need to reassign the right enum again because the MockDevice will return the wrong
    # peripheral_device_type and therefor assign the spc enum instead of smc.
    s.device.opcodes = smc

    r = s.initializeelementstatuswithrange(15, 3, rng=1, fast=1)
    cdb = r.cdb
    assert cdb[0] == s.device.opcodes.INITIALIZE_ELEMENT_STATUS_WITH_RANGE.value
    assert cdb[1] == 0x03
    assert scsi_ba_to_int(cdb[2:4]) == 15
    assert scsi_ba_to_int(cdb[6:8]) == 3

    cdb = r.unmarshall_cdb(cdb)
    assert cdb['opcode'] == s.device.opcodes.INITIALIZE_ELEMENT_STATUS_WITH_RANGE.value
    assert cdb['starting_element_address'] == 15
    assert cdb['number_of_elements'] == 3
    assert cdb['fast'] == 1
    assert cdb['range'] == 1

    d = InitializeElementStatusWithRange.unmarshall_cdb(InitializeElementStatusWithRange.marshall_cdb(cdb))
    assert d == cdb
예제 #6
0
    def initializeelementstatuswithrange(self, xfer, elements, **kwargs):
        """
        Returns a InitializeElementStatusWithRange Instance

        :param xfer: two byte indicating the address of the starting element
        :param elements: two byte representing a range of elements that should be initialized
        :param kwargs: a dict with key/value pairs
                       range = 0, a integer indicating if elements should be ignored
                       fast = 0, a integer indicating if  elements should be scanned for media presence
        :return: a InitializeElementStatusWithRange instance
        """
        opcode = self.device.opcodes.INITIALIZE_ELEMENT_STATUS_WITH_RANGE
        cmd = InitializeElementStatusWithRange(opcode, xfer, elements,
                                               **kwargs)
        self.execute(cmd)
        return cmd