Exemplo n.º 1
0
    def test(self):
        if self.gdb.one_hart_per_gdb() or not self.server.smp():
            return 'not_applicable'

        old_mtime = set()
        for _ in range(5):
            self.gdb.c_all(wait=False)
            time.sleep(2)
            self.gdb.interrupt_all()

            mtime_value = []
            counter = []
            for hart in self.target.harts:
                self.gdb.select_hart(hart)
                mv = self.gdb.p("mtime_value")
                assertNotIn(mv, old_mtime,
                        "mtime doesn't appear to be changing at all")
                mtime_value.append(mv)
                c = self.gdb.p("counter")
                assertNotEqual(c, 0,
                        "counter didn't increment; code didn't run?")
                counter.append(c)
                self.gdb.p("counter=0")

            old_mtime.update(mtime_value)

            mtime_spread = max(mtime_value) - min(mtime_value)
            print "mtime_spread:", mtime_spread
            counter_spread = max(counter) - min(counter)
            print "counter_spread:", counter_spread

            assertLess(mtime_spread, 100 * len(self.target.harts),
                    "Harts don't halt around the same time.")
Exemplo n.º 2
0
 def test(self):
     """Single step a bunch of times."""
     self.gdb.b("main:start")
     self.gdb.c()
     self.gdb.command("p i=0")
     last_pc = None
     advances = 0
     jumps = 0
     for _ in range(10):
         self.gdb.stepi()
         pc = self.gdb.p("$pc")
         assertNotEqual(last_pc, pc)
         if last_pc and pc > last_pc and pc - last_pc <= 4:
             advances += 1
         else:
             jumps += 1
         last_pc = pc
     # Some basic sanity that we're not running between breakpoints or
     # something.
     assertGreater(jumps, 1)
     assertGreater(advances, 5)
Exemplo n.º 3
0
 def test(self):
     """Single step a bunch of times."""
     self.gdb.b("main:start")
     self.gdb.c()
     self.gdb.command("p i=0")
     last_pc = None
     advances = 0
     jumps = 0
     for _ in range(100):
         self.gdb.stepi()
         pc = self.gdb.p("$pc")
         assertNotEqual(last_pc, pc)
         if last_pc and pc > last_pc and pc - last_pc <= 4:
             advances += 1
         else:
             jumps += 1
         last_pc = pc
     # Some basic sanity that we're not running between breakpoints or
     # something.
     assertGreater(jumps, 10)
     assertGreater(advances, 50)
Exemplo n.º 4
0
    def test(self):
        if self.gdb.one_hart_per_gdb() or not self.server.smp():
            raise TestNotApplicable

        old_mtime = set()
        for _ in range(5):
            self.gdb.c_all(wait=False)
            time.sleep(2)
            self.gdb.interrupt_all()

            mtime_value = []
            counter = []
            for hart in self.target.harts:
                self.gdb.select_hart(hart)
                mv = self.gdb.p("$s2")
                assertNotIn(mv, old_mtime,
                            "mtime doesn't appear to be changing at all")
                mtime_value.append(mv)
                c = self.gdb.p("$s0")
                assertNotEqual(c, 0,
                               "counter didn't increment; code didn't run?")
                counter.append(c)
                # Reset the counter for the next round.
                self.gdb.p("$s0=0")

            old_mtime.update(mtime_value)

            mtime_spread = max(mtime_value) - min(mtime_value)
            print "mtime_spread:", mtime_spread
            counter_spread = max(counter) - min(counter)
            print "counter_spread:", counter_spread

            assertLess(mtime_spread, 101 * (len(self.target.harts) - 1),
                       "Harts don't halt around the same time.")
            # spike executes normal code 5000 instructions at a time, so we
            # expect 5k instructions to be executed on one hart before the
            # other gets to go. Our loop (unoptimized) is quite a few
            # instructions, but allow for 5k anyway.
            assertLess(counter_spread, 5001 * (len(self.target.harts) - 1),
                       "Harts don't resume around the same time.")
Exemplo n.º 5
0
    def test(self):
        if self.gdb.one_hart_per_gdb() or not self.server.smp():
            return 'not_applicable'

        old_mtime = set()
        for _ in range(5):
            self.gdb.c_all(wait=False)
            time.sleep(2)
            self.gdb.interrupt_all()

            mtime_value = []
            counter = []
            for hart in self.target.harts:
                self.gdb.select_hart(hart)
                mv = self.gdb.p("$s2")
                assertNotIn(mv, old_mtime,
                        "mtime doesn't appear to be changing at all")
                mtime_value.append(mv)
                c = self.gdb.p("$s0")
                assertNotEqual(c, 0,
                        "counter didn't increment; code didn't run?")
                counter.append(c)
                # Reset the counter for the next round.
                self.gdb.p("$s0=0")

            old_mtime.update(mtime_value)

            mtime_spread = max(mtime_value) - min(mtime_value)
            print "mtime_spread:", mtime_spread
            counter_spread = max(counter) - min(counter)
            print "counter_spread:", counter_spread

            assertLess(mtime_spread, 101 * (len(self.target.harts) - 1),
                    "Harts don't halt around the same time.")
            # spike executes normal code 5000 instructions at a time, so we
            # expect 5k instructions to be executed on one hart before the
            # other gets to go. Our loop (unoptimized) is quite a few
            # instructions, but allow for 5k anyway.
            assertLess(counter_spread, 5001 * (len(self.target.harts) - 1),
                    "Harts don't resume around the same time.")
Exemplo n.º 6
0
 def test(self):
     previous_hart_count = [0 for h in self.target.harts]
     previous_interrupt_count = [0 for h in self.target.harts]
     # Check 10 times
     for i in range(10):
         # 3 attempts for each time we want the check to pass
         for attempt in range(3):
             self.gdb.global_command("echo round %d attempt %d\\n" %
                                     (i, attempt))
             self.gdb.c_all(wait=False)
             time.sleep(2)
             self.gdb.interrupt_all()
             hart_count = self.gdb.p("hart_count")
             interrupt_count = self.gdb.p("interrupt_count")
             ok = True
             for i, h in enumerate(self.target.harts):
                 if hart_count[i] <= previous_hart_count[i]:
                     ok = False
                     break
                 if interrupt_count[i] <= previous_interrupt_count[i]:
                     ok = False
                     break
                 self.gdb.p("$mie")
                 self.gdb.p("$mip")
                 self.gdb.p("$mstatus")
                 self.gdb.p("$priv")
                 self.gdb.p("buf", fmt="")
                 self.gdb.select_hart(h)
                 pc = self.gdb.p("$pc")
                 self.gdb.stepi()
                 stepped_pc = self.gdb.p("$pc")
                 assertNotEqual(pc, stepped_pc)
             previous_hart_count = hart_count
             previous_interrupt_count = interrupt_count
             if ok:
                 break
         else:
             assert False, \
                     "hart count or interrupt didn't increment as expected"
Exemplo n.º 7
0
 def test(self):
     previous_hart_count = [0 for h in self.target.harts]
     previous_interrupt_count = [0 for h in self.target.harts]
     for _ in range(10):
         self.gdb.c(wait=False)
         time.sleep(2)
         self.gdb.interrupt()
         self.gdb.p("$mie")
         self.gdb.p("$mip")
         self.gdb.p("$mstatus")
         self.gdb.p("$priv")
         self.gdb.p("buf", fmt="")
         hart_count = self.gdb.p("hart_count")
         interrupt_count = self.gdb.p("interrupt_count")
         for i, h in enumerate(self.target.harts):
             assertGreater(hart_count[i], previous_hart_count[i])
             assertGreater(interrupt_count[i], previous_interrupt_count[i])
             self.gdb.select_hart(h)
             pc = self.gdb.p("$pc")
             self.gdb.stepi()
             stepped_pc = self.gdb.p("$pc")
             assertNotEqual(pc, stepped_pc)