-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.go
More file actions
115 lines (98 loc) · 3.03 KB
/
main.go
File metadata and controls
115 lines (98 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package main
import (
"flag"
"math/rand"
"os"
"time"
)
var (
help bool
testName string
)
func init() {
flag.BoolVar(&help, "help", false, "help")
flag.StringVar(&testName, "test", "", "which test(s) do you want to run: basic/advance/all")
flag.Usage = usage
flag.Parse()
if help || (testName != "basic" && testName != "advance" && testName != "all") {
flag.Usage()
os.Exit(0)
}
rand.Seed(time.Now().UnixNano())
}
func main() {
yellow.Printf("Welcome to DHT-2025 Test Program!\n\n")
var basicFailRate float64
var forceQuitFailRate float64
var QASFailRate float64
switch testName {
case "all":
fallthrough
case "basic":
yellow.Println("Basic Test Begins:")
basicPanicked, basicFailedCnt, basicTotalCnt := basicTest()
if basicPanicked {
red.Printf("Basic Test Panicked.")
os.Exit(0)
}
basicFailRate = float64(basicFailedCnt) / float64(basicTotalCnt)
if basicFailRate > basicTestMaxFailRate {
red.Printf("Basic test failed with fail rate %.4f\n\n", basicFailRate)
} else {
green.Printf("Basic test passed with fail rate %.4f\n\n", basicFailRate)
}
if testName == "basic" {
break
}
time.Sleep(afterTestSleepTime)
fallthrough
case "advance":
yellow.Println("Advance Test Begins:")
/* ------ Force Quit Test Begins ------ */
forceQuitPanicked, forceQuitFailedCnt, forceQuitTotalCnt := forceQuitTest()
if forceQuitPanicked {
red.Printf("Force Quit Test Panicked.")
os.Exit(0)
}
forceQuitFailRate = float64(forceQuitFailedCnt) / float64(forceQuitTotalCnt)
if forceQuitFailRate > forceQuitMaxFailRate {
red.Printf("Force quit test failed with fail rate %.4f\n\n", forceQuitFailRate)
} else {
green.Printf("Force quit test passed with fail rate %.4f\n\n", forceQuitFailRate)
}
time.Sleep(afterTestSleepTime)
/* ------ Force Quit Test Ends ------ */
/* ------ Quit & Stabilize Test Begins ------ */
QASPanicked, QASFailedCnt, QASTotalCnt := quitAndStabilizeTest()
if QASPanicked {
red.Printf("Quit & Stabilize Test Panicked.")
os.Exit(0)
}
QASFailRate = float64(QASFailedCnt) / float64(QASTotalCnt)
if QASFailRate > QASMaxFailRate {
red.Printf("Quit & Stabilize test failed with fail rate %.4f\n\n", QASFailRate)
} else {
green.Printf("Quit & Stabilize test passed with fail rate %.4f\n\n", QASFailRate)
}
/* ------ Quit & Stabilize Test Ends ------ */
}
cyan.Println("\nFinal print:")
if basicFailRate > basicTestMaxFailRate {
red.Printf("Basic test failed with fail rate %.4f\n", basicFailRate)
} else {
green.Printf("Basic test passed with fail rate %.4f\n", basicFailRate)
}
if forceQuitFailRate > forceQuitMaxFailRate {
red.Printf("Force quit test failed with fail rate %.4f\n", forceQuitFailRate)
} else {
green.Printf("Force quit test passed with fail rate %.4f\n", forceQuitFailRate)
}
if QASFailRate > QASMaxFailRate {
red.Printf("Quit & Stabilize test failed with fail rate %.4f\n", QASFailRate)
} else {
green.Printf("Quit & Stabilize test passed with fail rate %.4f\n", QASFailRate)
}
}
func usage() {
flag.PrintDefaults()
}