#!/bin/sh
# This regression test is a part of SIPp.
# A 100rel UAS answers a PRACK with 200, then the INVITE with 200. A
# retransmitted PRACK must get the 200 of the PRACK again, not the 200
# of the INVITE, which does not complete the PRACK.
. "`dirname "$0"`/../functions"; init

sippbg -sf uas.xml -i 127.0.0.1 -p 5070 -m 1 -timeout 10
uas=$pid
# -nr: the UAC takes the repeated 200 from its scenario, not as a
# retransmission of the first one.
sippfg -sf uac.xml -nr -i 127.0.0.1 -p 5071 -m 1 127.0.0.1:5070 \
    -timeout 6 -timeout_error >/dev/null 2>&1
status=$?
wait $uas
uas_status=$?

if test $status -ne 0; then
    fail "UAC failed with $status on the retransmitted PRACK"
elif test $uas_status -ne 0; then
    fail "UAS failed with $uas_status"
else
    ok
fi
