#!/bin/bash
set -ex

. tests/lib

coproc userv --override 'execute cat -vet' games spong

stdout=${COPROC[0]}
stdin=${COPROC[1]}

print_expect_reply () {
    local m=$1
    local got
    echo >&$stdin "$m"
    read <&$stdout got
    local exp="$(printf '%s$\n' "$m")"
    test "$got" = "$exp"
}

print_expect_reply hi

service userv restart

print_expect_reply ho

echo ok.
