2022-10-04 15:23:42 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SCSI Target Emulator RaSCSI Reloaded
|
|
|
|
// for Raspberry Pi
|
|
|
|
//
|
|
|
|
// Copyright (C) 2022 Uwe Seimet
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-10-23 19:51:39 +00:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
2022-10-04 15:23:42 +00:00
|
|
|
#include "rascsi_exceptions.h"
|
|
|
|
|
|
|
|
using namespace scsi_defs;
|
|
|
|
|
|
|
|
TEST(RascsiExceptionsTest, IoException)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
throw io_exception("msg");
|
|
|
|
}
|
|
|
|
catch(const io_exception& e) {
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_STREQ("msg", e.what());
|
2022-10-04 15:23:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(RascsiExceptionsTest, FileNotFoundException)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
throw file_not_found_exception("msg");
|
|
|
|
}
|
|
|
|
catch(const file_not_found_exception& e) {
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_STREQ("msg", e.what());
|
2022-10-04 15:23:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(RascsiExceptionsTest, ScsiErrorException)
|
|
|
|
{
|
|
|
|
try {
|
2022-10-08 17:26:04 +00:00
|
|
|
throw scsi_exception(sense_key::UNIT_ATTENTION);
|
2022-10-04 15:23:42 +00:00
|
|
|
}
|
2022-10-08 17:26:04 +00:00
|
|
|
catch(const scsi_exception& e) {
|
2022-10-04 15:23:42 +00:00
|
|
|
EXPECT_EQ(sense_key::UNIT_ATTENTION, e.get_sense_key());
|
|
|
|
EXPECT_EQ(asc::NO_ADDITIONAL_SENSE_INFORMATION, e.get_asc());
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2022-10-08 17:26:04 +00:00
|
|
|
throw scsi_exception(sense_key::UNIT_ATTENTION, asc::LBA_OUT_OF_RANGE);
|
2022-10-04 15:23:42 +00:00
|
|
|
}
|
2022-10-08 17:26:04 +00:00
|
|
|
catch(const scsi_exception& e) {
|
2022-10-04 15:23:42 +00:00
|
|
|
EXPECT_EQ(sense_key::UNIT_ATTENTION, e.get_sense_key());
|
|
|
|
EXPECT_EQ(asc::LBA_OUT_OF_RANGE, e.get_asc());
|
|
|
|
}
|
|
|
|
}
|