From 65dd669d8306889841d4d42e3fb4c7b34d1d1819 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Thu, 15 Feb 2024 16:26:48 -0600 Subject: [PATCH] Allowed overriding prettyasserts.py with an external prettyasserts tool Unfortunately, prettyasserts.py is having a hard time keeping up with the constantly increasing number of tests. This is creating real friction when debugging, as it now takes ~6x the time to preprocess asserts as it does to actually compile the thing: $ time ./scripts/prettyasserts.py \ -a LFS_ASSERT -u LFS_UNREACHABLE \ lfs.t.a.c -o lfs.t.c real 0m16.187s user 0m16.163s sys 0m0.025s $ time gcc -c -O0 -I. lfs.t.c -o lfs.o real 0m2.466s user 0m2.345s sys 0m0.105s Externally, I've rewritten prettyasserts.py in Rust, with more attention towards performance (prettyasserts.py does quite a number of string allocations). The result is quite satisfying: $ time ~/prettyasserts/prettyasserts \ -a LFS_ASSERT -u LFS_UNREACHABLE \ lfs.t.a.c -o lfs.t.c real 0m0.504s user 0m0.464s sys 0m0.040s However, adding Rust as a requirement to test littlefs would be, uh, quite a big jump. So instead, littlefs keeps prettyassert.py, so only Python is needed out of the box, and if the slow preprocessing is too much users are welcome to provide their own prettyasserts binary via the PRETTYASSERTS env variable: $ time \ DEBUG=1 \ make test-runner -j real 0m22.204s user 0m44.841s sys 0m1.478s $ time \ DEBUG=1 PRETTYASSERTS=~/prettyasserts/prettyasserts \ make test-runner -j real 0m5.699s user 0m23.590s sys 0m1.151s --- Makefile | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index ba973ef3..8a3d79f7 100644 --- a/Makefile +++ b/Makefile @@ -18,15 +18,16 @@ TARGET ?= $(BUILDDIR)/liblfs.a endif -CC ?= gcc -AR ?= ar -SIZE ?= size -CTAGS ?= ctags -NM ?= nm -OBJDUMP ?= objdump -VALGRIND ?= valgrind -GDB ?= gdb -PERF ?= perf +CC ?= gcc +AR ?= ar +SIZE ?= size +CTAGS ?= ctags +NM ?= nm +OBJDUMP ?= objdump +VALGRIND ?= valgrind +GDB ?= gdb +PERF ?= perf +PRETTYASSERTS ?= ./scripts/prettyasserts.py SRC ?= $(filter-out $(wildcard *.t.* *.b.*),$(wildcard *.c)) OBJ := $(SRC:%.c=$(BUILDDIR)/%.o) @@ -522,10 +523,10 @@ $(BUILDDIR)/%.s: %.c $(CC) -S $(CFLAGS) $< -o $@ $(BUILDDIR)/%.c: %.a.c - ./scripts/prettyasserts.py -a LFS_ASSERT -u LFS_UNREACHABLE $< -o $@ + $(PRETTYASSERTS) -a LFS_ASSERT -u LFS_UNREACHABLE $< -o $@ $(BUILDDIR)/%.c: $(BUILDDIR)/%.a.c - ./scripts/prettyasserts.py -a LFS_ASSERT -u LFS_UNREACHABLE $< -o $@ + $(PRETTYASSERTS) -a LFS_ASSERT -u LFS_UNREACHABLE $< -o $@ $(BUILDDIR)/%.t.a.c: %.toml ./scripts/test.py -c $< $(TESTCFLAGS) -o $@