[CRIU] [PATCH] test: add rpc tests

Ruslan Kuprieiev kupruser at gmail.com
Sun Sep 15 13:33:31 EDT 2013


On 09/15/2013 05:57 PM, Andrew Vagin wrote:
> On Sun, Sep 15, 2013 at 03:31:01PM +0400, Ruslan Kuprieiev wrote:
>> On 09/15/2013 03:12 PM, Ruslan Kuprieiev wrote:
>>> On 09/15/2013 02:48 PM, Andrew Vagin wrote:
>>>>> diff --git a/test/rpc/run.sh b/test/rpc/run.sh
>>>>> new file mode 100755
>>>>> index 0000000..17f0f09
>>>>> --- /dev/null
>>>>> +++ b/test/rpc/run.sh
>>>>> @@ -0,0 +1,72 @@
>>>>> +#!/bin/bash
>>>>> +
>>>>> +source ../env.sh || exit 1
>>>>> +
>>>>> +function my_print {
>>>>> +    echo -e "\n**************************************************"
>>>>> +    echo -e "\t\t"$1
>>>>> +    echo -e "**************************************************\n"
>>>>> +
>>>>> +}
>>>>> +
>>>>> +function my_exit {
>>>>> +    if [ $1 -ne 0 ]; then
>>>>> +        echo FAIL
>>>>> +    fi
>>>>> +
>>>>> +    my_print "Shutdown service server"
>>>>> +    kill -SIGTERM ${SRV_PID}
>>>>> +
>>>>> +    exit $1
>>>>> +}
>>>>> +
>>>>> +IMGS_DIR_C="imgs_c"
>>>>> +IMGS_DIR_PY="imgs_py"
>>>>> +SERV_LOG="service.log"
>>>>> +REST_C_LOG="restore-c.log"
>>>>> +REST_PY_LOG="restore-py.log"
>>>>> +
>>>>> +my_print "Build services"
>>>>> +make clean && make || { echo "Failed to build"; exit 1; }
>>>>> +if [ $? -ne 0 ]; then
>>>>> +    echo FAIL
>>>>> +    exit 1
>>>>> +fi
>>>>> +rm -rf ${IMGS_DIR_C} ${IMGS_DIR_PY} ${REST_LOG_C} ${REST_LOG_PY}
>>>>> +mkdir ${IMGS_DIR_C} ${IMGS_DIR_PY}
>>>>> +
>>>>> +my_print "Start service server"
>>>>> +setsid ${CRIU} service -v4 -o ${SERV_LOG} --address
>>>>> ./criu_service.socket &
>>>>> +SRV_PID=${!}
>>>>> +if [ $? -ne 0 ]; then
>>>>> +    echo FAIL
>>>>> +    exit 1
>>>>> +fi
>>>>> +echo PID ${SRV_PID}
>>>>> +sleep 1 #server needs some time to initialize
>>>> I don't like this sleep. Your service is able to detach
>>>>
>>>> -d|--daemon           run in the background after creating socket
>>>>
>>>> so if it will be executed with the -d option, this sleep will be
>>>> unnecessary.
>>>>
>>> The reason why i didn't use daemonization is that i don't know how
>>> to get his pid in the script it that case.
>>>
>> I mean, i'm not sure, but it looks like after deamon() process has
>> another pid.
> Yes, it will.
>
>> And if i write "criu service -d", ${!} gives me pid that criu has at
>> the beginning, and i can't terminate server afterwards.
>> I thought, i can pkill criu, but it looks wrong.
> Can we use --pidfile? If this option is specidied, the server saves it's
> PID in the file.

I sent a patch for this, but still, i need to use "sleep 1", otherwise i 
get "No such file or directory" when test-c is trying to connect to 
socket. And it looks strange to me, because daemonization is run _after_ 
creating a socket.
What am I doing wrong now?

>
>>>>> +
>>>>> +my_print "Run test-c"
>>>>> +./test-c
>>>>> +if [ $? -ne 0 ]; then
>>>>> +    my_exit 1
>>>>> +fi
>>>>> +



More information about the CRIU mailing list