Opened 3 weeks ago

Last modified 8 days ago

#32172 needs_review task

port test suite to Android to run in emulator

Reported by: eighthave Owned by:
Priority: Medium Milestone: Tor: 0.4.3.x-final
Component: Core Tor/Tor Version:
Severity: Normal Keywords: Android, tbb-mobile
Cc: n8fr8, sysrqb Actual Points:
Parent ID: Points:
Reviewer: nickm Sponsor:

Description

Attached is the first stab at getting something from the test suite running in Android.

  • there is no /tmp on Android, there is /data/local/tmp for root and the shell user
  • no use in testing the user ID stuff, Android apps cannot ever change users

To get the full suite running, there will need to be larger changes:

  • either switch Python code to plain sh or hack to get Python running in Android emulator
  • port sh scripts to Android, it is not a full UNIX environment, so things like printf and others are not always there.
  • the shebang will need to be settable to #!/system/bin/sh or the tests need to be executed using sh test_keygen.sh

Child Tickets

Attachments (1)

0001-first-port-of-test-suite-to-Android-to-run-in-emulat.patch (2.3 KB) - added by eighthave 3 weeks ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 3 weeks ago by eighthave

comment:2 Changed 3 weeks ago by nickm

Milestone: Tor: 0.4.3.x-final
Reviewer: nickm

comment:3 Changed 3 weeks ago by nickm

Status: newneeds_review

comment:4 Changed 3 weeks ago by nickm

Status: needs_reviewneeds_revision

Good start! I've left a couple of comments on the PR. Additionally this needs a changes file.

WRT the other suggestions:

  • We already disable the python tests when python isn't found. Is there a place where we forget to do that?
  • I'm okay porting our shell scripts to a more generic sh, so long as shellcheck still passes.
  • I don't know what to do with the third one; maybe there's a way to make autoconf and automake override this? Is there a /usr/bin/env sh we could use?

comment:5 Changed 3 weeks ago by eighthave

I haven't even tried to use make check here, that will take a chunk of work. I assume that's where the python detection is. I'm just directly calling the test executables after copying them to the emulator, like this:

adb -e shell /data/local/tmp/test
adb -e shell /data/local/tmp/test-memwipe
adb -e shell /data/local/tmp/test-slow

From my very vague understanding of the all the bits of the test suite, I'm guessing there will be some that won't be worth porting to run in the Android emulator. So I think the question now is: what parts must be ported to have decent coverage? What parts are you worried about?

comment:6 Changed 3 weeks ago by teor

iOS also has a similar restriction on /tmp, apps get their own container directory with their own tmp.
https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html

comment:7 Changed 3 weeks ago by eighthave

Status: needs_revisionneeds_review

Since Android has no /tmp/ or mkdtemp(), I changed this to fake it, and check the results of mkdir() in the process.

That took too long, ./configure with cross bulids is always painful, and tor is unfortunately no exception. Then the tests have to run in an emulator. I spent at least 3 hours updating this.

comment:8 Changed 3 weeks ago by nickm

Status: needs_reviewneeds_revision

Looking better; I've added some questions and comments to the commit.

This still needs a changes file.

comment:9 Changed 3 weeks ago by eighthave

added a changes files

comment:10 Changed 8 days ago by teor

Status: needs_revisionneeds_review
Note: See TracTickets for help on using tickets.