Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dCache
cta
Commits
ecfe9a68
Commit
ecfe9a68
authored
5 years ago
by
Steven Murray
Browse files
Options
Downloads
Patches
Plain Diff
cta-immutable-file-test now prompts user before carrying out its destructive test
parent
6770c3a6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/ImmutableFileTest.cpp
+24
-0
24 additions, 0 deletions
tests/ImmutableFileTest.cpp
tests/ImmutableFileTest.hpp
+8
-0
8 additions, 0 deletions
tests/ImmutableFileTest.hpp
with
32 additions
and
0 deletions
tests/ImmutableFileTest.cpp
+
24
−
0
View file @
ecfe9a68
...
...
@@ -84,6 +84,13 @@ int ImmutableFileTest::exceptionThrowingMain(const int argc, char *const *const
return
0
;
}
if
(
userConfirmsDestroyFile
(
cmdLine
.
fileUrl
.
GetURL
()))
{
m_out
<<
"Starting destructive test on file "
<<
cmdLine
.
fileUrl
.
GetURL
()
<<
std
::
endl
;
}
else
{
m_out
<<
"Aborting"
<<
std
::
endl
;
return
0
;
}
if
(
cmdLine
.
fileUrl
.
IsLocalFile
())
{
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
cmdLine
.
fileUrl
.
GetURL
()
<<
" is local"
;
...
...
@@ -117,6 +124,23 @@ int ImmutableFileTest::exceptionThrowingMain(const int argc, char *const *const
return
0
;
}
//------------------------------------------------------------------------------
// userConfirmsDestroyFile
//------------------------------------------------------------------------------
bool
ImmutableFileTest
::
userConfirmsDestroyFile
(
const
std
::
string
&
fileUrl
)
const
{
m_out
<<
"WARNING"
<<
std
::
endl
;
m_out
<<
"You are about to destroy file "
<<
fileUrl
<<
std
::
endl
;
m_out
<<
"Are you sure you want to continue?"
<<
std
::
endl
;
std
::
string
userResponse
;
while
(
userResponse
!=
"yes"
&&
userResponse
!=
"no"
)
{
m_out
<<
"Please type either
\"
yes
\"
or
\"
no
\"
> "
;
std
::
getline
(
m_in
,
userResponse
);
}
return
userResponse
==
"yes"
;
}
//------------------------------------------------------------------------------
// fileExists
//------------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
tests/ImmutableFileTest.hpp
+
8
−
0
View file @
ecfe9a68
...
...
@@ -74,6 +74,14 @@ private:
*/
int
exceptionThrowingMain
(
const
int
argc
,
char
*
const
*
const
argv
);
/**
* Asks the user to confirm that they want to destroy the specified file.
*
* @param fileUrl The URL of the file.
* @return True if the user confirmed.
*/
bool
userConfirmsDestroyFile
(
const
std
::
string
&
fileUrl
)
const
;
/**
* @return True if the specified file exists
* @param url The XRootD URL of the file to be tested.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment