Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Algorithms Library Toolkit Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Hello
GitLab will be updated tonight at 22:00. Expect short outage.
Show more breadcrumbs
Algorithms Library Toolkit
Algorithms Library Toolkit Core
Commits
96aa70a1
Commit
96aa70a1
authored
3 years ago
by
Jan Trávníček
Browse files
Options
Downloads
Patches
Plain Diff
clang-tidy: fix issues in TimeoutAqlTest
parent
1525f468
No related branches found
No related tags found
1 merge request
!200
clang tidy fixes
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/testing/TimeoutAqlTest.cpp
+20
-20
20 additions, 20 deletions
tests/testing/TimeoutAqlTest.cpp
tests/testing/TimeoutAqlTest.hpp
+4
-4
4 additions, 4 deletions
tests/testing/TimeoutAqlTest.hpp
with
24 additions
and
24 deletions
tests/testing/TimeoutAqlTest.cpp
+
20
−
20
View file @
96aa70a1
...
@@ -25,10 +25,10 @@
...
@@ -25,10 +25,10 @@
#define FD_STDERR 2
#define FD_STDERR 2
/* Communication between signal handler and the rest of the program */
/* Communication between signal handler and the rest of the program */
int
g_Wakeup
[
2
]
;
// pipe for wakeup
std
::
array
<
int
,
2
>
g_Wakeup
;
// pipe for wakeup
int
g_RecvSignal
;
// signalled flag
bool
g_RecvSignal
;
// signalled flag
int
waitSignalTimeout
(
const
std
::
chrono
::
microseconds
&
duration
)
{
bool
waitSignalTimeout
(
const
std
::
chrono
::
microseconds
&
duration
)
{
struct
timeval
tv
;
struct
timeval
tv
;
fd_set
rd
;
fd_set
rd
;
...
@@ -48,10 +48,10 @@ std::string readFromFD ( int fd ) {
...
@@ -48,10 +48,10 @@ std::string readFromFD ( int fd ) {
std
::
string
res
;
std
::
string
res
;
int
rd
;
int
rd
;
char
buf
[
BUFSIZE
]
;
std
::
array
<
char
,
BUFSIZE
>
buf
;
while
(
(
rd
=
read
(
fd
,
&
buf
,
BUFSIZE
-
1
)
)
>
0
)
{
while
(
(
rd
=
read
(
fd
,
buf
.
data
(
),
buf
.
size
(
)
-
1
)
)
>
0
)
{
res
.
append
(
buf
,
rd
);
res
.
append
(
buf
.
data
(
)
,
rd
);
}
}
return
res
;
return
res
;
...
@@ -63,7 +63,7 @@ void writeToFD ( int fd, const std::string & message, const std::string & errorD
...
@@ -63,7 +63,7 @@ void writeToFD ( int fd, const std::string & message, const std::string & errorD
}
}
void
newSigChild
(
int
)
{
void
newSigChild
(
int
)
{
g_RecvSignal
=
1
;
g_RecvSignal
=
true
;
// write into the pipe so select can read something, this effectively means that SIGCHILD was raised
// write into the pipe so select can read something, this effectively means that SIGCHILD was raised
writeToFD
(
g_Wakeup
[
PIPE_WR
],
" "
,
"wakeup signalling"
);
writeToFD
(
g_Wakeup
[
PIPE_WR
],
" "
,
"wakeup signalling"
);
...
@@ -75,29 +75,29 @@ struct ChildStatus {
...
@@ -75,29 +75,29 @@ struct ChildStatus {
std
::
string
outAql
,
outStdout
,
outStderr
;
std
::
string
outAql
,
outStdout
,
outStderr
;
};
};
ChildStatus
_
TimeoutAqlTestImpl
(
const
std
::
chrono
::
microseconds
&
timeout
,
std
::
istream
&
is
)
{
ChildStatus
TimeoutAqlTestImpl
(
const
std
::
chrono
::
microseconds
&
timeout
,
std
::
istream
&
is
)
{
/* Register SIGCHLD handler */
/* Register SIGCHLD handler */
struct
sigaction
act
;
struct
sigaction
act
;
memset
(
&
act
,
0
,
sizeof
(
act
)
);
memset
(
&
act
,
0
,
sizeof
(
act
)
);
act
.
sa_handler
=
newSigChild
;
act
.
sa_handler
=
newSigChild
;
sigaction
(
SIGCHLD
,
&
act
,
nullptr
);
sigaction
(
SIGCHLD
,
&
act
,
nullptr
);
int
pipeAqlOutput
[
2
]
;
/* parent-child communication ( aql output ) */
std
::
array
<
int
,
2
>
pipeAqlOutput
;
/* parent-child communication ( aql output ) */
int
pipeStdout
[
2
]
;
/* parent-child communication ( child stdout ) */
std
::
array
<
int
,
2
>
pipeStdout
;
/* parent-child communication ( child stdout ) */
int
pipeStderr
[
2
]
;
/* parent-child communication ( child stderr ) */
std
::
array
<
int
,
2
>
pipeStderr
;
/* parent-child communication ( child stderr ) */
if
(
pipe
(
pipeAqlOutput
)
!=
0
)
if
(
pipe
(
pipeAqlOutput
.
data
(
)
)
!=
0
)
throw
std
::
runtime_error
(
"TimeoutAqlTest: Failed to initialize pipe (aql output)"
);
throw
std
::
runtime_error
(
"TimeoutAqlTest: Failed to initialize pipe (aql output)"
);
if
(
pipe
(
pipeStdout
)
!=
0
)
if
(
pipe
(
pipeStdout
.
data
(
)
)
!=
0
)
throw
std
::
runtime_error
(
"TimeoutAqlTest: Failed to initialize pipe (child stdout)"
);
throw
std
::
runtime_error
(
"TimeoutAqlTest: Failed to initialize pipe (child stdout)"
);
if
(
pipe
(
pipeStderr
)
!=
0
)
if
(
pipe
(
pipeStderr
.
data
(
)
)
!=
0
)
throw
std
::
runtime_error
(
"TimeoutAqlTest: Failed to initialize pipe (child stderr)"
);
throw
std
::
runtime_error
(
"TimeoutAqlTest: Failed to initialize pipe (child stderr)"
);
/* SIGCHLD was not yet raised, initialize communication pipe */
/* SIGCHLD was not yet raised, initialize communication pipe */
g_RecvSignal
=
0
;
g_RecvSignal
=
false
;
if
(
pipe
(
g_Wakeup
)
)
if
(
pipe
(
g_Wakeup
.
data
(
)
)
)
throw
std
::
runtime_error
(
"TimeoutAqlTest: Failed to initialize pipe (wakeup signalling)"
);
throw
std
::
runtime_error
(
"TimeoutAqlTest: Failed to initialize pipe (wakeup signalling)"
);
/* random seed for aql */
/* random seed for aql */
...
@@ -238,18 +238,18 @@ std::string printTest ( const std::vector < std::string > & queries ) {
...
@@ -238,18 +238,18 @@ std::string printTest ( const std::vector < std::string > & queries ) {
return
oss
.
str
(
);
return
oss
.
str
(
);
}
}
void
_
TimeoutAqlTest
(
const
std
::
chrono
::
microseconds
&
timeout
,
const
std
::
filesystem
::
path
&
file
,
bool
timeoutError
)
{
void
TimeoutAqlTest
Int
(
const
std
::
chrono
::
microseconds
&
timeout
,
const
std
::
filesystem
::
path
&
file
,
bool
timeoutError
)
{
std
::
ifstream
ifs
(
file
);
std
::
ifstream
ifs
(
file
);
REQUIRE
(
ifs
.
is_open
(
)
);
REQUIRE
(
ifs
.
is_open
(
)
);
auto
testChildStatus
=
_
TimeoutAqlTestImpl
(
timeout
,
ifs
);
auto
testChildStatus
=
TimeoutAqlTestImpl
(
timeout
,
ifs
);
processTestChildStatus
(
testChildStatus
,
timeout
,
timeoutError
,
printTest
(
file
)
);
processTestChildStatus
(
testChildStatus
,
timeout
,
timeoutError
,
printTest
(
file
)
);
}
}
void
_
TimeoutAqlTest
(
const
std
::
chrono
::
microseconds
&
timeout
,
const
std
::
vector
<
std
::
string
>
&
queries
,
bool
timeoutError
)
{
void
TimeoutAqlTest
Int
(
const
std
::
chrono
::
microseconds
&
timeout
,
const
std
::
vector
<
std
::
string
>
&
queries
,
bool
timeoutError
)
{
std
::
stringstream
ifs
;
std
::
stringstream
ifs
;
for
(
const
auto
&
q
:
queries
)
for
(
const
auto
&
q
:
queries
)
ifs
<<
q
<<
"
\n
"
;
ifs
<<
q
<<
"
\n
"
;
auto
testChildStatus
=
_
TimeoutAqlTestImpl
(
timeout
,
ifs
);
auto
testChildStatus
=
TimeoutAqlTestImpl
(
timeout
,
ifs
);
processTestChildStatus
(
testChildStatus
,
timeout
,
timeoutError
,
printTest
(
queries
)
);
processTestChildStatus
(
testChildStatus
,
timeout
,
timeoutError
,
printTest
(
queries
)
);
}
}
This diff is collapsed.
Click to expand it.
tests/testing/TimeoutAqlTest.hpp
+
4
−
4
View file @
96aa70a1
...
@@ -7,8 +7,8 @@
...
@@ -7,8 +7,8 @@
using
namespace
std
::
literals
::
chrono_literals
;
using
namespace
std
::
literals
::
chrono_literals
;
void
_
TimeoutAqlTest
(
const
std
::
chrono
::
microseconds
&
timeout
,
const
std
::
filesystem
::
path
&
file
,
bool
timeoutError
);
void
TimeoutAqlTest
Int
(
const
std
::
chrono
::
microseconds
&
timeout
,
const
std
::
filesystem
::
path
&
file
,
bool
timeoutError
);
void
_
TimeoutAqlTest
(
const
std
::
chrono
::
microseconds
&
timeout
,
const
std
::
vector
<
std
::
string
>
&
queries
,
bool
timeoutError
);
void
TimeoutAqlTest
Int
(
const
std
::
chrono
::
microseconds
&
timeout
,
const
std
::
vector
<
std
::
string
>
&
queries
,
bool
timeoutError
);
/**
/**
*
@
param
timeout
timeout
(
use
std
chrono
literals
)
ofthe
test
*
@
param
timeout
timeout
(
use
std
chrono
literals
)
ofthe
test
...
@@ -17,7 +17,7 @@ void _TimeoutAqlTest ( const std::chrono::microseconds & timeout, const std::vec
...
@@ -17,7 +17,7 @@ void _TimeoutAqlTest ( const std::chrono::microseconds & timeout, const std::vec
*/
*/
template
<
class
D
>
template
<
class
D
>
void
TimeoutAqlTest
(
const
D
&
timeout
,
const
std
::
vector
<
std
::
string
>
&
queries
,
bool
timeoutError
=
false
)
{
void
TimeoutAqlTest
(
const
D
&
timeout
,
const
std
::
vector
<
std
::
string
>
&
queries
,
bool
timeoutError
=
false
)
{
_
TimeoutAqlTest
(
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
timeout
),
queries
,
timeoutError
);
TimeoutAqlTest
Int
(
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
timeout
),
queries
,
timeoutError
);
}
}
/**
/**
...
@@ -27,5 +27,5 @@ void TimeoutAqlTest ( const D & timeout, const std::vector < std::string > & que
...
@@ -27,5 +27,5 @@ void TimeoutAqlTest ( const D & timeout, const std::vector < std::string > & que
*/
*/
template
<
class
D
>
template
<
class
D
>
void
TimeoutAqlTest
(
const
D
&
timeout
,
const
std
::
filesystem
::
path
&
file
,
bool
timeoutError
)
{
void
TimeoutAqlTest
(
const
D
&
timeout
,
const
std
::
filesystem
::
path
&
file
,
bool
timeoutError
)
{
_
TimeoutAqlTest
(
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
timeout
),
file
,
timeoutError
);
TimeoutAqlTest
Int
(
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
timeout
),
file
,
timeoutError
);
}
}
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