Skip to content

Commit 9f206d2

Browse files
timsherwoodclaude
andcommitted
Add debug test fixture to enable list command tests
- Add debug_test.c with fibonacci function for debug info testing - Add riscv.ld linker script for correct memory layout (0x80000000) - Update tests to use new debug_test fixture - All 5 previously skipped list tests now pass (294 total) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f4b5044 commit 9f206d2

File tree

4 files changed

+58
-19
lines changed

4 files changed

+58
-19
lines changed

tests/fixtures/debug_test

6.6 KB
Binary file not shown.

tests/fixtures/debug_test.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* Simple test program for debug info testing */
2+
3+
int fibonacci(int n) {
4+
if (n <= 1) {
5+
return n;
6+
}
7+
return fibonacci(n - 1) + fibonacci(n - 2);
8+
}
9+
10+
int main() {
11+
int result = fibonacci(7);
12+
return result;
13+
}

tests/fixtures/riscv.ld

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* Simple RISC-V linker script for MapacheSPIM */
2+
ENTRY(main)
3+
4+
MEMORY
5+
{
6+
ram (rwx) : ORIGIN = 0x80000000, LENGTH = 0x10000
7+
}
8+
9+
SECTIONS
10+
{
11+
.text : {
12+
*(.text*)
13+
} > ram
14+
15+
.rodata : {
16+
*(.rodata*)
17+
} > ram
18+
19+
.data : {
20+
*(.data*)
21+
} > ram
22+
23+
.bss : {
24+
*(.bss*)
25+
} > ram
26+
}

tests/test_console_working.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class TestConsoleCommands(unittest.TestCase):
2020

2121
SIMPLE_PATH = 'tests/fixtures/test_simple'
2222
FIBONACCI_PATH = 'examples/riscv/fibonacci/fibonacci'
23-
FIBONACCI_DEBUG_PATH = 'examples/riscv/fibonacci/fibonacci_debug'
23+
DEBUG_TEST_PATH = 'tests/fixtures/debug_test'
2424

2525
def setUp(self):
2626
"""Create a fresh console for each test"""
@@ -441,10 +441,10 @@ def test_list_with_debug_info(self):
441441
"""Test 'list' command with program compiled with -g"""
442442
# Check if debug binary exists
443443
from pathlib import Path
444-
if not Path(self.FIBONACCI_DEBUG_PATH).exists():
445-
self.skipTest(f'Debug binary not found: {self.FIBONACCI_DEBUG_PATH}')
444+
if not Path(self.DEBUG_TEST_PATH).exists():
445+
self.skipTest(f'Debug binary not found: {self.DEBUG_TEST_PATH}')
446446

447-
self.console.onecmd(f'load {self.FIBONACCI_DEBUG_PATH}')
447+
self.console.onecmd(f'load {self.DEBUG_TEST_PATH}')
448448

449449
# Should have debug info
450450
self.assertTrue(self.console.source_info.has_debug_info)
@@ -459,10 +459,10 @@ def test_list_with_debug_info(self):
459459
def test_list_after_stepping(self):
460460
"""Test 'list' shows correct line after stepping"""
461461
from pathlib import Path
462-
if not Path(self.FIBONACCI_DEBUG_PATH).exists():
463-
self.skipTest(f'Debug binary not found: {self.FIBONACCI_DEBUG_PATH}')
462+
if not Path(self.DEBUG_TEST_PATH).exists():
463+
self.skipTest(f'Debug binary not found: {self.DEBUG_TEST_PATH}')
464464

465-
self.console.onecmd(f'load {self.FIBONACCI_DEBUG_PATH}')
465+
self.console.onecmd(f'load {self.DEBUG_TEST_PATH}')
466466

467467
# Step a few times
468468
self.console.onecmd('step 3')
@@ -477,44 +477,44 @@ def test_list_after_stepping(self):
477477
def test_list_with_function_name(self):
478478
"""Test 'list <function>' to show source around function"""
479479
from pathlib import Path
480-
if not Path(self.FIBONACCI_DEBUG_PATH).exists():
481-
self.skipTest(f'Debug binary not found: {self.FIBONACCI_DEBUG_PATH}')
480+
if not Path(self.DEBUG_TEST_PATH).exists():
481+
self.skipTest(f'Debug binary not found: {self.DEBUG_TEST_PATH}')
482482

483-
self.console.onecmd(f'load {self.FIBONACCI_DEBUG_PATH}')
483+
self.console.onecmd(f'load {self.DEBUG_TEST_PATH}')
484484

485485
# Try listing around 'fibonacci' function
486486
self.console.onecmd('list fibonacci')
487487

488488
# Should not crash
489-
self.assertEqual(self.console.loaded_file, self.FIBONACCI_DEBUG_PATH)
489+
self.assertEqual(self.console.loaded_file, self.DEBUG_TEST_PATH)
490490

491491
def test_list_with_line_number(self):
492492
"""Test 'list <line>' to show source around specific line"""
493493
from pathlib import Path
494-
if not Path(self.FIBONACCI_DEBUG_PATH).exists():
495-
self.skipTest(f'Debug binary not found: {self.FIBONACCI_DEBUG_PATH}')
494+
if not Path(self.DEBUG_TEST_PATH).exists():
495+
self.skipTest(f'Debug binary not found: {self.DEBUG_TEST_PATH}')
496496

497-
self.console.onecmd(f'load {self.FIBONACCI_DEBUG_PATH}')
497+
self.console.onecmd(f'load {self.DEBUG_TEST_PATH}')
498498

499499
# Try listing around line 40
500500
self.console.onecmd('list 40')
501501

502502
# Should not crash
503-
self.assertEqual(self.console.loaded_file, self.FIBONACCI_DEBUG_PATH)
503+
self.assertEqual(self.console.loaded_file, self.DEBUG_TEST_PATH)
504504

505505
def test_list_alias(self):
506506
"""Test 'l' alias for list command"""
507507
from pathlib import Path
508-
if not Path(self.FIBONACCI_DEBUG_PATH).exists():
509-
self.skipTest(f'Debug binary not found: {self.FIBONACCI_DEBUG_PATH}')
508+
if not Path(self.DEBUG_TEST_PATH).exists():
509+
self.skipTest(f'Debug binary not found: {self.DEBUG_TEST_PATH}')
510510

511-
self.console.onecmd(f'load {self.FIBONACCI_DEBUG_PATH}')
511+
self.console.onecmd(f'load {self.DEBUG_TEST_PATH}')
512512

513513
# 'l' should work the same as 'list'
514514
self.console.onecmd('l')
515515

516516
# Should not crash
517-
self.assertEqual(self.console.loaded_file, self.FIBONACCI_DEBUG_PATH)
517+
self.assertEqual(self.console.loaded_file, self.DEBUG_TEST_PATH)
518518

519519
def test_list_without_loaded_program(self):
520520
"""Test 'list' without loading a program first"""

0 commit comments

Comments
 (0)