Skip to content

Commit 6905274

Browse files
Mingli Yuakuster
Mingli Yu
authored andcommitted
libteam: switch to python3
The original fix for team_basic_test.py only change the interpreter to python3, but still some error as below: # ./run-ptest File "/usr/lib64/libteam/ptest/./team_basic_test.py", line 35 print "Usage: team_basic_test.py [OPTION...]" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)? # ./run-ptest RUN #1 # "ip link add testteamx type team" # "teamnl testteamx getoption mode" # "ip link del testteamx" # "modprobe -r team_mode_loadbalance team_mode_roundrobin team_mode_activebackup team_mode_broadcast team" Traceback (most recent call last): File "/usr/lib64/libteam/ptest/./team_basic_test.py", line 206, in <module> main() File "/usr/lib64/libteam/ptest/./team_basic_test.py", line 203, in main btest.run() File "/usr/lib64/libteam/ptest/./team_basic_test.py", line 180, in run self._run_one_loop(i + 1) File "/usr/lib64/libteam/ptest/./team_basic_test.py", line 173, in _run_one_loop self._run_one_mode(mode_name) File "/usr/lib64/libteam/ptest/./team_basic_test.py", line 101, in _run_one_mode cmd_exec("teamnl %s getoption mode" % team_name, "*NOMODE*") File "/usr/lib64/libteam/ptest/./team_basic_test.py", line 80, in cmd_exec raise CmdExecUnexpectedOutputException(output, expected_output) __main__.CmdExecUnexpectedOutputException: Command execution output unexpected: "b'*NOMODE*'" != "*NOMODE*" So rework team_basic_test.py to fix the above issue. Signed-off-by: Mingli Yu <[email protected]> Signed-off-by: Armin Kuster <[email protected]>
1 parent 79b62c1 commit 6905274

File tree

3 files changed

+102
-29
lines changed

3 files changed

+102
-29
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
From 06050e79655f0fa7d9daeda1fbd3a9a2c7736841 Mon Sep 17 00:00:00 2001
2+
From: Mingli Yu <[email protected]>
3+
Date: Thu, 2 Dec 2021 15:08:25 +0800
4+
Subject: [PATCH] team_basic_test.py: switch to python3
5+
6+
Switch the script team_basic_test.py to python3
7+
8+
Upstream-Status: Submitted [https://github.com/jpirko/libteam/pull/63]
9+
10+
Signed-off-by: Mingli Yu <[email protected]>
11+
---
12+
scripts/team_basic_test.py | 28 ++++++++++++++--------------
13+
1 file changed, 14 insertions(+), 14 deletions(-)
14+
15+
diff --git a/scripts/team_basic_test.py b/scripts/team_basic_test.py
16+
index faabd18..0b64af2 100755
17+
--- a/scripts/team_basic_test.py
18+
+++ b/scripts/team_basic_test.py
19+
@@ -1,4 +1,4 @@
20+
-#! /usr/bin/env python
21+
+#! /usr/bin/env python3
22+
"""
23+
Basic test.
24+
25+
@@ -32,11 +32,11 @@ def usage():
26+
"""
27+
Print usage of this app
28+
"""
29+
- print "Usage: team_basic_test.py [OPTION...]"
30+
- print ""
31+
- print " -h, --help print this message"
32+
- print " -c, --loop-count=NUMBER number of loops (default 1)"
33+
- print " -p, --port=NETDEV port device (can be defined multiple times)"
34+
+ print("Usage: team_basic_test.py [OPTION...]")
35+
+ print("")
36+
+ print(" -h, --help print this message")
37+
+ print(" -c, --loop-count=NUMBER number of loops (default 1)")
38+
+ print(" -p, --port=NETDEV port device (can be defined multiple times)")
39+
sys.exit()
40+
41+
class CmdExecFailedException(Exception):
42+
@@ -55,15 +55,15 @@ class CmdExecUnexpectedOutputException(Exception):
43+
return "Command execution output unexpected: \"%s\" != \"%s\"" % (self.__output, self.__expected_output)
44+
45+
def print_output(out_type, string):
46+
- print("%s:\n"
47+
+ print(("%s:\n"
48+
"----------------------------\n"
49+
"%s"
50+
- "----------------------------" % (out_type, string))
51+
+ "----------------------------" % (out_type, string)))
52+
53+
def cmd_exec(cmd, expected_output=None, cleaner=False):
54+
cmd = cmd.rstrip(" ")
55+
if not cleaner:
56+
- print("# \"%s\"" % cmd)
57+
+ print(("# \"%s\"" % cmd))
58+
subp = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
59+
stderr=subprocess.PIPE)
60+
(data_stdout, data_stderr) = subp.communicate()
61+
@@ -74,7 +74,7 @@ def cmd_exec(cmd, expected_output=None, cleaner=False):
62+
if data_stderr:
63+
print_output("Stderr", data_stderr)
64+
raise CmdExecFailedException(subp.returncode)
65+
- output = data_stdout.rstrip()
66+
+ output = (data_stdout.rstrip()).decode()
67+
if expected_output:
68+
if output != expected_output:
69+
raise CmdExecUnexpectedOutputException(output, expected_output)
70+
@@ -166,7 +166,7 @@ TEAM_PORT_CONFIG='{"prio": 10}'
71+
os.removedirs("/tmp/team_test/")
72+
73+
def _run_one_loop(self, run_nr):
74+
- print "RUN #%d" % (run_nr)
75+
+ print("RUN #%d" % (run_nr))
76+
self._created_teams = []
77+
try:
78+
for mode_name in self._team_modes:
79+
@@ -176,7 +176,7 @@ TEAM_PORT_CONFIG='{"prio": 10}'
80+
cmd_exec("modprobe -r team_mode_loadbalance team_mode_roundrobin team_mode_activebackup team_mode_broadcast team");
81+
82+
def run(self):
83+
- for i in xrange(self._loop_count):
84+
+ for i in range(self._loop_count):
85+
self._run_one_loop(i + 1)
86+
87+
def main():
88+
@@ -186,8 +186,8 @@ def main():
89+
"hc:p:",
90+
["help", "loop-count=", "port="]
91+
)
92+
- except getopt.GetoptError, err:
93+
- print str(err)
94+
+ except getopt.GetoptError as err:
95+
+ print(str(err))
96+
usage()
97+
98+
btest = TeamBasicTest()
99+
--
100+
2.17.1
101+

meta-oe/recipes-support/libteam/libteam/0001-team_basic_test.py-use-python3-interpreter.patch

Lines changed: 0 additions & 28 deletions
This file was deleted.

meta-oe/recipes-support/libteam/libteam_1.31.bb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ SRC_URI = "git://github.com/jpirko/libteam;branch=master;protocol=https \
1111
file://0001-include-sys-select.h-for-fd_set-definition.patch \
1212
file://0002-teamd-Re-adjust-include-header-order.patch \
1313
file://0001-team_basic_test.py-disable-RedHat-specific-test.patch \
14-
file://0001-team_basic_test.py-use-python3-interpreter.patch \
14+
file://0001-team_basic_test.py-switch-to-python3.patch \
1515
file://run-ptest \
1616
"
1717
SRCREV = "3ee12c6d569977cf1cd30d0da77807a07aa77158"

0 commit comments

Comments
 (0)