mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-24 17:44:17 +01:00
tmpfs: Improve file time tests.
* The empty test case no longer fails because89f1dcb3eb
causes empty files to bypass the bug. * The bug still exists, so add a test case which exercises it. * While here, tighten up some of the checks. A similar patch has been submitted upstream. PR: 274615 X-MFC-With:89f1dcb3eb
Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D44609
This commit is contained in:
parent
4848eb3af2
commit
8311bc5f17
@ -36,10 +36,6 @@ empty_head() {
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
empty_body() {
|
||||
# Begin FreeBSD
|
||||
atf_expect_fail "Incorrect atime on FreeBSD: PR274615"
|
||||
# End FreeBSD
|
||||
|
||||
test_mount
|
||||
|
||||
atf_check -s eq:0 -o empty -e empty touch a
|
||||
@ -48,6 +44,42 @@ empty_body() {
|
||||
[ ${ost_birthtime} -eq ${ost_ctime} ] || atf_fail "Incorrect ctime"
|
||||
[ ${ost_birthtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
|
||||
|
||||
sleep 1
|
||||
atf_check -s eq:0 -o empty -e empty cat a
|
||||
eval $(stat -s a) || atf_fail "stat failed"
|
||||
[ ${st_atime} -gt ${ost_atime} ] || atf_fail "Incorrect atime"
|
||||
[ ${st_ctime} -eq ${ost_ctime} ] || atf_fail "Incorrect ctime"
|
||||
[ ${st_mtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
|
||||
|
||||
sleep 1
|
||||
ost_atime=${st_atime}
|
||||
echo foo >a || atf_fail "Write failed"
|
||||
eval $(stat -s a) || atf_fail "stat failed"
|
||||
[ ${st_atime} -gt ${ost_atime} ] || atf_fail "Incorrect atime"
|
||||
[ ${st_ctime} -gt ${ost_ctime} ] || atf_fail "Incorrect ctime"
|
||||
[ ${st_mtime} -gt ${ost_mtime} ] || atf_fail "Incorrect mtime"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
atf_test_case holey
|
||||
holey_head() {
|
||||
atf_set "descr" "Tests that creating a file consisting entirely" \
|
||||
"of a hole and later" \
|
||||
"manipulating it updates times correctly"
|
||||
atf_set "require.user" "root"
|
||||
}
|
||||
holey_body() {
|
||||
atf_expect_fail "https://bugs.freebsd.org/274615"
|
||||
|
||||
test_mount
|
||||
|
||||
atf_check -s eq:0 -o empty -e empty truncate -s 8k a
|
||||
eval $(stat -s a | sed -e 's|st_|ost_|g') || atf_fail "stat failed"
|
||||
[ ${ost_birthtime} -eq ${ost_atime} ] || atf_fail "Incorrect atime"
|
||||
[ ${ost_birthtime} -eq ${ost_ctime} ] || atf_fail "Incorrect ctime"
|
||||
[ ${ost_birthtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
|
||||
|
||||
sleep 1
|
||||
atf_check -s eq:0 -o ignore -e empty cat a
|
||||
eval $(stat -s a) || atf_fail "stat failed"
|
||||
@ -55,13 +87,6 @@ empty_body() {
|
||||
[ ${st_ctime} -eq ${ost_ctime} ] || atf_fail "Incorrect ctime"
|
||||
[ ${st_mtime} -eq ${ost_mtime} ] || atf_fail "Incorrect mtime"
|
||||
|
||||
sleep 1
|
||||
echo foo >a || atf_fail "Write failed"
|
||||
eval $(stat -s a) || atf_fail "stat failed"
|
||||
[ ${st_atime} -gt ${ost_atime} ] || atf_fail "Incorrect atime"
|
||||
[ ${st_ctime} -gt ${ost_ctime} ] || atf_fail "Incorrect ctime"
|
||||
[ ${st_mtime} -gt ${ost_mtime} ] || atf_fail "Incorrect mtime"
|
||||
|
||||
test_unmount
|
||||
}
|
||||
|
||||
@ -78,7 +103,7 @@ non_empty_body() {
|
||||
eval $(stat -s b | sed -e 's|st_|ost_|g') || atf_fail "stat failed"
|
||||
|
||||
sleep 1
|
||||
atf_check -s eq:0 -o ignore -e empty cat b
|
||||
atf_check -s eq:0 -o inline:"foo\n" -e empty cat b
|
||||
eval $(stat -s b) || atf_fail "stat failed"
|
||||
[ ${st_atime} -gt ${ost_atime} ] || atf_fail "Incorrect atime"
|
||||
[ ${st_ctime} -eq ${ost_ctime} ] || atf_fail "Incorrect ctime"
|
||||
@ -139,6 +164,7 @@ atf_init_test_cases() {
|
||||
. $(atf_get_srcdir)/h_funcs.subr
|
||||
|
||||
atf_add_test_case empty
|
||||
atf_add_test_case holey
|
||||
atf_add_test_case non_empty
|
||||
atf_add_test_case link
|
||||
atf_add_test_case rename
|
||||
|
Loading…
Reference in New Issue
Block a user