#!/bin/bash

echo
echo "TEST: $0"
echo "... testing standard VSL args"

echo "... -k keep"
CKSUM=$( ../varnishevent -k 1000 -r varnish.binlog | cksum)

if [ "$CKSUM" != '3569862329 1119' ]; then
    echo "ERROR: -k keep incorrect cksum: $CKSUM"
    exit 1
fi

echo "... -m tag:regex"
CKSUM=$( ../varnishevent -m RxURL:manual -m RxURL:pt-br -r varnish.binlog | cksum)

if [ "$CKSUM" != '968394035 24419' ]; then
    echo "ERROR: -m tag:regex incorrect cksum: $CKSUM"
    exit 1
fi

echo "... -s skip"
CKSUM=$( ../varnishevent -s 20000 -r varnish.binlog | cksum)

if [ "$CKSUM" != '1846333159 3668220' ]; then
    echo "ERROR: -s skip incorrect cksum: $CKSUM"
    exit 1
fi

echo "... -X regex"
CKSUM=$( ../varnishevent -X manual -r varnish.binlog | cksum)

if [ "$CKSUM" != '1394076397 3663437' ]; then
    echo "ERROR: -X regex incorrect cksum: $CKSUM"
    exit 1
fi

exit 0
