Commit 6d52d6ee authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

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: 's avatarAndrew Vagin <avagin@openvz.org>
Acked-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 16923109
...@@ -798,12 +798,15 @@ EOF ...@@ -798,12 +798,15 @@ EOF
# Here we may have two cases: either checkpoint is failed # Here we may have two cases: either checkpoint is failed
# with some error code, or checkpoint is complete but return # with some error code, or checkpoint is complete but return
# code is non-zero because of post dump action. # 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
if echo $TEST_EXPECTED_FAILURE | grep -q $tname; then echo "Expect dump falure: $retcode"
echo "Got expected dump failure" if [ "$retcode" -eq 0 ]; then
return 0 return 1
fi fi
dump_only=1
retcode=32
fi
if [ "$retcode" -ne 0 ] && [[ "$retcode" -ne 32 || -z "$dump_only" ]]; then
if [ $BATCH_TEST -eq 0 ]; then if [ $BATCH_TEST -eq 0 ]; then
echo WARNING: $tname returned $retcode and left running for debug needs echo WARNING: $tname returned $retcode and left running for debug needs
else else
...@@ -811,7 +814,6 @@ EOF ...@@ -811,7 +814,6 @@ EOF
fi fi
return 1 return 1
fi fi
cat $ddump/dump.log* | grep Error
if [ -n "$SNAPSHOT" ]; then if [ -n "$SNAPSHOT" ]; then
snappdir=../`basename $ddump` snappdir=../`basename $ddump`
......
...@@ -8,19 +8,19 @@ ...@@ -8,19 +8,19 @@
#include <linux/limits.h> #include <linux/limits.h>
#include <pthread.h> #include <pthread.h>
#include <syscall.h> #include <syscall.h>
#include <sys/socket.h>
#include "zdtmtst.h" #include "zdtmtst.h"
const char *test_doc = "Check that threads with different creds aren't checkpointed"; const char *test_doc = "Check that threads with different creds aren't checkpointed";
const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>"; 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) void *drop_caps_and_wait(void *arg)
{ {
int fd = *((int *) arg);
void *retcode = (void *)0xdeadbeaf;
cap_t caps; cap_t caps;
int *pipe = arg; char c;
caps = cap_get_proc(); caps = cap_get_proc();
if (!caps) { if (!caps) {
...@@ -38,41 +38,45 @@ void *drop_caps_and_wait(void *arg) ...@@ -38,41 +38,45 @@ void *drop_caps_and_wait(void *arg)
goto die; goto die;
} }
close(*pipe); if (write(fd, "a", 1) != 1) {
err("Unable to send a status");
goto die;
}
if (read(fd, &c, 1) != 1) {
err("Unable to read a status");
goto die;
}
while(1) retcode = NULL;
sleep(1000);
die: die:
cap_free(caps); cap_free(caps);
return NULL; return retcode;
} }
int main(int argc, char ** argv) int main(int argc, char ** argv)
{ {
int ret, pipefd[2]; int pipefd[2];
pthread_t thr; pthread_t thr;
char c;
char buf; void *retcode;
test_init(argc, argv); test_init(argc, argv);
if (pipe(pipefd) < 0) { if (socketpair(AF_FILE, SOCK_SEQPACKET, 0, pipefd)) {
err("pipe"); err("pipe");
return -1; 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"); err("Unable to create thread");
return -1; return -1;
} }
close(pipefd[1]);
/* /*
* Wait for child to signal us that it has droped caps. * Wait for child to signal us that it has droped caps.
*/ */
ret = read(pipefd[0], &buf, 1); if (read(pipefd[1], &c, 1) != 1) {
close(pipefd[0]);
if (ret < 0) {
err("read"); err("read");
return 1; return 1;
} }
...@@ -80,8 +84,19 @@ int main(int argc, char ** argv) ...@@ -80,8 +84,19 @@ int main(int argc, char ** argv)
test_daemon(); test_daemon();
test_waitsig(); test_waitsig();
fail("shouldn't dump successfully"); if (write(pipefd[1], &c, 1) != 1) {
err("write");
return 1;
}
if (pthread_join(thr, &retcode)) {
err("Unable to jount a thread");
return 1;
}
if (retcode != NULL)
return 1;
pass();
exit_group(ret); return 0;
return 1;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment