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