-
Notifications
You must be signed in to change notification settings - Fork 5
/
WHQL_Test.ps1
executable file
·182 lines (153 loc) · 6.04 KB
/
WHQL_Test.ps1
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#This Scripts could not used to run NDIS job current currently,it is still under developing
#Tested passed in following scenario :
#1.install all the guest platforms
#2.same version driver sumbit to HCK Manager at different time
#3.same driver w/ Different version use the same devicefamily
#todo list:
#1.NDIS test support
#2.Exception handle
#3.make the scripts into function
# Author: Mike Cao <[email protected]>
$ObjectModel = [Reflection.Assembly]::LoadFrom($env:WTTSTDIO + "microsoft.windows.Kits.Hardware.objectmodel.dll")
$ObjectModel = [Reflection.Assembly]::LoadFrom($env:WTTSTDIO + "microsoft.windows.Kits.Hardware.objectmodel.dbconnection.dll")
Clear-Host
Write-Host "Usage: %SystemRoot%\syswow64\WindowsPowerShell\v1.0\powershell.exe -file WHQLTest.ps1 <<ControllerMachineName>> <<Driver_name>> <<Driver version>> "
$ControllerName = $args[0]
$Driver = $args[1]
$Driver_version = $args[2]
$projectname = "virtio-win-prewhql-"+$Driver_version+"-"+$Driver
if ($Driver -eq $null -OR $Driver -eq "")
{
write-host "Pls supply which driver you want to be tested viostor, netkvm, vioscsi, balloon, vioser "
return
}
if ($Driver_version -eq $null -OR $Driver_version -eq "")
{
write-host "Need to supply the driver version for whql"
return
}
if ($ControllerName -eq $null -OR $ControllerName -eq "")
{
write-host "Need to supply the controller Name as a parameter to this script"
return
}
else
{
write-host connecting to the controller $ControllerName
}
# create a device family via the param provided by user
switch($Driver)
{
{$Driver -eq "viostor"}{Write-host "viostor";[string[]]$HardwareIds = "PCI\VEN_1AF4&DEV_1001&SUBSYS_00021AF4";break}
{$Driver -eq "netkvm"} {Write-host "netkvm";[. netkvm ;break}
{$Driver -eq "vioscsi"}{Write-host "vioscsi";[string[]]$HardwareIds = "PCI\VEN_1AF4&DEV_1004&SUBSYS_00081AF4";break}
{$Driver -eq "vioser"} {Write-host "vioser";[string[]]$HardwareIds = "PCI\VEN_1AF4&DEV_1003&SUBSYS_00031AF4";break}
{$Driver -eq "balloon"}{Write-host "balloon";[string[]]$HardwareIds = "PCI\VEN_1AF4&DEV_1002&SUBSYS_00051AF4";break}
default {Write-host Invalid driver name ,pls check whehter you type viostor netkvm vioscsi vioser balloon;return}
}
Write-Host switch done
# connect to the controller
$Manager = new-object -typename Microsoft.Windows.Kits.Hardware.ObjectModel.DBConnection.DatabaseProjectManager -Args $ControllerName, DTMJobs
$RootPool = $Manager.GetRootMachinePool()
$DefaultPool = $RootPool.DefaultPool
#load or create a machinepoolgroup
$TestPoolGroupFlag = 0
$RootPool.GetChildPools() | foreach {
if ($_.Name -eq $projectname)
{
Write-Host $_.Path
$TestPoolGroup = $_
$TestPoolGroupFlag = 1
}
}
if ($TestPoolGroup -eq "0")
{
$TestPoolGroup=$RootPool.CreateChildPool($projectname)
}
#load or create a project
$projectFlag = 0
$Manager.GetProjectNames() | foreach {
if ($_ -eq $projectname)
{
$Project = $Manager.GetProject($projectname)
$ProjectFlag = 1
}
}
if ($ProjectFlag -eq "0")
{
$Project = $Manager.CreateProject($projectname)
$TestPoolGroup = $RootPool.CreateChildPool($projectname)
}
$DeviceFamilyFlag = 0
$Manager.GetDeviceFamilies() | foreach {
Write-Host $_.name
if ($_.name -eq $Driver)
{
$DeviceFamily = $_
$DeviceFamilyFlag = 1
}
}
if ($DeviceFamilyFlag -eq "0")
{
$DeviceFamily = $Manager.CreateDeviceFamily($Driver, $HardwareIds)
}
# find all the computers in the default pool, and move them into the test pool
$DefaultPool.GetMachines() | foreach {
write-host $_.name
# create the pool
$TestPool = $TestPoolGroup.CreateChildPool($_.Name)
$DefaultPool.MoveMachineTo($_, $TestPool)
# now, make sure that the computers are in a ready state
$TestPool.GetMachines() | foreach { $_.SetMachineStatus([Microsoft.Windows.Kits.Hardware.ObjectModel.MachineStatus]::Ready, 1) }
# create a product instance by using the OS Platform of the first computer that you find
$ProductInstance = $Project.CreateProductInstance($_.name, $TestPool, $TestPool.GetMachines()[0].OSPlatform)
# create a target family by using the device family that you created earlier
$TargetFamily = $ProductInstance.CreateTargetFamily($DeviceFamily)
#find all the devices in this machine pool that are in this device family
$ProductInstance.FindTargetFromDeviceFamily($DeviceFamily) | foreach {
"attempting to add target $_.Name on machine $_.Machine.Name to TargetFamily"
# and add those to the target family
# check this first, to make sure that this can be added to the target family
if ($TargetFamily.IsValidTarget($_)) {
$TargetFamily.CreateTarget($_)
}
}
#schedule all tests
$ProductInstance.GetTests() | foreach {
"Test {0} is {1}" -f $_.Name.ToSTring(), $_.ScheduleOptions.ToString()
"Test {0} will Running!! " -f $_.Name.ToString()
$_.QueueTest();
}
}
Trap [Microsoft.Windows.Kits.Hardware.ObjectModel.ProjectManagerException] {
write-host ProjectManagerException occurs!!
exit
}
Trap [Microsoft.Windows.Kits.Hardware.ObjectModel.DataIntegrityException] {
write-host DataIntegrityException occurs!!
exit
}
Trap [Microsoft.Windows.Kits.Hardware.ObjectModel.MachineException] {
write-host MachineException occurs!!
exit
}
Trap [Microsoft.Windows.Kits.Hardware.ObjectModel.ProductInstanceException] {
write-host ProductInstanceException occurs!!
exit
}
Trap [Microsoft.Windows.Kits.Hardware.ObjectModel.ScheduleException] {
write-host ScheduleException occurs!!
exit
}
Trap [Microsoft.Windows.Kits.Hardware.ObjectModel.TargetException] {
write-host TargetException occurs!!
exit
}
Trap [Microsoft.Windows.Kits.Hardware.ObjectModel.TestException] {
write-host TestException occurs!!
exit
}
Trap [System.Management.Automation.MethodInvocationException] {
write-host MethodInvocationException!!
exit
}