docker: Bump default LLVM used for tests to 11
authorDave Marchevsky <davemarchevsky@fb.com>
Mon, 20 Dec 2021 22:47:11 +0000 (17:47 -0500)
committeryonghong-song <ys114321@gmail.com>
Tue, 21 Dec 2021 00:47:01 +0000 (16:47 -0800)
This is another prep commit for running docker tests on both 18.04 and
20.04 versions of ubuntu. 20.04 doesn't have some LLVM 8 libs that the
docker build expects, so bump to 11.

Bumping to 11 causes test_disassembler to fail because it expects a map
w/ a certain format with FD 3, and the LLVM bump causes the map to be
FD 4. The purpose of the test is to ensure that the format of the
diassembled map is correct, not that it has a specific FD, so make some
small changes to the test so that it doesn't care what the FD number is.

Dockerfile.tests
tests/python/test_disassembler.py

index 3b082364b65edfdc2d24578c6670b16780b689cf..c43b22cf3f530582bfea599c02c6ea435d092545 100644 (file)
@@ -1,7 +1,7 @@
 ARG UBUNTU_VERSION="18.04"
 FROM ubuntu:${UBUNTU_VERSION}
 
-ARG LLVM_VERSION="8"
+ARG LLVM_VERSION="11"
 ENV LLVM_VERSION=$LLVM_VERSION
 
 ARG UBUNTU_SHORTNAME="bionic"
index bf324d2b362462ca55eb20e91cf72bff356b9d22..794309a952fa3a98b704ad721865d32b845b39b2 100755 (executable)
@@ -151,7 +151,25 @@ class TestDisassembler(TestCase):
    1: (95) exit""",
             b.disassemble_func("test_func"))
         
-        self.assertEqual(
+        def _assert_equal_ignore_fd_id(s1, s2):
+            # In first line of string like
+            #    Layout of BPF map test_map (type HASH, FD 3, ID 0):
+            # Ignore everything from FD to end-of-line
+            # Compare rest of string normally
+            s1_lines = s1.split('\n')
+            s2_lines = s2.split('\n')
+            s1_first_cut = s1_lines[0]
+            s1_first_cut = s1_first_cut[0:s1_first_cut.index("FD")]
+            s2_first_cut = s2_lines[0]
+            s2_first_cut = s2_first_cut[0:s2_first_cut.index("FD")]
+
+            self.assertEqual(s1_first_cut, s2_first_cut)
+
+            s1_rest = '\n'.join(s1_lines[1:])
+            s2_rest = '\n'.join(s2_lines[1:])
+            self.assertEqual(s1_rest, s2_rest)
+
+        _assert_equal_ignore_fd_id(
             """Layout of BPF map test_map (type HASH, FD 3, ID 0):
   struct {
     int a;