~afrantzis/lava-test/spandex-gles2

« back to all changes in this revision

Viewing changes to tests/test_hwprofile.py

  • Committer: Paul Larson
  • Date: 2010-11-19 18:37:53 UTC
  • mto: This revision was merged to the branch mainline in revision 53.
  • Revision ID: paul.larson@canonical.com-20101119183753-ztt64opqo4sanqk7
Fix some unit tests that break if you run on ARM

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import unittest
18
18
 
19
19
import abrek.hwprofile
20
 
from abrek.utils import fake_file, clear_fakes
 
20
from abrek.utils import fake_file, clear_fakes, fake_machine, clear_fake_machine
21
21
from imposters import OutputImposter
22
22
from fixtures import TestCaseWithFixtures
23
23
 
78
78
VmallocChunk:     643316 kB"""
79
79
 
80
80
class HwprofileTests(unittest.TestCase):
81
 
    def test_get_cpu_devs(self):
 
81
    def test_get_cpu_devs_arm(self):
82
82
        fake_file('/proc/cpuinfo', ARM_CPUINFO_FILE)
 
83
        fake_machine('arm')
83
84
        devs = abrek.hwprofile.get_cpu_devs()
 
85
        clear_fake_machine()
84
86
        cpuinfo = {
85
87
            'attributes': {
86
 
                'CPU implementer': '0x41',
87
 
                'Features': 'swp half thumb fastmult vfp edsp neon vfpv3*',
88
 
                'CPU architecture': '7',
 
88
                'cpu_model_name': 'ARMv7 Processor rev 3 (v7l)',
 
89
                'cpu_features': 'swp half thumb fastmult vfp edsp neon vfpv3*',
 
90
                'cpu_variant': 1,
 
91
                'cpu_architecture': 7,
89
92
                'BogoMIPS': '483.16',
90
93
                'Hardware': 'OMAP3 Beagle Board',
91
 
                'CPU revision': '3',
92
 
                'CPU part': '0xc08',
 
94
                'cpu_implementer': 65,
 
95
                'cpu_part': 3080,
 
96
                'cpu_revision': 3,
93
97
                'Serial': '0000000000000000',
94
 
                'Processor': 'ARMv7 Processor rev 3 (v7l)',
95
 
                'CPU variant': '0x1',
96
98
                'Revision': '0020'},
97
99
            'description': 'Processor #0',
98
100
            'device_type': 'device.cpu'}
99
101
        self.assertEqual(cpuinfo, devs[0])
100
102
 
101
 
    def test_get_board_devs(self):
 
103
    def test_get_board_devs_x86(self):
 
104
        fake_machine('x86_64')
102
105
        fake_file('/sys/class/dmi/id/board_name', FAKE_BOARDNAME_FILE)
103
 
        fake_file('/sys/class/dmi/id/board_vendor', FAKE_BOARDVENDOR_FILE)
104
 
        fake_file('/sys/class/dmi/id/board_version', FAKE_BOARDVERSION_FILE)
105
 
        devs = abrek.hwprofile.get_board_devs()
 
106
        fake_file('/sys/class/dmi/id/board_vendor',
 
107
            FAKE_BOARDVENDOR_FILE)
 
108
        fake_file('/sys/class/dmi/id/board_version',
 
109
            FAKE_BOARDVERSION_FILE)
106
110
        boardinfo = {
107
111
            'attributes': {
108
112
                'version': 'ZZZZZZZ',
109
113
                'vendor': 'YYYYYYY'},
110
114
            'description': 'XXXXXXX',
111
115
            'device_type': 'device.board'}
 
116
        devs = abrek.hwprofile.get_board_devs()
 
117
        clear_fake_machine()
 
118
        self.assertEqual(boardinfo, devs[0])
 
119
 
 
120
    def test_get_board_devs_arm(self):
 
121
        fake_machine('arm')
 
122
        fake_file('/proc/cpuinfo', ARM_CPUINFO_FILE)
 
123
        boardinfo = {
 
124
            'description': 'OMAP3 Beagle Board',
 
125
            'device_type': 'device.board'}
 
126
        devs = abrek.hwprofile.get_board_devs()
 
127
        clear_fake_machine()
112
128
        self.assertEqual(boardinfo, devs[0])
113
129
 
114
130
    def test_get_mem_devs(self):
145
161
        self.assertEqual(errmsg, self.out.getvalue())
146
162
 
147
163
    def test_bad_boardinfo(self):
148
 
        machine = os.uname()[-1]
 
164
        fake_machine('x86_64')
149
165
        errmsg = "WARNING: Could not read board information\n"
150
166
        fake_file('/sys/class/dmi/id/board_name', newpath='/foo/bar')
 
167
        fake_file('/proc/cpuinfo', newpath='/foo/bar')
151
168
        devs = abrek.hwprofile.get_board_devs()
 
169
        clear_fake_machine()
152
170
        self.assertEqual([], devs)
153
 
        if machine in ('i686', 'x86_64'):
154
 
            self.assertEqual(errmsg, self.out.getvalue())
 
171
        self.assertEqual(errmsg, self.out.getvalue())
155
172
 
156
173
    def test_bad_meminfo(self):
157
174
        errmsg = "WARNING: Could not read memory information\n"