Skip to content

Commit 5499a13

Browse files
committed
fix: update shell command for Android compatibility and ensure existence of TEST_VAR directory in tests
1 parent d4ea979 commit 5499a13

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

src/adam_tools.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,8 +615,13 @@ adam_tool_result_t adam_tool_shell_exec(arena_t *arena, void *ctx,
615615
snprintf(full_cmd, cmd_size,
616616
"cd /d \"%s\" && cmd /c \"%s\" 2>&1",
617617
s->allowed_dirs[0], command);
618-
#elif defined(__APPLE__) || defined(__ANDROID__) || defined(__ios__)
619-
// macOS/iOS/Android: no GNU timeout command
618+
#elif defined(__ANDROID__)
619+
// Android has no /bin — sh lives at /system/bin/sh.
620+
snprintf(full_cmd, cmd_size,
621+
"cd \"%s\" && /system/bin/sh -c '%s' 2>&1",
622+
s->allowed_dirs[0], command);
623+
#elif defined(__APPLE__) || defined(__ios__)
624+
// macOS/iOS: no GNU timeout command
620625
snprintf(full_cmd, cmd_size,
621626
"cd \"%s\" && /bin/sh -c '%s' 2>&1",
622627
s->allowed_dirs[0], command);

test/test_adam.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4923,7 +4923,7 @@ TEST(integration_file_tools_sandbox) {
49234923

49244924
// List directory containing the file
49254925
arena_reset(a);
4926-
const char *l_args = "{\"path\":\"/tmp\"}";
4926+
const char *l_args = "{\"path\":\"" TEST_TMP "\"}";
49274927
adam_tool_result_t lr = adam_tool_list_directory(a, s, l_args, strlen(l_args));
49284928
ASSERT_EQ(lr.success, 1);
49294929
ASSERT(strstr(lr.for_llm, "adam_integ_test.txt") != NULL);
@@ -5147,10 +5147,12 @@ int main(void) {
51475147
printf("============================================================\n");
51485148

51495149
// TEST_TMP / TEST_VAR map to platform-writable dirs (see top of file).
5150-
// Ensure TEST_TMP exists so the file-sandbox / session tests can fopen /
5151-
// sqlite3_open inside it. EEXIST is fine; on Android the dir is already
5152-
// there (/data/local/tmp) and mkdir is a no-op.
5150+
// Ensure both exist so the file-sandbox / session / allow-dir tests can
5151+
// realpath() them. EEXIST is fine; on POSIX hosts the dirs are already
5152+
// there, on Windows MinGW we create them under the current drive root,
5153+
// on Android both point at /data/* which already exist.
51535154
adam_mkdir(TEST_TMP, 0755);
5155+
adam_mkdir(TEST_VAR, 0755);
51545156

51555157
adam_init();
51565158
mem_report_start();

0 commit comments

Comments
 (0)