Reduce complexity

- doesn't run all combinations, only those that make most differences
- also adds checks for python-six
This commit is contained in:
Peter Šurda 2021-08-08 09:59:58 +08:00
parent 0377ebff81
commit 8ad80247b2
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -1,25 +1,28 @@
#!/bin/bash
# tests checkdeps.py with all possible subsets of dependency packages installed
# 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)
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)
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)
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)
packages=(python-setuptools build-essential libssl-dev libcap-dev python-six)
;;
*)
echo "Unknown distro"
@ -31,9 +34,10 @@ echo "Using $method on $distro"
output=$(mktemp)
succeeded=0
failed=0
n=${#packages[@]}
# 0 - 2^n -1
for i in $(seq 0 $((2**${#packages[@]}-1))); do
# 0 - 2 * n - 1
for i in $(seq 0 $((2 * n - 1))); do
declare -a missing
missing=()
case $method in
@ -44,9 +48,10 @@ for i in $(seq 0 $((2**${#packages[@]}-1))); do
esac
# iterate packages
for j in $(seq 0 $((${#packages[@]}-1))); do
for j in $(seq 0 $((n - 1))); do
# should j-th item be included in i-th iteration?
if [ $(((i>>j)%2)) -eq 1 ]; then
# 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]}+"