#!/bin/sh
# Smoke test for the installed Qt 6 dxcb platform plugin.
#
# The plugin is built against Qt 6 private API bundled in the source
# package (see debian/README.source). If the bundled headers ever drift
# from the Qt 6 actually shipped in the archive, the mismatch shows up
# as symbols that cannot be resolved at load time -- which is exactly
# what this test looks for.

set -e

PLUGIN=$(dpkg -L dde-qtplatform-plugins | grep '/libdxcb\.so$')

if [ -z "$PLUGIN" ] || [ ! -f "$PLUGIN" ]; then
	echo "ERROR: libdxcb.so is not installed" >&2
	exit 1
fi
echo "found plugin: $PLUGIN"

if ldd -r "$PLUGIN" 2>&1 | grep -e "undefined symbol" -e "not found"; then
	echo "ERROR: unresolved symbols or missing libraries in $PLUGIN" >&2
	exit 1
fi

echo "PASS: $PLUGIN links cleanly against the Qt 6 in the archive"
