Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prep for and expand test infrastructure #76

Merged
merged 1 commit into from
Sep 29, 2016
Merged

Prep for and expand test infrastructure #76

merged 1 commit into from
Sep 29, 2016

Conversation

alexcrichton
Copy link
Member

This commit implements a few key features:

  • All tests are now executed against compiler-rt in addition to gcc_s. This is a reference implementation that will be guaranteed to exist so we can ensure that tests always run.
  • All test infrastructure now lives on the master branch of this repository, allowing it to be version controlled just as the code is. This has the benefits of being able to easily add a new platform, modify an existing platform, or reproduce what a platform is doing locally.

I've gotten a few tests to pass locally, but I suspect this isn't quite ready for merging yet. I'll try to fixup anything in the morning, but figured I'd get some thoughts!

// If anything returns `None` then the test is discarded, otherwise the two
// results are compared for equality and the test fails if this equality check
// fails.
macro_rules! check {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was pretty heinous to write, so I can try to document it a bit more if you'd like or tweak the interface. It was just the first thing I came up with!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Criminally beatiful.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty much what I had in mind for #72. From the looks of things I'm glad I didn't have to write it 😆.

@alexcrichton do you have any thoughts about benchmarks? I'm assuming the starting performance target is "not significantly worse", which shouldn't be too bad since most of the code is pretty direct translation. I still think some basic benchmarks would be a good sanity check just to ward off possible regressions. I don't know how big the overhead is for dynamic function lookup but we could do that for rustc-builtins as well to make it more 'fair', I suppose.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattico that's a good idea! I suspect that this'd be relatively easy to tweak to run benchmarks as well.

}

#[test]
fn inspect() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether it'd still be worth keeping this around, but curious for your thoughts!

}
}

declare!(___ashldi3, __ashldi3);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reexporting symbols from a native library in a cdylib ended up being pretty tricky, so I opted for this indirect accessor in lieu of other random linker hacks

if [[ $WEAK ]]; then
local symbols=( memcmp memcpy memmove memset )
for symbol in "${symbols[@]}"; do
$PREFIX$NM target/$TARGET/debug/deps/librlibc-*.rlib | grep -q "W $symbol"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't re-added this test, but I figure that it's something that should be tested in rlibc rather than here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, removing this is fine.

Copy link
Member

@japaric japaric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the new testing infra. It looks much simpler now and we have extra testing against compiler-rt.

Overall 👍 from me but I left some comments.

os: linux
install: cargo install xargo
script: xargo build --target $TARGET
- env: target $TARGET
Copy link
Member

@japaric japaric Sep 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks wrong, shouldn't it be TARGET = thumbv6m-none-eabi? Same with other the thumb targets.

if [[ $WEAK ]]; then
local symbols=( memcmp memcpy memmove memset )
for symbol in "${symbols[@]}"; do
$PREFIX$NM target/$TARGET/debug/deps/librlibc-*.rlib | grep -q "W $symbol"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, removing this is fine.

@@ -0,0 +1,3 @@
[submodule "compiler-rt/compiler-rt-cdylib/compiler-rt"]
path = compiler-rt/compiler-rt-cdylib/compiler-rt
url = https://github.com/llvm-mirror/compiler-rt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

llvm-mirror's and not rust-lang's compiler-rt? Are all of our patch just Makefiles related and it's OK to drop them?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah all our "patches" now are just makefile related I think. I have a feeling getting all tests working here will cause problems though!

}

#[test]
fn inspect() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nm output in this form is not too important so I'd be OK with dropping this test in this PR.

// If anything returns `None` then the test is discarded, otherwise the two
// results are compared for equality and the test fails if this equality check
// fails.
macro_rules! check {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Criminally beatiful.

// If it's not in libgcc, or we couldn't find
// libgcc, then just ignore this. We should have
// tests through compiler-rt in any case
None => return TestResult::passed(),
Copy link
Member

@japaric japaric Sep 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could the logic be changed to avoid calling quickcheck::quickcheck at all if the gcc_s symbol is not available?

qemu-system-ppc

ENV CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-linux-gnu-gcc \
CC=powerpc64-linux-gnu-gcc \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use the suffixed version (CC_powerpc64_...) here? My understanding is that CC also overrides the host compiler and, although we aren't using it here, I think it's better to avoid surprises in the future.

Some with the other Dockerfiles.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

os: linux
- env: TARGET=thumbv7em-none-eabihf WEAK=true
os: linux
install: cargo install xargo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installing Xargo takes a while. May be worth to (a) set cache: cargo in .travis.yml or (b) use one of the binary releases available via GitHub releases if it slows down the build job considerable.

Also cargo install Xargo requires a few extra packages: libcurl-dev libssl-dev cmake and maybe other stuff. If this command fails, then you can try installing those dependencies.

@alexcrichton
Copy link
Member Author

Hm ok, down to a few failures:

The "use qemu to emulate binaries we exec" support seems pretty sketchy. It's super nice to have but I can't get it to work...

@japaric any ideas on mips/powerpc64?

@japaric
Copy link
Member

japaric commented Sep 28, 2016

SIGTRAP if binary is executed manually, but succeeds if binary is executed with qemu-mips{,el}. Not sure why

Sounds like the wrong binfmt interpreter was installed.

powerpc64-unknown-linux-gnu - not sure what's going on here

I think it's the same issue: bad interpreter or perhaps, more likely, the interpreter was not properly registered.

Dou you see the same errors locally, and are you also using the multiarch/qemu-user-static trick locally?

Perhaps the register.sh script in multiarch/qemu-user-static has some errors? I've never seen binfmt related errors like these when letting the binfmt-support/qemu-user-static packages handle the installation of binfmt interpreters (cf smoke). :-/

This commit moves over most of the testing infrastructure to in-tree docker
images that are all dispatched to from Travis (no other test configuration).
This allows versioning modifications to the test infrastructure as well as the
code itself. Additionally separate docker images allows for easy modification of
one without worrying about tampering of others as well as easy addition of new
targets by simply adding a new `Dockerfile`.

Additionally this commit bundles the master version of the `compiler-rt` source
repository from `llvm-mirror/compiler-rt` to test against. The compiler-rt
library itself is compiled as a `cdylib` which is then dynamically located at
runtime and we look for symbols in. There's a few hoops here, but they currently
get the job done.

All tests now execute against both gcc_s and compiler-rt, and this
testing strategy is now all hidden behind a macro as well (refactoring
all existing tests along the way).
@alexcrichton
Copy link
Member Author

Success! I've finally got everything working. I don't really know how, but at this point I'm not gonna ask...

I've squashed everything into one commit, and restored only testing on the auto/try branch.

r? @japaric

@alexcrichton
Copy link
Member Author

Oh so there's a few nightly bugs the travis file also works around. The 32-bit cross-compilation will be fixed tonight but for now I rolled back those nightlies, and there's also a recent bug with ARM and float intrinsics (I think you found this?) that I fixed by rolling back a few nights as well. Fixes are in the pipeline on rust-lang/rust so we should be able to go back to the nightly channel in short order.

@japaric
Copy link
Member

japaric commented Sep 29, 2016

Success! I've finally got everything working.

An herculean task! Thank you @alexcrichton

I fixed by rolling back a few nights as well.
we should be able to go back to the nightly channel in short order.

👍

@homunkulus r+

@homunkulus
Copy link
Contributor

📌 Commit 8e161a7 has been approved by japaric

@homunkulus
Copy link
Contributor

⌛ Testing commit 8e161a7 with merge 8e161a7...

@homunkulus
Copy link
Contributor

💔 Test failed - status-appveyor

@alexcrichton
Copy link
Member Author

Aww :(

Want me to remove the gist part from appveyor as well?

@japaric japaric merged commit 52383ed into rust-lang:master Sep 29, 2016
@japaric
Copy link
Member

japaric commented Sep 29, 2016

Want me to remove the gist part from appveyor as well?

sigh I'll remove it.

The tests passed so I'm going to merge manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants