Commit 0feb5be1 authored by Steven Murray's avatar Steven Murray
Browse files

Added libcastortapeserverdaemonunittests THOUGH PLEASE BE AWARE THAT:

NOT ALL OF THE TAPEDAEMON UNITTESTS ARE BEING COMPILED AND THERE ARE
STILL UNITTESTS THAT ARE COMPILED THAT DO NOT PASS
parent 537fdb67
......@@ -3,6 +3,9 @@ cmake_minimum_required (VERSION 2.6)
include_directories(${PROJECT_SOURCE_DIR}/tapeserver)
include_directories(${PROJECT_SOURCE_DIR}/tapeserver/h)
add_library (castorserverdummies
ProcessCapDummy.cpp)
add_library (castorserverunittests SHARED
AtomicCounterTest.cpp
DaemonTest.cpp
......
/******************************************************************************
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 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 2
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#include "castor/server/ProcessCapDummy.hpp"
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
castor::server::ProcessCapDummy::~ProcessCapDummy()
throw() {
}
//------------------------------------------------------------------------------
// getProcText
//------------------------------------------------------------------------------
std::string castor::server::ProcessCapDummy::getProcText() {
return m_text;
}
//------------------------------------------------------------------------------
// setProcText
//------------------------------------------------------------------------------
void castor::server::ProcessCapDummy::setProcText(const std::string &text) {
m_text = text;
}
......@@ -87,3 +87,51 @@ add_dependencies(castorTapeServerDaemon castormessagesprotobuf)
add_executable(tapeserverd TapeDaemon.cpp)
target_link_libraries(tapeserverd castorTapeServerDaemon SCSI System Utils File TapeDrive castorcommon castorclient castorlegacymsg castorserver castortapegatewayprotocol castortapereactor ${LIBCAP_LIB} ${ZLIB_LIBRARIES} castormessages zmq)
# The
add_library(castortapeserverdaemonunittests SHARED
CatalogueDriveStateTest.cpp
CatalogueTest.cpp
DiskReadTaskTest.cpp
# DiskWriteTaskTest.cpp
# DiskWriteThreadPoolTest.cpp
DriveConfigTest.cpp
# MigrationReportPackerTest.cpp
ProcessForkerTest.cpp
# RecallReportPackerTest.cpp
# RecallTaskInjectorTest.cpp
# We dot know why but the TapeDaemonTest causes the following segmentation
# fault to occur in another test:
#
# [0;32m[----------] [m48 tests from OStoreDBPlusMockSchedulerTest/SchedulerTest
# [0;32m[ RUN ] [mOStoreDBPlusMockSchedulerTest/SchedulerTest.createStorageClass_new_as_adminOnAdminHost/0
#
#
# Program received signal SIGSEGV, Segmentation fault.
# 0x0000003b3a69c0d0 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const () from /usr/lib64/libstdc++.so.6
# Missing separate debuginfos, use: debuginfo-install boost-system-1.41.0-25.el6.x86_64 boost-thread-1.41.0-25.el6.x86_64 castor-lib-2.1.15-2657.slc6.x86_64 castor-lib-server-2.1.15-2657.slc6.x86_64 cryptopp-5.6.2-2.el6.x86_6
# 4 glibc-2.12-1.149.el6_6.9.x86_64 gmock-1.5.0-4.el6.x86_64 gtest-1.5.0-5.el6.x86_64 keyutils-libs-1.4-5.el6.x86_64 krb5-libs-1.10.3-33.el6.x86_64 libattr-2.4.44-7.el6.x86_64 libcap-2.16-5.5.el6.x86_64 libcom_err-1.41.12-21.
# el6.x86_64 libgcc-4.4.7-11.el6.x86_64 librados2-0.87.1-0.el6.x86_64 libselinux-2.0.94-5.8.el6.x86_64 libstdc++-4.4.7-11.el6.x86_64 libuuid-2.17.2-12.18.el6.x86_64 lttng-ust-2.4.1-1.el6.x86_64 nspr-4.10.6-1.el6_5.x86_64 nss-
# 3.16.2.3-3.el6_6.cern.x86_64 nss-util-3.16.2.3-2.el6_6.x86_64 openpgm-5.1.118-3.el6.x86_64 openssl-1.0.1e-30.el6_6.7.x86_64 protobuf-2.3.0-9.el6.x86_64 sqlite-3.6.20-1.el6.x86_64 userspace-rcu-0.7.7-1.el6.x86_64 xrootd-clie
# nt-libs-4.2.1-2.el6.x86_64 xrootd-libs-4.2.1-2.el6.x86_64 zeromq3-3.2.5-1.el6.x86_64 zlib-1.2.3-29.el6.x86_64
# (gdb) bt
# #0 0x0000003b3a69c0d0 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const () from /usr/lib64/libstdc++.so.6
# #1 0x00007ffff5746416 in cta::objectstore::RootEntry::getAgentRegisterAddress (this=0x7fffffffdb10) at /home/murrayc3/cta/checkout/CTA/objectstore/RootEntry.cpp:639
# #2 0x00007ffff5746589 in cta::objectstore::RootEntry::addOrGetAgentRegisterPointerAndCommit (this=0x7fffffffdb10, agent=..., log=...) at /home/murrayc3/cta/checkout/CTA/objectstore/RootEntry.cpp:649
# #3 0x00007ffff4f0ed69 in cta::(anonymous namespace)::OStoreDBWrapper<cta::objectstore::BackendVFS>::OStoreDBWrapper (this=0x822950, context="UnitTest") at /home/murrayc3/cta/checkout/CTA/scheduler/OStoreDB/OStoreDBFactory.
# hpp:61
# #4 0x00007ffff4f1a081 in cta::OStoreDBFactory<cta::objectstore::BackendVFS>::create (this=0x7ffff51bceb8) at /home/murrayc3/cta/checkout/CTA/scheduler/OStoreDB/OStoreDBFactory.hpp:257
# #5 0x00007ffff4f60800 in unitTests::SchedulerTest::SetUp (this=0x7f6510) at /home/murrayc3/cta/checkout/CTA/scheduler/SchedulerTest.cpp:89
# #6 0x00007ffff49ec023 in testing::Test::Run() () from /usr/lib64/libgtest.so.0
# #7 0x00007ffff49ec188 in testing::internal::TestInfoImpl::Run() () from /usr/lib64/libgtest.so.0
# #8 0x00007ffff49ec245 in testing::TestCase::Run() () from /usr/lib64/libgtest.so.0
# #9 0x00007ffff49ef10f in testing::internal::UnitTestImpl::RunAllTests() () from /usr/lib64/libgtest.so.0
# #10 0x00000000004adbe3 in main (argc=1, argv=0x7fffffffe1b8) at /home/murrayc3/cta/checkout/CTA/tests/unit_tests.cpp:26
# (gdb)
# TapeDaemon.cpp
# TapeDaemonTest.cpp
)
target_link_libraries(castortapeserverdaemonunittests
castorserverdummies)
......@@ -22,7 +22,7 @@
*****************************************************************************/
#include "castor/tape/tapeserver/daemon/DiskReadTask.hpp"
#include "castor/tape/tapeserver/daemon/DataConsumer.hpp"
#include "castor/tape/tapeserver/daemon/MemManager.hpp"
#include "castor/tape/tapeserver/daemon/MigrationMemoryManager.hpp"
#include "castor/tape/tapeserver/daemon/MemBlock.hpp"
#include "castor/log/LogContext.hpp"
#include "castor/log/StringLogger.hpp"
......@@ -33,6 +33,13 @@
namespace unitTests{
using namespace castor::tape::tapeserver::daemon;
class TestingArchiveJob: public cta::ArchiveJob {
public:
TestingArchiveJob() {
}
};
class FakeTapeWriteTask : public DataConsumer{
castor::server::BlockingQueue<MemBlock*> fifo;
unsigned long m_checksum;
......@@ -63,35 +70,50 @@ namespace unitTests{
// out.seekg(0, std::ios::beg);
return checksum;
}
TEST(castor_tape_tapeserver_daemon, DiskReadTaskTest){
char path[]="/tmp/testDRT-XXXXXX";
mkstemp(path);
std::ofstream out(path,std::ios::out | std::ios::binary);
castor::server::AtomicFlag flag;
castor::log::StringLogger log("castor_tape_tapeserver_daemon_DiskReadTaskTest");
castor::log::LogContext lc(log);
const int blockSize=1500;
const int fileSize(1024*2000);
const unsigned long original_checksum = mycopy(out,fileSize);
castor::tape::tapeserver::daemon::MigrationMemoryManager mm(1,blockSize,lc);
castor::tape::tapegateway::FileToMigrateStruct* file=new castor::tape::tapegateway::FileToMigrateStruct();
file->setPath(path);
file->setFileSize(fileSize);
const int blockNeeded=fileSize/mm.blockCapacity()+((fileSize%mm.blockCapacity()==0) ? 0 : 1);
int value=std::ceil(1024*2000./blockSize);
ASSERT_EQ(value,blockNeeded);
FakeTapeWriteTask ftwt;
ftwt.pushDataBlock(new MemBlock(1,blockSize));
castor::tape::tapeserver::daemon::DiskReadTask drt(ftwt,file,blockNeeded,flag);
drt.execute(lc);
ASSERT_EQ(original_checksum,ftwt.getChecksum());
delete ftwt.getFreeBlock();
}
// This test was commented out in the CMakeLists.txt file that would have
// compiled it. There was no comment explaining why it was commented out.
// The following commit message was associated with the commenting out of the
// CMakeLists.txt line:
//
// commit 165117042951769b7d0023933cc6e705b04fad54
// Author: David COME <david.come@cern.ch>
// Date: Tue Apr 22 11:35:11 2014 +0200
//
// Commented out DiskReadTaskTest
//
// This test is commented and left here in the hope that somebody in the future
// will have the time to make this test compile again.
//
//TEST(castor_tape_tapeserver_daemon, DiskReadTaskTest){
// char path[]="/tmp/testDRT-XXXXXX";
// mkstemp(path);
// std::ofstream out(path,std::ios::out | std::ios::binary);
// castor::server::AtomicFlag flag;
// castor::log::StringLogger log("castor_tape_tapeserver_daemon_DiskReadTaskTest");
// castor::log::LogContext lc(log);
//
// const int blockSize=1500;
// const int fileSize(1024*2000);
//
// const unsigned long original_checksum = mycopy(out,fileSize);
// castor::tape::tapeserver::daemon::MigrationMemoryManager mm(1,blockSize,lc);
//
// TestingArchiveJob file;
//
// file.archiveFile.lastKnownPath = path;
// file.archiveFile.size = fileSize;
//
// const int blockNeeded=fileSize/mm.blockCapacity()+((fileSize%mm.blockCapacity()==0) ? 0 : 1);
// int value=std::ceil(1024*2000./blockSize);
// ASSERT_EQ(value,blockNeeded);
//
// FakeTapeWriteTask ftwt;
// ftwt.pushDataBlock(new MemBlock(1,blockSize));
// castor::tape::tapeserver::daemon::DiskReadTask drt(ftwt,&file,blockNeeded,flag);
// drt.execute(lc);
//
// ASSERT_EQ(original_checksum,ftwt.getChecksum());
// delete ftwt.getFreeBlock();
//}
}
......@@ -24,11 +24,7 @@
#include "castor/tape/tapeserver/daemon/DiskWriteThreadPool.hpp"
#include "castor/tape/tapeserver/daemon/RecallTaskInjector.hpp"
#include "castor/tape/tapeserver/daemon/RecallReportPacker.hpp"
#include "castor/tape/tapegateway/FileToRecallStruct.hpp"
#include "castor/tape/tapeserver/daemon/ReportPackerInterface.hpp"
#include "castor/tape/tapeserver/client/ClientInterface.hpp"
#include "castor/tape/tapeserver/client/FakeClient.hpp"
#include "castor/tape/tapeserver/client/ClientInterface.hpp"
#include "castor/log/LogContext.hpp"
#include "castor/log/StringLogger.hpp"
#include "castor/tape/tapeserver/daemon/MigrationMemoryManager.hpp"
......
......@@ -24,7 +24,6 @@
#include "castor/log/StringLogger.hpp"
#include "castor/tape/tapeserver/daemon/MigrationReportPacker.hpp"
#include "castor/tape/tapeserver/drive/DriveInterface.hpp"
#include "castor/tape/tapeserver/client/FakeClient.hpp"
#include "serrno.h"
#include "scheduler/mockDB/MockSchedulerDatabase.hpp"
......
......@@ -28,8 +28,6 @@
#include "castor/messages/AcsProxyDummy.hpp"
#include "castor/messages/TapeserverProxyDummy.hpp"
#include "castor/server/ProcessCapDummy.hpp"
#include "castor/tape/tapeserver/client/ClientInterface.hpp"
#include "castor/tape/tapeserver/client/FakeClient.hpp"
#include "castor/tape/tapeserver/daemon/DiskWriteThreadPool.hpp"
#include "castor/tape/tapeserver/daemon/RecallTaskInjector.hpp"
#include "castor/tape/tapeserver/daemon/TapeServerReporter.hpp"
......
......@@ -41,13 +41,13 @@ namespace UnitTests {
public:
TestingRetrieveJob() {
}
}; // class TestingRetrieveJob
};
class TestingArchiveJob: public cta::ArchiveJob {
public:
TestingArchiveJob() {
}
}; // class TestingRetrieveJob
};
class castorTapeFileTest : public ::testing::Test {
protected:
......
......@@ -41,35 +41,6 @@ find_package( ZLIB REQUIRED )
# ../castor/server/ProcessCapDummy.cpp
#)
# Those tests are single threaded, functionnal and error tests. They could
# actually fail in helgrind/drd (but memcheck is recommended)
set_property(SOURCE
../castor/io/IoTest.cpp
APPEND PROPERTY COMPILE_FLAGS -fno-strict-aliasing)
#add_executable(castorUnitTests
# castorUnitTests.cpp
# ../castor/tape/tapeserver/daemon/AdminAcceptHandler.cpp
# ../castor/tape/tapeserver/daemon/DiskReadTaskTest.cpp
# ../castor/tape/tapeserver/daemon/Catalogue.cpp
# ../castor/tape/tapeserver/daemon/CatalogueDrive.cpp
# ../castor/tape/tapeserver/daemon/CatalogueDriveStateTest.cpp
# ../castor/tape/tapeserver/daemon/CatalogueTest.cpp
# ../castor/tape/tapeserver/daemon/DriveConfigTest.cpp
# ../castor/tape/tapeserver/daemon/ProcessForker.cpp
# ../castor/tape/tapeserver/daemon/ProcessForkerTest.cpp
# ../castor/tape/tapeserver/daemon/TapeDaemon.cpp
# ../castor/tape/tapeserver/daemon/TapeDaemonTest.cpp
# ../castor/tape/tapeserver/daemon/RecallTaskInjectorTest.cpp
# ../castor/tape/tapeserver/daemon/MigrationReportPackerTest.cpp
# ../castor/tape/tapeserver/daemon/RecallReportPackerTest.cpp
# ../castor/tape/tapeserver/daemon/DiskWriteThreadPoolTest.cpp
# ../castor/tape/tapeserver/daemon/DiskWriteTaskTest.cpp
# ${LIBCAPUNITTEST_SRC_FILES})
set_property(SOURCE ../SCSI/StructuresTest.cpp
PROPERTY COMPILE_FLAGS -fno-strict-aliasing
)
find_package (xrootd REQUIRED)
include_directories (${XROOTD_INCLUDE_DIR})
......
......@@ -11,6 +11,7 @@ target_link_libraries(unittests
castormessagesunittests
castorserverunittests
castortapereactorunittests
castortapeserverdaemonunittests
castortapeserverdriveunittests
castortapeserverfileunittests
castortapeserverscsiunittests
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment