-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrpt_utils_003.py
executable file
·50 lines (40 loc) · 1.52 KB
/
rpt_utils_003.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
#!/usr/bin/env python
"""
(C) Copyright IBM Corp. 2008
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This
file and program are licensed under a BSD style license. See
the Copying file included with the OpenHPI distribution for
full licensing terms.
Authors:
Jayashree Padmanabhan <[email protected]>
"""
import unittest
from openhpi import *
from rpt_resources import rptentries
from random import *
class TestSequence(unittest.TestCase):
"""
runTest : Starts with an RPTable of 10 resources and fetches
them randomly by the ResourceId and compares them against the original
resource. A failed comparison means the test failed,
otherwise the test passed.
Return value: 0 on success, 1 on failure
"""
def runTest(self):
rptable = RPTable()
oh_init_rpt(rptable);
resources = [];
for rpte in rptentries:
self.assertEqual(oh_add_resource(rptable, rpte, None, 0), 0)
resources.append(rpte)
while len(resources) > 0 :
k = randrange(0, len(resources), 1)
randentry = resources[k]
tmpentry = oh_get_resource_by_id(rptable, randentry.ResourceId)
self.assertEqual(tmpentry != None, True)
self.assertEqual(memcmp(randentry, tmpentry, sizeof_SaHpiRptEntryT), 0)
resources.pop(k)
if __name__=='__main__':
unittest.main()