-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add python3 virtual environment for docker-ptf #10599
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2b8e15e
Add python3 virtual environment for docker-ptf
ZhaohuiS b92bb18
Use absolute path for virtual python3 env
ZhaohuiS d9069fa
add version number for six
ZhaohuiS 374ff57
Update comments
ZhaohuiS edbd217
add some packages which installed in py2 environment
ZhaohuiS 8dfd850
Remove sflowtool, openBFDD and nanomsg
ZhaohuiS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
SPATH := $($(PTF_PY3)_SRC_PATH) | ||
DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/ptf-py3.mk rules/ptf-py3.dep | ||
DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) | ||
SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files)) | ||
|
||
$(PTF_PY3)_CACHE_MODE := GIT_CONTENT_SHA | ||
$(PTF_PY3)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) | ||
$(PTF_PY3)_DEP_FILES := $(DEP_FILES) | ||
$(PTF_PY3)_SMDEP_FILES := $(SMDEP_FILES) | ||
$(PTF_PY3)_SMDEP_PATHS := $(SPATH) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# ptf package | ||
|
||
PTF_PY3 = ptf-0.9.3-py3-none-any.whl | ||
$(PTF_PY3)_SRC_PATH = $(SRC_PATH)/ptf-py3 | ||
$(PTF_PY3)_PYTHON_VERSION = 3 | ||
$(PTF_PY3)_TEST = n | ||
SONIC_PYTHON_WHEELS += $(PTF_PY3) |
26 changes: 26 additions & 0 deletions
26
src/ptf-py3.patch/0001-Remove-ord-in-get_mac-to-avoid-TypeError.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
From a8b13b9fbaa16ddd305ba2df2238ef606ef222a7 Mon Sep 17 00:00:00 2001 | ||
From: Zhaohui Sun <zhaohuisun@microsoft.com> | ||
Date: Wed, 13 Apr 2022 09:24:46 +0000 | ||
Subject: [PATCH 1/2] Remove ord in get_mac() to avoid TypeError | ||
|
||
Signed-off-by: Zhaohui Sun <zhaohuisun@microsoft.com> | ||
--- | ||
src/ptf/netutils.py | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/src/ptf/netutils.py b/src/ptf/netutils.py | ||
index 752e76c..6aabe79 100644 | ||
--- a/src/ptf/netutils.py | ||
+++ b/src/ptf/netutils.py | ||
@@ -54,7 +54,7 @@ def get_if_index(iff): | ||
|
||
|
||
def get_mac(iff): | ||
- return ":".join(["%02x" % ord(char) for char in get_if(iff, SIOCGIFHWADDR)[18:24]]) | ||
+ return ":".join(["%02x" % char for char in get_if(iff, SIOCGIFHWADDR)[18:24]]) | ||
|
||
|
||
def set_promisc(s, iff, val=1): | ||
-- | ||
2.25.1 | ||
|
36 changes: 36 additions & 0 deletions
36
src/ptf-py3.patch/0002-Fill-byte-formatted-client-mac-address-in-DHCP-Disco.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
From 6e570e00ea05882d2db1e480ed041ea631bf37da Mon Sep 17 00:00:00 2001 | ||
From: Zhaohui Sun <zhaohuisun@microsoft.com> | ||
Date: Wed, 13 Apr 2022 09:25:28 +0000 | ||
Subject: [PATCH 2/2] Fill byte formatted client mac address in DHCP Discover | ||
packet | ||
|
||
Signed-off-by: Zhaohui Sun <zhaohuisun@microsoft.com> | ||
--- | ||
src/ptf/testutils.py | 9 +++++---- | ||
1 file changed, 5 insertions(+), 4 deletions(-) | ||
|
||
diff --git a/src/ptf/testutils.py b/src/ptf/testutils.py | ||
index ab67cea..83a9075 100755 | ||
--- a/src/ptf/testutils.py | ||
+++ b/src/ptf/testutils.py | ||
@@ -2712,12 +2712,13 @@ def __dhcp_mac_to_chaddr(mac_addr="00:01:02:03:04:05"): | ||
""" | ||
Private helper function to convert a 6-byte MAC address of form: | ||
'00:01:02:03:04:05' | ||
- into a 16-byte chaddr byte string of form: | ||
- '\x00\x01\x02\x03\x04\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' | ||
+ into a 16-byte chaddr byte of form: | ||
+ b'\x00\x01\x02\x03\x04\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' | ||
|
||
""" | ||
- chaddr = "".join([chr(int(octet, 16)) for octet in mac_addr.split(":")]) | ||
- chaddr += "\x00" * 10 | ||
+ import binascii | ||
+ chaddr = binascii.unhexlify(mac_addr.replace(':', '')) | ||
+ chaddr += b'\x00\x00\x00\x00\x00\x00' | ||
return chaddr | ||
|
||
|
||
-- | ||
2.25.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
0001-Remove-ord-in-get_mac-to-avoid-TypeError.patch | ||
0002-Fill-byte-formatted-client-mac-address-in-DHCP-Disco.patch |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python venv should be python, not sure if sflowtool, openbfdd, nanomsg has python part?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lguohan You are right, they are not python part, checked existing test cases, they don't have to be in virtual environment. Remove this part in my latest commit.
The usage is as below.