Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3#
4# Copyright (C) 2018 Uladzislau Rezki (Sony) <urezki@gmail.com>
5#
6# This is a test script for the kernel test driver to analyse vmalloc
7# allocator. Therefore it is just a kernel module loader. You can specify
8# and pass different parameters in order to:
9# a) analyse performance of vmalloc allocations;
10# b) stressing and stability check of vmalloc subsystem.
11
12TEST_NAME="test_hmm"
13DRIVER="test_hmm"
14
15# 1 if fails
16exitcode=1
17
18# Kselftest framework requirement - SKIP code is 4.
19ksft_skip=4
20
21check_test_requirements()
22{
23 uid=$(id -u)
24 if [ $uid -ne 0 ]; then
25 echo "$0: Must be run as root"
26 exit $ksft_skip
27 fi
28
29 if ! which modprobe > /dev/null 2>&1; then
30 echo "$0: You need modprobe installed"
31 exit $ksft_skip
32 fi
33
34 if ! modinfo $DRIVER > /dev/null 2>&1; then
35 echo "$0: You must have the following enabled in your kernel:"
36 echo "CONFIG_TEST_HMM=m"
37 exit $ksft_skip
38 fi
39}
40
41load_driver()
42{
43 modprobe $DRIVER > /dev/null 2>&1
44 if [ $? == 0 ]; then
45 major=$(awk "\$2==\"HMM_DMIRROR\" {print \$1}" /proc/devices)
46 mknod /dev/hmm_dmirror0 c $major 0
47 mknod /dev/hmm_dmirror1 c $major 1
48 fi
49}
50
51unload_driver()
52{
53 modprobe -r $DRIVER > /dev/null 2>&1
54 rm -f /dev/hmm_dmirror?
55}
56
57run_smoke()
58{
59 echo "Running smoke test. Note, this test provides basic coverage."
60
61 load_driver
62 $(dirname "${BASH_SOURCE[0]}")/hmm-tests
63 unload_driver
64}
65
66usage()
67{
68 echo -n "Usage: $0"
69 echo
70 echo "Example usage:"
71 echo
72 echo "# Shows help message"
73 echo "./${TEST_NAME}.sh"
74 echo
75 echo "# Smoke testing"
76 echo "./${TEST_NAME}.sh smoke"
77 echo
78 exit 0
79}
80
81function run_test()
82{
83 if [ $# -eq 0 ]; then
84 usage
85 else
86 if [ "$1" = "smoke" ]; then
87 run_smoke
88 else
89 usage
90 fi
91 fi
92}
93
94check_test_requirements
95run_test $@
96
97exit 0