MCPcopy Create free account
hub / github.com/iovisor/bcc / test_update_batch_subset

Method test_update_batch_subset

tests/python/test_map_batch_ops.py:120–142  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

118 self.assertEqual(count, -1*self.MAPSIZE)
119
120 def test_update_batch_subset(self):
121 # fill the hashmap
122 hmap = self.fill_hashmap()
123 keys = self.prepare_keys_subset(hmap, count=self.SUBSET_SIZE)
124 new_values = self.prepare_values_subset(hmap, count=self.SUBSET_SIZE)
125
126 hmap.items_update_batch(keys, new_values)
127
128 # check all the values in the map
129 # the first self.SUBSET_SIZE keys follow this rule value = keys * keys
130 # the remaning keys follow this rule : value = keys
131 i = 0
132 for k, v in sorted(hmap.items_lookup_batch(),
133 key=lambda kv:kv[0].value):
134 if i < self.SUBSET_SIZE:
135 # values are the square of the keys
136 self.assertEqual(v.value, k.value * k.value)
137 i += 1
138 else:
139 # values = keys
140 self.assertEqual(v.value, k.value)
141
142 self.assertEqual(i, self.SUBSET_SIZE)
143
144
145if __name__ == "__main__":

Callers

nothing calls this directly

Calls 5

fill_hashmapMethod · 0.95
prepare_keys_subsetMethod · 0.95
prepare_values_subsetMethod · 0.95
items_update_batchMethod · 0.80
items_lookup_batchMethod · 0.80

Tested by

no test coverage detected