[Toybox] [PATCH] tar.test: don't test non-`-p` behavior as root.
Rob Landley
rob at landley.net
Thu Aug 1 19:21:17 PDT 2024
On 8/1/24 10:24, enh wrote:
>> > i'm not sure what you're talking about? this isn't a hash-related test?
...
>> The tar "ownership" test.
>>
>> FAIL: tar ownership
...
> yes, on Android (as root, the only way we test) only two tests are skipped:
>
> SKIP: tar ownership
> SKIP: tar honor umask
>
> the reason for the former (as hinted at by the `skipnot chown
> nobody:nogroup dir/file 2>/dev/null`) is that there is no "nogroup" on
> Android.
$ grep ^no /etc/group
nogroup:x:65534:
nobody:x:65534:
On debian it appears to be an alias for nobody. Which probably shows up in "ls"
because it's first in the /etc/groups file. I have no idea why debian did that.
> an alternative here would be to use nobody:nobody, which works on all
> of Android/Debian/macOS. i don't know if we considered that at the
> time? it sounds familiar now i'm typing it out...
Ok, here's the problem:
$ git annotate tests/tar.test | grep '"ownership"' -A1
43d398ad5 (Elliott Hughes 2019-07-18 15:52:55 -0700 192)testing "ownership"
"$TAR dir/file | SUM 3" \
43d398ad5 (Elliott Hughes 2019-07-18 15:52:55 -0700 193)
"2d7b96c7025987215f5a41f10eaa84311160afdb\n" "" ""
$ git show 43d398ad5
commit 43d398ad5d7b14fb344fc2e5338177761b9a199a
Author: Elliott Hughes <enh at google.com>
Date: Thu Jul 18 15:52:55 2019 -0700
test.tar: fix tar tests on Android.
...
Fix the block/char special tests (the expectations were missing, but
they're never normally run on the host because the mknod fails).
Likewise add the missing expectation to the "ownership" test, which
isn't normally run on the host because the chown fails.
...
With this patch, all the tar tests now pass for me on both the device
and host.
The test came from you, and the hash came from you, and I was wondering what had
changed to produce a hatch that differed from the one you provided in the commit.
Especially since:
TAR='tar c --owner root --group sys --mtime @1234567890'
And thus:
skipnot chown nobody:nogroup dir/file 2>/dev/null
testing "ownership" "$TAR dir/file | SUM 3" \
"2d7b96c7025987215f5a41f10eaa84311160afdb\n" ""
In theory shouldn't care what user:group is on the file?
It looks like I checked in an unfinished test (hence the blank output), but the
REASON it was unfinished was a design issue, namely the $TAR macro disguises
variable ownership so you can't test with it so I need to override the fields to
provide a sstable tarball manually in this test, and I wasn't sure what they were.
Expecially since the UID/GID variance on mac is badly defined. It says:
$ grep nobody /etc/group
nobody:*:-2:
And in _theory_ that's getting typecast to (unsigned short) and thus trimmed to
65534 by the system somewhere, except on mac:
$ echo '#include <sys/stat.h>' | cc -E - | grep gid_t
typedef __uint32_t __darwin_gid_t;
typedef __darwin_gid_t gid_t;
If __uint32_t is 16 bits on MacOS it's... about what I expect there, really. And
if not, then it's getting truncated in the kernel, or by the filesystem, or...
Anyway, if this test doesn't work for you, and you submitted it, then me redoing
it shouldn't break you. Modulo "does the result test the same on android" is
something I can't answer until you try it and tell me. :)
(I still want an AOSP "lunch shellprompt" target that builds _just_ a little
qemu test system, but I'd still have to download and regularishly update a
half-terabyte of AOSP source to build it...)
Rob
More information about the Toybox
mailing list