]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fadvise: (tests) add helper to create files
authorThomas Weißschuh <thomas@t-8ch.de>
Sun, 16 Apr 2023 08:16:33 +0000 (10:16 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Sun, 16 Apr 2023 08:17:11 +0000 (10:17 +0200)
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
tests/ts/fadvise/drop

index e8c0071915289feab61ef2e5d7b8b963533dd62f..142fbf028b39356f33b88fcb1e1734ef368c3ad5 100755 (executable)
@@ -18,33 +18,37 @@ FILE="ddtest"
 BS=4k
 COUNT=8
 
-{
+create_file() {
     dd if=/dev/zero of="$FILE" bs=$BS count=$COUNT >& /dev/null
+}
+
+{
+    create_file
     "$TS_CMD_FINCORE" "$FILE"
     echo
 
-    dd if=/dev/zero of="$FILE" bs=$BS count=$COUNT >& /dev/null
+    create_file
     echo "whole file"
     "$TS_CMD_FADVISE" "$FILE"
     echo status: $?
     "$TS_CMD_FINCORE" "$FILE"
     echo
 
-    dd if=/dev/zero of="$FILE" bs=$BS count=$COUNT >& /dev/null
+    create_file
     echo "offset: 8192"
     "$TS_CMD_FADVISE" -o 8192 "$FILE"
     echo status: $?
     "$TS_CMD_FINCORE" "$FILE"
     echo
 
-    dd if=/dev/zero of="$FILE" bs=$BS count=$COUNT >& /dev/null
+    create_file
     echo "length: 16384"
     "$TS_CMD_FADVISE" -l 16384 "$FILE"
     echo status: $?
     "$TS_CMD_FINCORE" "$FILE"
     echo
 
-    dd if=/dev/zero of="$FILE" bs=$BS count=$COUNT >& /dev/null
+    create_file
     echo "offset: 8192, length: 16384 fd: 42"
     "$TS_CMD_FADVISE" -o 8192 -l 16384 --fd 42 42<"$FILE"
     echo status: $?