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
|
#
# Common shell routines for testing python modules
# Copyright (c) 2012-2016,2025 Red Hat.
#
# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check
python=${PCP_PYTHON_PROG}
python_basename=`basename ${PCP_PYTHON_PROG}`
[ -n "$python" ] || _notrun "No python interpreter configured in \$PCP_PYTHON_PROG"
eval $python -c exit 2>/dev/null || _notrun "Python interpreter \"$python\" failed"
# verify output from unittest indicates successful testing
_check_unittest()
{
__mode=$1
__file=$2
$PCP_ECHO_PROG $PCP_ECHO_N "$__mode - ""$PCP_ECHO_C"
if grep OK $__file
then
return 0
fi
# Give some hint as to what went wrong ...
#
$PCP_AWK_PROG <$__file '
$1 == "FAIL:" { want = 1 }
$1 == "File" { want = 1 }
want == 1 && $1 == "Ran" { exit }
want == 1 { print }'
return 1
}
_check_requests()
{
$python -c "import requests" >/dev/null 2>&1 || _notrun "$python requests package is not installed"
}
_check_python36()
{
$python -c "import sys; sys.exit(0 if sys.version_info >= (3, 6) else 1)" || _notrun "python 3+ is required"
}
_check_python3()
{
# python 3.6 is now the minimum accepted version
_check_python36
}
_check_http_filter()
{
tee -a $here/$seq.full \
| col -b \
| sed \
-e "s/^\(Host: localhost\):$port/\1:PORT/g" \
-e 's/^\(Content-Length:\) [1-9][0-9]*/\1 SIZE/g' \
-e 's/^\(User-Agent: python-requests\).*/\1 VERSION/g' \
-e 's/^\(Date:\).*/\1 DATE/g' \
-e 's/\(\"context\":\) [0-9][0-9]*/\1 CTXID/g' \
-e '/^Accept-Encoding: /d' \
-e 's/\(hostname=\): "'"$hostname"'"/\1:HOST/g' \
-e '/^Connection: keep-alive/d' \
-e '/ using stream socket$/d'
}
|