Add tests for the -T flag to each makefs backend. This includes tests
 for both mtree and directory scan options.
PR:             285630
Sponsored by:   Klara, Inc.
Sponsored by:   The FreeBSD Foundation
 Differential  D49492  
makefs: Add tests for the -T flag Authored by markj on Mar 25 2025, 1:57 PM. Tags None Referenced Files 
 
 
 
 
 
 
 
 
Details 
 Add tests for the -T flag to each makefs backend. This includes tests PR:             285630 
Diff Detail 
 Event Timeline
 Comment Actions I've reworked this diff and added tests for all backends, including msdos which didn't have any tests previously. Comment Actions There's one additional thing I'd like to point out here - the msdos backend does not pass these tests ATM, it's atime is completely different while mtime and ctime get set to timestamp - 1. I'll look into this separately. Comment Actions These are all good (at catching the current failures). 
 This guarantees (or not) documentation on the behavior regarding the priorities when the SOURCE_DATE_EPOCH environment variable is introduced later on (D49602). # This helper function can live in makefs_tests_common.sh
change_mtree_timestamp()
{
	filename="$1"
	timestamp="$2"
	sed -i "" "s/time=.*$/time=${timestamp}/g" "$filename"
}
...
atf_test_case T_flag_mtree cleanup
T_flag_mtree_body()
{
	timestamp_m=1742574909
	timestamp_T=1742574910
	create_test_dirs
	mkdir -p $TEST_INPUTS_DIR/dir1
	atf_check -e empty -o save:$TEST_SPEC_FILE -s exit:0 \
	    mtree -c -k "type,time" -p $TEST_INPUTS_DIR
	change_mtree_timestamp $TEST_SPEC_FILE $timestamp_m
	atf_check -e empty -o not-empty -s exit:0 \
	    $MAKEFS -M 1m $TEST_IMAGE $TEST_SPEC_FILE
	mount_image
	eval $(stat -s  $TEST_MOUNT_DIR/dir1)
	atf_check_equal $st_atime $timestamp_m
	atf_check_equal $st_mtime $timestamp_m
	atf_check_equal $st_ctime $timestamp_m
	common_cleanup
	atf_check -e empty -o not-empty -s exit:0 \
	    $MAKEFS -M 1m -T $timestamp_T $TEST_IMAGE $TEST_SPEC_FILE
	mount_image
	eval $(stat -s  $TEST_MOUNT_DIR/dir1)
	atf_check_equal $st_atime $timestamp_T
	atf_check_equal $st_mtime $timestamp_T
	atf_check_equal $st_ctime $timestamp_T
}
...I'm just trying to be very cautious about documenting (testing) this functionality. Comment Actions Address @jlduran 's comments - add testcases that test the interaction between -F and -T Comment Actions Thank you for pointing this out and for sketching out the testcase! 
 I've added testcases that test the interactions between -F and -T. Comment Actions Great! For a moment I thought this feature would be removed. There is another thing, but can be tested later: I am using -F just like you use it here in the tests, however, the documentation (on FreeBSD, not on NetBSD) has a very intimidating message: "This is almost certainly not the option you are looking for", so yet another combination should be tested: makefs with and without -T, and an mtree file (with a time=) as the last argument (similar to the original example). As said, it can be added later. Thank you! Comment Actions It's great to get tests added for things that are currently failing (already broken), but please tag it with atf_expect_fail Comment Actions 
 
  | ||||||||||||||||||||||||||||||||||||||||||