From 9de3af05ff4b8f3924cad8c09afe5a9e666f9fca Mon Sep 17 00:00:00 2001 From: nianyuu Date: Fri, 13 Jun 2025 20:25:02 +0800 Subject: [PATCH] fix AppSpawn_coldrun_ut timeout Signed-off-by: nianyuu --- interfaces/innerkits/client/appspawn_client.h | 3 +++ test/mock/app_spawn_stub.cpp | 12 +----------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/interfaces/innerkits/client/appspawn_client.h b/interfaces/innerkits/client/appspawn_client.h index b979e2b6..20edaf46 100644 --- a/interfaces/innerkits/client/appspawn_client.h +++ b/interfaces/innerkits/client/appspawn_client.h @@ -29,6 +29,9 @@ extern "C" { #ifdef ASAN_DETECTOR #define TIMEOUT_DEF 60 #define ASAN_TIMEOUT 60 +#elif APPSPAWN_TEST +#define TIMEOUT_DEF 2 +#define ASAN_TIMEOUT 2 #else #define TIMEOUT_DEF 2 #define ASAN_TIMEOUT 10 diff --git a/test/mock/app_spawn_stub.cpp b/test/mock/app_spawn_stub.cpp index 5de78bf4..df47d842 100644 --- a/test/mock/app_spawn_stub.cpp +++ b/test/mock/app_spawn_stub.cpp @@ -120,21 +120,11 @@ void SetDeveloperMode(bool mode) int GetParameter(const char *key, const char *def, char *value, uint32_t len) { - static uint32_t count = 0; - count++; if (strcmp(key, "startup.appspawn.cold.boot") == 0) { return strcpy_s(value, len, "true") == 0 ? strlen("true") : -1; } if (strcmp(key, "persist.appspawn.reqMgr.timeout") == 0) { - const char *tmp = def; - if ((count % 3) == 0) { // 3 test - return -1; - } else if ((count % 3) == 1) { // 3 test - tmp = "a"; - } else { - tmp = "5"; - } - return strcpy_s(value, len, tmp) == 0 ? strlen(tmp) : -1; + return strcpy_s(value, len, "2") == 0 ? strlen("2") : -1; // #ifdef APPSPAWN_TEST #define ASAN_TIMEOUT 2 } if (strcmp(key, "const.security.developermode.state") == 0) { return g_developerMode ? (strcpy_s(value, len, "true") == 0 ? strlen("true") : -1) : -1; -- Gitee