This is an archive of the discontinued LLVM Phabricator instance.

[XRay] Fix fdr-thread-order.cc when current directory contains fdr-thread-order.cc
ClosedPublic

Authored by MaskRay on Sep 27 2018, 5:21 PM.

Details

Summary

Currently,

cd test/xray/TestCases/Posix
$build/bin/llvm-lit fdr-thread-order.cc

fails because rm fdr-thread-order.* deletes the .cc file.

This patch uses:

  • %t as temporary directory name containing log files
  • %t.exe as executable name

it does not delete %t after the test finishes for debugging convenience
if something goes wrong. This matches the behavior of many other LLVM
components.

Diff Detail

Repository
rL LLVM

Event Timeline

MaskRay created this revision.Sep 27 2018, 5:21 PM
Herald added subscribers: Restricted Project, llvm-commits, delcypher. · View Herald TranscriptSep 27 2018, 5:21 PM
MaskRay updated this revision to Diff 167418.Sep 27 2018, 5:29 PM

Migrate from deprecaed options

Thanks for the patch -- some questions and suggestions below.

test/xray/TestCases/Posix/fdr-thread-order.cc
2 ↗(On Diff #167418)

I'm not a fan of the .exe extension here -- consider -bin instead?

4–5 ↗(On Diff #167418)

While we're here, can we change xray_fdr_log=true to xray_mode=xray-fdr in the XRAY_OPTIONS environment variable?

12 ↗(On Diff #167418)

Unfortunately, doing this makes it really easy to clog up the filesystem with log files upon failure (which I learned the hard way while working on these). The suggestion has been to re-create the sequence by hand if we want to debug, rather than to keep them lying around when the tests fail.

Thoughts?

MaskRay updated this revision to Diff 167428.Sep 27 2018, 8:01 PM
MaskRay marked an inline comment as done.

xray_fdr_log=true -> xray_mode=xray-fdr

MaskRay marked an inline comment as done.Sep 27 2018, 8:08 PM
MaskRay added inline comments.
test/xray/TestCases/Posix/fdr-thread-order.cc
2 ↗(On Diff #167418)

I am not a fan of Windows but chose .exe because I've seen %t.exe used in llvm-readobj gold lld tests. They are also used in compiler-rt/test/asan/TestCases/{Posix,Linux,Darwin}. In ELF, such executables are called ET_EXEC before PIE era. The .exe suffix should not be too exotic.

12 ↗(On Diff #167418)

If the tests use unique directory names to isolate, it shouldn't clog up the filesystem.

Are sizes of log files an issue? If not, I think not cleaning the temporary files should be favored, but right now tests put xray-log.* in the current directory, which easily lead to conflicts.

I've added back rm -rf %t here. We may discuss this later. If we reach a consensus, I can create a refactor revision for other tests as well, if needed.

dberris accepted this revision.Sep 27 2018, 8:35 PM

LGTM

test/xray/TestCases/Posix/fdr-thread-order.cc
2 ↗(On Diff #167418)

I see, that's a convincing reason to pick .exe too then. :)

12 ↗(On Diff #167418)

It's both the number and the potential size(s) of the logs generated. Because each new invocation will attempt to create a unique filename, it will be a problem if files accumulate upon failures. I see that there's a cleanup of the directory at the beginning of the test which somewhat mitigates this, which I somehow thought was removed.

So I think leaving the files behind is fine given that we'll delete the directory anyway at the beginning.

This revision is now accepted and ready to land.Sep 27 2018, 8:35 PM
This revision was automatically updated to reflect the committed changes.
MaskRay marked an inline comment as done.