Home | History | Annotate | Download | only in brillo_KernelVersionTest
      1 # Copyright 2015 The Chromium OS Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 import common
      6 from autotest_lib.client.bin import utils
      7 from autotest_lib.client.common_lib import error
      8 from autotest_lib.server import test
      9 
     10 
     11 _DEFAULT_MIN_VERSION = '3.10'
     12 
     13 
     14 class brillo_KernelVersionTest(test.test):
     15     """Verify that a Brillo device runs a minimum kernel version."""
     16     version = 1
     17 
     18     def run_once(self, host=None, min_version=_DEFAULT_MIN_VERSION):
     19         """Runs the test.
     20 
     21         @param host: A host object representing the DUT.
     22         @param min_version: Minimum kernel version required.
     23 
     24         @raise TestError: Something went wrong while trying to execute the test.
     25         @raise TestFail: The test failed.
     26         """
     27         try:
     28             result = host.run_output('uname -r').strip()
     29         except error.AutoservRunError:
     30             raise error.TestFail('Failed to check kernel version')
     31 
     32         if utils.compare_versions(result, min_version) < 0:
     33             raise error.TestFail(
     34                     'Device kernel version (%s) older than required (%s)' %
     35                     (result, min_version))
     36