[Toybox] macOS realpath test failures

enh enh at google.com
Fri Dec 2 10:19:12 PST 2022


On Wed, Nov 30, 2022 at 1:54 PM Rob Landley <rob at landley.net> wrote:

> On 11/28/22 12:41, enh via Toybox wrote:
> > github CI caught a few failures
>
> Sigh. There's a reason this has been on the todo list for literally years.
> It's
> corner cases all the way down and I don't have a mac test environment.
> (Works on
> linux not on mac means a libc function is returning something different,
> possibly because a syscall did, possibly because the VFS did something
> funky...)
>
> > (
> https://github.com/landley/toybox/actions/runs/3561813808/jobs/5983047254
> ):
> >
> > PASS: realpath -s
> >
> ............................................................................
> > ................................................
> > realpath: dos/three: Not a directory
>
> Not a directory? Up top we did:
>
>   mkdir -p one/two/three
>   ln -s ./one uno
>   ln -s one/two dos
>
> I don't THINK anything's done a cd or filesystem write since then?
> (one/two/three is a directory and dos points to "one/two"...)
>

*~/toybox/generated/testdir/testdir$ *ls -Rl

total 8

-rw-r--r--  1 enh  primarygroup   0 Dec  2 10:04 actual

lrwxr-xr-x  1 enh  primarygroup   7 Dec  2 10:04 dos -> one/two

-rw-r--r--  1 enh  primarygroup  54 Dec  2 10:04 expected

-rw-r--r--  1 enh  primarygroup   0 Dec  2 10:04 file

drwxr-xr-x  3 enh  primarygroup  96 Dec  2 10:04 one

lrwxr-xr-x  1 enh  primarygroup   5 Dec  2 10:04 uno -> ./one


./one:

total 0

drwxr-xr-x  3 enh  primarygroup  96 Dec  2 10:04 two


./one/two:

total 0

drwxr-xr-x  2 enh  primarygroup  64 Dec  2 10:04 three


./one/two/three:

total 0

*~/toybox/generated/testdir/testdir$ *

i added a bit of printf debugging to see exactly where it's failing, and
it's the openat() in the loop at the bottom of xabspath():

PASS: realpath -s
openat(4, three) 2 error
realpath: dos/three from /Users/enh/toybox/generated/testdir/testdir: Not a
directory
FAIL: realpath -s link/..
echo -ne '' | "/Users/enh/toybox/generated/testdir/realpath" -es dos/three
--- expected 2022-12-02 10:17:26.000000000 -0800
+++ actual 2022-12-02 10:17:26.000000000 -0800
@@ -1 +1,8 @@
-/Users/enh/toybox/generated/testdir/testdir/dos/three
+COMMAND    PID USER   FD   TYPE             DEVICE SIZE/OFF
 NODE NAME
+realpath 35535  enh  cwd    DIR               1,18      256
 19337560 /Users/enh/toybox/generated/testdir/testdir
+realpath 35535  enh  txt    REG               1,18    52840
 19337559 /Users/enh/toybox/generated/testdir/realpath
+realpath 35535  enh  txt    REG               1,18  2177216
1152921500312783005 /usr/lib/dyld
+realpath 35535  enh    0   PIPE 0x21ecbbc508f2f611    16384

+realpath 35535  enh    1w   REG               1,18        0
 19337607 /Users/enh/toybox/generated/testdir/testdir/actual
+realpath 35535  enh    2u   CHR               16,0  0t43970
 1155 /dev/ttys000
+realpath 35535  enh    4r  LINK               1,18        7
 19337567 /Users/enh/toybox/generated/testdir/testdir/dos
make: *** [test_realpath] Error 1
~/toybox$

(the lsof output there shows you what dirfd=4 is actually pointing to.)

> FAIL: realpath -s link/..
> > echo -ne '' |
> "/Users/runner/work/toybox/toybox/generated/testdir/realpath" -es
> > dos/three
> > --- expected 2022-11-28 04:54:16.000000000 +0000
> > +++ actual 2022-11-28 04:54:16.000000000 +0000
> > @@ -1 +0,0 @@
> > -/Users/runner/work/toybox/toybox/generated/testdir/testdir/dos/three
>
> Debris from that failure...
>
> > PASS: realpath -s .. eats symlink
> > PASS: realpath -s .. eats symlink in $PWD
>
> Neither of those actually looks at the filesystem because -s (don't expand
> symlinks) so there's potentially a getcwd() prepend then the ..
> cancellation is
> entirely string based...
>
> > FAIL: realpath -es dangling symlink
> > echo -ne '' |
> "/Users/runner/work/toybox/toybox/generated/testdir/realpath" -es
> > dangling 2>/dev/null || echo ok
> > --- expected 2022-11-28 04:54:16.000000000 +0000
> > +++ actual 2022-11-28 04:54:16.000000000 +0000
> > @@ -1 +1 @@
> > -ok
> > +/Users/runner/work/toybox/toybox/generated/testdir/testdir/dangling
>
> Adding -e however checks if the result exists. And the failure here is it
> SHOULDN'T, but MacOS thinks it DOES. (How do you even...?)
>
> > PASS: realpath -ms
> > realpath: one/two/ichi/two/ichi/two: Not a directory
>
> Our old friend again...
>
> > FAIL: realpath -es
> > echo -ne '' |
> "/Users/runner/work/toybox/toybox/generated/testdir/realpath" -es
> > one/two/ichi/two/ichi/two
> > --- expected 2022-11-28 04:54:16.000000000 +0000
> > +++ actual 2022-11-28 04:54:17.000000000 +0000
> > @@ -1 +0,0 @@
> >
> -/Users/runner/work/toybox/toybox/generated/testdir/testdir/one/two/ichi/two/ichi/two
>
> Sigh. If I stick printfs into a commit and push to a branch it'll
> _sometimes_
> run the tests on the new commit based on github server load, correct?
>
> Lemme finish fixing cp -s first (I.E. the rest of my relative path
> untangling
> todo item)...
>
> Rob
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20221202/88862687/attachment-0001.htm>


More information about the Toybox mailing list