1#!/usr/bin/python
2#
3# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7import logging, optparse, os, shutil, re, string
8from autotest_lib.client.common_lib import error
9from autotest_lib.client.bin import utils, test
10
11class kernel_Bootcache(test.test):
12    """Run the boot cache test on 3.8 Kernel version
13    """
14    version = 1
15    KERNEL_VER = '3.8'
16    Bin = '/usr/local/opt/punybench/bin/'
17
18
19    def initialize(self):
20        self.results = []
21        self.job.drop_caches_between_iterations = True
22
23
24    def _run(self, cmd, args):
25        """Run a puny test
26
27        Prepends the path to the puny benchmark bin.
28
29        Args:
30          cmd: command to be run
31          args: arguments for the command
32        """
33        result = utils.system_output(
34            os.path.join(self.Bin, cmd) + ' ' + args)
35        logging.debug(result)
36        return result
37
38
39    def run_once(self, args=[]):
40        kernel_ver = os.uname()[2]
41        if utils.compare_versions(kernel_ver, self.KERNEL_VER) != 0:
42            raise error.TestNAError('Applicable to 3.8 Kernel only')
43
44        """Run the boot cache test.
45        """
46        self._run('bootcachetest', "")
47