|
| 1 | +version: 0.1 |
| 2 | + |
| 3 | +android_test_host: amazon_linux_2 |
| 4 | + |
| 5 | +phases: |
| 6 | + install: |
| 7 | + commands: |
| 8 | + |
| 9 | + pre_test: |
| 10 | + commands: |
| 11 | + # Prepare the model and the tokenizer |
| 12 | + - adb -s $DEVICEFARM_DEVICE_UDID shell "ls -la /sdcard/" |
| 13 | + - adb -s $DEVICEFARM_DEVICE_UDID shell "mkdir -p /data/local/tmp/llama/" |
| 14 | + - adb -s $DEVICEFARM_DEVICE_UDID shell "mv /sdcard/tokenizer.bin /data/local/tmp/llama/tokenizer.bin" |
| 15 | + - adb -s $DEVICEFARM_DEVICE_UDID shell "mv /sdcard/xnnpack_llama2.pte /data/local/tmp/llama/xnnpack_llama2.pte" |
| 16 | + - adb -s $DEVICEFARM_DEVICE_UDID shell "chmod 664 /data/local/tmp/llama/tokenizer.bin" |
| 17 | + - adb -s $DEVICEFARM_DEVICE_UDID shell "chmod 664 /data/local/tmp/llama/xnnpack_llama2.pte" |
| 18 | + - adb -s $DEVICEFARM_DEVICE_UDID shell "ls -la /data/local/tmp/llama/" |
| 19 | + |
| 20 | + test: |
| 21 | + commands: |
| 22 | + # By default, the following ADB command is used by Device Farm to run your Instrumentation test. |
| 23 | + # Please refer to Android's documentation for more options on running instrumentation tests with adb: |
| 24 | + # https://developer.android.com/studio/test/command-line#run-tests-with-adb |
| 25 | + - echo "Starting the Instrumentation test" |
| 26 | + - | |
| 27 | + adb -s $DEVICEFARM_DEVICE_UDID shell "am instrument -r -w --no-window-animation \ |
| 28 | + $DEVICEFARM_TEST_PACKAGE_NAME/$DEVICEFARM_TEST_PACKAGE_RUNNER 2>&1 || echo \": -1\"" | |
| 29 | + tee $DEVICEFARM_LOG_DIR/instrument.log |
| 30 | +
|
| 31 | + # Parse the results |
| 32 | + - |- |
| 33 | + INSTRUMENT_LOG="$DEVICEFARM_LOG_DIR/instrument.log" |
| 34 | +
|
| 35 | + DID_ANY_TESTS_START=$(grep "INSTRUMENTATION_STATUS_CODE: 1" $INSTRUMENT_LOG | wc -l); |
| 36 | + TESTS_PASSED=$(grep "INSTRUMENTATION_STATUS_CODE: 0" $INSTRUMENT_LOG | wc -l); |
| 37 | + TESTS_ERRORED=$(grep "INSTRUMENTATION_STATUS_CODE: -1" $INSTRUMENT_LOG | wc -l); |
| 38 | + TESTS_FAILED=$(grep "INSTRUMENTATION_STATUS_CODE: -2" $INSTRUMENT_LOG | wc -l); |
| 39 | + TESTS_IGNORED=$(grep "INSTRUMENTATION_STATUS_CODE: -3" $INSTRUMENT_LOG | wc -l); |
| 40 | + TESTS_ASSUMPTION_FAILED=$(grep "INSTRUMENTATION_STATUS_CODE: -4" $INSTRUMENT_LOG | wc -l); |
| 41 | + TESTS_PROCESSES_CRASHED=$(grep "INSTRUMENTATION_RESULT: shortMsg=Process crashed." $INSTRUMENT_LOG | wc -l); |
| 42 | +
|
| 43 | + # And print the results so that the CI job can show them later |
| 44 | + - | |
| 45 | + INSTRUMENT_LOG="$DEVICEFARM_LOG_DIR/instrument.log" |
| 46 | +
|
| 47 | + if [ $DID_ANY_TESTS_START -eq 0 ]; |
| 48 | + then |
| 49 | + echo "[PyTorch] Marking the test suite as failed because no tests started!"; |
| 50 | + false; |
| 51 | + elif [ $TESTS_FAILED -ne 0 ]; |
| 52 | + then |
| 53 | + OBSERVED_TPS=$(grep "The observed TPS " $INSTRUMENT_LOG | tail -n 1) |
| 54 | +
|
| 55 | + if [ -n "${OBSERVED_TPS}" ]; |
| 56 | + then |
| 57 | + echo "[PyTorch] ${OBSERVED_TPS}"; |
| 58 | + else |
| 59 | + echo "[PyTorch] Marking the test suite as failed because it failed to load the model"; |
| 60 | + fi |
| 61 | + elif [ $TESTS_ERRORED -ne 0 ]; |
| 62 | + then |
| 63 | + echo "[PyTorch] Marking the test suite as failed because $TESTS_ERRORED tests errored!"; |
| 64 | + false; |
| 65 | + elif [ $TESTS_PROCESSES_CRASHED -ne 0 ]; |
| 66 | + then |
| 67 | + echo "[PyTorch] Marking the test suite as failed because the app crashed due to OOM!"; |
| 68 | + false; |
| 69 | + fi; |
| 70 | +
|
| 71 | + post_test: |
| 72 | + commands: |
| 73 | + |
| 74 | +artifacts: |
| 75 | + # By default, Device Farm will collect your artifacts from the $DEVICEFARM_LOG_DIR directory. |
| 76 | + - $DEVICEFARM_LOG_DIR |
0 commit comments