[Toybox] [PATCH] tests.tar: fix tests for macOS.

enh enh at google.com
Wed Aug 31 12:54:48 PDT 2022


On Tue, Aug 30, 2022 at 4:20 AM Rob Landley <rob at landley.net> wrote:

> On 8/29/22 19:22, enh via Toybox wrote:
> > ping? i saw you added another tar test, but let me know your thoughts on
> this
> > before i rebase and fix the new test...
>
> Sorry, under the weather all weekend (and today). Pascal's Apology probably
> applies to some of the emails I've sent, except instead of them being long
> due
> to lack of time they're long due to lack of focus...
>
> Applied.


thanks! (i actually let slip a "woo hoo!" when i saw the github ci green
again for the first time in many weeks!)


> I wanted to clean it up to not be testing for darwin 13 separate times
> and haven't worked out how yet, but can do so later.


since i'm the only one who actually has a mac (and, not coincidentally, the
only one who really cares about mac tests in ci), any time there's
something like that just let me know what you want and i can do it.


> (I need some sort of group
> skip mechanic, ala "optional".  Which I note is only still used in
> tests/sort.test since I yanked most command sub-options, so I should
> probably
> revisit that too. A simple shell "if test; then ... fi" doesn't say
> "skipped"
> for the tests it skipped, and saying SKIPNEXT=5 instead of =1 and having it
> count down seems a bit brittle vs START/STOP marker...)
>

ah, okay, yeah --- you can do the infrastructure :-)

i wished i'd had that too, but at the same time i was unconvinced we'd
manage to keep things physically grouped like that, or that it would be
clear without indentation, or that we'd be happy with the result even if we
had the option.

i almost sent a patch that had a has_working_sparse_files variable instead,
which at least seemed a bit more intention-revealing (and, tbh, i'm
expecting that some day someone will report that one of the more exotic
linux filesystems doesn't do sparse files properly!).


> Also, the hashes changing when anything differs is frustrating. I wanted
> to be
> sure I was creating binary identical tarballs, and I am, but... is there a
> better way to test that? (WITHOUT having the output each thing's comparing
> against be 20 lines of hex dump... Maybe just a few tests can be hashes
> and the
> rest can be tar -tv or something? Skipping half the tests entirely and
> calling
> that "compliance" is frustrating. Yes the important thing is that it not
> fail,
> but passing a test by sabotaging the test is not ideal. Hmmm...)
>
> What _are_ the different permissions for a symlink on mac?


they're actually in the script already: that's what
https://github.com/landley/toybox/blob/master/tests/tar.test#L141 is doing
(for the tests that already use `tar tv` rather than SHAs).


> Could you hack
> something like this into your test (with VERBOSE=all and the darwin
> skipnots
> commented out) and run it on mac and send me the saved tarballs? I'd like
> to
> know what I'm up against...
>

that doesn't work because testdir gets deleted? (and you can only run `make
tests` on the mac, not `make test_tar` because the infrastructure for the
latter assumes realpath, which doesn't exist on macOS.)

even putting a `sleep 666` at the end of tar.test, `find . -name save.*`
doesn't find anything?

(anyway, like i say, i don't think you need this anyway because the hack
for the appropriate expected permissions is already in the script if you
just want to switch those tests from SHAs to `tar tv`?)


> --- a/tests/tar.test
> +++ b/tests/tar.test
> @@ -21,9 +21,12 @@ TAR='tar c --owner root --group sys --mtime @1234567890'
>
>  # Different tars add variable trailing NUL padding (1024 bytes is just
> minimum)
>  # so look at first N 512-byte frames when analyzing header content.
> +CHOCULA=1
>  function SUM()
>  {
>    tee save.dat | head -c $(($1*512)) | sha1sum | sed "s/ .*//"
> +  while [ -e "save.$CHOCULA" ]; do CHOCULA=$((CHOCULA+1)); done
> +  mv save.dat save.$CHOCULA
>  }
>
>  function LST()
>
> Rob
>
> P.S. Because SUM() gets run in a subshell so changes to CHOCULA get
> discarded no
> matter how you try to export them.
>
> P.P.S Pascal's apology again. Didn't say I was recovered, I'm just trying
> not to
> fall behind...
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20220831/6b3fbb8c/attachment-0001.htm>


More information about the Toybox mailing list