Yifan Hong | 770ab05 | 2018-11-02 13:43:30 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # Copyright (C) 2018 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | import unittest |
cfig | 791378c | 2021-02-07 17:01:26 +0800 | [diff] [blame] | 18 | from extract_kernel import dump_version |
Yifan Hong | 770ab05 | 2018-11-02 13:43:30 -0700 | [diff] [blame] | 19 | |
| 20 | class ExtractKernelTest(unittest.TestCase): |
| 21 | def test_extract_version(self): |
cfig | 791378c | 2021-02-07 17:01:26 +0800 | [diff] [blame] | 22 | self.assertEqual("4.9.100", dump_version( |
| 23 | b'Linux version 4.9.100-a123 (a@a) (a) a\n\x00')) |
| 24 | self.assertEqual("4.9.123", dump_version( |
| 25 | b'Linux version 4.9.123 (@) () \n\x00')) |
Yifan Hong | 770ab05 | 2018-11-02 13:43:30 -0700 | [diff] [blame] | 26 | |
| 27 | def test_dump_self(self): |
| 28 | self.assertEqual("4.9.1", dump_version( |
| 29 | b"trash\x00Linux version 4.8.8\x00trash\x00" |
cfig | 791378c | 2021-02-07 17:01:26 +0800 | [diff] [blame] | 30 | b"other trash Linux version 4.9.1-g3 (2@s) (2) a\n\x00")) |