4 from autotest_lib
.client
.bin
import kernel_versions
7 class kernel_versions_test(unittest
.TestCase
):
9 def increases(self
, kernels
):
10 for i
in xrange(len(kernels
)-1):
13 ek1
= kernel_versions
.version_encode(k1
)
14 ek2
= kernel_versions
.version_encode(k2
)
15 self
.assertTrue(ek1
< ek2
,
16 '%s (-> %s) should sort < %s (-> %s)'
17 % (k1
, ek1
, k2
, ek2
) )
20 def test_version_encode(self
):
43 self
.increases(series1
)
44 self
.increases(['pathX'+k
for k
in series1
])
48 '2.6.18-smp-220.1_rc1',
49 '2.6.18-smp-220.1_rc1_fix',
50 '2.6.18-smp-220.1_rc1_patch',
51 '2.6.18-smp-220.1_rc9',
52 '2.6.18-smp-220.1_rc9_mm1',
53 '2.6.18-smp-220.1_rc9_mm2',
54 '2.6.18-smp-220.1_rc10',
55 '2.6.18-smp-220.1_rc98',
57 '2.6.18-smp-220.1_patch',
64 self
.increases(series2
)
65 self
.increases(['pathX'+k
for k
in series2
])
68 releases
= ['2.6.1' , '2.6.18-smp-220.0' ]
69 candidates
= ['2.6.1-rc1' , '2.6.18-smp-220.0_rc1']
70 experiments
= ['2.6.1-patch', '2.6.1-rc1_patch', '2.6.18-smp-220.0_patch',
73 def test_is_released_kernel(self
):
74 for v
in self
.releases
:
75 self
.assertTrue(kernel_versions
.is_released_kernel(v
))
76 for v
in self
.candidates
+ self
.experiments
:
77 self
.assertFalse(kernel_versions
.is_released_kernel(v
))
80 def test_is_release_candidate(self
):
81 for v
in self
.releases
+ self
.candidates
:
82 self
.assertTrue(kernel_versions
.is_release_candidate(v
))
83 for v
in self
.experiments
:
84 self
.assertFalse(kernel_versions
.is_release_candidate(v
))
87 if __name__
== "__main__":