Commit 714dfdb7 authored by Pavel Emelyanov's avatar Pavel Emelyanov

test: Add lib.c to libcriu tests

Just some common stuff.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 5d75c523
...@@ -4,18 +4,21 @@ all: test_sub test_self ...@@ -4,18 +4,21 @@ all: test_sub test_self
run: all run: all
./run.sh ./run.sh
test_sub: test_sub.o test_sub: test_sub.o lib.o
gcc $^ -L ../../lib -lcriu -o $@ gcc $^ -L ../../lib -lcriu -o $@
test_sub.o: test_sub.c test_sub.o: test_sub.c
gcc -c $^ -I ../../lib -o $@ gcc -c $^ -I ../../lib -o $@
test_self: test_self.o test_self: test_self.o lib.o
gcc $^ -L ../../lib -lcriu -o $@ gcc $^ -L ../../lib -lcriu -o $@
test_self.o: test_self.c test_self.o: test_self.c
gcc -c $^ -I ../../lib -o $@ gcc -c $^ -I ../../lib -o $@
lib.o: lib.c
gcc -c $^ -I ../../lib -o $@
clean: clean:
rm -rf 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
#include <stdio.h>
#include <errno.h>
#include <sys/wait.h>
void what_err_ret_mean(int 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 chk_exit(int status, int want)
{
if (WIFEXITED(status)) {
if (WEXITSTATUS(status) == want)
return 0;
printf(" `- FAIL (exit %d)\n", WEXITSTATUS(status));
} else if (WIFSIGNALED(status))
printf(" `- FAIL (die %d)\n", WTERMSIG(status));
else
printf(" `- FAIL (%#x)\n", status);
return 1;
}
void what_err_ret_mean(int ret);
int chk_exit(int status, int want);
...@@ -6,50 +6,7 @@ ...@@ -6,50 +6,7 @@
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
#include <sys/wait.h> #include <sys/wait.h>
#include "lib.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");
}
}
static inline int chk_exit(int status, int want)
{
if (WIFEXITED(status)) {
if (WEXITSTATUS(status) == want) {
printf(" `- Success\n");
return 0;
}
printf(" `- FAIL (exit %d)\n", WEXITSTATUS(status));
} else if (WIFSIGNALED(status))
printf(" `- FAIL (die %d)\n", WTERMSIG(status));
else
printf(" `- FAIL (%#x)\n", status);
return 1;
}
#define SUCC_DUMP_ECODE 41 #define SUCC_DUMP_ECODE 41
#define SUCC_RSTR_ECODE 43 #define SUCC_RSTR_ECODE 43
......
...@@ -4,48 +4,7 @@ ...@@ -4,48 +4,7 @@
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <signal.h> #include <signal.h>
#include "lib.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");
}
}
static inline int chk_exit(int status, int want)
{
if (WIFEXITED(status)) {
if (WEXITSTATUS(status) == want)
return 0;
printf(" `- FAIL (exit %d)\n", WEXITSTATUS(status));
} else if (WIFSIGNALED(status))
printf(" `- FAIL (die %d)\n", WTERMSIG(status));
else
printf(" `- FAIL (%#x)\n", status);
return 1;
}
static int stop = 0; static int stop = 0;
static void sh(int sig) static void sh(int sig)
......
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