Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
criu
Project
Project
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
zhul
criu
Commits
48042e65
Commit
48042e65
authored
Oct 24, 2012
by
Pavel Emelyanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zdtm: Test for shutdown unix sockets
Signed-off-by:
Pavel Emelyanov
<
xemul@parallels.com
>
parent
84710812
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
152 additions
and
0 deletions
+152
-0
zdtm.sh
test/zdtm.sh
+1
-0
Makefile
test/zdtm/live/static/Makefile
+1
-0
sockets01.c
test/zdtm/live/static/sockets01.c
+150
-0
No files found.
test/zdtm.sh
View file @
48042e65
...
@@ -32,6 +32,7 @@ streaming/pipe_loop00
...
@@ -32,6 +32,7 @@ streaming/pipe_loop00
streaming/pipe_shared00
streaming/pipe_shared00
transition/file_read
transition/file_read
static/sockets00
static/sockets00
static/sockets01
static/sock_opts00
static/sock_opts00
static/sock_opts01
static/sock_opts01
static/sockets_spair
static/sockets_spair
...
...
test/zdtm/live/static/Makefile
View file @
48042e65
...
@@ -39,6 +39,7 @@ TST_NOFILE = \
...
@@ -39,6 +39,7 @@ TST_NOFILE = \
utsname
\
utsname
\
pstree
\
pstree
\
sockets00
\
sockets00
\
sockets01
\
sockets_spair
\
sockets_spair
\
sockets_dgram
\
sockets_dgram
\
socket_queues
\
socket_queues
\
...
...
test/zdtm/live/static/sockets01.c
0 → 100644
View file @
48042e65
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <sys/un.h>
#include <sys/stat.h>
#include <limits.h>
#include <fcntl.h>
#include "zdtmtst.h"
const
char
*
test_doc
=
"Test unix sockets shutdown"
;
const
char
*
test_author
=
"Pavel Emelyanov <xemul@parallels.com>"
;
#define fin(msg) do { err(msg); exit(1); } while (0)
#define ffin(msg) do { fail(msg); exit(1); } while (0)
#define TEST_MSG "test-message"
static
char
buf
[
sizeof
(
TEST_MSG
)];
int
main
(
int
argc
,
char
*
argv
[])
{
int
spu
[
2
],
spb
[
2
],
dpu
[
2
],
dpb
[
2
],
dpd
[
2
];
int
ret
;
test_init
(
argc
,
argv
);
signal
(
SIGPIPE
,
SIG_IGN
);
/* spu -- stream pair, unidirectional shutdown */
if
(
socketpair
(
PF_UNIX
,
SOCK_STREAM
,
0
,
spu
)
<
0
)
fin
(
"no stream pair 1"
);
if
(
shutdown
(
spu
[
0
],
SHUT_RD
)
<
0
)
fin
(
"no stream shutdown 1"
);
/* spb -- stream pair, bidirectional shutdown */
if
(
socketpair
(
PF_UNIX
,
SOCK_STREAM
,
0
,
spb
)
<
0
)
fin
(
"no stream pair 2"
);
if
(
shutdown
(
spb
[
0
],
SHUT_RDWR
)
<
0
)
fin
(
"no stream shutdown 2"
);
/* dpu -- dgram pair, one end read shutdown */
if
(
socketpair
(
PF_UNIX
,
SOCK_DGRAM
,
0
,
dpu
)
<
0
)
fin
(
"no dgram pair 1"
);
if
(
shutdown
(
dpu
[
0
],
SHUT_RD
)
<
0
)
fin
(
"no dgram shutdown 1"
);
/* dpb -- dgram pair, one end read-write shutdown */
if
(
socketpair
(
PF_UNIX
,
SOCK_DGRAM
,
0
,
dpb
)
<
0
)
fin
(
"no dgram pair 2"
);
if
(
shutdown
(
dpb
[
0
],
SHUT_RDWR
)
<
0
)
fin
(
"no dgram shutdown 2"
);
/* dpd -- dgram pair, one end write shutdown with data */
if
(
socketpair
(
PF_UNIX
,
SOCK_DGRAM
,
0
,
dpd
)
<
0
)
fin
(
"no dgram pair 3"
);
if
(
write
(
dpd
[
0
],
TEST_MSG
,
sizeof
(
TEST_MSG
))
<
0
)
fin
(
"no dgram write"
);
if
(
shutdown
(
dpd
[
0
],
SHUT_WR
)
<
0
)
fin
(
"no dgram shutdown 3"
);
test_daemon
();
test_waitsig
();
/*
* spu -- check that one direction is blocked and
* the other one is not
*/
ret
=
write
(
spu
[
0
],
TEST_MSG
,
sizeof
(
TEST_MSG
));
if
(
ret
<
0
)
ffin
(
"SU shutdown broken 1"
);
ret
=
read
(
spu
[
1
],
buf
,
sizeof
(
buf
));
if
(
ret
<
0
)
ffin
(
"SU shutdown broken 2"
);
ret
=
write
(
spu
[
1
],
TEST_MSG
,
sizeof
(
TEST_MSG
));
if
(
ret
>=
0
)
ffin
(
"SU shutdown broken 3"
);
/*
* spb -- check that both ends are off
*/
ret
=
write
(
spb
[
0
],
TEST_MSG
,
sizeof
(
TEST_MSG
));
if
(
ret
>=
0
)
ffin
(
"SB shutdown broken 1"
);
ret
=
write
(
spb
[
1
],
TEST_MSG
,
sizeof
(
TEST_MSG
));
if
(
ret
>=
0
)
ffin
(
"SB shutdown broken 2"
);
/*
* dpu -- check that one direction works, and
* the other does not
*/
ret
=
write
(
dpu
[
0
],
TEST_MSG
,
sizeof
(
TEST_MSG
));
if
(
ret
<
0
)
ffin
(
"DU shutdown broken 1"
);
ret
=
read
(
dpu
[
1
],
buf
,
sizeof
(
buf
));
if
(
ret
<
0
)
ffin
(
"DU shutdown broken 2"
);
ret
=
write
(
dpu
[
1
],
TEST_MSG
,
sizeof
(
TEST_MSG
));
if
(
ret
>=
0
)
ffin
(
"DU shutdown broken 3"
);
/*
* dpb -- check that both ends are read
*/
ret
=
write
(
dpb
[
0
],
TEST_MSG
,
sizeof
(
TEST_MSG
));
if
(
ret
>=
0
)
ffin
(
"DB shutdown broken 1"
);
ret
=
write
(
dpb
[
1
],
TEST_MSG
,
sizeof
(
TEST_MSG
));
if
(
ret
>=
0
)
ffin
(
"DB shutdown broken 2"
);
/*
* dpd -- check that data is in there, but can't
* feed more
*/
ret
=
read
(
dpd
[
1
],
buf
,
sizeof
(
buf
));
if
(
ret
<
0
)
ffin
(
"DD shutdown nodata"
);
ret
=
write
(
dpd
[
0
],
TEST_MSG
,
sizeof
(
buf
));
if
(
ret
>=
0
)
ffin
(
"DB shutdown broken"
);
pass
();
return
0
;
}
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