From f0e6e15f9516be708fe7529f52ed01c628e28d28 Mon Sep 17 00:00:00 2001 From: spiritlhl <103393591+spiritLHLS@users.noreply.github.com> Date: Tue, 2 Jul 2024 15:16:32 +0800 Subject: [PATCH] Update disktest.go --- disk/disktest.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/disk/disktest.go b/disk/disktest.go index 6882963..05210fd 100644 --- a/disk/disktest.go +++ b/disk/disktest.go @@ -94,6 +94,14 @@ func ddTest1(path, deviceName, blockFile, blockName, blockCount, bs string) stri result += parseResultDD(tempText, blockCount) time.Sleep(1 * time.Second) } + // 清理缓存, 避免影响测试结果 + syncCmd := exec.Command("sync") + err = syncCmd.Run() + if err != nil { + if EnableLoger { + Logger.Info("sync command failed: " + err.Error()) + } + } // 读取测试 tempText, err = execDDTest(path+blockFile, "/dev/null", bs, blockCount) defer os.Remove(path + blockFile) @@ -150,6 +158,14 @@ func ddTest2(blockFile, blockName, blockCount, bs string) string { result += fmt.Sprintf("%-10s", "/root") + " " + fmt.Sprintf("%-15s", blockName) + " " } result += parseResultDD(tempText, blockCount) + // 清理缓存, 避免影响测试结果 + syncCmd := exec.Command("sync") + err = syncCmd.Run() + if err != nil { + if EnableLoger { + Logger.Info("sync command failed: " + err.Error()) + } + } // 读取测试 time.Sleep(1 * time.Second) tempText, err = execDDTest("/root/"+blockFile, "/dev/null", bs, blockCount)