#!/bin/sh

set -e

# Tango fails if the testbed's FQDN can't be resolved, which seems to happen
# in Incus containers.  Fix this up.
canonical_hostname="$(hostname -f)"
if ! echo "$canonical_hostname" | grep -Fq .; then
	canonical_hostname="$(hostname -A | cut -d' ' -f1)"
	(grep -v '^127\.0\.1\.1[[:space:]]' /etc/hosts; \
	 echo "127.0.1.1 $canonical_hostname $(hostname)") >/etc/hosts.new
	mv /etc/hosts.new /etc/hosts
fi

cd "$AUTOPKGTEST_TMP"

for py in $(py3versions -r 2>/dev/null); do
	echo "Testing with $py:"
	"$py" -c 'import tango; print(tango.Database().get_info())'
done
