~le-chi-thu/lava-test/add-verbose-argument

« back to all changes in this revision

Viewing changes to tests/test_hwprofile.py

  • Committer: Paul Larson
  • Date: 2011-09-22 17:58:01 UTC
  • mfrom: (92.1.4 using-lava-tool-2)
  • Revision ID: paul.larson@canonical.com-20110922175801-l99rky1xxsr6k3fn
Big refactoring branch to make lava-test use lava-tool.  Thanks to
Zygmunt and ChiThu!

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (c) 2010 Linaro
 
1
# Copyright (c) 2010, 2011 Linaro
2
2
#
3
3
# This program is free software: you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
16
16
import os
17
17
import unittest
18
18
 
19
 
import abrek.hwprofile
20
 
from abrek.utils import fake_file, clear_fakes, fake_machine, clear_fake_machine
21
 
from imposters import OutputImposter
22
 
from fixtures import TestCaseWithFixtures
 
19
import lava_test.core.hwprofile
 
20
from lava_test.utils import fake_file, clear_fakes, fake_machine, clear_fake_machine
 
21
from tests.imposters import OutputImposter
 
22
from tests.fixtures import TestCaseWithFixtures
23
23
 
24
24
 
25
25
class AptCache:
81
81
    def test_get_cpu_devs_arm(self):
82
82
        fake_file('/proc/cpuinfo', ARM_CPUINFO_FILE)
83
83
        fake_machine('arm')
84
 
        devs = abrek.hwprofile.get_cpu_devs()
 
84
        devs = lava_test.core.hwprofile.get_cpu_devs()
85
85
        clear_fake_machine()
86
86
        cpuinfo = {
87
87
            'attributes': {
113
113
                'vendor': 'YYYYYYY'},
114
114
            'description': 'XXXXXXX',
115
115
            'device_type': 'device.board'}
116
 
        devs = abrek.hwprofile.get_board_devs()
 
116
        devs = lava_test.core.hwprofile.get_board_devs()
117
117
        clear_fake_machine()
118
118
        self.assertEqual(boardinfo, devs[0])
119
119
 
123
123
        boardinfo = {
124
124
            'description': 'OMAP3 Beagle Board',
125
125
            'device_type': 'device.board'}
126
 
        devs = abrek.hwprofile.get_board_devs()
 
126
        devs = lava_test.core.hwprofile.get_board_devs()
127
127
        clear_fake_machine()
128
128
        self.assertEqual(boardinfo, devs[0])
129
129
 
130
130
    def test_get_mem_devs(self):
131
131
        fake_file('/proc/meminfo', FAKE_MEMINFO_FILE)
132
 
        devs = abrek.hwprofile.get_mem_devs()
 
132
        devs = lava_test.core.hwprofile.get_mem_devs()
133
133
        meminfo = {
134
134
            'attributes': {
135
135
                'kind': 'RAM',
139
139
        self.assertEqual(meminfo, devs[0])
140
140
 
141
141
    def test_get_usb_devs(self):
142
 
        devs = abrek.hwprofile.get_usb_devs()
 
142
        devs = lava_test.core.hwprofile.get_usb_devs()
143
143
        self.assertEqual('device.usb', devs[0]['device_type'])
144
144
 
145
145
 
156
156
    def test_bad_cpuinfo(self):
157
157
        errmsg = "WARNING: Could not read cpu information\n"
158
158
        fake_file('/proc/cpuinfo', newpath='/foo/bar')
159
 
        devs = abrek.hwprofile.get_cpu_devs()
 
159
        devs = lava_test.core.hwprofile.get_cpu_devs()
160
160
        self.assertEqual([], devs)
161
161
        self.assertEqual(errmsg, self.out.getvalue())
162
162
 
165
165
        errmsg = "WARNING: Could not read board information\n"
166
166
        fake_file('/sys/class/dmi/id/board_name', newpath='/foo/bar')
167
167
        fake_file('/proc/cpuinfo', newpath='/foo/bar')
168
 
        devs = abrek.hwprofile.get_board_devs()
 
168
        devs = lava_test.core.hwprofile.get_board_devs()
169
169
        clear_fake_machine()
170
170
        self.assertEqual([], devs)
171
171
        self.assertEqual(errmsg, self.out.getvalue())
173
173
    def test_bad_meminfo(self):
174
174
        errmsg = "WARNING: Could not read memory information\n"
175
175
        fake_file('/proc/meminfo', newpath='/foo/bar')
176
 
        devs = abrek.hwprofile.get_mem_devs()
 
176
        devs = lava_test.core.hwprofile.get_mem_devs()
177
177
        self.assertEqual([], devs)
178
178
        self.assertEqual(errmsg, self.out.getvalue())
179
179