History log of /freebsd/bin/cp/tests/cp_test.sh (Results 1 – 14 of 14)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 0729d1e8 09-Apr-2024 Dag-Erling Smørgrav <des@FreeBSD.org>

cp: Never follow symbolic links in destination.

Historically, BSD cp has followed symbolic links in the destination
when copying recursively, while GNU cp has not. POSIX is somewhat
vague on the to

cp: Never follow symbolic links in destination.

Historically, BSD cp has followed symbolic links in the destination
when copying recursively, while GNU cp has not. POSIX is somewhat
vague on the topic, but both interpretations are within bounds. In
33ad990ce974, cp was changed to apply the same logic for symbolic
links in the destination as for symbolic links in the source: follow
if not recursing (which is moot, as this situation can only arise
while recursing) or if the `-L` option was given. There is no support
for this in POSIX. We can either switch back, or go all the way.

Having carefully weighed the kind of trouble you can run into by
following unexpected symlinks up against the kind of trouble you can
run into by not following symlinks you expected to follow, we choose
to go all the way.

Note that this means we need to stat the destination twice: once,
following links, to check if it is or references the same file as the
source, and a second time, not following links, to set the dne flag
and determine the destination's type.

While here, remove a needless complication in the dne logic. We don't
need to explicitly reject overwriting a directory with a non-directory,
because it will fail anyway.

Finally, add test cases for copying a directory to a symlink and
overwriting a directory with a non-directory.

MFC after: never
Relnotes: yes
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D44578

show more ...


Revision tags: release/13.3.0
# ac56b9d8 14-Dec-2023 Dag-Erling Smørgrav <des@FreeBSD.org>

cp: Split the basic_symlink test case in two.

This test case tests two different things: first, that copying a symlink
results in a file with the same contents as the target of the symlink,
rather t

cp: Split the basic_symlink test case in two.

This test case tests two different things: first, that copying a symlink
results in a file with the same contents as the target of the symlink,
rather than a second symlink, and second, that cp will refuse to copy a
file to itself, or to a link to itself, or a link to its target. Leave
the first part in basic_symlink, move the second part to a new test case
named samefile, and slightly expand both cases.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D43062

show more ...


# d3a8e9b4 14-Dec-2023 Dag-Erling Smørgrav <des@FreeBSD.org>

cp: Add tests for symbolic link case.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans, allanjude
Differential Revision: https://reviews.freebsd.org/D43054


# 1fead66b 13-Dec-2023 Dag-Erling Smørgrav <des@FreeBSD.org>

cp: Add tests for hard link case.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D43052


Revision tags: release/14.0.0
# d0b2dbfa 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line sh pattern

Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix

show more ...


Revision tags: release/13.2.0
# 8b418c83 08-Feb-2023 Dag-Erling Smørgrav <des@FreeBSD.org>

cp: Adjust the sparse file tests.

* The sparsity check was ineffective: it compared the apparent size in bytes to the actual size in blocks. Instead, write a tool that reliably detects sparseness.

cp: Adjust the sparse file tests.

* The sparsity check was ineffective: it compared the apparent size in bytes to the actual size in blocks. Instead, write a tool that reliably detects sparseness.
* Some of the seq commands were missing an argument.
* Based on empirical evidence, 1 MB holes are not necessarily large enough to be preserved by the underlying filesystem. Increase the hole size to 16 MB.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: cracauer
Differential Revision: https://reviews.freebsd.org/D38414

show more ...


# 822fa7ae 01-Feb-2023 Dag-Erling Smørgrav <des@FreeBSD.org>

cp: Add tests involving sparse files.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D38290


Revision tags: release/12.4.0, release/13.1.0
# f00f8b4f 06-Apr-2022 Kyle Evans <kevans@FreeBSD.org>

cp: fix -R recursion detection

The correct logic is a lot simpler than the previous iteration. We
record the base fts_name to avoid having to worry about whether we
needed the root symlink name or

cp: fix -R recursion detection

The correct logic is a lot simpler than the previous iteration. We
record the base fts_name to avoid having to worry about whether we
needed the root symlink name or not (as applicable), then we can simply
shift all of that logic to after path translation to make it less
fragile.

If we're copying to DNE, then we'll have swapped out the NULL root_stat
pointer and then attempted to recurse on it. The previously nonexistent
directory shouldn't exist at all in the new structure, so just back out
from that tree entirely and move on.

The tests have been amended to indicate our expectations better with
subdirectory recursion. If we copy A to A/B, then we expect to copy
everything from A/B/* into A/B/A/B, with exception to the A that we
create in A/B.

Reviewed by: bapt
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D34655

show more ...


# 97e13037 23-Feb-2022 Cameron Katri <me@cameronkatri.com>

cp: Make -P work without -R as per POSIX

According to POSIX, cp should allow the `-P` flag to work whether `-R`
is specified or not. Currently, the `-P` option only works along with
`-R`.

PR: 199

cp: Make -P work without -R as per POSIX

According to POSIX, cp should allow the `-P` flag to work whether `-R`
is specified or not. Currently, the `-P` option only works along with
`-R`.

PR: 199466
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D30012

show more ...


# 33ad990c 27-Jan-2022 Kyle Evans <kevans@FreeBSD.org>

cp: fix -R with links

The traversal was previously not properly honoring -H/-L/-P. Notably,
we should not have been resolving symlinks encountered during traversal
when either -H or -P are specifie

cp: fix -R with links

The traversal was previously not properly honoring -H/-L/-P. Notably,
we should not have been resolving symlinks encountered during traversal
when either -H or -P are specified.

Sponsored by: Klara, Inc.
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D34063

show more ...


# 848263aa 27-Jan-2022 Kyle Evans <kevans@FreeBSD.org>

cp: fix some cases with infinite recursion

As noted in the PR, cp -R has some surprising behavior. Typically, when
you `cp -R foo bar` where both foo and bar exist, foo is cleanly copied
to foo/bar

cp: fix some cases with infinite recursion

As noted in the PR, cp -R has some surprising behavior. Typically, when
you `cp -R foo bar` where both foo and bar exist, foo is cleanly copied
to foo/bar. When you `cp -R foo foo` (where foo clearly exists), cp(1)
goes a little off the rails as it creates foo/foo, then discovers that
and creates foo/foo/foo, so on and so forth, until it eventually fails.

POSIX doesn't seem to disallow this behavior, but it isn't very useful.
GNU cp(1) will detect the recursion and squash it, but emit a message in
the process that it has done so.

This change seemingly follows the GNU behavior, but it currently doesn't
warn about the situation -- the author feels that the final product is
about what one might expect from doing this and thus, doesn't need a
warning. The author doesn't feel strongly about this.

PR: 235438
Reviewed by: bapt
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D33944

show more ...


Revision tags: release/12.3.0, release/13.0.0, release/12.2.0
# 5779bba9 23-Sep-2020 Kyle Evans <kevans@FreeBSD.org>

cp: tests: fix weird 20 insertion

This slipped in at the last moment. =(


# 5028ea32 23-Sep-2020 Kyle Evans <kevans@FreeBSD.org>

cp: add some basic tests

There are some tests available in the NetBSD test suite, but we don't
currently pass all of those; further investigation will go into that. For
now, just add a basic test as

cp: add some basic tests

There are some tests available in the NetBSD test suite, but we don't
currently pass all of those; further investigation will go into that. For
now, just add a basic test as well as a test that copies from /dev/null to a
file.

The /dev/null test confirms that the file gets created if it's empty, then
that it truncates the file if it's non-empty. This matches some usage that
was previously employed in the build and was replaced in r366042 by a
simpler shell construct.

I will also plan on coming back to expand these in due time.

MFC after: 1 week

show more ...