summaryrefslogtreecommitdiffstats
path: root/tests/ts/fincore
diff options
context:
space:
mode:
authorMasatake YAMATO2017-03-07 03:33:51 +0100
committerKarel Zak2017-03-23 12:46:40 +0100
commitc1cc045d127364898b9cfd654213ea04ea2d479a (patch)
tree855c7a88799c8e9d7e73940430f02aa2ac9bda9a /tests/ts/fincore
parentman: add a page for fincore command (diff)
downloadkernel-qcow2-util-linux-c1cc045d127364898b9cfd654213ea04ea2d479a.tar.gz
kernel-qcow2-util-linux-c1cc045d127364898b9cfd654213ea04ea2d479a.tar.xz
kernel-qcow2-util-linux-c1cc045d127364898b9cfd654213ea04ea2d479a.zip
tests: add cases for testing fincore command
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Diffstat (limited to 'tests/ts/fincore')
-rwxr-xr-xtests/ts/fincore/count194
1 files changed, 194 insertions, 0 deletions
diff --git a/tests/ts/fincore/count b/tests/ts/fincore/count
new file mode 100755
index 000000000..4bb891211
--- /dev/null
+++ b/tests/ts/fincore/count
@@ -0,0 +1,194 @@
+#!/bin/bash
+
+function header
+{
+ echo "[" "$1" "]"
+}
+
+function footer
+{
+ echo "return value: $1"
+}
+
+function make_input_name
+{
+ header=$1
+ prefix=i_
+ echo ${prefix}$(sed -e "s/[^-+a-zA-Z0-9_]/_/g"<<<"$header")
+}
+
+function run_dd_test
+{
+ header=$1
+ bs=$2
+ flags=$3
+
+ input=$(make_input_name "$header")
+ INPUT="${INPUT} ${input}"
+
+ if [ "$bs" = 0 ]; then
+ touch $input
+ else
+ $DD if=/dev/zero of=$input count=1 bs=$bs $flags
+ fi
+
+ $TS_CMD_FINCORE $input
+
+ footer "$?"
+}
+
+function run_dd_dd_test
+{
+ header=$1
+ flags0=$2
+ flags1=$3
+
+ bs=$PAGE_SIZE
+
+ input=$(make_input_name "$header")
+ INPUT="${INPUT} ${input}"
+
+ $DD if=/dev/zero of=$input count=1 bs=$bs $flags0
+ $DD if=/dev/zero of=$input count=1 bs=$bs $flags1
+
+ $TS_CMD_FINCORE $input
+
+ footer "$?"
+}
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="count file contents in core"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+PAGE_SIZE=$($TS_HELPER_SYSINFO pagesize)
+WINDOW_SIZE=$(( 32 * 1024 * PAGE_SIZE ))
+
+DD_FLAGS="status=none"
+DD="dd $DD_FLAGS"
+
+
+ts_check_test_command "$TS_CMD_FINCORE"
+ts_cd "$TS_OUTDIR"
+
+INPUT=
+input=
+
+{
+ input=no_such_file
+ INPUT="${INPUT} ${input}"
+
+ header "NO EXCITING FILE"
+ $TS_CMD_FINCORE $input
+ footer "$?"
+} >> $TS_OUTPUT 2>&1
+
+{
+ run_dd_test "EMPTY FILE" 0
+} >> $TS_OUTPUT 2>&1
+
+{
+ run_dd_test "SMALLER THAN PAGESIZE (incore)" $(( PAGE_SIZE / 2 ))
+} >> $TS_OUTPUT 2>&1
+
+{
+ run_dd_test "PAGESIZE -1 (incore)" $(( PAGE_SIZE - 1 ))
+} >> $TS_OUTPUT 2>&1
+
+{
+ run_dd_test "JUST PAGESIZE(incore)" $(( PAGE_SIZE ))
+} >> $TS_OUTPUT 2>&1
+
+{
+ run_dd_test "JUST PAGESIZE(directio)" $(( PAGE_SIZE )) "oflag=direct"
+} >> $TS_OUTPUT 2>&1
+
+{
+ run_dd_test "PAGESIZE + 1 (incore)" $(( PAGE_SIZE + 1 ))
+} >> $TS_OUTPUT 2>&1
+
+{
+ run_dd_test "TWO PAGES(incore)" $(( 2 * PAGE_SIZE ))
+} >> $TS_OUTPUT 2>&1
+
+{
+ run_dd_test "TWO PAGES(directio)" $(( 2 * PAGE_SIZE )) "oflag=direct"
+} >> $TS_OUTPUT 2>&1
+
+{
+ run_dd_dd_test "TWO PAGES(mixed directio/incore)" \
+ oflag=direct \
+ "oflag=append seek=1"
+} >> $TS_OUTPUT 2>&1
+
+{
+ run_dd_dd_test "TWO PAGES(mixed incore/directio)" \
+ "" \
+ "oflag=direct,append seek=1"
+} >> $TS_OUTPUT 2>&1
+
+{
+ hole_count=$(( WINDOW_SIZE / PAGE_SIZE - 2 ))
+ run_dd_dd_test "WINDOW SIZE(incore-sparse-incore)" \
+ "" \
+ "oflag=append seek=$hole_count"
+} >> $TS_OUTPUT 2>&1
+
+{
+ hole_count=$(( WINDOW_SIZE / PAGE_SIZE - 2 ))
+ run_dd_dd_test "WINDOW SIZE(directio-sparse-directio)" \
+ "oflag=direct" \
+ "oflag=append,direct seek=$hole_count"
+} >> $TS_OUTPUT 2>&1
+
+{
+ hole_count=$(( WINDOW_SIZE / PAGE_SIZE - 2 ))
+ run_dd_dd_test "WINDOW SIZE(incore-sparse-directio)" \
+ "" \
+ "oflag=append,direct seek=$hole_count"
+} >> $TS_OUTPUT 2>&1
+
+{
+ hole_count=$(( WINDOW_SIZE / PAGE_SIZE - 2 ))
+ run_dd_dd_test "WINDOW SIZE(directio-sparse-incore)" \
+ "oflag=direct" \
+ "oflag=append seek=$hole_count"
+} >> $TS_OUTPUT 2>&1
+
+{
+ hole_count=$(( WINDOW_SIZE / PAGE_SIZE - 1 ))
+ run_dd_dd_test "WINDOW SIZE + 1 page(incore-sparse-incore)" \
+ "" \
+ "oflag=append seek=$hole_count"
+} >> $TS_OUTPUT 2>&1
+
+{
+ hole_count=$(( WINDOW_SIZE / PAGE_SIZE - 1 ))
+ run_dd_dd_test "WINDOW SIZE + 1 page(directio-sparse-directio)" \
+ "oflag=direct" \
+ "oflag=append,direct seek=$hole_count"
+} >> $TS_OUTPUT 2>&1
+
+{
+ hole_count=$(( WINDOW_SIZE / PAGE_SIZE - 1 ))
+ run_dd_dd_test "WINDOW SIZE + 1 page(incore-sparse-directio)" \
+ "" \
+ "oflag=append,direct seek=$hole_count"
+} >> $TS_OUTPUT 2>&1
+
+{
+ hole_count=$(( WINDOW_SIZE / PAGE_SIZE - 1 ))
+ run_dd_dd_test "WINDOW SIZE + 1 page(directio-sparse-incore)" \
+ "oflag=direct" \
+ "oflag=append seek=$hole_count"
+} >> $TS_OUTPUT 2>&1
+
+{
+ header "MULTIPLE FILES"
+ $TS_CMD_FINCORE $INPUT
+ footer "$?"
+} >> $TS_OUTPUT 2>&1
+
+rm -f $INPUT
+ts_finalize