#!/bin/sh -efu

export HOME=${AUTOPKGTEST_TMP}

allpkg=$(dh_listpackages)

for p in $allpkg; do
    echo "Package being processed: $p"


    allbinaries=$(dpkg -L "$p"| grep "/usr/bin/")
	if [ -z "$allbinaries" ]; then
		echo "No binaries were found in this package"
		continue
	fi
		echo "Binaries of the package $p :"
    		echo "$allbinaries"
    for f in $allbinaries; do
	timeout 5s "$f" 
	ec=$?
	echo "tested $f: $ec"
	if [ $ec -eq 143 ]; then
	    echo "trapped status 143 and return success for $f"
	elif [ $ec -eq 2 ]; then
	    echo "Skipped exit code 2 for $f"
	else
	    echo "skipped"
        fi
    done
done

exit 0

