-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtests_functional
executable file
·68 lines (56 loc) · 1.51 KB
/
tests_functional
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
#!/usr/bin/env ruby
$LOAD_PATH.unshift('lib')
require 'einarc/baseraid'
# Throw in fake EINARC_LIB, it's for testing purposes anyway
Einarc::EINARC_LIB = ''
require 'einarc/software'
include Einarc
require 'test/unit'
class SoftwareTest < Test::Unit::TestCase
PHYS_SCSI_TESTS = [
['0:1', 'sda'],
['1:1', 'hda'],
['0:2', 'sdb'],
['0:2:5', 'sdb5'],
['0:3:23', 'sdc23'],
['0:26', 'sdz'],
['0:27', 'sdaa'],
['0:28', 'sdab'],
['0:28:245', 'sdab245'],
['0:52', 'sdaz'],
['0:53', 'sdba'],
['0:78', 'sdbz'],
['0:79', 'sdca'],
['0:676', 'sdyz'],
['0:677', 'sdza'],
['0:702', 'sdzz'],
['0:703', 'sdaaa'],
]
def test_char_to_number
assert_equal(1, Software.char_to_number('a'))
assert_equal(2, Software.char_to_number('b'))
assert_equal(26, Software.char_to_number('z'))
end
def test_number_to_char
assert_equal('a', Software.number_to_char(1))
assert_equal('b', Software.number_to_char(2))
assert_equal('z', Software.number_to_char(26))
end
def test_phys_to_scsi
PHYS_SCSI_TESTS.each { |t|
scsi, phys = t
assert_equal(scsi, Software.phys_to_scsi(phys))
}
end
def test_scsi_to_device
PHYS_SCSI_TESTS.each { |t|
scsi, phys = t
assert_equal("/dev/#{phys}", Software.scsi_to_device(scsi))
}
end
def test_parse_physical_string
assert_equal(['0:1'], Software.parse_physical_string('sda[0]'))
assert_equal(['0:1:2', '0:2:2'], Software.parse_physical_string('sdb2[1] sda2[0]'))
assert_equal(['0:1', '0:2'], Software.parse_physical_string('sda[0] sdb[1]'))
end
end