summaryrefslogtreecommitdiffstats
path: root/src/ceph-volume/ceph_volume/tests/functional/scripts/test_unicode.sh
blob: fe600b2ba541e7ff986a427caf19c098f45b185a (plain)
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
#!/bin/bash

# Not entirely sure why these executables don't seem to be available in the
# $PATH when running from tox. Calling out to `which` seems to fix it, at the
# expense of making the script a bit obtuse

mktemp=$(which mktemp)
cat=$(which cat)
grep=$(which grep)
PYTHON_EXECUTABLE=`which python3`
STDERR_FILE=$($mktemp)
INVALID="→"

echo "stderr file created: $STDERR_FILE"

INVALID="$INVALID" $PYTHON_EXECUTABLE $1 2> ${STDERR_FILE}

retVal=$?

if [ $retVal -ne 0 ]; then
    echo "Failed test: Unexpected failure from running Python script"
    echo "Below is output of stderr captured:"
    $cat "${STDERR_FILE}"
    exit $retVal
fi

$grep --quiet "$INVALID" ${STDERR_FILE}

retVal=$?
if [ $retVal -ne 0 ]; then
    echo "Failed test: expected to find \"${INVALID}\" character in tmpfile: \"${STDERR_FILE}\""
    echo "Below is output of stderr captured:"
    $cat "${STDERR_FILE}"
fi
exit $retVal