Beispiel #1
0
    def test_update(self):
        symbol_mapping_cache = SymbolMappingCache()
        cache_f = cStringIO.StringIO()
        cache_f.write(self._TEST_FUNCTION_CACHE)

        # No update from self._TEST_FUNCTION_CACHE
        symbol_mapping_cache.update(
            FUNCTION_SYMBOLS,
            self.MockBucketSet(self._TEST_FUNCTION_ADDRESS_LIST1),
            self.MockSymbolFinder(self._TEST_FUNCTION_DICT),
            cache_f,
        )
        for address in self._TEST_FUNCTION_ADDRESS_LIST1:
            self.assertEqual(self._TEST_FUNCTION_DICT[address], symbol_mapping_cache.lookup(FUNCTION_SYMBOLS, address))
        self.assertEqual(self._TEST_FUNCTION_CACHE, cache_f.getvalue())

        # Update to self._TEST_FUNCTION_ADDRESS_LIST2
        symbol_mapping_cache.update(
            FUNCTION_SYMBOLS,
            self.MockBucketSet(self._TEST_FUNCTION_ADDRESS_LIST2),
            self.MockSymbolFinder(self._TEST_FUNCTION_DICT),
            cache_f,
        )
        for address in self._TEST_FUNCTION_ADDRESS_LIST2:
            self.assertEqual(self._TEST_FUNCTION_DICT[address], symbol_mapping_cache.lookup(FUNCTION_SYMBOLS, address))
        self.assertEqual(self._EXPECTED_TEST_FUNCTION_CACHE, cache_f.getvalue())
    def test_update(self):
        symbol_mapping_cache = SymbolMappingCache()
        cache_f = cStringIO.StringIO()
        cache_f.write(self._TEST_FUNCTION_CACHE)

        # No update from self._TEST_FUNCTION_CACHE
        symbol_mapping_cache.update(
            FUNCTION_SYMBOLS,
            self.MockBucketSet(self._TEST_FUNCTION_ADDRESS_LIST1),
            self.MockSymbolFinder(self._TEST_FUNCTION_DICT), cache_f)
        for address in self._TEST_FUNCTION_ADDRESS_LIST1:
            self.assertEqual(
                self._TEST_FUNCTION_DICT[address],
                symbol_mapping_cache.lookup(FUNCTION_SYMBOLS, address))
        self.assertEqual(self._TEST_FUNCTION_CACHE, cache_f.getvalue())

        # Update to self._TEST_FUNCTION_ADDRESS_LIST2
        symbol_mapping_cache.update(
            FUNCTION_SYMBOLS,
            self.MockBucketSet(self._TEST_FUNCTION_ADDRESS_LIST2),
            self.MockSymbolFinder(self._TEST_FUNCTION_DICT), cache_f)
        for address in self._TEST_FUNCTION_ADDRESS_LIST2:
            self.assertEqual(
                self._TEST_FUNCTION_DICT[address],
                symbol_mapping_cache.lookup(FUNCTION_SYMBOLS, address))
        self.assertEqual(self._EXPECTED_TEST_FUNCTION_CACHE,
                         cache_f.getvalue())