summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/find_python.sh49
-rwxr-xr-xscripts/run_functional_tests12
-rwxr-xr-xscripts/run_regression2
-rwxr-xr-xscripts/stl-sim18
-rwxr-xr-xscripts/trex-console18
5 files changed, 77 insertions, 22 deletions
diff --git a/scripts/find_python.sh b/scripts/find_python.sh
index e9607fe5..cf475f73 100755
--- a/scripts/find_python.sh
+++ b/scripts/find_python.sh
@@ -1,7 +1,7 @@
#!/bin/bash
-# if no variable of $PYTHON is define - we try to find it
-function find_python {
+# function finds python2
+function find_python2 {
# two candidates - machine python and cisco linux python
MACHINE_PYTHON=python
CEL_PYTHON=/router/bin/python-2.7.4
@@ -24,27 +24,50 @@ function find_python {
exit -1
}
+# function finds python3
function find_python3 {
MACHINE_PYTHON=python3
ITAY_PYTHON=/auto/proj-pcube-b/apps/PL-b/tools/python3.4/bin/python3
- PYTHON3=$MACHINE_PYTHON
- PCHECK=`$PYTHON3 -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34)"`
+ PYTHON=$MACHINE_PYTHON
+ PCHECK=`$PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34)"`
if [ $? -eq 0 ]; then
return
fi
- PYTHON3=$ITAY_PYTHON
- PCHECK=`$PYTHON3 -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34)"`
+ PYTHON=$ITAY_PYTHON
+ PCHECK=`$PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34)"`
if [ $? -eq 0 ]; then
return
fi
- echo "*** $PYTHON3 - python version does not match, 3.4 is required"
+ echo "*** $PYTHON - python version does not match, 3.4 is required"
exit -1
}
-if [ -z "$PYTHON" ]; then
- find_python
-fi
+case "$1" in
+ "--python2") # we want python2
+ find_python2
+ ;;
+ "--python3") # we want python3
+ find_python3
+ ;;
+ *)
+ if [ -z "$PYTHON" ]; then # no python env. var
+ case $USER in
+ imarom|hhaim|ybrustin|ibarnea) # dev users, 70% python3 30% python2
+ case $(($RANDOM % 10)) in
+ [7-9])
+ find_python2
+ ;;
+ *)
+ find_python3
+ ;;
+ esac
+ ;;
+ *) # default is python2
+ find_python2
+ ;;
+ esac
+ fi
+ ;;
+esac
+
-if [ -z "$PYTHON3" ]; then
- find_python3
-fi
diff --git a/scripts/run_functional_tests b/scripts/run_functional_tests
index 6e6a00a1..6212b40b 100755
--- a/scripts/run_functional_tests
+++ b/scripts/run_functional_tests
@@ -1,6 +1,6 @@
#!/bin/bash
-source find_python.sh
+source find_python.sh --python2
cd automation/regression
# Python 2
@@ -13,13 +13,17 @@ else
exit -1
fi
+cd -
+source find_python.sh --python3
+cd -
+
# Python 3
echo Python3 test
-$PYTHON3 trex_unit_test.py --functional $@
+$PYTHON trex_unit_test.py --functional $@
if [ $? -eq 0 ]; then
- printf "\n$PYTHON3 test succeeded\n\n"
+ printf "\n$PYTHON test succeeded\n\n"
else
- printf "\n*** $PYTHON3 test failed\n\n"
+ printf "\n*** $PYTHON test failed\n\n"
exit -1
fi
diff --git a/scripts/run_regression b/scripts/run_regression
index 5bb33652..02746bab 100755
--- a/scripts/run_regression
+++ b/scripts/run_regression
@@ -1,6 +1,6 @@
#!/bin/bash
-source find_python.sh
+source find_python.sh --python2
cd automation/regression
$PYTHON trex_unit_test.py --exclude functional $@
diff --git a/scripts/stl-sim b/scripts/stl-sim
index 57fe4fa8..198d1275 100755
--- a/scripts/stl-sim
+++ b/scripts/stl-sim
@@ -1,6 +1,20 @@
#!/bin/bash
-source find_python.sh
+INPUT_ARGS=$@
+
+if [[ $@ =~ '--python2' ]]; then
+ INPUT_ARGS=${@//--python2/}
+ source find_python.sh --python2
+fi
+
+if [[ $@ =~ '--python3' ]]; then
+ INPUT_ARGS=${@//--python3/}
+ source find_python.sh --python3
+fi
+
+if [ -z "$PYTHON" ]; then
+ source find_python.sh
+fi
export PYTHONPATH=automation/trex_control_plane/stl
-$PYTHON -m trex_stl_lib.trex_stl_sim -p $PWD $@
+$PYTHON -m trex_stl_lib.trex_stl_sim -p $PWD $INPUT_ARGS
diff --git a/scripts/trex-console b/scripts/trex-console
index ea253fdd..0fcf656a 100755
--- a/scripts/trex-console
+++ b/scripts/trex-console
@@ -1,9 +1,23 @@
#!/bin/bash
-source find_python.sh
+INPUT_ARGS=$@
+
+if [[ $@ =~ '--python2' ]]; then
+ INPUT_ARGS=${@//--python2/}
+ source find_python.sh --python2
+fi
+
+if [[ $@ =~ '--python3' ]]; then
+ INPUT_ARGS=${@//--python3/}
+ source find_python.sh --python3
+fi
+
+if [ -z "$PYTHON" ]; then
+ source find_python.sh
+fi
export PYTHONPATH=automation/trex_control_plane/stl
printf "\nUsing '$PYTHON' as Python interpeter\n\n"
-$PYTHON -m console.trex_console $@
+$PYTHON -m console.trex_console $INPUT_ARGS