Nintendo Entertainment System console with controller

Test-driven NES development (2): green, then red again

🔁 Where we left In part 1 we built a blank NES project and one test, tests/hello.lua, that expects “HELLO” in the nametable at column 12, row 14. The suite was red, for the right reason. Today we go around the loop twice: 🟢 make hello.lua pass with the least code possible 🔴 notice that green is not enough: the screen is still blank 🟢 add a font 🔴 write a test that the least code cannot pass The code is on branch part-2 of nes-tdd-demo: git clone -b part-2 https://github.com/ilmanzo/nes-tdd-demo. ...

December 2, 2026 · Andrea Manzini
Nintendo Famicom console with controllers

Test-driven NES development (1): red

🎮 Why test an NES game? During Hack Week 26 I wrote Hack to the Future, an endless runner for the Nintendo Entertainment System, in C. A 1983 console has no debugger you can attach to, no printf, and no unit test framework. What it has is an emulator: Mesen2 embeds a Lua scripting engine (if you need a refresher, see my previous Lua posts) and a headless --testRunner mode, so a script can run the ROM, press buttons, read RAM, VRAM and sprite memory, and exit with a status code. That is everything a test needs. The game ended up with about ten Lua test files, and they saved me many times (a drone that never hit a standing player, a HUD that scrolled with the playfield…). In this series I will rebuild the idea from scratch, in the smallest possible program, following the classic red-green-refactor loop: 🔴 write a test, watch it fail 🟢 write the least code that makes it pass 🔵 clean up, with the tests as safety net Goal of the series: a sprite you can move with the d-pad. Tiny, but it touches video, memory and input. Today: the toolbox, the blank project, and the first failing test. ...

November 30, 2026 · Andrea Manzini

How much code are you testing ? (3)

▶️ Intro : Let Me Be On the previous post we continued our journey with a more complex scenario, using a mix of gdb and valgrind to trace all the function execution inside a given binary. This time, hold on because we’re cranking up the complexity. We’ll dive deeper into low-level analysis and explore how to use Intel PIN, a powerful dynamic instrumentation framework for manipulating and inspecting executable code at runtime. (Photo by FURQAN KHURSHID) ...

June 17, 2025 · Andrea Manzini

playing with eBPF interface - 2

In the last post we introduced the BCC framework to interface Python code with eBPF facility. Now we are ready to make one step further! #!/usr/bin/python3 import bcc bpf = bcc.BPF(text=""" #include <uapi/linux/ptrace.h> int trace_malloc(struct pt_regs *ctx, size_t size) { bpf_trace_printk("size=%d\\n",size); return 0; };""") bpf.attach_uprobe(name="c",sym="malloc",fn_name="trace_malloc") while 1: (task, pid, cpu, flags, ts, msg) = bpf.trace_fields() print(f"task={task}\tmsg={msg}") This code is a little more complex, but still quite easy: first of all we use bcc to attach an “user space probe” instead of a kernel probe, and the function being observed will be libc’s malloc. ...

May 19, 2021 · Andrea Manzini
Buy Me a Coffee at ko-fi.com Buy Me A Coffee

This site does not use cookies or collect any personal data. © 2026 Andrea Manzini.