1#!/bin/sh 2# Ensure that cp -a --link maintains timestamps if possible 3 4# Copyright (C) 2011-2023 Free Software Foundation, Inc. 5 6# This program is free software: you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation, either version 3 of the License, or 9# (at your option) any later version. 10 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15 16# You should have received a copy of the GNU General Public License 17# along with this program. If not, see <https://www.gnu.org/licenses/>. 18 19. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src 20print_ver_ cp 21 22# Check that the timestamps of the symlink are copied 23# if we're using hardlink to symlink emulation. 24touch file 25ln -s file link || framework_failure_ 26touch -m -h -d 2011-01-01 link || 27 skip_ "Your system doesn't support updating symlink timestamps" 28case $(stat --format=%y link) in 29 2011-01-01*) ;; 30 *) skip_ "Your system doesn't support updating symlink timestamps" ;; 31esac 32 33# link.cp is probably a hardlink, but may also be a symlink 34# In either case the timestamp should match the original. 35cp -al link link.cp || fail=1 36case $(stat --format=%y link.cp) in 37 2011-01-01*) ;; 38 *) fail=1 ;; 39esac 40 41Exit $fail 42