mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-13 20:12:26 +00:00
This is a squash commit, the unsquashed development went through many unstable phases which would break bisects. The unsquashed branch is: https://github.com/cirosantilli/linux-kernel-module-cheat/tree/v3.0-unsquash The main improvement of this release was to greatly generalize the testing system. The key addition was cli_function.py, which allows scripts such as ./run to be transparently called either from Python or from the command line. New tests scripts were created using this improved framework: test-baremetal and test-user-mode. We were lazy to port some of less important tests to the new setup, TODO's were added, and we need comes they will be fixed. Getting started is however sacred as usual and should work. Other changes include: - gem5: update to 7fa4c946386e7207ad5859e8ade0bbfc14000d91 - run: --tmux-args implies --tmux - run: add --userland-args to make userland arguments across QEMU and gem5 Get rid of --userland-before as a consequence. - bring initrd and initramfs back to life - build-userland: create --static to make build a bit easier - gem5: --gem5-worktree also set --gem5-build-id - remove --gem5, use --emulator gem5 everywhere Allow passing --emulator multiple times for transparent tests selection just like --arch. - test-userland: allow selecting just a few tests - linux: update to v4.20 - buildroot: update to 2018.08 The main motivation for this was to fix the build for Ubuntu 18.10, which has glibc 2.28, which broke the 2018.05 build at the m4-host package with: #error "Please port gnulib fseeko.c to your platform! - getvar --type input - failed xen attempt, refactor timer, failed svc attempt, aarch64 use gicv3 - build-doc: exit 1 on error, add to release testing - build: add --apt option to make things easier on other distros - build-linux: --no-modules-install
93 lines
3.3 KiB
Python
Executable File
93 lines
3.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import common
|
|
import shell_helpers
|
|
from shell_helpers import LF
|
|
|
|
class Main(common.TestCliFunction):
|
|
def __init__(self):
|
|
super().__init__(
|
|
description='''\
|
|
Test and benchmark the Linux kernel boot. Use inits that exit immediately.
|
|
'''
|
|
)
|
|
self.add_argument(
|
|
'--size',
|
|
default=1,
|
|
type=int,
|
|
help='''\
|
|
See ./test --help for --size.
|
|
'''
|
|
)
|
|
|
|
def _bench(self, **kwargs):
|
|
words = []
|
|
for line in self.run.get_cli(**kwargs):
|
|
words.extend(line)
|
|
extra_params = shell_helpers.ShellHelpers().cmd_to_string(words + [LF])
|
|
run_args = kwargs.copy()
|
|
run_args.update(self.common_args)
|
|
self.run_test(self.run, run_args, extra_params)
|
|
|
|
def timed_main(self):
|
|
# TODO bring this benchmark code back to life. Likely should go inside run with an option
|
|
#gem5_insts() (
|
|
# printf "instructions $(./gem5-stat --arch "$1" sim_insts)\n" >> "$self.env['test_boot_benchmark_file']"
|
|
# newline
|
|
#)
|
|
#
|
|
#qemu_insts() (
|
|
# common_arch="$1"
|
|
# ./qemu-trace2txt --arch "$common_arch"
|
|
# common_qemu_trace_txt_file="$("$getvar" --arch "$common_arch" qemu_trace_txt_file)"
|
|
# printf "instructions $(wc -l "${common_qemu_trace_txt_file}" | cut -d' ' -f1)\n" >> "$self.env['test_boot_benchmark_file']"
|
|
# newline
|
|
#)
|
|
#
|
|
#rm -f "${self.env['test_boot_benchmark_file']}"
|
|
self.run = self.import_path_main('run')
|
|
self.common_args = self.get_common_args()
|
|
self.common_args['ctrl_c_host'] = True
|
|
self.common_args['quit_after_boot'] = True
|
|
if (self.env['emulator'] == 'qemu' or
|
|
(self.env['emulator'] == 'gem5' and self.env['size'] >= 2)):
|
|
self._bench()
|
|
if self.env['host_arch'] == self.env['arch']:
|
|
# TODO: find out why it fails.
|
|
if self.env['emulator'] != 'gem5':
|
|
self._bench(kvm=True)
|
|
if self.env['emulator'] == 'qemu' and self.env['size'] >= 2:
|
|
self._bench(trace='exec_tb')
|
|
if self.env['emulator'] == 'gem5' and self.env['size'] >= 3:
|
|
if self.env['arch'] == 'x86_64':
|
|
cpu_types = [
|
|
# TODO segfault
|
|
#'DerivO3CPU'
|
|
]
|
|
elif self.env['is_arm']:
|
|
cpu_types = [
|
|
'DerivO3CPU',
|
|
'HPI',
|
|
]
|
|
for cpu_type in cpu_types:
|
|
self._bench(
|
|
extra_emulator_args=[
|
|
'--cpu-type', cpu_type,
|
|
'--caches',
|
|
'--l2cache',
|
|
'--l1d_size', '1024kB',
|
|
'--l1i_size', '1024kB',
|
|
'--l2_size', '1024kB',
|
|
'--l3_size', '1024kB',
|
|
],
|
|
)
|
|
if self.env['arch'] == 'aarch64':
|
|
# Do a fuller testing for aarch64.
|
|
for build_type in ['debug', 'fast']:
|
|
self._bench(gem5_build_type=build_type)
|
|
# Requires patching the executable.
|
|
# self._bench(gem5_script='biglittle')
|
|
|
|
if __name__ == '__main__':
|
|
Main().cli()
|