Commit c9277285 by chenke

Fix method 'test_discover' assertError in test_driver.py

The error info as follows:

testtools.matchers._impl.MismatchError: !=:
reference = {'cpid_info': '0000:5e:00.0', 'cpid_type': 'pci'}
actual    = {'cpid_info': u'0000:be:00.0', 'cpid_type': u'pci'}

The reason for assertError is that 'intel-fpga-dev.2' is found
earilier than 'intel-fpga-dev.1' randomly because of the module
'glob.glob'.

In cyborg/accelerator/drivers/fpga/intel/sysinfo.py Line 81,
method all_pf_fpgas(), it use glob.glob(..) to find fpga dirvers.
However, this glob module does not guarantee that the file name
obtained is ordered.

For convenience, we can sort the fpgas before assert.

Reference docs:
https://docs.python.org/2.7/library/glob.html?highlight=glob#glob.glob
https://docs.python.org/2.7/library/os.html?highlight=listdir#os.listdir
http://landcareweb.com/questions/34393/an-ri-qi-shun-xu-sou-suo-glob

Change-Id: Ie9de5d7ec06064f557620ec4ee21f7bd776c2add
parent 6a0c367c
......@@ -80,6 +80,7 @@ class TestIntelFPGADriver(base.TestCase):
'cpid_type': 'pci'}}]
intel = IntelFPGADriver()
fpgas = intel.discover()
list.sort(fpgas, key=lambda x: x._obj_deployable_list[0].name)
self.assertEqual(2, len(fpgas))
for i in range(len(fpgas)):
fpga_dict = fpgas[i].as_dict()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment