mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-23 10:09:57 +00:00
zdtm: check a test result for static/different_creds
CRIU should not affect process states when it can't dump them. Cc: Tycho Andersen <tycho.andersen@canonical.com> Signed-off-by: Andrew Vagin <avagin@openvz.org> Acked-by: Tycho Andersen <tycho.andersen@canonical.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
16923109c6
commit
6d52d6ee21
2 changed files with 43 additions and 26 deletions
14
test/zdtm.sh
14
test/zdtm.sh
|
|
@ -798,12 +798,15 @@ EOF
|
|||
# Here we may have two cases: either checkpoint is failed
|
||||
# with some error code, or checkpoint is complete but return
|
||||
# code is non-zero because of post dump action.
|
||||
if [ "$retcode" -ne 0 ] && [[ "$retcode" -ne 32 || -z "$dump_only" ]]; then
|
||||
if echo $TEST_EXPECTED_FAILURE | grep -q $tname; then
|
||||
echo "Got expected dump failure"
|
||||
return 0
|
||||
if echo $TEST_EXPECTED_FAILURE | grep -q $tname; then
|
||||
echo "Expect dump falure: $retcode"
|
||||
if [ "$retcode" -eq 0 ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
dump_only=1
|
||||
retcode=32
|
||||
fi
|
||||
if [ "$retcode" -ne 0 ] && [[ "$retcode" -ne 32 || -z "$dump_only" ]]; then
|
||||
if [ $BATCH_TEST -eq 0 ]; then
|
||||
echo WARNING: $tname returned $retcode and left running for debug needs
|
||||
else
|
||||
|
|
@ -811,7 +814,6 @@ EOF
|
|||
fi
|
||||
return 1
|
||||
fi
|
||||
cat $ddump/dump.log* | grep Error
|
||||
|
||||
if [ -n "$SNAPSHOT" ]; then
|
||||
snappdir=../`basename $ddump`
|
||||
|
|
|
|||
|
|
@ -8,19 +8,19 @@
|
|||
#include <linux/limits.h>
|
||||
#include <pthread.h>
|
||||
#include <syscall.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "zdtmtst.h"
|
||||
|
||||
const char *test_doc = "Check that threads with different creds aren't checkpointed";
|
||||
const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>";
|
||||
|
||||
#define exit_group(code) \
|
||||
syscall(__NR_exit_group, code)
|
||||
|
||||
void *drop_caps_and_wait(void *arg)
|
||||
{
|
||||
int fd = *((int *) arg);
|
||||
void *retcode = (void *)0xdeadbeaf;
|
||||
cap_t caps;
|
||||
int *pipe = arg;
|
||||
char c;
|
||||
|
||||
caps = cap_get_proc();
|
||||
if (!caps) {
|
||||
|
|
@ -38,41 +38,45 @@ void *drop_caps_and_wait(void *arg)
|
|||
goto die;
|
||||
}
|
||||
|
||||
close(*pipe);
|
||||
if (write(fd, "a", 1) != 1) {
|
||||
err("Unable to send a status");
|
||||
goto die;
|
||||
}
|
||||
|
||||
while(1)
|
||||
sleep(1000);
|
||||
if (read(fd, &c, 1) != 1) {
|
||||
err("Unable to read a status");
|
||||
goto die;
|
||||
}
|
||||
|
||||
retcode = NULL;
|
||||
die:
|
||||
cap_free(caps);
|
||||
return NULL;
|
||||
return retcode;
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
int ret, pipefd[2];
|
||||
int pipefd[2];
|
||||
pthread_t thr;
|
||||
|
||||
char buf;
|
||||
char c;
|
||||
void *retcode;
|
||||
|
||||
test_init(argc, argv);
|
||||
|
||||
if (pipe(pipefd) < 0) {
|
||||
if (socketpair(AF_FILE, SOCK_SEQPACKET, 0, pipefd)) {
|
||||
err("pipe");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pthread_create(&thr, NULL, drop_caps_and_wait, pipefd)) {
|
||||
if (pthread_create(&thr, NULL, drop_caps_and_wait, &pipefd[0])) {
|
||||
err("Unable to create thread");
|
||||
return -1;
|
||||
}
|
||||
close(pipefd[1]);
|
||||
|
||||
/*
|
||||
* Wait for child to signal us that it has droped caps.
|
||||
*/
|
||||
ret = read(pipefd[0], &buf, 1);
|
||||
close(pipefd[0]);
|
||||
if (ret < 0) {
|
||||
if (read(pipefd[1], &c, 1) != 1) {
|
||||
err("read");
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -80,8 +84,19 @@ int main(int argc, char ** argv)
|
|||
test_daemon();
|
||||
test_waitsig();
|
||||
|
||||
fail("shouldn't dump successfully");
|
||||
if (write(pipefd[1], &c, 1) != 1) {
|
||||
err("write");
|
||||
return 1;
|
||||
}
|
||||
|
||||
exit_group(ret);
|
||||
return 1;
|
||||
if (pthread_join(thr, &retcode)) {
|
||||
err("Unable to jount a thread");
|
||||
return 1;
|
||||
}
|
||||
if (retcode != NULL)
|
||||
return 1;
|
||||
|
||||
pass();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue