summaryrefslogtreecommitdiffstats
path: root/tests/ts/fadvise
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:10:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:10:49 +0000
commitcfe5e3905201349e9cf3f95d52ff4bd100bde37d (patch)
treed0baf160cbee3195249d095f85e52d20c21acf02 /tests/ts/fadvise
parentInitial commit. (diff)
downloadutil-linux-cfe5e3905201349e9cf3f95d52ff4bd100bde37d.tar.xz
util-linux-cfe5e3905201349e9cf3f95d52ff4bd100bde37d.zip
Adding upstream version 2.39.3.upstream/2.39.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ts/fadvise')
-rwxr-xr-xtests/ts/fadvise/drop67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/ts/fadvise/drop b/tests/ts/fadvise/drop
new file mode 100755
index 0000000..7c7eee5
--- /dev/null
+++ b/tests/ts/fadvise/drop
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="drop page caches related to a file"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_FADVISE"
+ts_check_test_command "$TS_CMD_FINCORE"
+ts_check_test_command "$TS_CMD_FINDMNT"
+
+ts_check_prog "dd"
+ts_check_prog "sleep"
+
+ts_cd "$TS_OUTDIR"
+
+FILE="ddtest"
+BS=4k
+COUNT=8
+
+FILE_FS="$("$TS_CMD_FINDMNT" -nr -o FSTYPE -T "$PWD")"
+if [[ "$FILE_FS" = "tmpfs" ]]; then
+ ts_skip "fincore does not work on tmpfs"
+fi
+
+create_file() {
+ dd if=/dev/zero of="$FILE" bs=$BS count=$COUNT conv=fsync >& /dev/null
+}
+
+{
+ create_file
+ "$TS_CMD_FINCORE" "$FILE"
+ echo
+
+ create_file
+ echo "whole file"
+ "$TS_CMD_FADVISE" "$FILE"
+ echo status: $?
+ "$TS_CMD_FINCORE" "$FILE"
+ echo
+
+ create_file
+ echo "offset: 8192"
+ "$TS_CMD_FADVISE" -o 8192 "$FILE"
+ echo status: $?
+ "$TS_CMD_FINCORE" "$FILE"
+ echo
+
+ create_file
+ echo "length: 16384"
+ "$TS_CMD_FADVISE" -l 16384 "$FILE"
+ echo status: $?
+ "$TS_CMD_FINCORE" "$FILE"
+ echo
+
+ create_file
+ echo "offset: 8192, length: 16384 fd: 42"
+ "$TS_CMD_FADVISE" -o 8192 -l 16384 --fd 42 42<"$FILE"
+ echo status: $?
+ "$TS_CMD_FINCORE" "$FILE"
+ echo
+
+ rm "$FILE"
+} >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
+
+ts_finalize