rm -f ${RESULT_DIR}/require_scratch
}
+# we need the scratch device and it needs to not be an lvm device
+_require_scratch_nolvm()
+{
+ _require_scratch_nocheck
+
+ # This works if we don't have LVM, all we want is to skip if the scratch
+ # device is an lvm device.
+ $LVM_PROG lvdisplay $SCRATCH_DEV > /dev/null 2>&1
+ [ $? -eq 0 ] && _notrun "test requires a non-lvm scratch device"
+}
+
# we need the scratch device and it should be checked post test.
_require_scratch()
{
rm -f $testfile 2>&1 > /dev/null
}
+# Format a swapfile and return its size in bytes
_format_swapfile() {
local fname="$1"
local sz="$2"
+ local swap_log=""
rm -f "$fname"
touch "$fname"
$CHATTR_PROG +C "$fname" > /dev/null 2>&1
_pwrite_byte 0x61 0 "$sz" "$fname" >> $seqres.full
# Ignore permission complaints on filesystems that don't support perms
- $MKSWAP_PROG "$fname" 2>&1 >> $seqres.full | \
- grep -v "insecure permission"
+ swap_log=$($MKSWAP_PROG "$fname" 2>&1 | grep -v "insecure permission")
+ echo $swap_log >> $seqres.full
+
+ echo $swap_log | grep -oP '\w+(?= bytes)'
}
_swapon_file() {
_scratch_mount
# Minimum size for mkswap is 10 pages
- _format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10))
+ _format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10)) > /dev/null
# ext* has supported all variants of swap files since their
# introduction, so swapon should not fail.
esac
}
+_has_kernel_config()
+{
+ local option=$1
+ local uname=$(uname -r)
+ local config_list="$KCONFIG_PATH
+ /proc/config.gz
+ /lib/modules/$uname/build/.config
+ /boot/config-$uname
+ /lib/kernel/config-$uname"
+
+ for config in $config_list; do
+ [ ! -f $config ] && continue
+ [ $config = "/proc/config.gz" ] && break
+ grep -qE "^${option}=[my]" $config
+ return
+ done
+
+ [ ! -f $config ] && _notrun "Could not locate kernel config file"
+
+ # We can only get here with /proc/config.gz
+ _require_command "$GZIP_PROG" gzip
+ $GZIP_PROG -cd $config | grep -qE "^${option}=[my]"
+}
+
+_require_kernel_config()
+{
+ _has_kernel_config $1 || _notrun "Installed kernel not built with $1"
+}
+
init_rc
################################################################################