Scripts for buildbot / cloud-init / etc for running tests.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

107 lines
2.9 KiB

#!/bin/bash
# Tests checkdeps.py with each package missing individually, and then present
# individually. It's not a full test of all combinations, but these are
# unnecessarily long. This approach has a complexity of n * 2, whereas
# a complete test has a complexity of n ** 2
distro=$(grep ^VERSION_CODENAME= /etc/os-release | cut -d= -f2)
case $distro in
trusty)
method="apt-get"
packages=(python-qt4 python-msgpack python-pyopencl python-setuptools build-essential libssl-dev libcap-dev python-prctl python-six)
;;
xenial)
method="apt-get"
packages=(python-qt4 python-msgpack python-pyopencl python-setuptools build-essential libssl-dev libcap-dev python-prctl python-six)
;;
bionic)
method="apt-get"
packages=(python-qt4 python-msgpack python-pyopencl python-setuptools build-essential libssl-dev libcap-dev python-prctl python-six)
;;
focal)
method="apt-get"
packages=(python-setuptools build-essential libssl-dev libcap-dev python-six)
;;
*)
echo "Unknown distro"
exit 0
esac
echo "Using $method on $distro"
output=$(mktemp)
succeeded=0
failed=0
n=${#packages[@]}
# 0 - 2 * n - 1
for i in $(seq 0 $((2 * n - 1))); do
declare -a missing
missing=()
case $method in
apt-get)
cmd="sudo apt-get remove --autoremove -y -qq"
;;
*);;
esac
# iterate packages
for j in $(seq 0 $((n - 1))); do
# should j-th item be included in i-th iteration?
# present in first half, or absent in second half
if ((i < n ? i % n != j : i % n == j)); then
case $method in
apt-get)
cmd="$cmd ${packages[j]}+"
;;
esac
else
case $method in
apt-get)
missing+=("${packages[j]}")
cmd="$cmd ${packages[j]}"
;;
esac
fi
done
echo -n "${missing[*]}: "
$cmd &> /dev/null
#echo "python checkdeps.py"
python checkdeps.py > "$output" 2> /dev/null
toinstall=$(sed -E 's/.*apt-get install (.*)(`.*|$)/\1/p;d' < "$output" | xargs -n 1 echo)
toinstalla=($toinstall)
fail=0
for a in ${missing[*]}; do
for b in ${toinstalla[*]}; do
if [ "$a" == "$b" ]; then
break
fi
done
if ! [ "$a" == "$b" ]; then
fail=1
fi
done
for a in ${toinstalla[*]}; do
for b in ${missing[*]}; do
if [ "$a" == "$b" ]; then
break
fi
done
if ! [ "$a" == "$b" ]; then
fail=1
fi
done
if [ $fail -eq 0 ]; then
echo "OK"
succeeded=$((succeeded+1))
else
echo "FAIL"
echo " " $toinstall
failed=$((failed+1))
fi
done
echo "Succeeded: $succeeded"
echo " Failed: $failed"