]>
git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/truncate/truncate_timestamps.ksh
3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 # You may only use this file in accordance with the terms of version
8 # A full copy of the text of the CDDL should have accompanied this
9 # source. A copy of the CDDL is also available via the Internet at
10 # http://www.illumos.org/license/CDDL.
14 # Copyright 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
17 .
$STF_SUITE/tests
/functional
/truncate
/truncate.cfg
18 .
$STF_SUITE/include
/libtest.shlib
19 .
$STF_SUITE/include
/math.shlib
23 # Ensure both truncate(2)/ftruncate(2) update target file mtime/ctime attributes
27 # 2. Truncate the file
28 # 3. Verify both mtime/ctime are updated
29 # 4. Rinse and repeat for both truncate(2) and ftruncate(2) with various sizes
32 verify_runnable
"both"
34 function verify_truncate
# <filename> <filesize> <option>
40 log_must mkfile
$sizeavg $filename # always start with $sizeavg
41 typeset
-i timestm
="$(stat -c %Y $filename)"
42 typeset
-i timestc
="$(stat -c %Z $filename)"
44 log_must
$STF_SUITE/tests
/functional
/truncate
/truncate_test
-s $size $filename $option
45 verify_eq
$size "$(stat -c %s $filename)" "size"
46 verify_ne
$timestm "$(stat -c %Y $filename)" "mtime"
47 verify_ne
$timestc "$(stat -c %Z $filename)" "ctime"
48 log_must
rm -f $filename
53 [[ -f $truncfile ]] && rm -f $truncfile
56 log_assert
"Ensure both truncate(2)/ftruncate(2) update target file timestamps"
59 truncfile
="$TESTDIR/truncate.$$"
61 sizeavg
="$((256*1024))"
62 sizemax
="$((1024*1024))"
65 verify_truncate
$truncfile $sizemin ""
66 verify_truncate
$truncfile $sizeavg ""
67 verify_truncate
$truncfile $sizemax ""
70 verify_truncate
$truncfile $sizemin "-f"
71 verify_truncate
$truncfile $sizeavg "-f"
72 verify_truncate
$truncfile $sizemax "-f"
74 log_pass
"Successful truncation correctly update timestamps"