mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-18 00:58:31 +00:00
tcp: Automate TCP stream c/r
This test is very basic :( Need more work on it. One note about --close arg to crtools -- bash leaves all fds open when laucnhing progams, and for restore this is critical, as one of them can be busy. Iterating over all the possibel fds and closing them is "do not want" thing. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
b2fced0601
commit
4debf589f6
2 changed files with 64 additions and 0 deletions
|
|
@ -356,6 +356,7 @@ int main(int argc, char *argv[])
|
|||
{ "ext-unix-sk", no_argument, 0, 'x' },
|
||||
{ "help", no_argument, 0, 'h' },
|
||||
{ SK_EST_PARAM, no_argument, 0, 42 },
|
||||
{ "close", required_argument, 0, 43 },
|
||||
{ },
|
||||
};
|
||||
|
||||
|
|
@ -423,6 +424,14 @@ int main(int argc, char *argv[])
|
|||
pr_info("Will dump TCP connections\n");
|
||||
opts.tcp_established_ok = true;
|
||||
break;
|
||||
case 43: {
|
||||
int fd;
|
||||
|
||||
fd = atoi(optarg);
|
||||
pr_info("Closing fd %d\n", fd);
|
||||
close(fd);
|
||||
break;
|
||||
}
|
||||
case 'h':
|
||||
default:
|
||||
goto usage;
|
||||
|
|
|
|||
55
test/tcp/run.sh
Normal file
55
test/tcp/run.sh
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
|
||||
PORT=12345
|
||||
CLN_PIPE="./clnt_pipe"
|
||||
SRV_LOG="./srv.log"
|
||||
CLN_LOG="./cln.log"
|
||||
DDIR="dump"
|
||||
CRTOOLS="../../crtools"
|
||||
|
||||
TEXT=$(hexdump -C /dev/urandom | head -n 1)
|
||||
|
||||
echo "Building services"
|
||||
|
||||
make clean && make || { echo "Failed to build"; exit 1; }
|
||||
rm -rf ${DDIR} ${SRV_LOG} ${CLN_LOG} ${CLN_PIPE}
|
||||
mkdir ${DDIR}
|
||||
|
||||
echo "Starting server"
|
||||
|
||||
setsid ./srv ${PORT} > ${SRV_LOG} 2>&1 &
|
||||
SRV_PID=${!}
|
||||
|
||||
echo "Starting pipe"
|
||||
mkfifo ${CLN_PIPE}
|
||||
|
||||
echo "Starting client"
|
||||
./cln "127.0.0.1" ${PORT} < ${CLN_PIPE} > ${CLN_LOG} &
|
||||
CLN_PID=${!}
|
||||
|
||||
exec 3>${CLN_PIPE}
|
||||
echo "Make it run"
|
||||
echo "${TEXT}" >&3
|
||||
|
||||
function fail {
|
||||
echo "$@"
|
||||
kill -9 ${CLN_PID}
|
||||
kill -9 ${SRV_PID}
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "Suspend server"
|
||||
${CRTOOLS} dump -D ${DDIR} -o dump.log -t ${SRV_PID} --tcp-established -vvvv || fail "Fail to dump server"
|
||||
sleep 1
|
||||
echo "Resume server"
|
||||
${CRTOOLS} restore -D ${DDIR} -o restore.log -t ${SRV_PID} -d --tcp-established -vvvv --close 3 || fail "Fail to restore server"
|
||||
|
||||
echo "Make client run again"
|
||||
echo "${TEXT}" >&3
|
||||
|
||||
echo "Collect results"
|
||||
exec 3>&-
|
||||
wait ${CLN_PID}
|
||||
kill -9 ${SRV_PID}
|
||||
Loading…
Add table
Add a link
Reference in a new issue