2022-10-06 16:15:19 +02:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-12-05 09:58:23 -08:00
|
|
|
// SCSI Target Emulator PiSCSI
|
2022-10-06 16:15:19 +02:00
|
|
|
// for Raspberry Pi
|
|
|
|
//
|
|
|
|
// Copyright (C) 2022 Uwe Seimet
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-10-23 21:51:39 +02:00
|
|
|
#include <gtest/gtest.h>
|
2022-10-08 19:26:04 +02:00
|
|
|
|
2022-12-05 09:58:23 -08:00
|
|
|
#include "piscsi/command_context.h"
|
2022-10-06 16:15:19 +02:00
|
|
|
|
2022-10-08 19:26:04 +02:00
|
|
|
TEST(CommandContext, GetSerializer)
|
|
|
|
{
|
|
|
|
CommandContext context("", -1);
|
|
|
|
|
|
|
|
// There is nothing more that can be tested
|
|
|
|
context.GetSerializer();
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(CommandContext, IsValid)
|
|
|
|
{
|
|
|
|
CommandContext context("", -1);
|
|
|
|
|
|
|
|
EXPECT_FALSE(context.IsValid());
|
|
|
|
|
|
|
|
context.SetFd(1);
|
|
|
|
EXPECT_TRUE(context.IsValid());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(CommandContext, Cleanup)
|
|
|
|
{
|
|
|
|
CommandContext context("", 0);
|
|
|
|
|
|
|
|
EXPECT_EQ(0, context.GetFd());
|
|
|
|
context.Cleanup();
|
|
|
|
EXPECT_EQ(-1, context.GetFd());
|
|
|
|
}
|
2022-10-06 16:15:19 +02:00
|
|
|
|
|
|
|
TEST(CommandContext, ReturnLocalizedError)
|
|
|
|
{
|
2022-10-08 19:26:04 +02:00
|
|
|
CommandContext context("en_US", -1);
|
2022-10-06 16:15:19 +02:00
|
|
|
|
|
|
|
EXPECT_FALSE(context.ReturnLocalizedError(LocalizationKey::ERROR_LOG_LEVEL));
|
|
|
|
}
|
2022-10-08 19:26:04 +02:00
|
|
|
|
|
|
|
TEST(CommandContext, ReturnStatus)
|
|
|
|
{
|
|
|
|
CommandContext context("", -1);
|
|
|
|
|
|
|
|
EXPECT_TRUE(context.ReturnStatus(true, "status"));
|
|
|
|
EXPECT_FALSE(context.ReturnStatus(false, "status"));
|
|
|
|
}
|