This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Add support for Android targets to lit.cfg.
AbandonedPublic

Authored by danalbert on Jul 18 2014, 5:03 PM.

Details

Summary

For accurate testing on Android, test compilation needs to more closely match the Android build system. This means flipping all the switches for -nostdlibinc, -nostdlib, etc. and instead using the libraries that were either prebuilt or built by the system.

Android's build system isn't able to efficiently handle many small builds run concurrently. The downside of this is that directly using the Android build system to compile each test cannot be done in parallel, and would take roughly 7 hours to complete a test run.

To deal with this, when config.android is true, lit.cfg will pull all of the cppflags and ldflags right out of config instead of trying to determine them on its own. It's dirtied a little bit by crtbegin and crtend.

The other thing this patch does is deal with pushing the built test to the android device, running it on the device, and removing it when done. There are a few intricacies wrapped around adb shell, as adb considers all commands that were able to be run on the device, regardless of their exit codes, to be successful. As such, the commands are run as adb shell COMMAND; echo $?, and the last line of stdout is read to determine the real exit status.

Diff Detail

Event Timeline

danalbert updated this revision to Diff 11676.Jul 18 2014, 5:03 PM
danalbert retitled this revision from to [libcxx] Add support for Android targets to lit.cfg..
danalbert updated this object.
danalbert edited the test plan for this revision. (Show Details)
danalbert added a reviewer: mclow.lists.
danalbert added a subscriber: Unknown Object (MLST).
danalbert added inline comments.Jul 18 2014, 5:07 PM
test/lit.cfg
279

Nothing past here is actually a change (or at least, shouldn't be). It's just diff doing an awful job of detecting a whole block being indented.

danalbert updated this revision to Diff 11713.Jul 21 2014, 10:58 AM

Previous patch had accidentally removed the -c flag from expected compile failure tests.

abdulras added inline comments.
test/lit.cfg
94

The compile_only is misleading. !compile_only implies compile and link. I think that using an enum would be much nicer here:

(COMPILE_ONLY, LINK_ONLY, COMPILE_AND_LINK) = xrange(3)
209

Does this have to be /data/nativetest? Personally, I would vote for /data/local/tmp/nativetest/.

210

Might be nice to make a parameter to specify where adb is.

212

Ick. Can you chain this together using exit code checks please? This feels fragile (quoting and reliance on the exec passing it through to the shell appropriately).

219

Hmm... perhaps make the test location a member variable?

danalbert added inline comments.Jul 21 2014, 2:04 PM
test/lit.cfg
94

self._build(..., compile_only=False) might be misleading, but callers wouldn't write that. They'd write self._build(...), which does exactly what it says it does.

209

I'll make it configurable.

210

This set up is only intended to be used as part of a platform build, so it uses the freshly built adb. Expanding this config to work with the NDK is a task for another day.

212

This cmd is never run. It's only returned so LIT can dump the command that was run in the even of an error. All this line is doing is printing clang ... && adb push ....

danalbert updated this revision to Diff 11717.Jul 21 2014, 2:09 PM

Make the on device directory that tests copy to configurable.

danalbert updated this revision to Diff 11718.Jul 21 2014, 2:11 PM

Last diff upload was the wrong patch.

danalbert updated this revision to Diff 11770.Jul 22 2014, 11:36 AM

Major change in this revision is that tests get placed into their own working directory on the device rather than being lumped in together. This is done because we need to also push any .dat files that live in the same directory as the test source file to the device as well, and there are duplicate .dat files in the test tree that prevent us from placing them all in the same directory.

There's also a small refactoring of some of the ADB calls.

EricWF edited edge metadata.Jul 31 2014, 3:52 PM

There are going to be some merge conflicts between this and D4329. If my patch gets accepted first I would be more than willing to re-generate the diff for this patch. Hopefully I'll be able to take a look at this tonight depending on how long it takes me to get my android environment set up.

I probably need to regenerate it anyway. I believe I've made some changes in our tree since this was updated (this patch will already be applied when you sync aosp).

test/lit.cfg
95

Whoops. Somehow the compiler got passed twice.

danalbert updated this revision to Diff 12562.Aug 15 2014, 10:28 AM
danalbert edited edge metadata.

Rebased onto current lit.cfg so that this change merges cleanly.

danalbert updated this revision to Diff 12607.Aug 17 2014, 11:15 PM

Rebased on to current master.

Did phabricator get smart enough to realize that most of the diff is just an indent? O_o

Someone teach git to do this.

danalbert planned changes to this revision.Aug 18 2014, 5:55 PM

This has gotten far too gross and fallen way out of sync with the rest of the changes that have been going in. I'm waiting for http://reviews.llvm.org/D4952 to land, and then I'll massage these changes in to that.

In D4594#23, @danalbert wrote:

Someone teach git to do this.

Amen!

danalbert abandoned this revision.Aug 22 2014, 2:56 PM

We're going to find a more generic approach to this problem (one that will also support things like QEMU targets).