1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2018, FUJITSU LIMITED. All rights reserved.
# Global variables
# NDCTL
if [ -z $NDCTL ]; then
if [ -f "../ndctl/ndctl" ] && [ -x "../ndctl/ndctl" ]; then
export NDCTL=../ndctl/ndctl
elif [ -f "./ndctl/ndctl" ] && [ -x "./ndctl/ndctl" ]; then
export NDCTL=./ndctl/ndctl
else
echo "Couldn't find an ndctl binary"
exit 1
fi
fi
# DAXCTL
if [ -z $DAXCTL ]; then
if [ -f "../daxctl/daxctl" ] && [ -x "../daxctl/daxctl" ]; then
export DAXCTL=../daxctl/daxctl
elif [ -f "./daxctl/daxctl" ] && [ -x "./daxctl/daxctl" ]; then
export DAXCTL=./daxctl/daxctl
else
echo "Couldn't find an daxctl binary"
exit 1
fi
fi
# CXL
if [ -z $CXL ]; then
if [ -f "../cxl/cxl" ] && [ -x "../cxl/cxl" ]; then
export CXL=../cxl/cxl
elif [ -f "./cxl/cxl" ] && [ -x "./cxl/cxl" ]; then
export CXL=./cxl/cxl
else
echo "Couldn't find a cxl binary"
exit 1
fi
fi
if [ -z $TEST_PATH ]; then
export TEST_PATH=.
fi
# NFIT_TEST_BUS[01]
#
NFIT_TEST_BUS0="nfit_test.0"
NFIT_TEST_BUS1="nfit_test.1"
CXL_TEST_BUS="cxl_test"
ACPI_BUS="ACPI.NFIT"
E820_BUS="e820"
# Functions
# err
# $1: line number which error detected
# $2: cleanup function (optional)
#
err()
{
echo test/$(basename $0): failed at line $1
[ -n "$2" ] && "$2"
exit $rc
}
reset()
{
$NDCTL disable-region -b $NFIT_TEST_BUS0 all
$NDCTL init-labels -f -b $NFIT_TEST_BUS0 all
$NDCTL enable-region -b $NFIT_TEST_BUS0 all
}
resetV()
{
$NDCTL disable-region -b $NFIT_TEST_BUS0 all
$NDCTL init-labels -f -V 1.2 -b $NFIT_TEST_BUS0 all
$NDCTL enable-region -b $NFIT_TEST_BUS0 all
}
reset1()
{
$NDCTL disable-region -b $NFIT_TEST_BUS1 all
$NDCTL init-labels -f -b $NFIT_TEST_BUS1 all
$NDCTL enable-region -b $NFIT_TEST_BUS1 all
}
# check_min_kver
# $1: Supported kernel version. format: X.Y
#
check_min_kver()
{
local ver="$1"
: "${KVER:=$(uname -r)}"
[ -n "$ver" ] || return 1
[[ "$ver" == "$(echo -e "$ver\n$KVER" | sort -V | head -1)" ]]
}
# do_skip
# $1: Skip message
#
do_skip()
{
echo kernel $(uname -r): $1
exit 77
}
# check_prereq
# $1: command to check
#
check_prereq()
{
if ! command -v "$1" >/dev/null; then
do_skip "missing $1, skipping..."
fi
}
# _cleanup
#
_cleanup()
{
$NDCTL disable-region -b $NFIT_TEST_BUS0 all
$NDCTL disable-region -b $NFIT_TEST_BUS1 all
modprobe -r nfit_test
}
_cxl_cleanup()
{
$NDCTL disable-region -b $CXL_TEST_BUS all
modprobe -r cxl_test
}
# json2var
# stdin: json
#
json2var()
{
sed -e "s/[{}\",]//g; s/\[//g; s/\]//g; s/:/=/g"
}
# check_dmesg
# $1: line number where this is called
check_dmesg()
{
# validate no WARN or lockdep report during the run
sleep 1
log=$(journalctl -r -k --since "-$((SECONDS+1))s")
grep -q "Call Trace" <<< $log && err $1
true
}
# CXL COMMON
CXL_TEST_QOS_CLASS=42
|