#!/bin/bash

# Copy STDOUT to FD3. This prevents the XTRACE output to be mixed
# with the normal STDOUT used for piping.
exec 3>&1

# Redirect XTRACE output to the new FD3
BASH_XTRACEFD="3"

# Activate Tracing and exit-on-error
set -ex

echo "----- start testing -----"
echo "USER: ${USER}"

DBTYPE="${0##*-}"

echo "---- Preparing test files ----"

DATAFILE="${AUTOPKGTEST_TMP}/datafile"

cat > "${DATAFILE}" <<End-of-message
-------------------------------------
This is line 1 of the message.
This is line 2 of the message.
This is line 3 of the message.
This is line 4 of the message.
This is the last line of the message.
-------------------------------------
End-of-message

echo
echo "---- Testing /usr/sbin/bregex ----"

echo -en "line . of the message\r" | /usr/sbin/bregex -f "${DATAFILE}"

echo
echo "---- Testing /usr/sbin/bwild ----"

echo -en "*line ? of the message.\r" | /usr/sbin/bwild -f "${DATAFILE}"

echo
echo "---- Testing /usr/sbin/bbconsjson ----"

/usr/sbin/bbconsjson

echo
echo "---- Testing /usr/sbin/bdirjson ----"

/usr/sbin/bdirjson

echo
echo "---- Testing /usr/sbin/bfdjson ----"

/usr/sbin/bfdjson

echo
echo "---- Testing /usr/sbin/bsdjson ----"

/usr/sbin/bsdjson


