Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
697dd058
Commit
697dd058
authored
Sep 07, 2016
by
Victor Kotlyar
Browse files
Moved castor::utils::SmartArrayPtr to
cta::SmartArrayPtr
parent
91daee59
Changes
7
Hide whitespace changes
Inline
Side-by-side
common/CMakeLists.txt
View file @
697dd058
...
...
@@ -145,6 +145,7 @@ set (COMMON_UNIT_TESTS_LIB_SRC_FILES
log/StringLoggerTest.cpp
remoteFS/RemotePathTest.cpp
SmartFdTest.cpp
SmartArrayPtrTest.cpp
CRCTest.cpp
threading/DaemonTest.cpp
threading/SocketPairTest.cpp
...
...
tapeserver/castor/utils
/SmartArrayPtr.hpp
→
common
/SmartArrayPtr.hpp
View file @
697dd058
/******************************************************************************
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
* 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.
*
* 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
****************************************************************************
*/
*
You should have received a copy of the GNU General Public License
*
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
...
...
@@ -29,8 +24,7 @@
#include
<stdio.h>
namespace
castor
{
namespace
utils
{
namespace
cta
{
/**
* A smart pointer that owns a pointer to an array and unlike std::unique_ptr
...
...
@@ -156,6 +150,5 @@ private:
};
// class SmartArrayPtr
}
// namespace utils
}
// namespace castor
}
// namespace cta
tapeserver/castor/utils
/SmartArrayPtrTest.cpp
→
common
/SmartArrayPtrTest.cpp
View file @
697dd058
/******************************************************************************
/*
* The CERN Tape Archive (CTA) project
* Copyright (C) 2015 CERN
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
* 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.
*
* 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
****************************************************************************
*/
*
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
"c
astor/utils
/SmartArrayPtr.hpp"
#include
"c
ommon
/SmartArrayPtr.hpp"
#include
<gtest/gtest.h>
#include
<list>
...
...
@@ -33,7 +28,7 @@
namespace
unitTests
{
class
ca
stor_utils
_SmartArrayPtrTest
:
public
::
testing
::
Test
{
class
c
t
a_SmartArrayPtrTest
:
public
::
testing
::
Test
{
protected:
virtual
void
SetUp
()
{
...
...
@@ -43,25 +38,25 @@ protected:
}
};
TEST_F
(
ca
stor_utils
_SmartArrayPtrTest
,
constructor
)
{
TEST_F
(
c
t
a_SmartArrayPtrTest
,
constructor
)
{
char
*
ptr
=
new
char
[
10
];
ca
stor
::
utils
::
SmartArrayPtr
<
char
>
smartPtr
(
ptr
);
c
t
a
::
SmartArrayPtr
<
char
>
smartPtr
(
ptr
);
ASSERT_EQ
(
ptr
,
smartPtr
.
get
());
}
TEST_F
(
ca
stor_utils
_SmartArrayPtrTest
,
reset
)
{
TEST_F
(
c
t
a_SmartArrayPtrTest
,
reset
)
{
char
*
ptr
=
new
char
[
10
];
ca
stor
::
utils
::
SmartArrayPtr
<
char
>
smartPtr
;
c
t
a
::
SmartArrayPtr
<
char
>
smartPtr
;
ASSERT_EQ
((
char
*
)
0
,
smartPtr
.
get
());
smartPtr
.
reset
(
ptr
);
ASSERT_EQ
(
ptr
,
smartPtr
.
get
());
}
TEST_F
(
ca
stor_utils
_SmartArrayPtrTest
,
assignment
)
{
ca
stor
::
utils
::
SmartArrayPtr
<
char
>
smartPtr1
;
ca
stor
::
utils
::
SmartArrayPtr
<
char
>
smartPtr2
;
TEST_F
(
c
t
a_SmartArrayPtrTest
,
assignment
)
{
c
t
a
::
SmartArrayPtr
<
char
>
smartPtr1
;
c
t
a
::
SmartArrayPtr
<
char
>
smartPtr2
;
ASSERT_EQ
((
char
*
)
0
,
smartPtr1
.
get
());
ASSERT_EQ
((
char
*
)
0
,
smartPtr2
.
get
());
...
...
@@ -75,19 +70,19 @@ TEST_F(castor_utils_SmartArrayPtrTest, assignment) {
ASSERT_EQ
(
ptr
,
smartPtr2
.
get
());
}
TEST_F
(
ca
stor_utils
_SmartArrayPtrTest
,
releaseNull
)
{
ca
stor
::
utils
::
SmartArrayPtr
<
char
>
smartPtr
;
TEST_F
(
c
t
a_SmartArrayPtrTest
,
releaseNull
)
{
c
t
a
::
SmartArrayPtr
<
char
>
smartPtr
;
ASSERT_THROW
(
smartPtr
.
release
(),
cta
::
exception
::
NotAnOwner
);
}
TEST_F
(
ca
stor_utils
_SmartArrayPtrTest
,
subscriptRead
)
{
TEST_F
(
c
t
a_SmartArrayPtrTest
,
subscriptRead
)
{
char
*
ptr
=
new
char
[
4
];
ptr
[
0
]
=
'T'
;
ptr
[
1
]
=
'e'
;
ptr
[
2
]
=
's'
;
ptr
[
3
]
=
't'
;
ca
stor
::
utils
::
SmartArrayPtr
<
char
>
smartPtr
(
ptr
);
c
t
a
::
SmartArrayPtr
<
char
>
smartPtr
(
ptr
);
ASSERT_EQ
(
ptr
,
smartPtr
.
get
());
ASSERT_EQ
(
'T'
,
smartPtr
[
0
]);
...
...
@@ -96,14 +91,14 @@ TEST_F(castor_utils_SmartArrayPtrTest, subscriptRead) {
ASSERT_EQ
(
't'
,
smartPtr
[
3
]);
}
TEST_F
(
ca
stor_utils
_SmartArrayPtrTest
,
subscriptAssigment
)
{
TEST_F
(
c
t
a_SmartArrayPtrTest
,
subscriptAssigment
)
{
char
*
ptr
=
new
char
[
4
];
ptr
[
0
]
=
'T'
;
ptr
[
1
]
=
'e'
;
ptr
[
2
]
=
's'
;
ptr
[
3
]
=
't'
;
ca
stor
::
utils
::
SmartArrayPtr
<
char
>
smartPtr
(
ptr
);
c
t
a
::
SmartArrayPtr
<
char
>
smartPtr
(
ptr
);
ASSERT_EQ
(
ptr
,
smartPtr
.
get
());
ASSERT_EQ
(
'T'
,
smartPtr
[
0
]);
...
...
tapeserver/castor/tape/reactor/PollReactorImpl.cpp
View file @
697dd058
...
...
@@ -21,7 +21,7 @@
#include
"common/exception/BadAlloc.hpp"
#include
"castor/tape/reactor/PollReactorImpl.hpp"
#include
"c
astor/utils
/SmartArrayPtr.hpp"
#include
"c
ommon
/SmartArrayPtr.hpp"
#include
"castor/utils/utils.hpp"
#include
<unistd.h>
...
...
@@ -90,7 +90,7 @@ void castor::tape::reactor::PollReactorImpl::removeHandler(
//------------------------------------------------------------------------------
void
castor
::
tape
::
reactor
::
PollReactorImpl
::
handleEvents
(
const
int
timeout
)
{
nfds_t
nfds
=
0
;
ca
stor
::
utils
::
SmartArrayPtr
<
struct
pollfd
>
fds
(
buildPollFds
(
nfds
));
c
t
a
::
SmartArrayPtr
<
struct
pollfd
>
fds
(
buildPollFds
(
nfds
));
const
int
pollrc
=
poll
(
fds
.
get
(),
nfds
,
timeout
);
...
...
@@ -121,7 +121,7 @@ struct pollfd *castor::tape::reactor::PollReactorImpl::buildPollFds(
nfds_t
&
nfds
)
{
nfds
=
m_handlers
.
size
();
ca
stor
::
utils
::
SmartArrayPtr
<
struct
pollfd
>
fds
;
c
t
a
::
SmartArrayPtr
<
struct
pollfd
>
fds
;
try
{
fds
.
reset
(
new
struct
pollfd
[
nfds
]);
}
catch
(
std
::
bad_alloc
&
ba
)
{
...
...
tapeserver/castor/tape/tapeserver/daemon/ProcessForker.cpp
View file @
697dd058
...
...
@@ -44,7 +44,7 @@
#include
"castor/tape/tapeserver/daemon/LabelSession.hpp"
#include
"castor/tape/tapeserver/daemon/ProcessForker.hpp"
#include
"castor/tape/tapeserver/daemon/ProcessForkerUtils.hpp"
#include
"c
astor/utils
/SmartArrayPtr.hpp"
#include
"c
ommon
/SmartArrayPtr.hpp"
#include
"castor/utils/utils.hpp"
#include
"catalogue/CatalogueFactory.hpp"
#include
"common/exception/Exception.hpp"
...
...
tapeserver/castor/tape/tapeserver/daemon/ProcessForkerUtils.cpp
View file @
697dd058
...
...
@@ -23,7 +23,7 @@
#include
"castor/io/io.hpp"
#include
"castor/tape/tapeserver/daemon/ProcessForkerUtils.hpp"
#include
"c
astor/utils
/SmartArrayPtr.hpp"
#include
"c
ommon
/SmartArrayPtr.hpp"
#include
"castor/utils/utils.hpp"
#include
"common/exception/Exception.hpp"
...
...
@@ -469,7 +469,7 @@ std::string castor::tape::tapeserver::daemon::ProcessForkerUtils::
throw
ex
;
}
utils
::
SmartArrayPtr
<
char
>
payloadBuf
(
new
char
[
payloadLen
]);
cta
::
SmartArrayPtr
<
char
>
payloadBuf
(
new
char
[
payloadLen
]);
io
::
readBytes
(
fd
,
timeout
,
payloadLen
,
payloadBuf
.
get
());
return
std
::
string
(
payloadBuf
.
get
(),
payloadLen
);
...
...
tapeserver/castor/utils/CMakeLists.txt
View file @
697dd058
...
...
@@ -35,7 +35,6 @@ target_link_libraries(ctautils castorlog)
install
(
TARGETS ctautils DESTINATION usr/
${
CMAKE_INSTALL_LIBDIR
}
)
add_library
(
ctautilsunittests SHARED
SmartArrayPtrTest.cpp
UtilsTest.cpp
)
install
(
TARGETS ctautilsunittests DESTINATION usr/
${
CMAKE_INSTALL_LIBDIR
}
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment