From 50383d6e788bbd0b281bbe01c787027c152fffd4 Mon Sep 17 00:00:00 2001 From: qiyinxi Date: Sat, 5 Dec 2026 22:22:25 +0100 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=EF=BC=9A=E7=AD=89=20SDK=20?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E6=8D=A2=E5=A5=BD=E6=97=B6=E5=85=88=E7=9C=8B?= =?UTF-8?q?=20previous=20=E5=86=8D=E7=9C=8B=20sdk\emulator?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TestImageGatesSurviveDirectorySwapAndRecovery/install 偶发报 sdk\emulator\emulator.exe「找不到路径」。等待条件先看 sdk\emulator、 再看 previous,两眼之间正好赶上 swapIn 的第一次改名(sdk\emulator 改到 previous)时,会看到旧的 sdk\emulator 和新出现的 previous, 以为换好了,其实第二次改名还没做,sdk\emulator 不在。 改成先看 previous 再看 sdk\emulator:previous 一直留到 finishInstall(被测试拿着的 mas-avd.json.lock 挡住),在它之后看到的 sdk\emulator 只能是第二次改名放上去的。产品代码不动。 Refs ModAVD/ModAVD#403 --- internal/update/images_windows_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/update/images_windows_test.go b/internal/update/images_windows_test.go index 56de6f0c..53cf5f8b 100644 --- a/internal/update/images_windows_test.go +++ b/internal/update/images_windows_test.go @@ -178,8 +178,13 @@ func TestImageGatesSurviveDirectorySwapAndRecovery(t *testing.T) { t.Error("update worker did not finish") } }) + // The two directories are looked at one after the other, not at once. swapIn first renames sdk\emulator + // to previous, then the stage to sdk\emulator; previous stays until finishInstall, which waits for + // metaLock. Looking at sdk\emulator first could see the old one just before the first rename and + // previous just after it, with sdk\emulator missing in between (ModAVD/ModAVD#403). Looking at + // previous first, sdk\emulator seen after it can only be the one the second rename put there. deadline := time.Now().Add(5 * time.Second) - for !isDir(u.l.emulator()) || !isDir(u.l.previousEmulator()) { + for !isDir(u.l.previousEmulator()) || !isDir(u.l.emulator()) { select { case <-done: t.Fatalf("update ended before metadata commit: %+v %v", result, updateErr)