Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
fbeb7a1a
Unverified
Commit
fbeb7a1a
authored
Jul 03, 2018
by
2xsec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: cleanup concurrent.c
Signed-off-by:
2xsec
<
dh48.jeong@samsung.com
>
parent
1c95b732
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
concurrent.c
src/tests/concurrent.c
+14
-1
No files found.
src/tests/concurrent.c
View file @
fbeb7a1a
...
@@ -71,13 +71,14 @@ struct thread_args {
...
@@ -71,13 +71,14 @@ struct thread_args {
static
void
do_function
(
void
*
arguments
)
static
void
do_function
(
void
*
arguments
)
{
{
char
name
[
NAME_MAX
+
1
];
char
name
[
NAME_MAX
+
1
];
struct
thread_args
*
args
=
arguments
;
struct
thread_args
*
args
=
arguments
;
struct
lxc_container
*
c
;
struct
lxc_container
*
c
;
sprintf
(
name
,
"lxc-test-concurrent-%d"
,
args
->
thread_id
);
sprintf
(
name
,
"lxc-test-concurrent-%d"
,
args
->
thread_id
);
args
->
return_code
=
1
;
args
->
return_code
=
1
;
c
=
lxc_container_new
(
name
,
NULL
);
c
=
lxc_container_new
(
name
,
NULL
);
if
(
!
c
)
{
if
(
!
c
)
{
fprintf
(
stderr
,
"Unable to instantiate container (%s)
\n
"
,
name
);
fprintf
(
stderr
,
"Unable to instantiate container (%s)
\n
"
,
name
);
...
@@ -97,14 +98,17 @@ static void do_function(void *arguments)
...
@@ -97,14 +98,17 @@ static void do_function(void *arguments)
}
else
if
(
strcmp
(
args
->
mode
,
"start"
)
==
0
)
{
}
else
if
(
strcmp
(
args
->
mode
,
"start"
)
==
0
)
{
if
(
c
->
is_defined
(
c
)
&&
!
c
->
is_running
(
c
))
{
if
(
c
->
is_defined
(
c
)
&&
!
c
->
is_running
(
c
))
{
c
->
want_daemonize
(
c
,
true
);
c
->
want_daemonize
(
c
,
true
);
if
(
!
c
->
start
(
c
,
false
,
NULL
))
{
if
(
!
c
->
start
(
c
,
false
,
NULL
))
{
fprintf
(
stderr
,
"Starting the container (%s) failed...
\n
"
,
name
);
fprintf
(
stderr
,
"Starting the container (%s) failed...
\n
"
,
name
);
goto
out
;
goto
out
;
}
}
if
(
!
c
->
wait
(
c
,
"RUNNING"
,
15
))
{
if
(
!
c
->
wait
(
c
,
"RUNNING"
,
15
))
{
fprintf
(
stderr
,
"Waiting the container (%s) to start failed...
\n
"
,
name
);
fprintf
(
stderr
,
"Waiting the container (%s) to start failed...
\n
"
,
name
);
goto
out
;
goto
out
;
}
}
sleep
(
delay
);
sleep
(
delay
);
}
}
}
else
if
(
strcmp
(
args
->
mode
,
"stop"
)
==
0
)
{
}
else
if
(
strcmp
(
args
->
mode
,
"stop"
)
==
0
)
{
...
@@ -113,6 +117,7 @@ static void do_function(void *arguments)
...
@@ -113,6 +117,7 @@ static void do_function(void *arguments)
fprintf
(
stderr
,
"Stopping the container (%s) failed...
\n
"
,
name
);
fprintf
(
stderr
,
"Stopping the container (%s) failed...
\n
"
,
name
);
goto
out
;
goto
out
;
}
}
if
(
!
c
->
wait
(
c
,
"STOPPED"
,
15
))
{
if
(
!
c
->
wait
(
c
,
"STOPPED"
,
15
))
{
fprintf
(
stderr
,
"Waiting the container (%s) to stop failed...
\n
"
,
name
);
fprintf
(
stderr
,
"Waiting the container (%s) to stop failed...
\n
"
,
name
);
goto
out
;
goto
out
;
...
@@ -126,9 +131,12 @@ static void do_function(void *arguments)
...
@@ -126,9 +131,12 @@ static void do_function(void *arguments)
}
}
}
}
}
}
args
->
return_code
=
0
;
args
->
return_code
=
0
;
out:
out:
lxc_container_put
(
c
);
lxc_container_put
(
c
);
if
(
debug
)
if
(
debug
)
lxc_log_close
();
lxc_log_close
();
}
}
...
@@ -189,6 +197,7 @@ int main(int argc, char *argv[]) {
...
@@ -189,6 +197,7 @@ int main(int argc, char *argv[]) {
}
}
modes
[
i
]
=
tok
;
modes
[
i
]
=
tok
;
}
}
if
(
modes
)
if
(
modes
)
modes
[
i
]
=
NULL
;
modes
[
i
]
=
NULL
;
break
;
break
;
...
@@ -208,6 +217,7 @@ int main(int argc, char *argv[]) {
...
@@ -208,6 +217,7 @@ int main(int argc, char *argv[]) {
for
(
iter
=
1
;
iter
<=
iterations
;
iter
++
)
{
for
(
iter
=
1
;
iter
<=
iterations
;
iter
++
)
{
int
fd
;
int
fd
;
fd
=
open
(
"/"
,
O_RDONLY
);
fd
=
open
(
"/"
,
O_RDONLY
);
if
(
fd
<
0
)
{
if
(
fd
<
0
)
{
fprintf
(
stderr
,
"Failed to open /
\n
"
);
fprintf
(
stderr
,
"Failed to open /
\n
"
);
...
@@ -216,11 +226,13 @@ int main(int argc, char *argv[]) {
...
@@ -216,11 +226,13 @@ int main(int argc, char *argv[]) {
if
(
!
quiet
)
if
(
!
quiet
)
printf
(
"
\n
Iteration %d/%d maxfd:%d
\n
"
,
iter
,
iterations
,
fd
);
printf
(
"
\n
Iteration %d/%d maxfd:%d
\n
"
,
iter
,
iterations
,
fd
);
close
(
fd
);
close
(
fd
);
for
(
i
=
0
;
modes
[
i
];
i
++
)
{
for
(
i
=
0
;
modes
[
i
];
i
++
)
{
if
(
!
quiet
)
if
(
!
quiet
)
printf
(
"Executing (%s) for %d containers...
\n
"
,
modes
[
i
],
nthreads
);
printf
(
"Executing (%s) for %d containers...
\n
"
,
modes
[
i
],
nthreads
);
for
(
j
=
0
;
j
<
nthreads
;
j
++
)
{
for
(
j
=
0
;
j
<
nthreads
;
j
++
)
{
args
[
j
].
thread_id
=
j
;
args
[
j
].
thread_id
=
j
;
args
[
j
].
mode
=
modes
[
i
];
args
[
j
].
mode
=
modes
[
i
];
...
@@ -242,6 +254,7 @@ int main(int argc, char *argv[]) {
...
@@ -242,6 +254,7 @@ int main(int argc, char *argv[]) {
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
}
if
(
args
[
j
].
return_code
)
{
if
(
args
[
j
].
return_code
)
{
fprintf
(
stderr
,
"thread returned error %d
\n
"
,
args
[
j
].
return_code
);
fprintf
(
stderr
,
"thread returned error %d
\n
"
,
args
[
j
].
return_code
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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