From 8ad80247b21f0ece8f51f5919fe24d3b637f3f66 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Sun, 8 Aug 2021 09:59:58 +0800 Subject: [PATCH] Reduce complexity - doesn't run all combinations, only those that make most differences - also adds checks for python-six --- test-checkdeps.sh | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/test-checkdeps.sh b/test-checkdeps.sh index 8fef607..2400015 100755 --- a/test-checkdeps.sh +++ b/test-checkdeps.sh @@ -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]}+"