#!/bin/sh
# Build the upstream libstoken example against libstoken-dev and run it.
set -eu

srcdir="$PWD"
cd "$AUTOPKGTEST_TMP"
cp "$srcdir/examples/libstoken-test.c" .
gcc -o libstoken-test libstoken-test.c $(pkg-config --cflags --libs stoken)

# Sample v2 token from the upstream test suite (no device ID or password).
tok0=258491750817210752367175001073261277346642631755724762324173166222072472716737543
out=$(printf '1234\n' | ./libstoken-test "$tok0")
echo "$out"
echo "$out" | grep -Eq '^Tokencode: [0-9]{6,8}$'
