File: runTestLibusb.sh

package info (click to toggle)
python-libusb1 3.3.1%2Bds-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 504 kB
  • sloc: python: 3,259; sh: 98; makefile: 5
file content (78 lines) | stat: -rwxr-xr-x 1,963 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# Run tests against multiple libusb versions.
# Useful to check backward-compatibility with libusb versions which lack some
# exports.
set -eu

if [ $# -lt 4 ]; then
  echo "Usage: $0 python remote remote_name changeset [changeset [...]]"
  exit 1
fi
python="$1"
remote="$2"
remote_name="$3"
shift 3

if [ "x$python" = "x" ]; then
  echo "<python> argument must not be empty"
  exit 1
fi

python_libusb1="$(dirname "$(realpath "$0")")"
base="${python_libusb1}/test-libusb"
venv_dir="${base}/$(basename "$python")"
build_base="${base}/build"
repo_dir="${base}/repo/${remote_name}"

test -e "$venv_dir" && rm -r "$venv_dir"
virtualenv --python "$python" "$venv_dir"
"${venv_dir}/bin/pip" install "$python_libusb1"

if [ -e "$repo_dir" ]; then
  git -C "$repo_dir" fetch
else
  git clone --no-checkout "$remote" "$repo_dir"
fi
cd "$repo_dir"
# Also test against system-installed libusb
lib_dir_list=("")
# Build all first, test later, so errors are all visible at the end
while [ $# -ne 0 ]; do
  changeset="$1"
  shift
  build_dir="${build_base}/${remote_name}/${changeset}"
  if [ ! -e "$build_dir" ]; then
    mkdir -p "$build_dir"
    git checkout --force "$changeset"
    git clean --force -dx
    ./autogen.sh --prefix="$build_dir"
    make
    make install
  fi
  lib_dir_list+=("${build_dir}/lib")
done

result=0
venv_python="${venv_dir}/bin/python"
for lib_dir in "${lib_dir_list[@]}"; do
  export LD_LIBRARY_PATH="${lib_dir}"
  if "$venv_python" -m usb1.testUSB1; then
    :
  else
    echo "usb1.testUSB1 failed with ${lib_dir}: status=$?"
    result=1
  fi
  if "$venv_python" "${python_libusb1}/examples/listdevs.py"; then
    :
  else
    echo "examples/listdevs.py failed with ${lib_dir}: status=$?"
    result=1
  fi
  if timeout --preserve-status --signal INT 1 "$venv_python" "${python_libusb1}/examples/hotplug.py"; then
    :
  else
    echo "examples/hotplug.py failed with ${lib_dir}: status=$?"
    result=1
  fi
done
exit $result