[v5,5/9] app/test-cmdline: support python3 only
Checks
Commit Message
Changed script to explicitly use python3 only to avoid
maintaining python 2 and removed deprecation notice.
Cc: Olivier Matz <olivier.matz@6wind.com>
Signed-off-by: Louise Kilheeney <louise.kilheeney@intel.com>
---
v5: fixed python3 issue casuing script to fail
---
app/test-cmdline/cmdline_test.py | 9 ++-------
app/test-cmdline/cmdline_test_data.py | 1 +
mk/rte.sdktest.mk | 2 +-
3 files changed, 4 insertions(+), 8 deletions(-)
Comments
On Fri, Aug 21, 2020 at 10:14:48AM +0100, Louise Kilheeney wrote:
> Changed script to explicitly use python3 only to avoid
> maintaining python 2 and removed deprecation notice.
>
> Cc: Olivier Matz <olivier.matz@6wind.com>
>
> Signed-off-by: Louise Kilheeney <louise.kilheeney@intel.com>
>
> ---
> v5: fixed python3 issue casuing script to fail
It would be good to add a little more detail of the failure and fix to help
reviewers, I believe the fix is the typecast to int() around the division
to avoid floating point numbers messing up the loop count.
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> app/test-cmdline/cmdline_test.py | 9 ++-------
> app/test-cmdline/cmdline_test_data.py | 1 +
> mk/rte.sdktest.mk | 2 +-
> 3 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/app/test-cmdline/cmdline_test.py b/app/test-cmdline/cmdline_test.py
> index 954428e2bf..074fed7e7f 100755
> --- a/app/test-cmdline/cmdline_test.py
> +++ b/app/test-cmdline/cmdline_test.py
> @@ -1,9 +1,8 @@
> -#!/usr/bin/env python
> +#!/usr/bin/env python3
> # SPDX-License-Identifier: BSD-3-Clause
> # Copyright(c) 2010-2014 Intel Corporation
>
> # Script that runs cmdline_test app and feeds keystrokes into it.
> -from __future__ import print_function
> import cmdline_test_data
> import os
> import pexpect
> @@ -19,10 +18,6 @@ def runTest(child, test):
> return 0
> child.expect(test["Result"], 1)
>
> -if sys.version_info.major < 3:
> - print("WARNING: Python 2 is deprecated for use in DPDK, and will not work in future releases.", file=sys.stderr)
> - print("Please use Python 3 instead", file=sys.stderr)
> -
> #
> # history test is a special case
> #
> @@ -43,7 +38,7 @@ def runHistoryTest(child):
> i = 0
>
> # fill the history with numbers
> - while i < history_size / 10:
> + while i < int(history_size / 10):
> # add 1 to prevent from parsing as octals
> child.send("1" + str(i).zfill(8) + cmdline_test_data.ENTER)
> # the app will simply print out the number
> diff --git a/app/test-cmdline/cmdline_test_data.py b/app/test-cmdline/cmdline_test_data.py
> index 114d2cb6a0..2d9b3262a6 100644
> --- a/app/test-cmdline/cmdline_test_data.py
> +++ b/app/test-cmdline/cmdline_test_data.py
> @@ -1,3 +1,4 @@
> +#!/usr/bin/env python3
> # SPDX-License-Identifier: BSD-3-Clause
> # Copyright(c) 2010-2014 Intel Corporation
>
> diff --git a/mk/rte.sdktest.mk b/mk/rte.sdktest.mk
> index 803018ba3a..ad7ef138f0 100644
> --- a/mk/rte.sdktest.mk
> +++ b/mk/rte.sdktest.mk
> @@ -63,7 +63,7 @@ coverage:
> @mkdir -p $(AUTOTEST_DIR) ; \
> cd $(AUTOTEST_DIR) ; \
> if [ -f $(RTE_OUTPUT)/app/test ]; then \
> - python $(RTE_SDK)/test/cmdline_test/cmdline_test.py \
> + python3 $(RTE_SDK)/test/cmdline_test/cmdline_test.py \
> $(RTE_OUTPUT)/app/cmdline_test; \
> ulimit -S -n 100 ; \
> python $(RTE_SDK)/app/test/autotest.py \
> --
> 2.17.1
>
@@ -1,9 +1,8 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2010-2014 Intel Corporation
# Script that runs cmdline_test app and feeds keystrokes into it.
-from __future__ import print_function
import cmdline_test_data
import os
import pexpect
@@ -19,10 +18,6 @@ def runTest(child, test):
return 0
child.expect(test["Result"], 1)
-if sys.version_info.major < 3:
- print("WARNING: Python 2 is deprecated for use in DPDK, and will not work in future releases.", file=sys.stderr)
- print("Please use Python 3 instead", file=sys.stderr)
-
#
# history test is a special case
#
@@ -43,7 +38,7 @@ def runHistoryTest(child):
i = 0
# fill the history with numbers
- while i < history_size / 10:
+ while i < int(history_size / 10):
# add 1 to prevent from parsing as octals
child.send("1" + str(i).zfill(8) + cmdline_test_data.ENTER)
# the app will simply print out the number
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2010-2014 Intel Corporation
@@ -63,7 +63,7 @@ coverage:
@mkdir -p $(AUTOTEST_DIR) ; \
cd $(AUTOTEST_DIR) ; \
if [ -f $(RTE_OUTPUT)/app/test ]; then \
- python $(RTE_SDK)/test/cmdline_test/cmdline_test.py \
+ python3 $(RTE_SDK)/test/cmdline_test/cmdline_test.py \
$(RTE_OUTPUT)/app/cmdline_test; \
ulimit -S -n 100 ; \
python $(RTE_SDK)/app/test/autotest.py \