#!/bin/bash
###############################################################################
##
## Copyright (c) 2009
##
## This program is free software;  you can redistribute it and#or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
## for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program;  if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
###############################################################################
#
# Description:  Test program for Kerrighed checkpoint/restart of single
#               process using callbacks.
#
# Authors:      Eugen Feller, eugen.feller@uni-duesseldorf.de
#               Matthieu Fertré, matthieu.fertre@kerlabs.com
#

source `dirname $0`/lib_cr.sh

description="Run, C, C (no cb), K, R, C (no cb), C, K, R"

TESTCMD="bi-server-socket"

# Run, C, C, K, R, C, C, K, R
cr_callbacks01()
{
    TCID="$FUNCNAME"               # Identifier of this testcase.
    TST_COUNT=$[$TST_COUNT+1]      # Test case number.

    runcommand +CHECKPOINTABLE || return $?

    checkpoint_process $PID $TESTCMD || return $?

    # checkpoint wo callbacks (-b) must fail
    checkpoint_process_must_fail $PID $TESTCMD "-b" || return $?

    kill_group $PID $TESTCMD || return $?

    restart_process $PID 1 $TESTCMD || return $?

    # checkpoint wo callbacks (-b) must fail
    checkpoint_process_must_fail $PID $TESTCMD "-b" || return $?

    checkpoint_process $PID $TESTCMD  || return $?

    kill_group $PID $TESTCMD || return $?

    restart_process $PID 2 $TESTCMD || return $?

    kill_group $PID $TESTCMD || return $?

    print_success $?
    return $?
}

CR_setup $@ || exit $?

cr_callbacks01 || exit $?

# run the same test but with signal-context callbacks
TESTCMD_OPTIONS="-s -q"
cr_callbacks01 || exit $?
