28538f8d9721d6b6503d16b4c6e7db1350cb7c53
braney
  Thu Sep 10 09:41:44 2026 -0700
lib/tests: add faSpeedReadTest, covering the FASTA read buffer growth, refs #38320

Eleven cases, each a set of line lengths. Each one writes a FASTA file,
reads it back with faMixedSpeedReadNext, and checks the name, the size,
every base and the terminating NUL.

The test frees the buffer before each case, so the growth starts from the
same place every time. That is what makes a shape reproduce a given sequence
of buffer sizes, and so what makes these shapes mean anything. Freeing also
means a write past the end of the buffer has to survive a free before the
next case can print.

The shapes are the one from the ticket, a variant whose overrun was small
enough to go unnoticed, the edges of the initial 65536 buffer, the first
doubling, a short line before a long one, a record spanning several
doublings, an evenly wrapped control, a single short line, and a two record
file so the second record is checked for anything the first left behind.

Against the code before the previous commit the test reports a short read
and differing bases on the first case, and exits non zero.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

diff --git src/lib/tests/makefile src/lib/tests/makefile
index ba04435e7d6..cfa34defdc0 100644
--- src/lib/tests/makefile
+++ src/lib/tests/makefile
@@ -1,46 +1,53 @@
 kentSrc = ../..
 include ../../inc/common.mk
 
 MYLIBDIR = ../../lib/${MACHTYPE}
 MYLIBS = ${MYLIBDIR}/jkweb.a
 BIN_DIR = bin/${MACHTYPE}
 
 pipelineTester = ${BIN_DIR}/pipelineTester
 
 test: errCatchTest htmlPageTest htmlExpandUrlTest htmlSanitizeTest pipelineTests dyStringTest \
     mimeTests base64Tests quotedPTests safeTest hashTest fetchUrlTest gff3Test \
     tabixTest vcfTest hacTreeTest mmHashTest testSumDoubles jsonQueryTest \
-    dnaCodonTest pathSimplifyTest
+    dnaCodonTest pathSimplifyTest faSpeedReadTest
 	rm -r output fetchUrlTest testSumDoubles
 	@echo tested all
 
 
 mkdirs:
 	${MKDIR} output ${BIN_DIR}
 
 testSumDoubles: testSumDoubles.o ${MYLIBS}
 	@${MKDIR} $(dir $@)
 	${CC} ${COPT} -o ./testSumDoubles testSumDoubles.o ${MYLIBS} ${L}
 
 pathSimplifyTest: pathSimplifyTest.o ${MYLIBS} mkdirs
 	@${MKDIR} $(dir $@)
 	${CC} ${COPT} -o ${BIN_DIR}/pathSimplifyTest pathSimplifyTest.o ${MYLIBS} ${L}
 	${STRIP} ${BIN_DIR}/pathSimplifyTest${EXE}
 	${BIN_DIR}/pathSimplifyTest > output/pathSimplifyTest
 	diff expected/pathSimplifyTest output/pathSimplifyTest
 
+faSpeedReadTest: faSpeedReadTest.o ${MYLIBS} mkdirs
+	@${MKDIR} $(dir $@)
+	${CC} ${COPT} -o ${BIN_DIR}/faSpeedReadTest faSpeedReadTest.o ${MYLIBS} ${L}
+	${STRIP} ${BIN_DIR}/faSpeedReadTest${EXE}
+	${BIN_DIR}/faSpeedReadTest > output/faSpeedReadTest
+	diff expected/faSpeedReadTest output/faSpeedReadTest
+
 dnaCodonTest: dnaCodonTest.o ${MYLIBS} mkdirs
 	@${MKDIR} $(dir $@)
 	${CC} ${COPT} -o ${BIN_DIR}/dnaCodonTest dnaCodonTest.o ${MYLIBS} ${L}
 	${STRIP} ${BIN_DIR}/dnaCodonTest${EXE}
 	${BIN_DIR}/dnaCodonTest > output/dnaCodonTest
 	diff expected/dnaCodonTest output/dnaCodonTest
 
 htmlSanitizeTest: htmlSanitizeTest.o ${MYLIBS} mkdirs
 	@${MKDIR} $(dir $@)
 	${CC} ${COPT} -o ${BIN_DIR}/htmlSanitizeTest htmlSanitizeTest.o ${MYLIBS} ${L}
 	${STRIP} ${BIN_DIR}/htmlSanitizeTest${EXE}
 	${BIN_DIR}/htmlSanitizeTest > output/htmlSanitizeTest
 	diff expected/htmlSanitizeTest output/htmlSanitizeTest
 
 errCatchTest: errCatchTest.o ${MYLIBS} mkdirs