def setup_module():
    """Setup the test tidy reprs for the test classes in the module."""
    global OLD_PWD
    OLD_PWD = os.getcwd()
    os.chdir(os.path.join(os.path.dirname(__file__),
                          'ubsan_output_test_files'))

    ubsan1_repr = [
        Message(
            os.path.abspath('files/ubsan1.cpp'), 4, 5,
            "signed integer overflow: 2147483647 + 1 cannot be represented "
            "in type 'int'", "UndefinedBehaviorSanitizer"),
    ]

    ubsan2_repr = [
        Message(
            os.path.abspath('files/ubsan2.cpp'), 13, 10,
            "load of value 7, which is not a valid value for type 'enum E'",
            "UndefinedBehaviorSanitizer"),
        Message(os.path.abspath('files/ubsan2.cpp'), 21, 7,
                "load of value 2, which is not a valid value for type 'bool'",
                "UndefinedBehaviorSanitizer"),
    ]

    UBSANOutputParserTestCase.ubsan1_repr = ubsan1_repr
    UBSANOutputParserTestCase.ubsan2_repr = ubsan2_repr
    UBSANPListConverterTestCase.ubsan1_repr = ubsan1_repr
    UBSANPListConverterTestCase.ubsan2_repr = ubsan2_repr
    def setUp(self):
        """Setup the OutputParser."""
        self.parser = UBSANParser()
        self.ubsan1_repr = [
            Message(
                os.path.abspath('files/ubsan1.cpp'),
                4, 5,
                "signed integer overflow: 2147483647 + 1 cannot be "
                "represented in type 'int'",
                "UndefinedBehaviorSanitizer"),
        ]

        self.ubsan2_repr = [
            Message(
                os.path.abspath('files/ubsan2.cpp'),
                13, 10,
                "load of value 7, which is not a valid value for type "
                "'enum E'",
                "UndefinedBehaviorSanitizer"),
            Message(
                os.path.abspath('files/ubsan2.cpp'),
                21, 7,
                "load of value 2, which is not a valid value for type 'bool'",
                "UndefinedBehaviorSanitizer"),
        ]
Example #3
0
 def setUp(self):
     """Setup the OutputParser."""
     self.parser = TSANParser()
     self.tsan_repr = [
         Message(
             os.path.abspath('files/tsan.cpp'), 24, 2,
             "SEGV on unknown address 0x000000000000 (pc 0x0000004b525c bp "
             "0x7fff93b54920 sp 0x7fff93b548b0 T23755)", "ThreadSanitizer",
             [
                 Event(os.path.abspath('files/tsan.cpp'), 24, 2,
                       "    #1 main files/tsan.cpp:24:2 (a.out+0x4b529e)"),
                 Event(
                     os.path.abspath('files/tsan.cpp'), 18, 14,
                     "    #0 insert_in_table(unsigned long, int) "
                     "files/tsan.cpp:18:14 (a.out+0x4b525b)")
             ], [
                 Event(
                     os.path.abspath('files/tsan.cpp'), 24, 2,
                     "==23755==The signal is caused by a WRITE memory access.\n"
                     "==23755==Hint: address points to the zero page.\n"
                     "    #0 insert_in_table(unsigned long, int) "
                     "files/tsan.cpp:18:14 (a.out+0x4b525b)\n"
                     "    #1 main files/tsan.cpp:24:2 (a.out+0x4b529e)\n"
                     "    #2 __libc_start_main /build/glibc-OTsEL5/glibc-2.27/"
                     "csu/../csu/libc-start.c:310 (libc.so.6+0x21b96)\n"
                     "    #3 _start <null> (a.out+0x41c8d9)\n")
             ]),
     ]
Example #4
0
 def setUp(self):
     """Setup the OutputParser."""
     self.parser = ASANParser()
     self.asan_repr = [
         Message(
             os.path.abspath('files/asan.cpp'),
             5, 10,
             "heap-use-after-free on address 0x614000000044 at pc "
             "0x0000004f4b45 bp 0x7ffd40559120 sp 0x7ffd40559118",
             "AddressSanitizer",
             [Event(
                 os.path.abspath('files/asan.cpp'),
                 5, 10,
                 "    #0 0x4f4b44 in main files/asan.cpp:5:10"
             )],
             [Event(
                 os.path.abspath('files/asan.cpp'),
                 5, 10,
                 "READ of size 4 at 0x614000000044 thread T0\n"
                 "    #0 0x4f4b44 in main files/asan.cpp:5:10\n"
                 "    #1 0x7f334b52eb96 in __libc_start_main (??)\n"
                 "    #2 0x41aaf9 in _start (??)\n"
             )]
         ),
     ]
Example #5
0
 def setUp(self):
     """ Setup the OutputParser. """
     self.parser = LSANParser()
     self.lsan_repr = [
         Message(
             os.path.abspath('files/lsan.c'),
             4, 7,
             "detected memory leaks",
             "LeakSanitizer",
             [Event(
                 os.path.abspath('files/lsan.c'),
                 4, 7,
                 "    #1 0x4da26a in main files/lsan.c:4:7"
             )],
             [Event(
                 os.path.abspath('files/lsan.c'),
                 4, 7,
                 "Direct leak of 7 byte(s) in 1 object(s) allocated from:\n"
                 "    #0 0x4af01b in __interceptor_malloc /projects/"
                 "compiler-rt/lib/asan/asan_malloc_linux.cc:52:3\n"
                 "    #1 0x4da26a in main files/lsan.c:4:7\n"
                 "    #2 0x7f076fd9cec4 in __libc_start_main "
                 "libc-start.c:287\n"
                 "SUMMARY: AddressSanitizer: 7 byte(s) "
                 "leaked in 1 allocation(s)\n"
             )]),
     ]
Example #6
0
def setup_module():
    """Setup the test tidy reprs for the test classes in the module."""
    global OLD_PWD
    OLD_PWD = os.getcwd()
    os.chdir(os.path.join(os.path.dirname(__file__), 'asan_output_test_files'))

    asan_repr = [
        Message(
            os.path.abspath('files/asan.cpp'), 5, 10,
            "heap-use-after-free on address 0x614000000044 at pc "
            "0x0000004f4b45 bp 0x7ffd40559120 sp 0x7ffd40559118",
            "AddressSanitizer", [
                Event(os.path.abspath('files/asan.cpp'), 5, 10,
                      "    #0 0x4f4b44 in main files/asan.cpp:5:10")
            ], [
                Event(
                    os.path.abspath('files/asan.cpp'), 5, 10,
                    "READ of size 4 at 0x614000000044 thread T0\n"
                    "    #0 0x4f4b44 in main files/asan.cpp:5:10\n"
                    "    #1 0x7f334b52eb96 in __libc_start_main (??)\n"
                    "    #2 0x41aaf9 in _start (??)\n")
            ]),
    ]

    ASANOutputParserTestCase.asan_repr = asan_repr
    ASANPListConverterTestCase.asan_repr = asan_repr
def setup_module():
    """Setup the test tidy reprs for the test classes in the module."""
    global OLD_PWD
    OLD_PWD = os.getcwd()
    os.chdir(os.path.join(os.path.dirname(__file__), 'tsan_output_test_files'))

    tsan_repr = [
        Message(
            os.path.abspath('files/tsan.cpp'), 24, 2,
            "SEGV on unknown address 0x000000000000 (pc 0x0000004b525c bp "
            "0x7fff93b54920 sp 0x7fff93b548b0 T23755)", "ThreadSanitizer", [
                Event(os.path.abspath('files/tsan.cpp'), 24, 2,
                      "    #1 main files/tsan.cpp:24:2 (a.out+0x4b529e)"),
                Event(
                    os.path.abspath('files/tsan.cpp'), 18, 14,
                    "    #0 insert_in_table(unsigned long, int) "
                    "files/tsan.cpp:18:14 (a.out+0x4b525b)")
            ], [
                Event(
                    os.path.abspath('files/tsan.cpp'), 24, 2,
                    "==23755==The signal is caused by a WRITE memory access.\n"
                    "==23755==Hint: address points to the zero page.\n"
                    "    #0 insert_in_table(unsigned long, int) "
                    "files/tsan.cpp:18:14 (a.out+0x4b525b)\n"
                    "    #1 main files/tsan.cpp:24:2 (a.out+0x4b529e)\n"
                    "    #2 __libc_start_main /build/glibc-OTsEL5/glibc-2.27/"
                    "csu/../csu/libc-start.c:310 (libc.so.6+0x21b96)\n"
                    "    #3 _start <null> (a.out+0x41c8d9)\n")
            ]),
    ]

    TSANOutputParserTestCase.tsan_repr = tsan_repr
    TSANPListConverterTestCase.tsan_repr = tsan_repr
 def setUp(self):
     """ Setup the OutputParser. """
     self.parser = MSANParser()
     self.msan_repr = [
         Message(os.path.abspath('files/msan.cpp'), 7, 7,
                 "use-of-uninitialized-value", "MemorySanitizer", [
                     Event(os.path.abspath('files/msan.cpp'), 7, 7,
                           "    #0 0x4940da in main files/msan.cpp:7:7")
                 ], [
                     Event(
                         os.path.abspath('files/msan.cpp'), 7, 7,
                         "    #0 0x4940da in main files/msan.cpp:7:7\n"
                         "    #1 0x7fed9df58b96 in __libc_start_main (??)\n"
                         "    #2 0x41b2d9 in _start (??)\n")
                 ]),
     ]
Example #9
0
def setup_module():
    """Setup the test tidy reprs for the test classes in the module."""
    global OLD_PWD
    OLD_PWD = os.getcwd()
    os.chdir(os.path.join(os.path.dirname(__file__), 'msan_output_test_files'))

    msan_repr = [
        Message(os.path.abspath('files/msan.cpp'), 7, 7,
                "use-of-uninitialized-value", "MemorySanitizer", [
                    Event(os.path.abspath('files/msan.cpp'), 7, 7,
                          "    #0 0x4940da in main files/msan.cpp:7:7")
                ], [
                    Event(
                        os.path.abspath('files/msan.cpp'), 7, 7,
                        "    #0 0x4940da in main files/msan.cpp:7:7\n"
                        "    #1 0x7fed9df58b96 in __libc_start_main (??)\n"
                        "    #2 0x41b2d9 in _start (??)\n")
                ]),
    ]

    MSANOutputParserTestCase.msan_repr = msan_repr
    MSANPListConverterTestCase.msan_repr = msan_repr
Example #10
0
    def setUp(self):
        """Setup the OutputParser."""
        self.parser = ClangTidyParser()

        # tidy1.out Message/Note representation
        self.tidy1_repr = [
            Message(
                os.path.abspath('files/test.cpp'),
                8, 12,
                'Division by zero',
                'clang-analyzer-core.DivideZero',
                [Event(
                    os.path.abspath('files/test.cpp'),
                    8, 12,
                    'Division by zero')]),
            Message(
                os.path.abspath('files/test.cpp'),
                8, 12,
                'remainder by zero is undefined',
                'clang-diagnostic-division-by-zero')
        ]

        # tidy2.out Message/Note representation
        self.tidy2_repr = [
            Message(
                os.path.abspath('files/test2.cpp'),
                5, 7,
                "unused variable 'y'",
                'clang-diagnostic-unused-variable'),
            Message(
                os.path.abspath('files/test2.cpp'),
                13, 12,
                'Division by zero',
                'clang-analyzer-core.DivideZero',
                [
                    Event(
                        os.path.abspath('files/test2.cpp'),
                        9, 7,
                        "Left side of '||' is false"),
                    Event(
                        os.path.abspath('files/test2.cpp'),
                        9, 3,
                        'Taking false branch'),
                    Event(
                        os.path.abspath('files/test2.cpp'),
                        13, 12,
                        'Division by zero')
                ]),
            Message(
                os.path.abspath('files/test2.cpp'),
                13, 12,
                'remainder by zero is undefined',
                'clang-diagnostic-division-by-zero'),
        ]

        # tidy2_v6.out Message/Note representation
        self.tidy2_v6_repr = [
            Message(
                os.path.abspath('files/test2.cpp'),
                13, 12,
                'Division by zero',
                'clang-analyzer-core.DivideZero',
                [
                    Event(
                        os.path.abspath('files/test2.cpp'),
                        9, 7,
                        "Left side of '||' is false"),
                    Event(
                        os.path.abspath('files/test2.cpp'),
                        9, 16,
                        "Assuming 'x' is 0"),
                    Event(
                        os.path.abspath('files/test2.cpp'),
                        9, 3,
                        'Taking false branch'),
                    Event(
                        os.path.abspath('files/test2.cpp'),
                        13, 12,
                        'Division by zero')
                ]),
            Message(
                os.path.abspath('files/test2.cpp'),
                13, 12,
                'remainder by zero is undefined',
                'clang-diagnostic-division-by-zero'),
        ]

        # tidy3.out Message/Note representation
        self.tidy3_repr = [
            Message(
                os.path.abspath('files/test3.cpp'),
                4, 12,
                'use nullptr',
                'modernize-use-nullptr',
                None,
                None,
                [Event(
                    os.path.abspath('files/test3.cpp'),
                    4, 12,
                    'nullptr')]),
            Message(
                os.path.abspath('files/test3.hh'),
                6, 6,
                "Dereference of null pointer (loaded from variable 'x')",
                'clang-analyzer-core.NullDereference',
                [
                    Event(
                        os.path.abspath('files/test3.cpp'),
                        4, 3,
                        "'x' initialized to a null pointer value"),
                    Event(
                        os.path.abspath('files/test3.cpp'),
                        6, 11,
                        "Assuming 'argc' is > 3"),
                    Event(
                        os.path.abspath('files/test3.cpp'),
                        6, 3,
                        'Taking true branch'),
                    Event(
                        os.path.abspath('files/test3.cpp'),
                        7, 9,
                        "Passing null pointer value via 1st parameter 'x'"),
                    Event(
                        os.path.abspath('files/test3.cpp'),
                        7, 5,
                        "Calling 'bar'"),
                    Event(
                        os.path.abspath('files/test3.hh'),
                        6, 6,
                        "Dereference of null pointer (loaded from variable "
                        "'x')")
                ])
        ]

        # tidy5.out Message/Note representation
        self.tidy5_repr = [
            Message(
                os.path.abspath('files/test4.cpp'),
                3, 26,
                'identifier after literal will be treated '
                'as a reserved user-defined literal suffix in C++11',
                'clang-diagnostic-c++11-compat-reserved-user-defined-literal'),
            Message(
                os.path.abspath('files/test4.cpp'),
                10, 12,
                'Division by zero',
                'clang-analyzer-core.DivideZero',
                [Event(
                    os.path.abspath('files/test4.cpp'),
                    10, 12,
                    'Division by zero')]),
            Message(
                os.path.abspath('files/test4.cpp'),
                10, 12,
                'remainder by zero is undefined',
                'clang-diagnostic-division-by-zero')
        ]

        # tidy5_v6.out Message/Note representation
        self.tidy5_v6_repr = [
            Message(
                os.path.abspath('files/test4.cpp'),
                3, 26,
                'invalid suffix on literal; C++11 requires a space '
                'between literal and identifier',
                'clang-diagnostic-reserved-user-defined-literal'),
            Message(
                os.path.abspath('files/test4.cpp'),
                10, 12,
                'remainder by zero is undefined',
                'clang-diagnostic-division-by-zero')
        ]

        # tidy6.out Message/Note representation
        self.tidy6_repr = [
            Message(
                os.path.abspath('files/test5.cpp'),
                10, 9,
                'no matching function for call to \'get_type\'',
                'clang-diagnostic-error',
                [
                    Event(
                        os.path.abspath('files/test5.cpp'),
                        2, 18,
                        'candidate template ignored: substitution failure '
                        '[with T = int *]: type \'int *\' cannot be used '
                        'prior to \'::\' because it has no members'),
                    Event(
                        os.path.abspath('files/test5.cpp'),
                        5, 6,
                        'candidate template ignored: substitution failure '
                        '[with T = int]: array size is negative'),
                ]
            )]