MCPcopy Create free account
hub / github.com/PiSCSI/piscsi / TEST

Function TEST

cpp/test/scsi_command_util_test.cpp:17–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15using namespace scsi_command_util;
16
17TEST(ScsiCommandUtilTest, ModeSelect6)
18{
19 const int LENGTH = 26;
20
21 vector<int> cdb(6);
22 vector<uint8_t> buf(LENGTH);
23
24 // PF (vendor-specific parameter format) must not fail but be ignored
25 cdb[1] = 0x00;
26 ModeSelect(scsi_command::eCmdModeSelect6, cdb, buf, LENGTH, 0);
27
28 cdb[0] = 0x15;
29 // PF (standard parameter format)
30 cdb[1] = 0x10;
31 // Request 512 bytes per sector
32 buf[9] = 0x00;
33 buf[10] = 0x02;
34 buf[11] = 0x00;
35 EXPECT_THAT([&] { ModeSelect(scsi_command::eCmdModeSelect6, cdb, buf, LENGTH, 256); },
36 Throws<scsi_exception>(AllOf(
37 Property(&scsi_exception::get_sense_key, sense_key::illegal_request),
38 Property(&scsi_exception::get_asc, asc::invalid_field_in_parameter_list))))
39 << "Requested sector size does not match current sector size";
40
41 // Page 0
42 buf[12] = 0x00;
43 EXPECT_THAT([&] { ModeSelect(scsi_command::eCmdModeSelect6, cdb, buf, LENGTH, 512); },
44 Throws<scsi_exception>(AllOf(
45 Property(&scsi_exception::get_sense_key, sense_key::illegal_request),
46 Property(&scsi_exception::get_asc, asc::invalid_field_in_parameter_list))))
47 << "Unsupported page 0 was not rejected";
48
49 // Page 3 (Format Device Page)
50 buf[12] = 0x03;
51 EXPECT_THAT([&] { ModeSelect(scsi_command::eCmdModeSelect6, cdb, buf, LENGTH, 512); },
52 Throws<scsi_exception>(AllOf(
53 Property(&scsi_exception::get_sense_key, sense_key::illegal_request),
54 Property(&scsi_exception::get_asc, asc::invalid_field_in_parameter_list))))
55 << "Requested sector size does not match current sector size";
56
57 // Match the requested to the current sector size
58 buf[24] = 0x02;
59 EXPECT_THAT([&] { ModeSelect(scsi_command::eCmdModeSelect6, cdb, buf, LENGTH - 1, 512); },
60 Throws<scsi_exception>(AllOf(
61 Property(&scsi_exception::get_sense_key, sense_key::illegal_request),
62 Property(&scsi_exception::get_asc, asc::invalid_field_in_parameter_list))))
63 << "Not enough command parameters";
64
65 EXPECT_FALSE(ModeSelect(scsi_command::eCmdModeSelect6, cdb, buf, LENGTH, 512).empty());
66}
67
68TEST(ScsiCommandUtilTest, ModeSelect10)
69{

Callers

nothing calls this directly

Calls 5

GetInt24Function · 0.85
GetInt32Function · 0.85
SetInt16Function · 0.85
SetInt32Function · 0.85
GetInt16Function · 0.70

Tested by

no test coverage detected