Symbolic links in llvm/clang tests

Björn Pettersson A via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 29 08:07:24 PDT 2016


> -----Original Message-----
> From: Rafael Espíndola [mailto:rafael.espindola at gmail.com]
> Sent: den 29 juni 2016 16:57
> To: Björn Pettersson A <bjorn.a.pettersson at ericsson.com>
> Cc: llvm-commits <llvm-commits at lists.llvm.org>
> Subject: Re: Symbolic links in llvm/clang tests
> 
> On 29 June 2016 at 10:42, Björn Pettersson A
> <bjorn.a.pettersson at ericsson.com> wrote:
> > Hello Rafael!
> >
> >
> >
> > I found some test cases in llvm/clang that creates symbolic links to
> > directories
> >
> > (which you seem to have been involved according to commit history).
> >
> >
> >
> > The problem is that the testcases basically are doing
> >
> >    ln -sf foo bar
> >
> > where foo is a directory.
> >
> >
> >
> > This will, as expected, create a symbolic link, bar -> foo, the first time
> > the test executes.
> >
> >
> >
> > But if I run the test a second time (without clean in between), then ln will
> > treat the
> >
> > already present bar as a target directory and create the symbolic link in
> > that directory.
> >
> > So we basically get a link: foo/foo -> ../foo
> >
> >
> >
> >
> >
> > Man page for ln says:
> >
> >
> >
> > Usage: ln [OPTION]... [-T] TARGET LINK_NAME   (1st form)
> >
> >   or:  ln [OPTION]... TARGET                  (2nd form)
> >
> >   or:  ln [OPTION]... TARGET... DIRECTORY     (3rd form)
> >
> >   or:  ln [OPTION]... -t DIRECTORY TARGET...  (4th form)
> >
> >
> >
> > So basically we end up with “1st form” the first time, and “3rd form” the
> > second time.
> >
> >
> >
> >
> >
> > All of this is not really a big problem, but it creates a recursive
> > directory structure
> >
> > (and some poorly written programs that traverses the directory structure
> > runs into problems..).
> >
> >
> >
> > One solution is to use -T option to always end up treating bar as a
> > LINK_NAME and not a DIRECTORY.
> >
> > Another is to let the test case remove the old symlink (if it exists) before
> > creating it again.
> >
> >
> >
> > The test cases that I’ve found (so far) that has this problem are:
> >
> >   llvm/test/MC/ELF/comp-dir.s
> >
> >   clang/test/Driver/no-canonical-prefixes.c
> >
> >   clang/test/Tooling/clang-check-pwd.cpp
> >
> >
> >
> >
> >
> > What do you think, should these tests be corrected into using “ln -sf -T”?
> >
> 
> Looks like that option is missing from ln on OS X. How about just
> adding a "rm -f" to delete any existing symbol links?
> 
> Cheers,
> Rafael

Yes, if ln behaves differently on different platforms/OS then the solution to remove any old symlink using "rm -f" before (re)creating it would be a much better solution.

/Björn



More information about the llvm-commits mailing list