diff options
author | Mingli Yu <mingli.yu@windriver.com> | 2021-12-02 15:59:47 +0800 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2021-12-02 07:52:17 -0800 |
commit | a12cd7869b4f6ff11e6b67dd3f243298941641e7 (patch) | |
tree | 8280d6681776b4335c552ccdea434b362620e068 /meta-oe/recipes-support | |
parent | d0f133d642fe88b9c0bf93cbee3c31c7a9cd17db (diff) | |
download | meta-openembedded-a12cd7869b4f6ff11e6b67dd3f243298941641e7.tar.gz |
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 <mingli.yu@windriver.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-oe/recipes-support')
3 files changed, 102 insertions, 29 deletions
diff --git a/meta-oe/recipes-support/libteam/libteam/0001-team_basic_test.py-switch-to-python3.patch b/meta-oe/recipes-support/libteam/libteam/0001-team_basic_test.py-switch-to-python3.patch new file mode 100644 index 000000000..69276aba9 --- /dev/null +++ b/meta-oe/recipes-support/libteam/libteam/0001-team_basic_test.py-switch-to-python3.patch | |||
@@ -0,0 +1,101 @@ | |||
1 | From 06050e79655f0fa7d9daeda1fbd3a9a2c7736841 Mon Sep 17 00:00:00 2001 | ||
2 | From: Mingli Yu <mingli.yu@windriver.com> | ||
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 <mingli.yu@windriver.com> | ||
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 | |||
diff --git a/meta-oe/recipes-support/libteam/libteam/0001-team_basic_test.py-use-python3-interpreter.patch b/meta-oe/recipes-support/libteam/libteam/0001-team_basic_test.py-use-python3-interpreter.patch deleted file mode 100644 index e27e4f329..000000000 --- a/meta-oe/recipes-support/libteam/libteam/0001-team_basic_test.py-use-python3-interpreter.patch +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | From 571c141b434dff13494c6a3afe621f63a8e610e9 Mon Sep 17 00:00:00 2001 | ||
2 | From: Andrey Zhizhikin <andrey.z@gmail.com> | ||
3 | Date: Mon, 27 Jan 2020 14:29:34 +0000 | ||
4 | Subject: [PATCH] team_basic_test.py: use python3 interpreter | ||
5 | |||
6 | Use python3 since python2 is EOL and has been removed from several | ||
7 | distributions. | ||
8 | |||
9 | Upstream-Status: Pending | ||
10 | |||
11 | Signed-off-by: Andrey Zhizhikin <andrey.z@gmail.com> | ||
12 | --- | ||
13 | scripts/team_basic_test.py | 2 +- | ||
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/scripts/team_basic_test.py b/scripts/team_basic_test.py | ||
17 | index b05be9e..ad980e8 100755 | ||
18 | --- a/scripts/team_basic_test.py | ||
19 | +++ b/scripts/team_basic_test.py | ||
20 | @@ -1,4 +1,4 @@ | ||
21 | -#! /usr/bin/env python | ||
22 | +#! /usr/bin/env python3 | ||
23 | """ | ||
24 | Basic test. | ||
25 | |||
26 | -- | ||
27 | 2.17.1 | ||
28 | |||
diff --git a/meta-oe/recipes-support/libteam/libteam_1.31.bb b/meta-oe/recipes-support/libteam/libteam_1.31.bb index f1cad9321..a3bed722e 100644 --- a/meta-oe/recipes-support/libteam/libteam_1.31.bb +++ b/meta-oe/recipes-support/libteam/libteam_1.31.bb | |||
@@ -11,7 +11,7 @@ SRC_URI = "git://github.com/jpirko/libteam;branch=master;protocol=https \ | |||
11 | file://0001-include-sys-select.h-for-fd_set-definition.patch \ | 11 | file://0001-include-sys-select.h-for-fd_set-definition.patch \ |
12 | file://0002-teamd-Re-adjust-include-header-order.patch \ | 12 | file://0002-teamd-Re-adjust-include-header-order.patch \ |
13 | file://0001-team_basic_test.py-disable-RedHat-specific-test.patch \ | 13 | 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 \ |
15 | file://run-ptest \ | 15 | file://run-ptest \ |
16 | " | 16 | " |
17 | SRCREV = "3ee12c6d569977cf1cd30d0da77807a07aa77158" | 17 | SRCREV = "3ee12c6d569977cf1cd30d0da77807a07aa77158" |