Beispiel #1
0
 def test_pop_raises_if_no_more_states(self):
     queue = TraceQueue()
     try:
         queue.pop()
         self.fail()
     except KeyError as exc:
         self.assertEqual(exc.args[0], 'pop from empty trace queue')
Beispiel #2
0
 def test_pop_removes_state_from_untraced_and_adds_to_traced(self):
     queue = TraceQueue()
     queue.push(ProcessorState(pc=0x0005))
     self.assertEqual(queue.untraced_processor_states,
                      set([ProcessorState(pc=0x0005)]))
     state = queue.pop()
     self.assertEqual(state.pc, 0x0005)
     self.assertEqual(queue.untraced_processor_states, set())
     self.assertEqual(queue.traced_processor_states,
                      set([ProcessorState(pc=0x0005)]))
Beispiel #3
0
 def test_push_doesnt_add_state_if_already_in_traced(self):
     queue = TraceQueue()
     queue.push(ProcessorState(pc=0x0005))
     self.assertEqual(len(queue), 1)
     queue.pop()
     queue.push(ProcessorState(pc=0x0005))
     self.assertEqual(len(queue), 0)
Beispiel #4
0
 def test_pop_returns_states_in_pc_sorted_order(self):
     queue = TraceQueue()
     queue.push(ProcessorState(pc=0x0003))
     queue.push(ProcessorState(pc=0x0001))
     queue.push(ProcessorState(pc=0x0002))
     self.assertEqual(queue.pop().pc, 0x0001)
     self.assertEqual(queue.pop().pc, 0x0002)
     self.assertEqual(queue.pop().pc, 0x0003)
Beispiel #5
0
 def test_push_adds_state_to_untraced(self):
     queue = TraceQueue()
     queue.push(ProcessorState(pc=0x0005))
     self.assertEqual(queue.untraced_processor_states,
                      set([ProcessorState(pc=0x0005)]))
     queue.push(ProcessorState(0x0006))
     self.assertEqual(
         set(queue.untraced_processor_states),
         set([ProcessorState(pc=0x0005),
              ProcessorState(pc=0x0006)]))
Beispiel #6
0
 def test_len_returns_untraced_length(self):
     queue = TraceQueue()
     queue.push(ProcessorState(pc=0x0001))
     queue.push(ProcessorState(pc=0x0002))
     self.assertEqual(len(queue), 2)
Beispiel #7
0
 def test_ctor(self):
     queue = TraceQueue()
     self.assertEqual(queue.traced_processor_states, set())
     self.assertEqual(queue.untraced_processor_states, SortedSet())