1#- 2# SPDX-License-Identifier: BSD-2-Clause 3# 4# Copyright (c) 2025 The FreeBSD Foundation 5# 6# This software was developed by Klara, Inc. 7# under sponsorship from the FreeBSD Foundation. 8# 9# Redistribution and use in source and binary forms, with or without 10# modification, are permitted provided that the following conditions are 11# met: 12# 1. Redistributions of source code must retain the above copyright 13# notice, this list of conditions and the following disclaimer. 14# 2. Redistributions in binary form must reproduce the above copyright 15# notice, this list of conditions and the following disclaimer in 16# the documentation and/or other materials provided with the distribution. 17# 18# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28# SUCH DAMAGE. 29# 30 31MAKEFS="makefs -t msdos" 32MOUNT="mount_msdosfs" 33 34. "$(dirname "$0")/makefs_tests_common.sh" 35 36common_cleanup() 37{ 38 if ! test_md_device=$(cat $TEST_MD_DEVICE_FILE); then 39 echo "$TEST_MD_DEVICE_FILE could not be opened; has an md(4) device been attached?" 40 return 41 fi 42 43 umount -f /dev/$test_md_device || : 44 mdconfig -d -u $test_md_device || : 45} 46 47atf_test_case T_flag_dir cleanup 48T_flag_dir_body() 49{ 50 timestamp=1742574908 # Even value, timestamp precision is 2s. 51 52 create_test_dirs 53 mkdir -p $TEST_INPUTS_DIR/dir1 54 atf_check -o not-empty \ 55 $MAKEFS -T $timestamp -s 1m $TEST_IMAGE $TEST_INPUTS_DIR 56 57 mount_image 58 eval $(stat -s $TEST_MOUNT_DIR/dir1) 59 # FAT directory entries don't have an access time, just a date. 60 #atf_check_equal $st_atime $timestamp 61 atf_check_equal $st_mtime $timestamp 62 atf_check_equal $st_ctime $timestamp 63} 64 65T_flag_dir_cleanup() 66{ 67 common_cleanup 68} 69 70atf_test_case T_flag_F_flag cleanup 71T_flag_F_flag_body() 72{ 73 timestamp_F=1742574908 # Even value, timestamp precision is 2s. 74 timestamp_T=1742574910 75 create_test_dirs 76 mkdir -p $TEST_INPUTS_DIR/dir1 77 78 atf_check -o save:$TEST_SPEC_FILE $MTREE -c -p $TEST_INPUTS_DIR 79 change_mtree_timestamp $TEST_SPEC_FILE $timestamp_F 80 atf_check -o not-empty \ 81 $MAKEFS -F $TEST_SPEC_FILE -T $timestamp_T -s 1m $TEST_IMAGE $TEST_INPUTS_DIR 82 83 mount_image 84 eval $(stat -s $TEST_MOUNT_DIR/dir1) 85 # FAT directory entries don't have an access time, just a date. 86 #atf_check_equal $st_atime $timestamp 87 atf_check_equal $st_mtime $timestamp_F 88 atf_check_equal $st_ctime $timestamp_F 89} 90 91T_flag_F_flag_cleanup() 92{ 93 common_cleanup 94} 95 96atf_test_case T_flag_mtree cleanup 97T_flag_mtree_body() 98{ 99 timestamp=1742574908 # Even value, timestamp precision is 2s. 100 101 create_test_dirs 102 mkdir -p $TEST_INPUTS_DIR/dir1 103 atf_check -o save:$TEST_SPEC_FILE $MTREE -c -p $TEST_INPUTS_DIR 104 atf_check -o not-empty \ 105 $MAKEFS -T $timestamp -s 1m $TEST_IMAGE $TEST_SPEC_FILE 106 107 mount_image 108 eval $(stat -s $TEST_MOUNT_DIR/dir1) 109 # FAT directory entries don't have an access time, just a date. 110 #atf_check_equal $st_atime $timestamp 111 atf_check_equal $st_mtime $timestamp 112 atf_check_equal $st_ctime $timestamp 113} 114 115T_flag_mtree_cleanup() 116{ 117 common_cleanup 118} 119 120atf_init_test_cases() 121{ 122 atf_add_test_case T_flag_dir 123 atf_add_test_case T_flag_F_flag 124 atf_add_test_case T_flag_mtree 125} 126