Skip to content

Commit 20e47ab

Browse files
committed
Fix path
1 parent 41a585c commit 20e47ab

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

.github/workflows/llm-android.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ jobs:
128128
LOGCAT_PID=$!
129129
if [ "$MODEL_PRESET" = "custom" ]; then GRADLE_ARGS="-PmodelPreset=$MODEL_PRESET -PcustomPteUrl=$CUSTOM_PTE_URL -PcustomTokenizerUrl=$CUSTOM_TOKENIZER_URL"; else GRADLE_ARGS="-PmodelPreset=$MODEL_PRESET"; fi
130130
./gradlew connectedCheck $GRADLE_ARGS; TEST_EXIT_CODE=$?
131-
adb pull /data/local/tmp/llama/response.txt /tmp/response.txt || true
131+
adb pull /sdcard/Android/data/com.example.executorchllamademo/files/response.txt /tmp/response.txt || true
132132
kill $LOGCAT_PID || true
133133
exit $TEST_EXIT_CODE
134134

llm/android/LlamaDemo/app/src/androidTest/java/com/example/executorchllamademo/UIWorkflowTest.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,21 @@ private boolean waitForModelLoaded(ActivityScenario<MainActivity> scenario, long
248248

249249
/**
250250
* Writes the model response to a file that can be pulled from the device.
251-
* The file is written to /data/local/tmp/llama/response.txt
251+
* Writes to app's external files directory which is accessible via adb.
252252
*/
253253
private void writeResponseToFile(String response) {
254-
File outputFile = new File("/data/local/tmp/llama/response.txt");
255-
try (FileWriter writer = new FileWriter(outputFile)) {
256-
writer.write(response);
254+
try {
255+
Context context = ApplicationProvider.getApplicationContext();
256+
// Use external files dir which is accessible without root
257+
File externalDir = context.getExternalFilesDir(null);
258+
if (externalDir != null) {
259+
File outputFile = new File(externalDir, "response.txt");
260+
try (FileWriter writer = new FileWriter(outputFile)) {
261+
writer.write(response);
262+
}
263+
android.util.Log.i("UIWorkflowTest", "Response written to: " + outputFile.getAbsolutePath());
264+
}
257265
} catch (IOException e) {
258-
// Log but don't fail the test if we can't write the file
259266
android.util.Log.e("UIWorkflowTest", "Failed to write response file", e);
260267
}
261268
}

0 commit comments

Comments
 (0)