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
4baff50c
Commit
4baff50c
authored
Jan 16, 2012
by
Cyrill Gorcunov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zdtm: Add pthread00 test
Signed-off-by:
Cyrill Gorcunov
<
gorcunov@openvz.org
>
parent
8cc08ada
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
353 additions
and
64 deletions
+353
-64
zdtm.sh
test/zdtm.sh
+1
-0
Makefile
test/zdtm/live/static/Makefile
+66
-64
pthread00.c
test/zdtm/live/static/pthread00.c
+286
-0
No files found.
test/zdtm.sh
View file @
4baff50c
...
...
@@ -16,6 +16,7 @@ $ZP/static/write_read00
$ZP
/static/write_read01
$ZP
/static/write_read02
$ZP
/static/wait00
$ZP
/static/pthread00
$ZP
/static/file_shared
$ZP
/streaming/pipe_loop00
$ZP
/streaming/pipe_shared00
...
...
test/zdtm/live/static/Makefile
View file @
4baff50c
...
...
@@ -3,66 +3,67 @@ LIB = $(LIBDIR)/libzdtmtst.a
override
CPPFLAGS
+=
-I
$(LIBDIR)
CFLAGS
=
-g
-O2
-Wall
TST_NOFILE
=
\
busyloop00
\
sleeping00
\
pid00
\
wait00
\
zombie00
\
fpu00
\
futex
\
mmx00
\
sse00
\
sse20
\
mprotect00
\
timers
\
unbound_sock
\
socket_aio
\
msgque
\
inotify_system
\
inotify_system_nodel
\
shm
\
ptrace_sig
\
pipe00
\
# jobctl00
\
TST_FILE
=
\
write_read00
\
write_read01
\
write_read02
\
write_read10
\
maps00
\
link10
\
file_attr
\
deleted_unix_sock
\
deleted_dev
\
unlink_fstat00
\
unlink_fstat01
\
unlink_largefile
\
mtime_mmap
\
fifo
\
fifo_wronly
\
unlink_fifo
\
unlink_fifo_wronly
\
file_shared
\
TST_DIR
=
\
cwd00
\
overmount_dev
\
overmount_file
\
overmount_fifo
\
overmount_sock
\
TST
=
\
$(TST_NOFILE)
\
$(TST_FILE)
\
$(TST_DIR)
\
env00
\
umask00
\
TST_STATE
=
\
conntracks
\
route_rules
\
TST_NOFILE
=
\
busyloop00
\
sleeping00
\
pid00
\
wait00
\
zombie00
\
fpu00
\
futex
\
mmx00
\
sse00
\
sse20
\
mprotect00
\
timers
\
unbound_sock
\
socket_aio
\
msgque
\
inotify_system
\
inotify_system_nodel
\
shm
\
ptrace_sig
\
pipe00
\
pthread00
\
# jobctl00
\
TST_FILE
=
\
write_read00
\
write_read01
\
write_read02
\
write_read10
\
maps00
\
link10
\
file_attr
\
deleted_unix_sock
\
deleted_dev
\
unlink_fstat00
\
unlink_fstat01
\
unlink_largefile
\
mtime_mmap
\
fifo
\
fifo_wronly
\
unlink_fifo
\
unlink_fifo_wronly
\
file_shared
\
TST_DIR
=
\
cwd00
\
overmount_dev
\
overmount_file
\
overmount_fifo
\
overmount_sock
\
TST
=
\
$(TST_NOFILE)
\
$(TST_FILE)
\
$(TST_DIR)
\
env00
\
umask00
\
TST_STATE
=
\
conntracks
\
route_rules
\
SRC
=
$
(
TST:%
=
%.c
)
...
...
@@ -125,12 +126,13 @@ wait_stop:
$(TST)
:
$(LIB)
futex.o
:
override CFLAGS += -pthread
futex
:
override LDFLAGS += -pthread
jobctl00
:
override LDLIBS += -lutil
socket_aio
:
override LDLIBS += -lrt
futex.o
:
override CFLAGS += -pthread
futex
:
override LDFLAGS += -pthread
jobctl00
:
override LDLIBS += -lutil
socket_aio
:
override LDLIBS += -lrt
unlink_largefile
:
override CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
inotify_system_nodel
:
override CFLAGS += -DNODEL
pthread00
:
override LDLIBS += -pthread
$(LIB)
:
force
$(MAKE)
-C
$(LIBDIR)
...
...
test/zdtm/live/static/pthread00.c
0 → 100644
View file @
4baff50c
/*
* A simple testee program with threads
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <pthread.h>
#include "zdtmtst.h"
#define gettid() pthread_self()
const
char
*
test_doc
=
"Create a few pthreads/forks and compare TLS and mmap data on restore
\n
"
;
const
char
*
test_author
=
"Cyrill Gorcunov <gorcunov@openvz.org"
;
static
pthread_mutex_t
mtx
=
PTHREAD_MUTEX_INITIALIZER
;
static
__thread
char
tls_data
[
10
];
#define TRANSITION_CREATED 1
#define TRANSITION_STARTED 2
#define TRANSITION_PASSED 4
#define TRANSITION_FAILED 8
#define MAP(map, i) (((int *)map)[i])
#define SET_CREATED(map, i) MAP(map, i) |= TRANSITION_CREATED
#define SET_STARTED(map, i) MAP(map, i) |= TRANSITION_STARTED
#define SET_PASSED(map, i) MAP(map, i) |= TRANSITION_PASSED
#define SET_FAILED(map, i) MAP(map, i) |= TRANSITION_FAILED
#define IS_CREATED(map, i) (MAP(map, i) & TRANSITION_CREATED)
#define IS_STARTED(map, i) (MAP(map, i) & TRANSITION_STARTED)
#define IS_PASSED(map, i) (MAP(map, i) & TRANSITION_PASSED)
#define IS_FAILED(map, i) (MAP(map, i) & TRANSITION_FAILED)
static
void
*
ff1
(
void
*
map
)
{
char
__tls_data
[
10
]
=
"1122334455"
;
pid_t
pid
;
int
status
;
memcpy
(
tls_data
,
__tls_data
,
sizeof
(
tls_data
));
pid
=
test_fork
();
if
(
pid
<
0
)
{
exit
(
1
);
}
else
if
(
pid
==
0
)
{
SET_CREATED
(
map
,
4
);
while
(
1
)
{
int
ret
=
0
;
pthread_mutex_lock
(
&
mtx
);
if
(
memcmp
(
tls_data
,
__tls_data
,
sizeof
(
tls_data
)))
ret
=
1
;
pthread_mutex_unlock
(
&
mtx
);
if
(
ret
)
{
if
(
IS_STARTED
(
map
,
4
))
{
SET_FAILED
(
map
,
4
);
exit
(
4
);
}
}
else
{
if
(
IS_STARTED
(
map
,
4
))
{
SET_PASSED
(
map
,
4
);
exit
(
4
);
}
}
sleep
(
1
);
}
}
SET_CREATED
(
map
,
5
);
while
(
1
)
{
int
ret
=
0
;
pthread_mutex_lock
(
&
mtx
);
if
(
memcmp
(
tls_data
,
__tls_data
,
sizeof
(
tls_data
)))
ret
=
1
;
pthread_mutex_unlock
(
&
mtx
);
if
(
ret
)
{
if
(
IS_STARTED
(
map
,
5
))
SET_FAILED
(
map
,
5
);
}
else
{
SET_PASSED
(
map
,
5
);
}
if
(
IS_STARTED
(
map
,
5
))
break
;
sleep
(
1
);
}
test_msg
(
"Waiting for %d
\n
"
,
pid
);
waitpid
(
pid
,
&
status
,
P_ALL
);
return
NULL
;
}
static
void
*
f1
(
void
*
map
)
{
char
__tls_data
[
10
]
=
"3122131212"
;
pthread_t
th
;
pid_t
pid
;
int
status
;
memcpy
(
tls_data
,
__tls_data
,
sizeof
(
tls_data
));
if
(
pthread_create
(
&
th
,
NULL
,
&
ff1
,
map
))
perror
(
"Cant create thread"
);
pid
=
test_fork
();
if
(
pid
<
0
)
{
fail
(
"Failed to test_fork()
\n
"
);
exit
(
1
);
}
else
if
(
pid
==
0
)
{
SET_CREATED
(
map
,
2
);
while
(
1
)
{
int
ret
=
0
;
pthread_mutex_lock
(
&
mtx
);
if
(
memcmp
(
tls_data
,
__tls_data
,
sizeof
(
tls_data
)))
ret
=
1
;
pthread_mutex_unlock
(
&
mtx
);
if
(
ret
)
{
if
(
IS_STARTED
(
map
,
2
))
{
SET_FAILED
(
map
,
2
);
exit
(
2
);
}
}
else
{
if
(
IS_STARTED
(
map
,
2
))
{
SET_PASSED
(
map
,
2
);
exit
(
2
);
}
}
sleep
(
1
);
}
}
SET_CREATED
(
map
,
3
);
while
(
1
)
{
int
ret
=
0
;
pthread_mutex_lock
(
&
mtx
);
if
(
memcmp
(
tls_data
,
__tls_data
,
sizeof
(
tls_data
)))
ret
=
1
;
pthread_mutex_unlock
(
&
mtx
);
if
(
ret
)
{
if
(
IS_STARTED
(
map
,
3
))
SET_FAILED
(
map
,
3
);
}
else
{
SET_PASSED
(
map
,
3
);
}
if
(
IS_STARTED
(
map
,
3
))
break
;
sleep
(
1
);
}
pthread_join
(
th
,
NULL
);
test_msg
(
"Waiting for %d
\n
"
,
pid
);
waitpid
(
pid
,
&
status
,
P_ALL
);
return
NULL
;
}
static
void
*
f2
(
void
*
map
)
{
char
__tls_data
[
10
]
=
"wasdfrdgdc"
;
pid_t
pid
;
int
status
;
memcpy
(
tls_data
,
__tls_data
,
sizeof
(
tls_data
));
pid
=
test_fork
();
if
(
pid
<
0
)
{
fail
(
"Failed to test_fork()
\n
"
);
exit
(
1
);
}
else
if
(
pid
==
0
)
{
SET_CREATED
(
map
,
0
);
while
(
1
)
{
int
ret
=
0
;
pthread_mutex_lock
(
&
mtx
);
if
(
memcmp
(
tls_data
,
__tls_data
,
sizeof
(
tls_data
)))
ret
=
1
;
pthread_mutex_unlock
(
&
mtx
);
if
(
ret
)
{
if
(
IS_STARTED
(
map
,
0
))
{
SET_FAILED
(
map
,
0
);
exit
(
0
);
}
}
else
{
if
(
IS_STARTED
(
map
,
0
))
{
SET_PASSED
(
map
,
0
);
exit
(
0
);
}
}
sleep
(
1
);
}
}
SET_CREATED
(
map
,
1
);
while
(
1
)
{
int
ret
=
0
;
pthread_mutex_lock
(
&
mtx
);
if
(
memcmp
(
tls_data
,
__tls_data
,
sizeof
(
tls_data
)))
ret
=
1
;
pthread_mutex_unlock
(
&
mtx
);
if
(
ret
)
{
if
(
IS_STARTED
(
map
,
1
))
SET_FAILED
(
map
,
1
);
}
else
{
SET_PASSED
(
map
,
1
);
}
if
(
IS_STARTED
(
map
,
1
))
break
;
sleep
(
1
);
}
test_msg
(
"Waiting for %d
\n
"
,
pid
);
waitpid
(
pid
,
&
status
,
P_ALL
);
return
NULL
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
pthread_t
th1
,
th2
;
int
rc1
,
rc2
;
void
*
map
;
test_init
(
argc
,
argv
);
test_msg
(
"%s pid %d
\n
"
,
argv
[
0
],
getpid
());
map
=
mmap
(
NULL
,
1024
,
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
|
MAP_ANONYMOUS
,
-
1
,
0
);
if
(
map
==
MAP_FAILED
)
{
fail
(
"Can't map"
);
exit
(
1
);
}
rc1
=
pthread_create
(
&
th1
,
NULL
,
&
f1
,
map
);
rc2
=
pthread_create
(
&
th2
,
NULL
,
&
f2
,
map
);
if
(
rc1
|
rc2
)
{
fail
(
"Can't pthread_create"
);
exit
(
1
);
}
test_msg
(
"Waiting until all threads are created
\n
"
);
for
(;;)
{
if
(
IS_CREATED
(
map
,
0
)
&&
IS_CREATED
(
map
,
1
)
&&
IS_CREATED
(
map
,
2
)
&&
IS_CREATED
(
map
,
3
)
&&
IS_CREATED
(
map
,
4
)
&&
IS_CREATED
(
map
,
5
))
break
;
sleep
(
1
);
}
SET_STARTED
(
map
,
0
);
SET_STARTED
(
map
,
1
);
SET_STARTED
(
map
,
2
);
SET_STARTED
(
map
,
3
);
SET_STARTED
(
map
,
4
);
SET_STARTED
(
map
,
5
);
test_daemon
();
test_waitsig
();
test_msg
(
"Waiting while all threads are joined
\n
"
);
pthread_join
(
th1
,
NULL
);
pthread_join
(
th2
,
NULL
);
if
(
IS_PASSED
(
map
,
0
)
&&
IS_PASSED
(
map
,
1
)
&&
IS_PASSED
(
map
,
2
)
&&
IS_PASSED
(
map
,
3
)
&&
IS_PASSED
(
map
,
4
)
&&
IS_PASSED
(
map
,
5
))
pass
();
else
fail
();
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