Skip to content

Leave the engine self-tests out of the APK - #269

Merged
xroche merged 2 commits into
masterfrom
drop-engine-selftests
Nov 1, 2026
Merged

xroche merged 2 commits into
masterfrom
drop-engine-selftests

Conversation

@xroche

@xroche xroche commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

The engine's self-tests were about 40% of its own compiled sources, and the app never asks for them. So the build defines HTS_NO_SELFTEST, which engine #2036 added for this, and drops the 24 self-test sources. The unsigned release APK falls from 24430732 to 22612108 bytes, and libhttrack.so loses about 10% on both ABIs.

Typing -#test into the Scan Rules field used to reach the self-test dispatcher, because that field passes its tokens through unfiltered. The engine now prints a refusal, and neither path ever crawled.

The new test holds the engine's own if SELFTESTS list against the one Android.mk builds, because nothing else links them.

xroche and others added 2 commits October 31, 2026 21:59
The self-test sources were about 40% of libhttrack's compiled code, and
nothing in the app can reach -#test, which is the only entry point that
runs them. Engine #2036 added the HTS_NO_SELFTEST guard around that call
site, so define it here and drop the 24 self-test sources from the
libhttrack source list.

Both halves are needed. A self-test source compiled under the macro
fails on the #error in htsselftest_int.h, and defining nothing while the
sources are gone leaves hts_selftest undefined at link time.

Measured on a release build at pin b0972289: the unsigned APK falls from
24430732 to 22612108 bytes, libhttrack.so from 8619880 to 7732952 on
arm64-v8a and from 8943032 to 8015128 on x86_64.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
The review found the earlier comment overclaimed. A user can reach -#test
by typing it into the Scan Rules field, which passes its tokens through
unfiltered, so say the app never asks for a self-test instead.

It also found the one real weakness: this repo now knows which engine
sources are self-tests, and nothing links the two lists. Re-adding one of
today's self-tests fails to compile on the #error in htsselftest_int.h,
but an engine that later adds a self-test without that header would come
back silently. So read the engine's own "if SELFTESTS" block and assert
our source list shares nothing with it. Mutation-checked: adding
htsopt_selftest.c back to the list turns the test red.

TestSources gains the flattened Android.mk reader CodeqlScopeTest had, so
the two tests parse the makefile the same way.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
@xroche
xroche enabled auto-merge (squash) November 1, 2026 07:50
@xroche
xroche merged commit 26ed8e1 into master Nov 1, 2026
7 checks passed
@xroche
xroche deleted the drop-engine-selftests branch November 1, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant