Introduce portable, endian-clean structures using shifts and masks instead of bitfields (#66)

* Introduce portable, endian-clean structures using shifts and masks instead of bitfields
* Modernize SCSIExecute with RAII and exceptions
* Convert SP-IN calls to use the new portable SCSI structures and functions
* Convert SP-OUT code to use the new portable SCSI structures and functions
* Delete bitfield-based code and remove runtime endian check
Closes: https://github.com/scsitape/stenc/issues/63
This commit is contained in:
James Wilson
2022-05-13 22:43:58 +02:00
committed by GitHub
parent 1508f432ad
commit eeb7d72686
5 changed files with 770 additions and 1000 deletions
+5 -5
View File
@@ -38,7 +38,7 @@ Vendor: ACME \n\
Product ID: Ultrium-1000 \n\
Product Revision: 1234\n"s};
std::ostringstream oss;
print_device_inquiry(oss, reinterpret_cast<const SCSI_PAGE_INQ*>(response));
print_device_inquiry(oss, reinterpret_cast<const scsi::inquiry_data&>(response));
REQUIRE(oss.str() == expected_output);
}
@@ -56,7 +56,7 @@ Drive Output: Not decrypting\n\
Drive Input: Not encrypting\n\
Key Instance Counter: 0\n"s};
std::ostringstream oss;
print_device_status(oss, std::make_unique<SSP_DES>(reinterpret_cast<const SSP_PAGE_BUFFER*>(page)).get(), true);
print_device_status(oss, reinterpret_cast<const scsi::page_des&>(page), true);
REQUIRE(oss.str() == expected_output);
}
@@ -78,7 +78,7 @@ Key Instance Counter: 1\n\
Encryption Algorithm: 1\n\
Drive Key Desc.(uKAD): Hello world!\n"s};
std::ostringstream oss;
print_device_status(oss, std::make_unique<SSP_DES>(reinterpret_cast<const SSP_PAGE_BUFFER*>(page)).get(), true);
print_device_status(oss, reinterpret_cast<const scsi::page_des&>(page), true);
REQUIRE(oss.str() == expected_output);
}
@@ -91,7 +91,7 @@ TEST_CASE("Test SCSI get next block encryption status output 1", "[output]")
const std::string expected_output {"\
Volume Encryption: Not encrypted\n"s};
std::ostringstream oss;
print_volume_status(oss, std::make_unique<SSP_NBES>(reinterpret_cast<const SSP_PAGE_BUFFER*>(page)).get());
print_volume_status(oss, reinterpret_cast<const scsi::page_nbes&>(page));
REQUIRE(oss.str() == expected_output);
}
@@ -107,6 +107,6 @@ TEST_CASE("Test SCSI get next block encryption status output 2", "[output]")
Volume Encryption: Encrypted and able to decrypt\n\
Volume Algorithm: 1\n"s};
std::ostringstream oss;
print_volume_status(oss, std::make_unique<SSP_NBES>(reinterpret_cast<const SSP_PAGE_BUFFER*>(page)).get());
print_volume_status(oss, reinterpret_cast<const scsi::page_nbes&>(page));
REQUIRE(oss.str() == expected_output);
}