Esempio n. 1
0
    def testFillingFirstPage(self, MockEncodeAddressUnwinds):
        MockEncodeAddressUnwinds.return_value = EncodedAddressUnwind(
            0, b'\x00')

        self.assertEqual(
            [
                EncodedFunctionUnwind(page_number=0,
                                      page_offset=0,
                                      address_unwinds=REFUSE_TO_UNWIND),
                EncodedFunctionUnwind(page_number=0,
                                      page_offset=100 >> 1,
                                      address_unwinds=EncodedAddressUnwind(
                                          0, b'\x00')),
                EncodedFunctionUnwind(page_number=0,
                                      page_offset=200 >> 1,
                                      address_unwinds=EncodedAddressUnwind(
                                          0, b'\x00')),
                EncodedFunctionUnwind(page_number=0,
                                      page_offset=300 >> 1,
                                      address_unwinds=REFUSE_TO_UNWIND),
            ],
            list(
                EncodeFunctionUnwinds([
                    FunctionUnwind(address=1100, size=100, address_unwinds=()),
                    FunctionUnwind(address=1200, size=100, address_unwinds=()),
                ],
                                      text_section_start_address=1000)))
Esempio n. 2
0
    def testFillingGaps(self, MockEncodeAddressUnwinds):
        MockEncodeAddressUnwinds.return_value = EncodedAddressUnwind(
            0, b'\x00')

        self.assertEqual(
            [
                EncodedFunctionUnwind(page_number=0,
                                      page_offset=0,
                                      address_unwinds=EncodedAddressUnwind(
                                          0, b'\x00')),
                EncodedFunctionUnwind(page_number=0,
                                      page_offset=50 >> 1,
                                      address_unwinds=TRIVIAL_UNWIND),
                EncodedFunctionUnwind(page_number=0,
                                      page_offset=100 >> 1,
                                      address_unwinds=EncodedAddressUnwind(
                                          0, b'\x00')),
            ],
            list(
                EncodeFunctionUnwinds([
                    FunctionUnwind(address=0, size=50, address_unwinds=()),
                    FunctionUnwind(
                        address=100, size=PAGE_SIZE - 100, address_unwinds=()),
                ],
                                      text_section_start_address=0)))
Esempio n. 3
0
 def testOverlappedFunctions(self, _):
     self.assertRaises(
         # Eval generator with `list`. Otherwise the code will not execute.
         AssertionError,
         lambda: list(
             EncodeFunctionUnwinds([
                 FunctionUnwind(address=0, size=100, address_unwinds=()),
                 FunctionUnwind(address=50, size=100, address_unwinds=()),
             ])))
Esempio n. 4
0
    def testEncodeOrder(self, MockEncodeAddressUnwinds):
        MockEncodeAddressUnwinds.return_value = EncodedAddressUnwind(
            0, b'\x00')

        self.assertEqual([
            EncodedFunctionUnwind(page_number=0,
                                  page_offset=0,
                                  address_unwinds=EncodedAddressUnwind(
                                      0, b'\x00')),
            EncodedFunctionUnwind(page_number=0,
                                  page_offset=100 >> 1,
                                  address_unwinds=EncodedAddressUnwind(
                                      0, b'\x00')),
        ],
                         list(
                             EncodeFunctionUnwinds([
                                 FunctionUnwind(address=100,
                                                size=PAGE_SIZE - 100,
                                                address_unwinds=()),
                                 FunctionUnwind(address=0,
                                                size=100,
                                                address_unwinds=()),
                             ])))