Debian Codegraph @

tests/ts/fadvise/drop

raw ◀ ▶
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 if [[ -n "$GITLAB_CI" ]]; then
28 ts_skip "fadvise test does not work in Debians salsa CI"
29 fi
30
31 create_file() {
32 dd if=/dev/zero of="$FILE" bs=$BS count=$COUNT conv=fsync >& /dev/null
33 }
34
35 do_fincore() {
36 "$TS_CMD_FINCORE" --output RES,SIZE,FILE "$FILE"
37 }
38
39 {
40 create_file
41 do_fincore
42 echo
43
44 create_file
45 echo "whole file"
46 "$TS_CMD_FADVISE" "$FILE"
47 echo status: $?
48 do_fincore
49 echo
50
51 create_file
52 echo "offset: $(( 2 * $BS ))"
53 "$TS_CMD_FADVISE" --offset $(( 2 * $BS )) "$FILE"
54 echo status: $?
55 do_fincore
56 echo
57
58 create_file
59 echo "length: $(( 4 * $BS ))"
60 "$TS_CMD_FADVISE" --length $(( 4 * $BS )) "$FILE"
61 echo status: $?
62 do_fincore
63 echo
64
65 create_file
66 echo "offset: $(( 2 * $BS )), length: $(( 4 * $BS )) fd: 42"
67 "$TS_CMD_FADVISE" --offset $(( 2 * $BS )) --length $(( 4 * $BS )) --fd 42 42<"$FILE"
68 echo status: $?
69 do_fincore
70 echo
71
72 rm "$FILE"
73 } >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
74
75 ts_finalize