예제 #1
0
    def test(self):
        self.gdb.b("main")
        output = self.gdb.c()
        assertIn(" main ", output)
        self.gdb.b("trap_entry")
        output = self.gdb.c()
        assertIn(" trap_entry ", output)
        assertEqual(self.gdb.p("$mip") & 0x80, 0x80)
        assertEqual(self.gdb.p("interrupt_count"), 0)
        # You'd expect local to still be 0, but it looks like spike doesn't
        # jump to the interrupt handler immediately after the write to
        # mtimecmp.
        assertLess(self.gdb.p("local"), 1000)
        self.gdb.command("delete breakpoints")
        for _ in range(10):
            self.gdb.c(wait=False)
            time.sleep(2)
            self.gdb.interrupt()
            interrupt_count = self.gdb.p("interrupt_count")
            local = self.gdb.p("local")
            if interrupt_count > 1000 and \
                    local > 1000:
                return

        assertGreater(interrupt_count, 1000)
        assertGreater(local, 1000)
예제 #2
0
    def test(self):
        self.gdb.b("main")
        output = self.gdb.c()
        assertIn(" main ", output)
        self.gdb.b("trap_entry")
        output = self.gdb.c()
        assertIn(" trap_entry ", output)
        assertEqual(self.gdb.p("$mip") & 0x80, 0x80)
        assertEqual(self.gdb.p("interrupt_count"), 0)
        # You'd expect local to still be 0, but it looks like spike doesn't
        # jump to the interrupt handler immediately after the write to
        # mtimecmp.
        assertLess(self.gdb.p("local"), 1000)
        self.gdb.command("delete breakpoints")
        for _ in range(10):
            self.gdb.c(wait=False)
            time.sleep(2)
            self.gdb.interrupt()
            interrupt_count = self.gdb.p("interrupt_count")
            local = self.gdb.p("local")
            if interrupt_count > 1000 and \
                    local > 1000:
                return

        assertGreater(interrupt_count, 1000)
        assertGreater(local, 1000)
예제 #3
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.")
예제 #4
0
 def check_reg(self, name):
     a = random.random()
     b = random.random()
     self.gdb.p_raw("$%s=%f" % (name, a))
     self.gdb.stepi()
     assertLess(abs(float(self.gdb.p_raw("$%s" % name)) - a), .001)
     self.gdb.p_raw("$%s=%f" % (name, b))
     self.gdb.stepi()
     assertLess(abs(float(self.gdb.p_raw("$%s" % name)) - b), .001)
예제 #5
0
 def check_reg(self, name):
     a = random.random()
     b = random.random()
     self.gdb.p_raw("$%s=%f" % (name, a))
     self.gdb.stepi()
     assertLess(abs(float(self.gdb.p_raw("$%s" % name)) - a), .001)
     self.gdb.p_raw("$%s=%f" % (name, b))
     self.gdb.stepi()
     assertLess(abs(float(self.gdb.p_raw("$%s" % name)) - b), .001)
예제 #6
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.")
예제 #7
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.")
예제 #8
0
    def check_reg(self, name, alias):
        if self.hart.extensionSupported('F'):
            mstatus_fs = 0x00006000
            self.gdb.p("$mstatus=$mstatus|0x%x" % mstatus_fs)
            self.gdb.stepi()
            a = random.random()
            b = random.random()
            self.gdb.p_fpr("$%s=%f" % (name, a))
            assertLess(abs((self.gdb.p_fpr("$%s" % alias)) - a), .001)
            self.gdb.stepi()
            assertLess(abs((self.gdb.p_fpr("$%s" % name)) - a), .001)
            assertLess(abs((self.gdb.p_fpr("$%s" % alias)) - a), .001)
            self.gdb.p_fpr("$%s=%f" % (alias, b))
            assertLess(abs((self.gdb.p_fpr("$%s" % name)) - b), .001)
            self.gdb.stepi()
            assertLess(abs((self.gdb.p_fpr("$%s" % name)) - b), .001)
            assertLess(abs((self.gdb.p_fpr("$%s" % alias)) - b), .001)

            size = self.gdb.p("sizeof($%s)" % name)
            if self.hart.extensionSupported('D'):
                assertEqual(size, 8)
            else:
                assertEqual(size, 4)
        else:
            output = self.gdb.p_raw("$" + name)
            assertRegexpMatches(output, r"void|Could not fetch register.*")
            output = self.gdb.p_raw("$" + alias)
            assertRegexpMatches(output, r"void|Could not fetch register.*")
예제 #9
0
    def check_reg(self, name, alias):
        if self.hart.extensionSupported('F'):
            self.gdb.p_raw("$mstatus=$mstatus | 0x00006000")
            self.gdb.stepi()
            a = random.random()
            b = random.random()
            self.gdb.p_raw("$%s=%f" % (name, a))
            assertLess(abs(float(self.gdb.p_raw("$%s" % alias)) - a), .001)
            self.gdb.stepi()
            assertLess(abs(float(self.gdb.p_raw("$%s" % name)) - a), .001)
            assertLess(abs(float(self.gdb.p_raw("$%s" % alias)) - a), .001)
            self.gdb.p_raw("$%s=%f" % (alias, b))
            assertLess(abs(float(self.gdb.p_raw("$%s" % name)) - b), .001)
            self.gdb.stepi()
            assertLess(abs(float(self.gdb.p_raw("$%s" % name)) - b), .001)
            assertLess(abs(float(self.gdb.p_raw("$%s" % alias)) - b), .001)

            size = self.gdb.p("sizeof($%s)" % name)
            if self.hart.extensionSupported('D'):
                assertEqual(size, 8)
            else:
                assertEqual(size, 4)
        else:
            output = self.gdb.p_raw("$" + name)
            assertEqual(output, "void")
            output = self.gdb.p_raw("$" + alias)
            assertEqual(output, "void")
예제 #10
0
 def check_reg(self, name, alias):
     self.gdb.p_raw("$mstatus=$mstatus | 0x00006000")
     self.gdb.stepi()
     a = random.random()
     b = random.random()
     self.gdb.p_raw("$%s=%f" % (name, a))
     assertLess(abs(float(self.gdb.p_raw("$%s" % alias)) - a), .001)
     self.gdb.stepi()
     assertLess(abs(float(self.gdb.p_raw("$%s" % name)) - a), .001)
     assertLess(abs(float(self.gdb.p_raw("$%s" % alias)) - a), .001)
     self.gdb.p_raw("$%s=%f" % (alias, b))
     assertLess(abs(float(self.gdb.p_raw("$%s" % name)) - b), .001)
     self.gdb.stepi()
     assertLess(abs(float(self.gdb.p_raw("$%s" % name)) - b), .001)
     assertLess(abs(float(self.gdb.p_raw("$%s" % alias)) - b), .001)
예제 #11
0
    def check_reg(self, name, alias):
        if self.hart.extensionSupported('F'):
            self.gdb.p_raw("$mstatus=$mstatus | 0x00006000")
            self.gdb.stepi()
            a = random.random()
            b = random.random()
            self.gdb.p_raw("$%s=%f" % (name, a))
            assertLess(abs(float(self.gdb.p_raw("$%s" % alias)) - a), .001)
            self.gdb.stepi()
            assertLess(abs(float(self.gdb.p_raw("$%s" % name)) - a), .001)
            assertLess(abs(float(self.gdb.p_raw("$%s" % alias)) - a), .001)
            self.gdb.p_raw("$%s=%f" % (alias, b))
            assertLess(abs(float(self.gdb.p_raw("$%s" % name)) - b), .001)
            self.gdb.stepi()
            assertLess(abs(float(self.gdb.p_raw("$%s" % name)) - b), .001)
            assertLess(abs(float(self.gdb.p_raw("$%s" % alias)) - b), .001)

            size = self.gdb.p("sizeof($%s)" % name)
            if self.hart.extensionSupported('D'):
                assertEqual(size, 8)
            else:
                assertEqual(size, 4)
        else:
            output = self.gdb.p_raw("$" + name)
            assertEqual(output, "void")
            output = self.gdb.p_raw("$" + alias)
            assertEqual(output, "void")