blob: 002e38734dc89406624122ff2a6510b4d8341926 [file] [log] [blame]
Yifan Hong770ab052018-11-02 13:43:30 -07001#!/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
17import unittest
cfig791378c2021-02-07 17:01:26 +080018from extract_kernel import dump_version
Yifan Hong770ab052018-11-02 13:43:30 -070019
20class ExtractKernelTest(unittest.TestCase):
21 def test_extract_version(self):
cfig791378c2021-02-07 17:01:26 +080022 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 Hong770ab052018-11-02 13:43:30 -070026
27 def test_dump_self(self):
28 self.assertEqual("4.9.1", dump_version(
29 b"trash\x00Linux version 4.8.8\x00trash\x00"
cfig791378c2021-02-07 17:01:26 +080030 b"other trash Linux version 4.9.1-g3 (2@s) (2) a\n\x00"))