• 5 posts
  • 2 comments
Joined 11 days ago
Cake day: November 23rd, 2026

behave is a small Go tool (MIT) I made for checking whether a rewritten command line tool still behaves like the original.

You point it at the original binary. It reads --help, generates a few hundred cases (each flag, some values, stdin and file inputs, bad arguments), runs them and records stdout, stderr and the exit code into a YAML spec. Then you replay that spec against the new binary and every difference shows up as a failing case. Timestamps, pids and temp paths can be masked with regex rules, and the spec can live in CI.

I mostly used it on the uutils Rust rewrites of GNU coreutils, findutils, sed and procps. That led to 44 upstream bug reports and 51 fix PRs, 34 of them merged.

Install: go install github.com/emirmrkaljevic/behave/cmd/behave@latest (or the Homebrew tap). Feedback welcome.

I wrote behave in Go to check whether a rewrite of a command line tool really behaves like the original.

It treats the tool as a black box: it reads --help and the man page, generates cases (flags, flag pairs, odd stdin, missing files, bad values), runs them and records stdout, stderr and the exit code into a spec file. Then it replays the spec against another binary and every difference shows up as a failing case.

Most of my use so far was comparing GNU coreutils, findutils, sed and procps with the uutils Rust rewrites. That turned into 44 upstream bug reports and 51 fix PRs, 34 of them merged by mid November.

Some details: every case runs in a fresh temp dir with a fixed environment and its own timeout, cases that change between runs are marked flaky and skipped, and built-in normalizers (plus your own regex rules) strip timestamps, pids and temp paths before comparing. The same binary also runs as an MCP server. Install with go install github.com/emirmrkaljevic/behave/cmd/behave@latest or from the Homebrew tap. MIT licensed.

Feedback on the spec format or the case generator is welcome.

I kept buying hardware (case LCDs, RGB controllers, mice) that only ships a Windows app, so I built usb-rea. You capture USB traffic with USBPcap or usbmon while using the vendor app, and it groups the packets, diffs them, infers the command structure and drafts a small open-source Linux driver you can test. It also runs as an MCP server, so an LLM client can drive the analysis step by step. I validated it against public captures of devices whose protocols are already documented (Turing Smart Screen, Thermalright LCD), so the output can be checked against known ground truth. It is MIT licensed, feedback and captures of stubborn devices are welcome.

Since Ubuntu started shipping the Rust rewrite of coreutils by default, I got curious how close it really is to the GNU tools in day to day edge cases.

So I wrote a small recorder. It runs a CLI on a few hundred cases and saves what it did: stdout, stderr, exit code and the files it touched. Then it replays the same cases against another binary and shows the diffs.

Pointed at GNU coreutils 9.12 vs uutils, most differences were not crashes. They were error message wording, exit codes, option parsing corners (a bare - being taken as an option value) and a few things that turned out to be GNU version differences rather than bugs.

I reported what I found upstream: 44 bug reports and 51 small fix PRs so far, 34 merged. The uutils folks have been great to work with.

The tool is open source (MIT), works on any CLI, not only coreutils: https://github.com/emirmrkaljevic/behave

Curious if anyone here has run into a uutils difference that broke a script for them.

A lot of small hardware (case LCD screens, RGB controllers, AIO coolers, mice, macro pads) is only configurable through a closed Windows app, so on Linux it either works half way or not at all. I made usb-rea to shorten the reverse engineering part.

You capture USB traffic (USBPcap on Windows, usbmon on Linux) while clicking through the vendor app, optionally noting what you did (“brightness 50”, “colour red”). usb-rea groups the transfers into commands, finds the fields that change, checksums, handshakes and image streams, and writes an evidence report, a Wireshark Lua dissector and a small pyusb driver skeleton that you can turn into a proper open driver.

It is a plain CLI (it can also run as an MCP server), MIT licensed, on PyPI as usb-rea, and usb-rea demo runs the whole pipeline on a synthetic capture so you can try it without any hardware. It is tested against protocols that open projects already document (liquidctl, rivalcfg) and public Wireshark captures.

If you have a device stuck behind a Windows app and a capture where it gets things wrong, I would like to hear about it.

I have been sending small fixes to uutils, the Rust rewrites of coreutils, findutils, sed and procps. The way I find the bugs is simple: record how the GNU tool behaves on a few hundred cases (stdout, stderr, exit code, files it touches), then replay the same cases against the uutils build and read the diffs.

The write-up is about what that turned up. Almost nothing was a crash. It was error message wording, option parsing edge cases like a bare - being eaten as an option value, exit codes, and a few GNU version differences that look like bugs but are really version pins.

So far that is 44 bug reports and 51 fix PRs upstream, 34 of them merged. The recorder is a small open source tool I wrote: https://github.com/emirmrkaljevic/behave

Happy to hear how others test rewrites for compatibility.

  • Partly. The capture side is USB specific (it reads usbmon/USBPcap pcapng, endpoints and control setup packets), but the inference part is not: it diffs payloads between labelled actions and looks for constant headers, counters, length fields, checksums and value fields. Network protocols would mostly need a different front end that feeds it TCP/UDP payloads. That isn’t built in today. For network protocols Netzob is worth a look, it has been doing that kind of inference for years. File formats are harder because you rarely get clean “I changed exactly one thing” pairs, but the same diffing trick works if you save the file twice with one setting changed.

A lot of small hardware (AIO cooler screens, RGB hubs, stream decks, case LCDs) only ships a Windows app, and the usual route to Linux support is someone staring at Wireshark for an evening. I built usb-rea to do the step after Wireshark.

You capture with usbmon on Linux or USBPcap on Windows, label what you clicked in the vendor app (brightness 0, 50, 100, fan 30%, and so on), and it infers the command layout: constant headers, which byte follows which setting, counters, checksums like CRC16, lookup tables and image streams. It then writes a Markdown report where every claim points to Wireshark frame numbers, plus a standalone pyusb driver.

On public captures of the NZXT Kraken X it recovers the fan command byte for byte as liquidctl sends it, and the generated driver produces identical packets for values it never saw. It is alpha, MIT, pip install usb-rea, and usb-rea demo --device fan runs without any hardware.

If you have a device that only works on Windows, I am happy to run a capture through it and post the result.