forked from dgubanovv/qa-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
diag_drv_lin.py
261 lines (225 loc) · 15 KB
/
diag_drv_lin.py
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
import os
import sys
import re
import pytest
from tools.diagper import DiagWrapper, download_diag, get_actual_diag_version, uninstall_diag
from tools import driver
from tools.utils import remove_directory, get_atf_logger
from infra.test_base import TestBase
from tools.ops import get_arch, OpSystem
from tools.command import Command
log = get_atf_logger()
def setup_module(module):
#import tools._test_setup # uncomment for manual test setup
os.environ["TEST"] = "diag_drv_lin"
class TestDiag(TestBase):
@classmethod
def setup_class(cls):
# set DUT_PORT before TestBase.setup_class() because it's needed inside
dut_felicity = os.environ.get('DUT_FELICITY', None)
if dut_felicity is not None:
os.environ['DUT_PORT'] = dut_felicity
os.environ['DUT_FW_CARD'] = 'Felicity'
# init from base class
super(TestDiag, cls).setup_class()
try:
cls.log_server_dir = cls.create_logs_dir_on_log_server()
cls.os = OpSystem()
cls.install_firmwares()
# uninstall previously installed diag on linux to be able to install rpm or deb
if cls.os.is_linux():
uninstall_diag()
cls.diag_dir = download_diag(cls.diag_version)
cls.diag_ver = get_actual_diag_version(cls.diag_version)
cls.diag_drv_path = '/opt/aquantia/diag/mbu/Os/linux/driver/src'
if cls.os.is_rhel():
cls.diag_drv_path = '{}/mbu/Os/linux/driver/src'.format(cls.diag_dir)
Command(cmd='cd {}; make'.format(cls.diag_drv_path)).run_join(15)
cls.lin_diag_drv = driver.Driver(port=cls.dut_port,
drv_type=driver.DRV_TYPE_SRC_DIAG_LIN, version='latest')
cls.lin_prod_drv = driver.Driver(port=cls.dut_port, version=cls.dut_drv_version)
except Exception as e:
log.exception("Failed while setting up class")
raise e
@classmethod
def teardown_class(cls):
super(TestDiag, cls).teardown_class()
# DiagWrapper.exec_single("--password !h:ahT8uW6 --flash_erase")
if cls.os.is_linux():
uninstall_diag()
else:
remove_directory(cls.diag_dir)
def setup_method(self, method):
super(TestDiag, self).setup_method(method)
if self.lin_diag_drv.is_loaded():
log.info("Unloading diag drivers")
self.lin_diag_drv.unload()
if self.lin_prod_drv.is_loaded():
log.info("Unloading prod drivers")
self.lin_prod_drv.unload()
if sys.platform == "win32" and 'darwin' not in sys.platform:
params = ["-h", "/?", "-?"]
else:
params = ["-h", "-?"]
def test_temp_witn_no_drv(self):
log.info("Running Diag with -s option with no loaded prod and diag drivers")
output = DiagWrapper.exec_single("-s -p -d {} --raise".format(self.dut_port.replace("00","0")), self.diag_dir)
assert output["returncode"] == 0, "Error, DIAG exits with return code {}".format(output["returncode"])
assert not self.lin_prod_drv.is_loaded(), "Error, prod driver has to be unloaded"
assert not self.lin_prod_drv.is_bound(), "Error, prod driver has to be unbound"
assert not self.lin_diag_drv.is_loaded(), "Error, diag driver has to be unloaded"
assert not self.lin_diag_drv.is_bound(), "Error, diag driver has to be unbound"
def test_temp_prod_is_bound(self):
log.info("Running Diag with -s option with loaded and bound prod driver")
self.lin_prod_drv.install()
output = DiagWrapper.exec_single("-s -p -d {} --raise".format(self.dut_port.replace("00","0")), self.diag_dir)
assert output["returncode"] == 0, "Error, DIAG exits with return code {}".format(output["returncode"])
assert self.lin_prod_drv.is_loaded(), "Error, prod driver has to be loaded"
assert self.lin_prod_drv.is_bound(), "Error, prod driver has to be bound"
assert not self.lin_diag_drv.is_loaded(), "Error, diag driver has to be unloaded"
assert not self.lin_diag_drv.is_bound(), "Error, diag driver has to be unbound"
def test_temp_prod_is_loaded(self):
log.info("Running Diag with -s option with with loaded and unbound prod driver")
self.lin_prod_drv.install()
self.lin_prod_drv.unbind()
output = DiagWrapper.exec_single("-s -p -d {} --raise".format(self.dut_port.replace("00","0")), self.diag_dir)
assert output["returncode"] == 0, "Error, DIAG exits with return code {}".format(output["returncode"])
assert self.lin_prod_drv.is_loaded(), "Error, prod driver has to be loaded"
assert not self.lin_prod_drv.is_bound(), "Error, prod driver has to be unbound"
assert not self.lin_diag_drv.is_loaded(), "Error, diag driver has to be unloaded"
assert not self.lin_diag_drv.is_bound(), "Error, diag driver has to be unbound"
def test_temp_prod_is_bound_and_diag_is_loaded(self):
log.info("Running Diag with -s option with bound prod driver and loaded diag driver")
self.lin_diag_drv.load(self.diag_drv_path)
self.lin_diag_drv.unbind()
self.lin_prod_drv.install()
output = DiagWrapper.exec_single("-s -p -d {} --raise".format(self.dut_port.replace("00","0")), self.diag_dir)
assert output["returncode"] == 0, "Error, DIAG exits with return code {}".format(output["returncode"])
assert self.lin_prod_drv.is_loaded(), "Error, prod driver has to be loaded"
assert self.lin_prod_drv.is_bound(), "Error, prod driver has to be bound"
assert self.lin_diag_drv.is_loaded(), "Error, diag driver has to be loaded"
assert not self.lin_diag_drv.is_bound(), "Error, diag driver has to be unbound"
def test_temp_prod_is_loaded_and_diag_is_bound(self):
log.info("Running Diag with -s option with loaded prod driver and bound diag driver")
self.lin_prod_drv.install()
self.lin_prod_drv.unbind()
self.lin_diag_drv.load(self.diag_drv_path)
output = DiagWrapper.exec_single("-s -p -d {} --raise".format(self.dut_port.replace("00","0")), self.diag_dir)
assert output["returncode"] == 0, "Error, DIAG exits with return code {}".format(output["returncode"])
assert self.lin_prod_drv.is_loaded(), "Error,prod driver has to be loaded"
assert not self.lin_prod_drv.is_bound(), "Error,prod driver has to be unbound"
assert self.lin_diag_drv.is_loaded(), "Error, diag driver has to be loaded"
assert self.lin_diag_drv.is_bound(), "Error, diag driver has to be bound"
def test_temp_prod_is_loaded_and_diag_is_loaded(self):
log.info("Running Diag with -s option with loaded prod driver and loaded diag driver")
self.lin_prod_drv.install()
self.lin_prod_drv.unbind()
self.lin_diag_drv.load(self.diag_drv_path)
self.lin_diag_drv.unbind()
output = DiagWrapper.exec_single("-s -p -d {} --raise".format(self.dut_port.replace("00","0")), self.diag_dir)
assert output["returncode"] == 0, "Error, DIAG exits with return code {}".format(output["returncode"])
assert self.lin_prod_drv.is_loaded(), "Error, prod driver has to be loaded"
assert not self.lin_prod_drv.is_bound(), "Error, prod driver has to be unbound"
assert self.lin_diag_drv.is_loaded(), "Error, diag driver has to be loaded"
assert not self.lin_diag_drv.is_bound(), "Error, diag driver has to be unbound"
def test_temp_diag_is_loaded(self):
log.info("Running Diag with -s option with loaded diag driver")
self.lin_diag_drv.load(self.diag_drv_path)
self.lin_diag_drv.unbind()
output = DiagWrapper.exec_single("-s -p -d {} --raise".format(self.dut_port.replace("00","0")), self.diag_dir)
assert output["returncode"] == 0, "Error, DIAG exits with return code {}".format(output["returncode"])
assert not self.lin_prod_drv.is_loaded(), "Error, prod driver has to be unloaded"
assert not self.lin_prod_drv.is_bound(), "Error, prod driver has to be unbound"
assert self.lin_diag_drv.is_loaded(), "Error, diag driver has to be loaded"
assert not self.lin_diag_drv.is_bound(), "Error, diag driver has to be unbound"
def test_temp_diag_is_bound(self):
log.info("Running Diag with -s option with bound diag driver")
self.lin_diag_drv.load(self.diag_drv_path)
output = DiagWrapper.exec_single("-s -p -d {} --raise".format(self.dut_port.replace("00","0")), self.diag_dir)
assert output["returncode"] == 0, "Error, DIAG exits with return code {}".format(output["returncode"])
assert not self.lin_prod_drv.is_loaded(), "Error, prod driver has to be unloaded"
assert not self.lin_prod_drv.is_bound(), "Error, prod driver has to be unbound"
assert self.lin_diag_drv.is_loaded(), "Error, diag driver has to be loaded"
assert self.lin_diag_drv.is_bound(), "Error, diag driver has to be bound"
def test_perm_witn_no_drv(self):
log.info("Running Diag with -k option with no loaded prod and diag drivers")
output = DiagWrapper.exec_single("-k -p -d {} --raise".format(self.dut_port.replace("00","0")), self.diag_dir)
assert output["returncode"] == 0, "Error, DIAG exits with return code {}".format(output["returncode"])
assert not self.lin_prod_drv.is_loaded(), "Error, prod driver has to be unloaded"
assert not self.lin_prod_drv.is_bound(), "Error, prod driver has to be unbound"
assert self.lin_diag_drv.is_loaded(), "Error, diag driver has to be loaded"
assert self.lin_diag_drv.is_bound(), "Error, diag driver has to be bound"
def test_perm_prod_is_bound(self):
log.info("Running Diag with -k option with loaded and bound prod driver")
self.lin_prod_drv.install()
output = DiagWrapper.exec_single("-k -p -d {} --raise".format(self.dut_port.replace("00","0")), self.diag_dir)
assert output["returncode"] == 0, "Error, DIAG exits with return code {}".format(output["returncode"])
assert self.lin_prod_drv.is_loaded(), "Error, prod driver has to be loaded"
assert not self.lin_prod_drv.is_bound(), "Error, prod driver has to be unbound"
assert self.lin_diag_drv.is_loaded(), "Error, diag driver has to be loaded"
assert self.lin_diag_drv.is_bound(), "Error, diag driver has to be bound"
def test_perm_prod_is_loaded(self):
log.info("Running Diag with -k option with with loaded and unbound prod driver")
self.lin_prod_drv.install()
self.lin_prod_drv.unbind()
output = DiagWrapper.exec_single("-k -p -d {} --raise".format(self.dut_port.replace("00","0")), self.diag_dir)
assert output["returncode"] == 0, "Error, DIAG exits with return code {}".format(output["returncode"])
assert self.lin_prod_drv.is_loaded(), "Error, prod driver has to be loaded"
assert not self.lin_prod_drv.is_bound(), "Error, prod driver has to be unbound"
assert self.lin_diag_drv.is_loaded(), "Error, diag driver has to be loaded"
assert self.lin_diag_drv.is_bound(), "Error, diag driver has to be bound"
def test_perm_prod_is_bound_and_diag_is_loaded(self):
log.info("Running Diag with -k option with bound prod driver and loaded diag driver")
self.lin_diag_drv.load(self.diag_drv_path)
self.lin_diag_drv.unbind()
self.lin_prod_drv.install()
output = DiagWrapper.exec_single("-k -p -d {} --raise".format(self.dut_port.replace("00","0")), self.diag_dir)
assert output["returncode"] == 0, "Error, DIAG exits with return code {}".format(output["returncode"])
assert self.lin_prod_drv.is_loaded(), "Error, prod driver has to be loaded"
assert not self.lin_prod_drv.is_bound(), "Error, prod driver has to be unbound"
assert self.lin_diag_drv.is_loaded(), "Error, diag driver has to be loaded"
assert self.lin_diag_drv.is_bound(), "Error, diag driver has to be bound"
def test_perm_prod_is_loaded_and_diag_is_bound(self):
log.info("Running Diag with -k option with loaded prod driver and bound diag driver")
self.lin_prod_drv.install()
self.lin_prod_drv.unbind()
self.lin_diag_drv.load(self.diag_drv_path)
output = DiagWrapper.exec_single("-k -p -d {} --raise".format(self.dut_port.replace("00","0")), self.diag_dir)
assert output["returncode"] == 0, "Error, DIAG exits with return code {}".format(output["returncode"])
assert self.lin_prod_drv.is_loaded(), "Error, prod driver has to be loaded"
assert not self.lin_prod_drv.is_bound(), "Error, prod driver has to be unbound"
assert self.lin_diag_drv.is_loaded(), "Error, diag driver has to be loaded"
assert self.lin_diag_drv.is_bound(), "Error, diag driver has to be bound"
def test_perm_prod_is_loaded_and_diag_is_loaded(self):
log.info("Running Diag with -k option with loaded prod driver and loaded diag driver")
self.lin_prod_drv.install()
self.lin_prod_drv.unbind()
self.lin_diag_drv.load(self.diag_drv_path)
self.lin_diag_drv.unbind()
output = DiagWrapper.exec_single("-k -p -d {} --raise".format(self.dut_port.replace("00","0")), self.diag_dir)
assert output["returncode"] == 0, "Error, DIAG exits with return code {}".format(output["returncode"])
assert self.lin_prod_drv.is_loaded(), "Error, prod driver has to be loaded"
assert not self.lin_prod_drv.is_bound(), "Error, prod driver has to be unbound"
assert self.lin_diag_drv.is_loaded(), "Error, diag driver has to be loaded"
assert self.lin_diag_drv.is_bound(), "Error, diag driver has to be bound"
def test_perm_diag_is_loaded(self):
log.info("Running Diag with -k option with loaded diag driver")
self.lin_diag_drv.load(self.diag_drv_path)
self.lin_diag_drv.unbind()
output = DiagWrapper.exec_single("-k -p -d {} --raise".format(self.dut_port.replace("00","0")), self.diag_dir)
assert output["returncode"] == 0, "Error, DIAG exits with return code {}".format(output["returncode"])
assert not self.lin_prod_drv.is_loaded(), "Error, prod driver has to be unloaded"
assert not self.lin_prod_drv.is_bound(), "Error, prod driver has to be unbound"
assert self.lin_diag_drv.is_loaded(), "Error, diag driver has to be loaded"
assert self.lin_diag_drv.is_bound(), "Error, diag driver has to be bound"
def test_perm_diag_is_bound(self):
log.info("Running Diag with -k option with bound diag driver")
self.lin_diag_drv.load(self.diag_drv_path)
output = DiagWrapper.exec_single("-k -p -d {} --raise".format(self.dut_port.replace("00","0")), self.diag_dir)
assert output["returncode"] == 0, "Error, DIAG exits with return code {}".format(output["returncode"])
assert not self.lin_prod_drv.is_loaded(), "Error, prod driver has to be unloaded"
assert not self.lin_prod_drv.is_bound(), "Error, prod driver has to be unbound"
assert self.lin_diag_drv.is_loaded(), "Error, diag driver has to be loaded"
assert self.lin_diag_drv.is_bound(), "Error, diag driver has to be bound"
if __name__ == "__main__":
pytest.main([__file__, "-s", "-v"])