[Toybox] test.c hex/octal bug
Rob Landley
rob at landley.net
Wed Nov 25 14:05:07 PST 2020
On 11/24/20 5:06 PM, Luke Frankart wrote:
> I found that `toybox test -w` returned true for a file with 0440 mode bits, and
> was able to find failures for other cases (below).
>
> I think the root cause and fix is to use octal 0111 instead of hexadecimal 0x111
> on this line:
> https://github.com/landley/toybox/blob/master/toys/posix/test.c#L74
Oops. Reflex. I should add a test for this...
And "make test_test" fails because it complains there's no trailing ']' which it
should only do when called as '[', and that's because a standalone build of test
doesn't include the command multiplexer so it doesn't dispatch on the filename,
instead it hardwired calls the first entry in toy_list which is sorted and '['
comes before 't'. The fix is to USE_SH() instead of USE_TEST() around the
OLDTOY() since it's a nofork so the [ version can _only_ be called from the
shell (unlike busybox which installs it in the filesystem for some reason).
Ah, and the _other_ reason tests/test.test hasn't got chmod +x on it (so it gets
called by "make tests", which is plural because "make test" builds _this_
command standalone.) is that the second half of the test file is a bunch of
comments of tests I should add to it.
Specifically, THIS one falls under:
# TODO: Test rwx gu t
And it's not -t (that's is a TTY), it's -k to test the sticky bit, which I don't
seem to have implemented?
Ok, try now?
Thanks,
Rob
More information about the Toybox
mailing list