]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/workunits/cephadm/test_cephadm.sh: detect python3 and python2
authorSage Weil <sage@redhat.com>
Wed, 18 Dec 2019 17:08:42 +0000 (11:08 -0600)
committerSage Weil <sage@redhat.com>
Sat, 21 Dec 2019 15:03:55 +0000 (09:03 -0600)
Only test on whichever pythons are available on the host.

Signed-off-by: Sage Weil <sage@redhat.com>
qa/workunits/cephadm/test_cephadm.sh

index 20cb382fb016ad475b2e47d4718ec974c571dc8d..fed89a25c23c80facd6cce470a05fc19a5f9f3f2 100755 (executable)
@@ -37,25 +37,34 @@ if ! [ -x "$CEPHADM" ]; then
 fi
 
 # respawn ourselves with a shebang
-PYTHONS="python3 python2"  # which pythons we test
 if [ -z "$PYTHON_KLUDGE" ]; then
-   TMPBINDIR=$(mktemp -d)
-   trap "rm -rf $TMPBINDIR" EXIT
-   ORIG_CEPHADM="$CEPHADM"
-   CEPHADM="$TMPBINDIR/cephadm"
-   for p in $PYTHONS; do
-       echo "=== re-running with $p ==="
-       ln -s `which $p` $TMPBINDIR/python
-       echo "#!$TMPBINDIR/python" > $CEPHADM
-       cat $ORIG_CEPHADM >> $CEPHADM
-       chmod 700 $CEPHADM
-       $TMPBINDIR/python --version
-       PYTHON_KLUDGE=1 CEPHADM=$CEPHADM $0
-       rm $TMPBINDIR/python
-   done
-   rm -rf $TMPBINDIR
-   echo "PASS with all of: $PYTHONS"
-   exit 0
+    # see which pythons we should test with
+    PYTHONS=""
+    which python3 && PYTHONS="$PYTHONS python3"
+    which python2 && PYTHONS="$PYTHONS python2"
+    echo "PYTHONS $PYTHONS"
+    if [ -z $PYTHONS ]; then
+       echo "No PYTHONS found!"
+       exit 1
+    fi
+
+    TMPBINDIR=$(mktemp -d)
+    trap "rm -rf $TMPBINDIR" EXIT
+    ORIG_CEPHADM="$CEPHADM"
+    CEPHADM="$TMPBINDIR/cephadm"
+    for p in $PYTHONS; do
+       echo "=== re-running with $p ==="
+       ln -s `which $p` $TMPBINDIR/python
+       echo "#!$TMPBINDIR/python" > $CEPHADM
+       cat $ORIG_CEPHADM >> $CEPHADM
+       chmod 700 $CEPHADM
+       $TMPBINDIR/python --version
+       PYTHON_KLUDGE=1 CEPHADM=$CEPHADM $0
+       rm $TMPBINDIR/python
+    done
+    rm -rf $TMPBINDIR
+    echo "PASS with all of: $PYTHONS"
+    exit 0
 fi
 
 # add image to args