@@ -23,7 +23,7 @@ func main() {
2323 memorytestFlag .BoolVar (& help , "h" , false , "Show help information" )
2424 memorytestFlag .BoolVar (& showVersion , "v" , false , "show version" )
2525 memorytestFlag .StringVar (& language , "l" , "" , "Language parameter (en or zh)" )
26- memorytestFlag .StringVar (& testMethod , "m" , "" , "Specific Test Method (sysbench or dd or winsat)" )
26+ memorytestFlag .StringVar (& testMethod , "m" , "" , "Specific Test Method (stream or dd or sysbench or winsat)" )
2727 memorytestFlag .BoolVar (& memory .EnableLoger , "log" , false , "Enable logging" )
2828 memorytestFlag .Parse (os .Args [1 :])
2929 if help {
@@ -41,13 +41,21 @@ func main() {
4141 } else {
4242 language = strings .ToLower (language )
4343 }
44- if testMethod == "" || strings .ToLower (testMethod ) == "sysbench" {
45- testMethod = "sysbench"
46- } else if strings .ToLower (testMethod ) == "dd" {
47- testMethod = "dd"
44+ // Parse and normalize test method
45+ testMethod = strings .ToLower (testMethod )
46+ if testMethod == "" {
47+ // Use automatic priority: stream > dd > sysbench (with mbw fallback)
48+ testMethod = "auto"
4849 }
4950 if runtime .GOOS == "windows" {
5051 switch testMethod {
52+ case "stream" :
53+ if language == "en" {
54+ res = "STREAM is not supported on Windows, using Winsat for testing.\n "
55+ } else {
56+ res = "Windows下不支持STREAM,使用Winsat进行测试。\n "
57+ }
58+ res += memory .WinsatTest (language )
5159 case "dd" :
5260 res = memory .WindowsDDTest (language )
5361 if res == "" || strings .TrimSpace (res ) == "" {
@@ -66,7 +74,8 @@ func main() {
6674 }
6775 res += memory .WinsatTest (language )
6876 default :
69- if testMethod != "winsat" && testMethod != "" {
77+ // For auto or winsat or any other method
78+ if testMethod != "winsat" && testMethod != "auto" {
7079 if language == "en" {
7180 res = "Detected host is Windows, using Winsat for testing.\n "
7281 } else {
@@ -77,14 +86,39 @@ func main() {
7786 }
7887 } else {
7988 switch testMethod {
80- case "sysbench" :
81- res = memory .SysBenchTest (language )
82- if res == "" {
83- res = "sysbench test failed, switch to use dd test.\n "
89+ case "stream" :
90+ res = memory .StreamTest (language )
91+ if res == "" || strings .TrimSpace (res ) == "" {
92+ if language == "en" {
93+ res = "STREAM test failed, switching to DD for testing.\n "
94+ } else {
95+ res = "STREAM测试失败,切换使用DD进行测试。\n "
96+ }
8497 res += memory .DDTest (language )
8598 }
8699 case "dd" :
87100 res = memory .DDTest (language )
101+ case "sysbench" :
102+ res = memory .SysBenchTest (language )
103+ if res == "" || strings .TrimSpace (res ) == "" {
104+ if language == "en" {
105+ res = "Sysbench test failed, switching to DD for testing.\n "
106+ } else {
107+ res = "Sysbench测试失败,切换使用DD进行测试。\n "
108+ }
109+ res += memory .DDTest (language )
110+ }
111+ case "auto" :
112+ // Priority: stream > dd > sysbench (with mbw fallback built into each)
113+ res = memory .StreamTest (language )
114+ if res == "" || strings .TrimSpace (res ) == "" {
115+ // Stream failed or not available, try DD
116+ res = memory .DDTest (language )
117+ if res == "" || strings .TrimSpace (res ) == "" {
118+ // DD failed, try sysbench as final fallback
119+ res = memory .SysBenchTest (language )
120+ }
121+ }
88122 default :
89123 res = "Unsupported test method"
90124 }
0 commit comments