Commit 022afe8b authored by Pavel Emelyanov's avatar Pavel Emelyanov

test: Clean old libcriu tests

New ones cover more and can be used in Jenkins
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent afa47b23
all: build/test test_sub test_self all: test_sub test_self
.PHONY: all .PHONY: all
run: all run: all
...@@ -16,12 +16,6 @@ test_self: test_self.o ...@@ -16,12 +16,6 @@ test_self: test_self.o
test_self.o: test_self.c test_self.o: test_self.c
gcc -c $^ -I ../../lib -o $@ gcc -c $^ -I ../../lib -o $@
build/test: build/test.o
gcc $^ -L ../../lib -lcriu -o $@
build/test.o: test.c
gcc -c $^ -I ../../lib -o $@
clean: clean:
rm -rf build test_sub test_sub.o test_self test_sub.o rm -rf test_sub test_sub.o test_self test_sub.o
.PHONY: clean .PHONY: clean
#!/bin/bash
while :; do
sleep 1
done
#!/bin/bash
source ../env.sh || exit 1
export PROTODIR=`readlink -f "${PWD}/../../protobuf"`
echo $PROTODIR
LOOP_PID=0
function title_print {
echo -e "\n**************************************************"
echo -e "\t\t"$1
echo -e "**************************************************\n"
}
function _exit {
if [ $1 -ne 0 ]; then
echo "FAIL"
fi
if [ $LOOP_PID -ne 0 ]; then
kill -SIGTERM $LOOP_PID
fi
title_print "Shutdown service server"
kill -SIGTERM `cat pidfile`
exit $1
}
function check_and_term {
title_print "Check and term $1"
ps -C $1
pkill $1
}
title_print "Build programs"
make clean
mkdir build
cd build
mkdir imgs_loop
mkdir imgs_test
make -C ../ || { echo "FAIL"; exit 1; }
title_print "Start service server"
${CRIU} service -v4 -o service.log --address criu_service.socket -d --pidfile `pwd`/pidfile || { echo "FAIL"; exit 1; }
title_print "Run loop.sh"
setsid ../loop.sh < /dev/null &> loop.log &
LOOP_PID=${!}
echo "pid ${LOOP_PID}"
title_print "Run test.c"
ln -s ../../../lib/libcriu.so libcriu.so.1
LD_LIBRARY_PATH=.
export LD_LIBRARY_PATH
./test ${LOOP_PID} || _exit $?
title_print "Restore test.c"
${CRIU} restore -v4 -o restore-test.log -D imgs_test --shell-job || _exit $?
_exit 0
#include "criu.h"
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
static void what_err_ret_mean(ret)
{
/* NOTE: errno is set by libcriu */
switch (ret) {
case -EBADE:
perror("RPC has returned fail");
break;
case -ECONNREFUSED:
perror("Unable to connect to CRIU");
break;
case -ECOMM:
perror("Unable to send/recv msg to/from CRIU");
break;
case -EINVAL:
perror("CRIU doesn't support this type of request."
"You should probably update CRIU");
break;
case -EBADMSG:
perror("Unexpected response from CRIU."
"You should probably update CRIU");
break;
default:
perror("Unknown error type code."
"You should probably update CRIU");
}
}
int main(int argc, char *argv[])
{
int ret, fd;
criu_set_service_address("criu_service.socket");
puts("--- Check ---");
ret = criu_check();
if (ret < 0) {
what_err_ret_mean(ret);
return -1;
} else
puts("Success");
puts("--- Dump loop ---");
criu_init_opts();
criu_set_pid(atoi(argv[1]));
criu_set_log_file("dump.log");
criu_set_log_level(4);
fd = open("imgs_loop", O_DIRECTORY);
criu_set_images_dir_fd(fd);
ret = criu_dump();
if (ret < 0) {
what_err_ret_mean(ret);
return -1;
} else if (ret == 0)
puts("Success");
puts("--- Restore loop ---");
criu_init_opts();
criu_set_log_level(4);
criu_set_log_file("restore.log");
criu_set_images_dir_fd(fd);
ret = criu_restore();
if (ret < 0) {
what_err_ret_mean(ret);
return -1;
} else if (ret > 0) {
puts("Success");
printf("pid %d\n", ret);
}
puts("--- Dump myself ---");
criu_init_opts();
criu_set_leave_running(true);
criu_set_shell_job(true);
criu_set_images_dir_fd(open("imgs_test", O_DIRECTORY));
ret = criu_dump();
if (ret < 0) {
what_err_ret_mean(ret);
return -1;
} else {
puts("Success");
if (ret == 1)
puts("Restored");
}
return 0;
}
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