summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej Żenczykowski <maze@google.com>2023-03-27 23:00:09 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-03-27 23:00:09 +0000
commit66ad14845d399c639969de39bc703ec0aed3067c (patch)
treed3341280b2e1d68166aceaaa9c8612430d7481a3
parent3e867473caa71338180e5dbb69ae955836a69364 (diff)
parent94ca59234d6524913173a3ce44b777672e016ded (diff)
downloadtests-66ad14845d399c639969de39bc703ec0aed3067c.tar.gz
net-test: use sys.maxsize not platform.architecture()[0] am: acb7b4a1e1 am: da81d25346 am: cf9b195937 am: 94ca59234d
Original change: https://android-review.googlesource.com/c/kernel/tests/+/2506773 Change-Id: Ie0561168837c5d5ce46beb99cf7eb6e2dc002c74 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rwxr-xr-xnet/test/bpf.py8
1 files changed, 2 insertions, 6 deletions
diff --git a/net/test/bpf.py b/net/test/bpf.py
index cef1a37..b96c82a 100755
--- a/net/test/bpf.py
+++ b/net/test/bpf.py
@@ -18,9 +18,9 @@
import ctypes
import os
-import platform
import resource
import socket
+import sys
import csocket
import cstruct
@@ -32,10 +32,6 @@ import net_test
# around this problem and pick the right syscall nr, we can additionally check
# the bitness of the python interpreter. Assume that the 64-bit architectures
# are not running with COMPAT_UTS_MACHINE and must be 64-bit at all times.
-#
-# Is there a better way of doing this?
-# Is it correct to use os.uname()[4] instead of platform.machine() ?
-# Should we use 'sys.maxsize > 2**32' instead of platform.architecture()[0] ?
__NR_bpf = { # pylint: disable=invalid-name
"aarch64-32bit": 386,
"aarch64-64bit": 280,
@@ -47,7 +43,7 @@ __NR_bpf = { # pylint: disable=invalid-name
"x86_64-32bit": 357,
"x86_64-64bit": 321,
"riscv64-64bit": 280,
-}[os.uname()[4] + "-" + platform.architecture()[0]]
+}[os.uname()[4] + "-" + ("64" if sys.maxsize > 0x7FFFFFFF else "32") + "bit"]
# After ACK merge of 5.10.168 is when support for this was backported from
# upstream Linux 5.14 and was merged into ACK android{12,13}-5.10 branches.