def main():
    # SMC ElementAddressAssignment
    dev = MockModeSenseEAA()
    dev.opcodes = smc
    s = SCSI(dev)
    i = s.modesense10(page_code=MODESENSE10.PAGE_CODE.ELEMENT_ADDRESS_ASSIGNMENT).result
    assert i["medium_type"] == 97
    assert i["device_specific_parameter"] == 98

    assert len(i["mode_pages"]) == 1

    assert i["mode_pages"][0]["ps"] == 1
    assert i["mode_pages"][0]["spf"] == 0
    assert i["mode_pages"][0]["page_code"] == MODESENSE10.PAGE_CODE.ELEMENT_ADDRESS_ASSIGNMENT
    assert i["mode_pages"][0]["first_medium_transport_element_address"] == 257
    assert i["mode_pages"][0]["num_medium_transport_elements"] == 258
    assert i["mode_pages"][0]["first_storage_element_address"] == 259
    assert i["mode_pages"][0]["num_storage_elements"] == 260
    assert i["mode_pages"][0]["first_import_element_address"] == 261
    assert i["mode_pages"][0]["num_import_elements"] == 262
    assert i["mode_pages"][0]["first_data_transfer_element_address"] == 263
    assert i["mode_pages"][0]["num_data_transfer_elements"] == 264

    d = ModeSense10.unmarshall_datain(ModeSense10.marshall_datain(i))
    assert d == i

    # SPC Control
    dev = MockModeSenseControl()
    dev.opcodes = smc
    s = SCSI(dev)
    i = s.modesense10(page_code=MODESENSE10.PAGE_CODE.CONTROL).result
    assert i["medium_type"] == 0
    assert i["device_specific_parameter"] == 0x90

    assert len(i["mode_pages"]) == 1

    assert i["mode_pages"][0]["ps"] == 1
    assert i["mode_pages"][0]["spf"] == 0
    assert i["mode_pages"][0]["page_code"] == MODESENSE10.PAGE_CODE.CONTROL
    assert i["mode_pages"][0]["tst"] == 4
    assert i["mode_pages"][0]["tmf_only"] == 1
    assert i["mode_pages"][0]["dpicz"] == 1
    assert i["mode_pages"][0]["d_sense"] == 1
    assert i["mode_pages"][0]["gltsd"] == 1
    assert i["mode_pages"][0]["rlec"] == 1
    assert i["mode_pages"][0]["queue_algorithm_modifier"] == 9
    assert i["mode_pages"][0]["nuar"] == 1
    assert i["mode_pages"][0]["qerr"] == 3
    assert i["mode_pages"][0]["vs"] == 1
    assert i["mode_pages"][0]["rac"] == 1
    assert i["mode_pages"][0]["ua_intlck_ctrl"] == 3
    assert i["mode_pages"][0]["swp"] == 1
    assert i["mode_pages"][0]["ato"] == 1
    assert i["mode_pages"][0]["tas"] == 1
    assert i["mode_pages"][0]["atmpe"] == 1
    assert i["mode_pages"][0]["rwwp"] == 1
    assert i["mode_pages"][0]["autoload_mode"] == 7
    assert i["mode_pages"][0]["busy_timeout_period"] == 500
    assert i["mode_pages"][0]["extended_self_test_completion_time"] == 700

    d = ModeSense10.unmarshall_datain(ModeSense10.marshall_datain(i))
    assert d == i

    # SPC Control Ext 1
    dev = MockModeSenseControlExt1()
    dev.opcodes = smc
    s = SCSI(dev)
    i = s.modesense10(page_code=MODESENSE10.PAGE_CODE.CONTROL, sub_page_code=1).result
    assert i["medium_type"] == 0
    assert i["device_specific_parameter"] == 0x90

    assert len(i["mode_pages"]) == 1

    assert i["mode_pages"][0]["ps"] == 1
    assert i["mode_pages"][0]["spf"] == 1
    assert i["mode_pages"][0]["page_code"] == MODESENSE10.PAGE_CODE.CONTROL
    assert i["mode_pages"][0]["sub_page_code"] == 1
    assert i["mode_pages"][0]["tcmos"] == 1
    assert i["mode_pages"][0]["scsip"] == 1
    assert i["mode_pages"][0]["ialuae"] == 1
    assert i["mode_pages"][0]["initial_command_priority"] == 15
    assert i["mode_pages"][0]["maximum_sense_data_length"] == 29

    d = ModeSense10.unmarshall_datain(ModeSense10.marshall_datain(i))
    assert d == i

    # SPC Disconnect
    dev = MockModeSenseDisconnect()
    dev.opcodes = smc
    s = SCSI(dev)
    i = s.modesense10(page_code=MODESENSE10.PAGE_CODE.DISCONNECT_RECONNECT).result
    assert i["medium_type"] == 0
    assert i["device_specific_parameter"] == 0x90

    assert len(i["mode_pages"]) == 1

    assert i["mode_pages"][0]["ps"] == 1
    assert i["mode_pages"][0]["spf"] == 0
    assert i["mode_pages"][0]["page_code"] == MODESENSE10.PAGE_CODE.DISCONNECT_RECONNECT
    assert i["mode_pages"][0]["buffer_full_ratio"] == 122
    assert i["mode_pages"][0]["buffer_empty_ratio"] == 123
    assert i["mode_pages"][0]["bus_inactivity_limit"] == 2371
    assert i["mode_pages"][0]["disconnect_time_limit"] == 2372
    assert i["mode_pages"][0]["connect_time_limit"] == 2373
    assert i["mode_pages"][0]["maximum_burst_size"] == 2374
    assert i["mode_pages"][0]["emdp"] == 1
    assert i["mode_pages"][0]["fair_arbitration"] == 7
    assert i["mode_pages"][0]["dimm"] == 1
    assert i["mode_pages"][0]["dtdc"] == 7
    assert i["mode_pages"][0]["first_burst_size"] == 2375

    d = ModeSense10.unmarshall_datain(ModeSense10.marshall_datain(i))
    assert d == i
Example #2
0
def main():
    # SMC ElementAddressAssignment
    with MockSCSI(MockModeSenseEAA(smc)) as s:
        i = s.modesense10(
            page_code=MODESENSE10.PAGE_CODE.ELEMENT_ADDRESS_ASSIGNMENT).result
        assert i['medium_type'] == 97
        assert i['device_specific_parameter'] == 98

        assert len(i['mode_pages']) == 1

        assert i['mode_pages'][0]['ps'] == 1
        assert i['mode_pages'][0]['spf'] == 0
        assert i['mode_pages'][0][
            'page_code'] == MODESENSE10.PAGE_CODE.ELEMENT_ADDRESS_ASSIGNMENT
        assert i['mode_pages'][0][
            'first_medium_transport_element_address'] == 257
        assert i['mode_pages'][0]['num_medium_transport_elements'] == 258
        assert i['mode_pages'][0]['first_storage_element_address'] == 259
        assert i['mode_pages'][0]['num_storage_elements'] == 260
        assert i['mode_pages'][0]['first_import_element_address'] == 261
        assert i['mode_pages'][0]['num_import_elements'] == 262
        assert i['mode_pages'][0]['first_data_transfer_element_address'] == 263
        assert i['mode_pages'][0]['num_data_transfer_elements'] == 264

        d = ModeSense10.unmarshall_datain(ModeSense10.marshall_datain(i))
        assert d == i

        # SPC Control
        s.device = MockModeSenseControl(smc)
        i = s.modesense10(page_code=MODESENSE10.PAGE_CODE.CONTROL).result
        assert i['medium_type'] == 0
        assert i['device_specific_parameter'] == 0x90

        assert len(i['mode_pages']) == 1

        assert i['mode_pages'][0]['ps'] == 1
        assert i['mode_pages'][0]['spf'] == 0
        assert i['mode_pages'][0]['page_code'] == MODESENSE10.PAGE_CODE.CONTROL
        assert i['mode_pages'][0]['tst'] == 4
        assert i['mode_pages'][0]['tmf_only'] == 1
        assert i['mode_pages'][0]['dpicz'] == 1
        assert i['mode_pages'][0]['d_sense'] == 1
        assert i['mode_pages'][0]['gltsd'] == 1
        assert i['mode_pages'][0]['rlec'] == 1
        assert i['mode_pages'][0]['queue_algorithm_modifier'] == 9
        assert i['mode_pages'][0]['nuar'] == 1
        assert i['mode_pages'][0]['qerr'] == 3
        assert i['mode_pages'][0]['vs'] == 1
        assert i['mode_pages'][0]['rac'] == 1
        assert i['mode_pages'][0]['ua_intlck_ctrl'] == 3
        assert i['mode_pages'][0]['swp'] == 1
        assert i['mode_pages'][0]['ato'] == 1
        assert i['mode_pages'][0]['tas'] == 1
        assert i['mode_pages'][0]['atmpe'] == 1
        assert i['mode_pages'][0]['rwwp'] == 1
        assert i['mode_pages'][0]['autoload_mode'] == 7
        assert i['mode_pages'][0]['busy_timeout_period'] == 500
        assert i['mode_pages'][0]['extended_self_test_completion_time'] == 700

        d = ModeSense10.unmarshall_datain(ModeSense10.marshall_datain(i))
        assert d == i

        # SPC Control Ext 1
        s.device = MockModeSenseControlExt1(smc)
        i = s.modesense10(page_code=MODESENSE10.PAGE_CODE.CONTROL,
                          sub_page_code=1).result
        assert i['medium_type'] == 0
        assert i['device_specific_parameter'] == 0x90

        assert len(i['mode_pages']) == 1

        assert i['mode_pages'][0]['ps'] == 1
        assert i['mode_pages'][0]['spf'] == 1
        assert i['mode_pages'][0]['page_code'] == MODESENSE10.PAGE_CODE.CONTROL
        assert i['mode_pages'][0]['sub_page_code'] == 1
        assert i['mode_pages'][0]['tcmos'] == 1
        assert i['mode_pages'][0]['scsip'] == 1
        assert i['mode_pages'][0]['ialuae'] == 1
        assert i['mode_pages'][0]['initial_command_priority'] == 15
        assert i['mode_pages'][0]['maximum_sense_data_length'] == 29

        d = ModeSense10.unmarshall_datain(ModeSense10.marshall_datain(i))
        assert d == i

        # SPC Disconnect
        s.device = MockModeSenseDisconnect(smc)
        i = s.modesense10(
            page_code=MODESENSE10.PAGE_CODE.DISCONNECT_RECONNECT).result
        assert i['medium_type'] == 0
        assert i['device_specific_parameter'] == 0x90

        assert len(i['mode_pages']) == 1

        assert i['mode_pages'][0]['ps'] == 1
        assert i['mode_pages'][0]['spf'] == 0
        assert i['mode_pages'][0][
            'page_code'] == MODESENSE10.PAGE_CODE.DISCONNECT_RECONNECT
        assert i['mode_pages'][0]['buffer_full_ratio'] == 122
        assert i['mode_pages'][0]['buffer_empty_ratio'] == 123
        assert i['mode_pages'][0]['bus_inactivity_limit'] == 2371
        assert i['mode_pages'][0]['disconnect_time_limit'] == 2372
        assert i['mode_pages'][0]['connect_time_limit'] == 2373
        assert i['mode_pages'][0]['maximum_burst_size'] == 2374
        assert i['mode_pages'][0]['emdp'] == 1
        assert i['mode_pages'][0]['fair_arbitration'] == 7
        assert i['mode_pages'][0]['dimm'] == 1
        assert i['mode_pages'][0]['dtdc'] == 7
        assert i['mode_pages'][0]['first_burst_size'] == 2375

        d = ModeSense10.unmarshall_datain(ModeSense10.marshall_datain(i))
        assert d == i
    def test_main(self):
        # SMC ElementAddressAssignment
        with MockSCSI(MockModeSenseEAA(smc)) as s:
            i = s.modesense10(page_code=MODESENSE10.PAGE_CODE.
                              ELEMENT_ADDRESS_ASSIGNMENT).result
            self.assertEqual(i['medium_type'], 97)
            self.assertEqual(i['device_specific_parameter'], 98)

            self.assertEqual(len(i['mode_pages']), 1)

            self.assertEqual(i['mode_pages'][0]['ps'], 1)
            self.assertEqual(i['mode_pages'][0]['spf'], 0)
            self.assertEqual(i['mode_pages'][0]['page_code'],
                             MODESENSE10.PAGE_CODE.ELEMENT_ADDRESS_ASSIGNMENT)
            self.assertEqual(
                i['mode_pages'][0]['first_medium_transport_element_address'],
                257)
            self.assertEqual(
                i['mode_pages'][0]['num_medium_transport_elements'], 258)
            self.assertEqual(
                i['mode_pages'][0]['first_storage_element_address'], 259)
            self.assertEqual(i['mode_pages'][0]['num_storage_elements'], 260)
            self.assertEqual(
                i['mode_pages'][0]['first_import_element_address'], 261)
            self.assertEqual(i['mode_pages'][0]['num_import_elements'], 262)
            self.assertEqual(
                i['mode_pages'][0]['first_data_transfer_element_address'], 263)
            self.assertEqual(i['mode_pages'][0]['num_data_transfer_elements'],
                             264)

            d = ModeSense10.unmarshall_datain(ModeSense10.marshall_datain(i))
            self.assertEqual(d, i)

            # SPC Control
            s.device = MockModeSenseControl(smc)
            i = s.modesense10(page_code=MODESENSE10.PAGE_CODE.CONTROL).result
            self.assertEqual(i['medium_type'], 0)
            self.assertEqual(i['device_specific_parameter'], 0x90)

            self.assertEqual(len(i['mode_pages']), 1)

            self.assertEqual(i['mode_pages'][0]['ps'], 1)
            self.assertEqual(i['mode_pages'][0]['spf'], 0)
            self.assertEqual(i['mode_pages'][0]['page_code'],
                             MODESENSE10.PAGE_CODE.CONTROL)
            self.assertEqual(i['mode_pages'][0]['tst'], 4)
            self.assertEqual(i['mode_pages'][0]['tmf_only'], 1)
            self.assertEqual(i['mode_pages'][0]['dpicz'], 1)
            self.assertEqual(i['mode_pages'][0]['d_sense'], 1)
            self.assertEqual(i['mode_pages'][0]['gltsd'], 1)
            self.assertEqual(i['mode_pages'][0]['rlec'], 1)
            self.assertEqual(i['mode_pages'][0]['queue_algorithm_modifier'], 9)
            self.assertEqual(i['mode_pages'][0]['nuar'], 1)
            self.assertEqual(i['mode_pages'][0]['qerr'], 3)
            self.assertEqual(i['mode_pages'][0]['vs'], 1)
            self.assertEqual(i['mode_pages'][0]['rac'], 1)
            self.assertEqual(i['mode_pages'][0]['ua_intlck_ctrl'], 3)
            self.assertEqual(i['mode_pages'][0]['swp'], 1)
            self.assertEqual(i['mode_pages'][0]['ato'], 1)
            self.assertEqual(i['mode_pages'][0]['tas'], 1)
            self.assertEqual(i['mode_pages'][0]['atmpe'], 1)
            self.assertEqual(i['mode_pages'][0]['rwwp'], 1)
            self.assertEqual(i['mode_pages'][0]['autoload_mode'], 7)
            self.assertEqual(i['mode_pages'][0]['busy_timeout_period'], 500)
            self.assertEqual(
                i['mode_pages'][0]['extended_self_test_completion_time'], 700)

            d = ModeSense10.unmarshall_datain(ModeSense10.marshall_datain(i))
            self.assertEqual(d, i)

            # SPC Control Ext 1
            s.device = MockModeSenseControlExt1(smc)
            i = s.modesense10(page_code=MODESENSE10.PAGE_CODE.CONTROL,
                              sub_page_code=1).result
            self.assertEqual(i['medium_type'], 0)
            self.assertEqual(i['device_specific_parameter'], 0x90)

            self.assertEqual(len(i['mode_pages']), 1)

            self.assertEqual(i['mode_pages'][0]['ps'], 1)
            self.assertEqual(i['mode_pages'][0]['spf'], 1)
            self.assertEqual(i['mode_pages'][0]['page_code'],
                             MODESENSE10.PAGE_CODE.CONTROL)
            self.assertEqual(i['mode_pages'][0]['sub_page_code'], 1)
            self.assertEqual(i['mode_pages'][0]['tcmos'], 1)
            self.assertEqual(i['mode_pages'][0]['scsip'], 1)
            self.assertEqual(i['mode_pages'][0]['ialuae'], 1)
            self.assertEqual(i['mode_pages'][0]['initial_command_priority'],
                             15)
            self.assertEqual(i['mode_pages'][0]['maximum_sense_data_length'],
                             29)

            d = ModeSense10.unmarshall_datain(ModeSense10.marshall_datain(i))
            self.assertEqual(d, i)

            # SPC Disconnect
            s.device = MockModeSenseDisconnect(smc)
            i = s.modesense10(
                page_code=MODESENSE10.PAGE_CODE.DISCONNECT_RECONNECT).result
            self.assertEqual(i['medium_type'], 0)
            self.assertEqual(i['device_specific_parameter'], 0x90)

            self.assertEqual(len(i['mode_pages']), 1)

            self.assertEqual(i['mode_pages'][0]['ps'], 1)
            self.assertEqual(i['mode_pages'][0]['spf'], 0)
            self.assertEqual(i['mode_pages'][0]['page_code'],
                             MODESENSE10.PAGE_CODE.DISCONNECT_RECONNECT)
            self.assertEqual(i['mode_pages'][0]['buffer_full_ratio'], 122)
            self.assertEqual(i['mode_pages'][0]['buffer_empty_ratio'], 123)
            self.assertEqual(i['mode_pages'][0]['bus_inactivity_limit'], 2371)
            self.assertEqual(i['mode_pages'][0]['disconnect_time_limit'], 2372)
            self.assertEqual(i['mode_pages'][0]['connect_time_limit'], 2373)
            self.assertEqual(i['mode_pages'][0]['maximum_burst_size'], 2374)
            self.assertEqual(i['mode_pages'][0]['emdp'], 1)
            self.assertEqual(i['mode_pages'][0]['fair_arbitration'], 7)
            self.assertEqual(i['mode_pages'][0]['dimm'], 1)
            self.assertEqual(i['mode_pages'][0]['dtdc'], 7)
            self.assertEqual(i['mode_pages'][0]['first_burst_size'], 2375)

            d = ModeSense10.unmarshall_datain(ModeSense10.marshall_datain(i))
            self.assertEqual(d, i)