PR27725, better objcopy -p times

Nanosecond rather than second resolution.

	PR 27725
	* configure.ac: Check for sys/time.h and utimensat.  Use standard
	checks for mkstemp and mkdtemp.  Whitespace.  Check for nanosecond
	members of struct stat.
	* rename.c: Prefer sys/time.h for utimes over utime.h for utime.
	(STAT_TIMESPEC, STAT_TIMESPEC_NS): Define
	(get_stat_atime_ns, get_stat_mtime_ns): New inline functions.
	(get_stat_atime, get_stat_mtime): Likewise.
	(set_times): Choose first available of utimensat, utimes, utime.
	Use above inline functions to set timespec and timeval values.
	* configure: Regenerate.
	* config.in: Regenerate.
	* testsuite/binutils-all/objcopy.exp (objcopy_test): Add test of
	file timestamp when --preserve-dates is used.
This commit is contained in:
Alan Modra
2021-04-15 00:36:42 +09:30
parent d0ecdcddc3
commit 985e026451
6 changed files with 348 additions and 50 deletions

View File

@@ -77,6 +77,7 @@ proc objcopy_test {testname srcfile type asflags ldflags} {
return
}
set xflags "--preserve-dates"
sleep 1
}
set got [binutils_run $OBJCOPY "$OBJCOPYFLAGS $xflags $t_tempfile $t_copyfile"]
@@ -102,6 +103,17 @@ proc objcopy_test {testname srcfile type asflags ldflags} {
if [string equal "" $exec_output] then {
pass "objcopy $type ($testname)"
if { $type == "executable" } {
set dir [file dirname $t_copyfile]
set f2 [file tail $t_copyfile]
set status [remote_exec host find "$dir -name $f2 -newer $t_tempfile -print"]
set exec_output [lindex $status 1]
if [string equal "" $exec_output] then {
pass "objcopy $type ($testname) timestamp"
} else {
fail "objcopy $type ($testname) timestamp"
}
}
} else {
send_log "$exec_output\n"
verbose "$exec_output" 1