Debian Codegraph @

tests/ts/fadvise/drop

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #!/bin/bash
2
3 TS_TOPDIR="${0%/*}/../.."
4 TS_DESC="drop page caches related to a file"
5
6 . "$TS_TOPDIR"/functions.sh
7 ts_init "$*"
8
9 ts_check_test_command "$TS_CMD_FADVISE"
10 ts_check_test_command "$TS_CMD_FINCORE"
11 ts_check_test_command "$TS_CMD_FINDMNT"
12
13 ts_check_prog "dd"
14 ts_check_prog "sleep"
15
16 ts_cd "$TS_OUTDIR"
17
18 FILE="ddtest"
19 BS=65536
20 COUNT=8
21
22 FS="$("$TS_CMD_FINDMNT" --noheadings --raw --output FSTYPE --target "$PWD")"
23 if [[ "$FS" = "tmpfs" || "$FS" = "overlay" || "$FS" = "" ]]; then
24 ts_skip "fincore does not work on tmpfs or unknown fs"
25 fi
26
27 create_file() {
28 dd if=/dev/zero of="$FILE" bs=$BS count=$COUNT conv=fsync >& /dev/null
29 }
30
31 do_fincore() {
32 "$TS_CMD_FINCORE" --output RES,SIZE,FILE "$FILE"
33 }
34
35 {
36 create_file
37 do_fincore
38 echo
39
40 create_file
41 echo "whole file"
42 "$TS_CMD_FADVISE" "$FILE"
43 echo status: $?
44 do_fincore
45 echo
46
47 create_file
48 echo "offset: $(( 2 * $BS ))"
49 "$TS_CMD_FADVISE" --offset $(( 2 * $BS )) "$FILE"
50 echo status: $?
51 do_fincore
52 echo
53
54 create_file
55 echo "length: $(( 4 * $BS ))"
56 "$TS_CMD_FADVISE" --length $(( 4 * $BS )) "$FILE"
57 echo status: $?
58 do_fincore
59 echo
60
61 create_file
62 echo "offset: $(( 2 * $BS )), length: $(( 4 * $BS )) fd: 42"
63 "$TS_CMD_FADVISE" --offset $(( 2 * $BS )) --length $(( 4 * $BS )) --fd 42 42<"$FILE"
64 echo status: $?
65 do_fincore
66 echo
67
68 rm "$FILE"
69 } >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
70
71 ts_finalize