Skip to content
Snippets Groups Projects
Commit 5e55c15f authored by Steven Murray's avatar Steven Murray
Browse files

Added cta_mediachanger_acs_AcsTest unit-tests

parent 0b5a9d85
No related branches found
No related tags found
No related merge requests found
......@@ -238,6 +238,7 @@ Unit tests and system tests with virtual tape drives
%{_libdir}/libctadaemonunittests.so*
%{_libdir}/libctamediachangerunittests.so*
%{_libdir}/libctamediachangeracsdaemonunittests.so*
%{_libdir}/libctamediachangeracsunittests.so*
%{_bindir}/cta-systemTests
%{_libdir}/libctadaemonunittests-multiprocess.so*
%attr(0644,root,root) %{_datadir}/%{name}-%{ctaVersion}/unittest/*.suppr
......
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "common/exception/InvalidArgument.hpp"
#include "mediachanger/acs/Acs.hpp"
#include <gtest/gtest.h>
namespace unitTests {
class cta_mediachanger_acs_AcsTest: public ::testing::Test {
protected:
virtual void SetUp() {
}
virtual void TearDown() {
}
};
/**
* Tests good day senario with Acs::strToDrveId.
*/
TEST_F(cta_mediachanger_acs_AcsTest, goodDayStr2DriveId) {
using namespace cta::mediachanger::acs;
const std::string str("1:2:3:4");
const auto driveId = Acs::str2DriveId(str);
ASSERT_EQ(1, driveId.panel_id.lsm_id.acs);
ASSERT_EQ(2, driveId.panel_id.lsm_id.lsm);
ASSERT_EQ(3, driveId.panel_id.panel);
ASSERT_EQ(4, driveId.drive);
}
/**
* Tests too many components with Acs::strToDrveId.
*/
TEST_F(cta_mediachanger_acs_AcsTest, tooManyComponentsStr2DriveId) {
using namespace cta::mediachanger::acs;
const std::string str("1:2:3:4:5");
ASSERT_THROW(Acs::str2DriveId(str), cta::exception::InvalidArgument);
}
/**
* Tests too few components with Acs::strToDrveId.
*/
TEST_F(cta_mediachanger_acs_AcsTest, tooFewComponentsStr2DriveIdgoodDayStr2DriveId) {
using namespace cta::mediachanger::acs;
const std::string str("1:2:3");
ASSERT_THROW(Acs::str2DriveId(str), cta::exception::InvalidArgument);
}
/**
* Tests tool long component with Acs::strToDrveId.
*/
TEST_F(cta_mediachanger_acs_AcsTest, tooLongAcsComponentStr2DriveId) {
using namespace cta::mediachanger::acs;
const std::string str("1111:2:3:4");
ASSERT_THROW(Acs::str2DriveId(str), cta::exception::InvalidArgument);
}
/**
* Tests tool long component with Acs::strToDrveId.
*/
TEST_F(cta_mediachanger_acs_AcsTest, tooLongLsmComponentStr2DriveId) {
using namespace cta::mediachanger::acs;
const std::string str("1:2222:3:4");
ASSERT_THROW(Acs::str2DriveId(str), cta::exception::InvalidArgument);
}
/**
* Tests tool long component with Acs::strToDrveId.
*/
TEST_F(cta_mediachanger_acs_AcsTest, tooLongPanComponentStr2DriveId) {
using namespace cta::mediachanger::acs;
const std::string str("1:2:3333:4");
ASSERT_THROW(Acs::str2DriveId(str), cta::exception::InvalidArgument);
}
/**
* Tests tool long component with Acs::strToDrveId.
*/
TEST_F(cta_mediachanger_acs_AcsTest, tooLongDrvComponentStr2DriveId) {
using namespace cta::mediachanger::acs;
const std::string str("1:2:3:4444");
ASSERT_THROW(Acs::str2DriveId(str), cta::exception::InvalidArgument);
}
} // namespace unitTests
......@@ -41,6 +41,27 @@ set_target_properties (cta-acs PROPERTIES
COMPILE_FLAGS -I/usr/include/CDK
COMPILE_DEFINITIONS LINUX)
################################################################################
# Rules to build and install unit-tests
################################################################################
set(MEDIACHANGER_ACS_UNIT_TESTS_LIB_SRC_FILES
AcsTest.cpp)
add_library (ctamediachangeracsunittests SHARED
${MEDIACHANGER_ACS_UNIT_TESTS_LIB_SRC_FILES})
set_property(TARGET ctamediachangeracsunittests PROPERTY SOVERSION "${CTA_SOVERSION}")
set_property(TARGET ctamediachangeracsunittests PROPERTY VERSION "${CTA_LIBVERSION}")
target_link_libraries (ctamediachangeracsunittests
cta-acs)
set_target_properties (ctamediachangeracsunittests PROPERTIES
COMPILE_FLAGS -I/usr/include/CDK
COMPILE_DEFINITIONS LINUX)
install(TARGETS ctamediachangeracsunittests DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
################################################################################
# Rules to build and install castor-tape-acs-dismount
################################################################################
......
......@@ -41,6 +41,7 @@ target_link_libraries(cta-unitTests
ctadaemonunittests
ctamediachangerunittests
ctamediachangeracsdaemonunittests
ctamediachangeracsunittests
${GMOCK_LIB}
gtest
pthread)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment