blob: 2f3dbc060bc9025f5a6ec9daa41ff4deca35d2e6 [file] [log] [blame]
# Copyright (c) 2015 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import logging
import os
from autotest_lib.client.bin import test, utils
from autotest_lib.client.common_lib import error
from autotest_lib.client.cros import kernel_config
class kernel_FirmwareRequest(test.test):
Test asynchronous firmware loading
version = 1
def set_module_locking(self, enabled):
Enable/disable LSM request_firmware location locking
Inspired by security_ModuleLocking
sysctl = "/proc/sys/kernel/chromiumos/module_locking"
value = '1\n' if enabled else '0\n'
if os.path.exists(sysctl):
open(sysctl, "w").write(value)
raise error.TestNAError("module locking sysctl not available; may not be able to load test FW")
def test_is_valid(self):
Check if this test is worth running, based on whether the kernel
.config has the right features
config = kernel_config.KernelConfig()
return len(config.failures()) == 0
def do_fw_test(self):
Run one iteration of the test
Return non-zero if failed
ret = utils.system("./", ignore_status=True)
if ret:
raise error.TestFail("FW request test failed: %d" % (ret))
def run_once(self):
This test will run the firmware request kernel self test (from
upstream). This tests that the request_firmware() and
request_firmware_nowait() kernel APIs are somewhat sane. It tries to
load the empty filename ("") as well as a small toy firmware, and
checks that it matches. It also makes sure a non-existent firmware
cannot be found.
We rerun the same test several times to increase the probability of
catching errors.
Needs to disable module locking so we can load test firmwares from
non-standard locations (e.g., /tmp)
num_loops = 50
module_name = "test_firmware"
if not self.test_is_valid():
raise error.TestNAError("FW test module is not available for this test")
if not utils.module_is_loaded(module_name):
raise error.TestNAError("FW test module is not available for this test")
self.set_module_locking(False)"iterations: %d", num_loops)
for i in range(0, num_loops):