git: 9b8224b950fb - main - cp: Drop test helper
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 16 Sep 2025 13:38:30 UTC
The branch main has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=9b8224b950fb74c8674d257a5a4795baa759c35b
commit 9b8224b950fb74c8674d257a5a4795baa759c35b
Author: Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2025-09-16 13:38:03 +0000
Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2025-09-16 13:38:26 +0000
cp: Drop test helper
Now that stat(1) can report whether a file is sparse, we no longer need
a helper program for our tests.
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D52482
---
ObsoleteFiles.inc | 3 ++
bin/cp/tests/Makefile | 2 --
bin/cp/tests/cp_test.sh | 2 +-
bin/cp/tests/sparse.c | 73 -------------------------------------------------
4 files changed, 4 insertions(+), 76 deletions(-)
diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc
index 02a727d631bd..ae83035b5de5 100644
--- a/ObsoleteFiles.inc
+++ b/ObsoleteFiles.inc
@@ -51,6 +51,9 @@
# xargs -n1 | sort | uniq -d;
# done
+# 20250911: This tool is no longer needed
+OLD_FILES+=usr/tests/bin/cp/sparse
+
# 20250826: Remove a misspelled manual
OLD_FILES+=usr/share/man/man3/sysdecode_syscallnames.3.gz
diff --git a/bin/cp/tests/Makefile b/bin/cp/tests/Makefile
index 3fa9ae8f0685..a1917ada8fbf 100644
--- a/bin/cp/tests/Makefile
+++ b/bin/cp/tests/Makefile
@@ -1,7 +1,5 @@
PACKAGE= tests
ATF_TESTS_SH= cp_test
-PROGS+= sparse
-BINDIR= ${TESTSDIR}
.include <bsd.test.mk>
diff --git a/bin/cp/tests/cp_test.sh b/bin/cp/tests/cp_test.sh
index 999993bfad67..fdf50d042f0b 100755
--- a/bin/cp/tests/cp_test.sh
+++ b/bin/cp/tests/cp_test.sh
@@ -384,7 +384,7 @@ samefile_body()
file_is_sparse()
{
- atf_check ${0%/*}/sparse "$1"
+ atf_check -o match:"^[0-9]+-[0-9]" stat -h "$1"
}
files_are_equal()
diff --git a/bin/cp/tests/sparse.c b/bin/cp/tests/sparse.c
deleted file mode 100644
index 78957581a56c..000000000000
--- a/bin/cp/tests/sparse.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-
- * Copyright (c) 2023 Klara, Inc.
- *
- * SPDX-License-Identifier: BSD-2-Clause
- */
-
-#include <err.h>
-#include <fcntl.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sysexits.h>
-#include <unistd.h>
-
-static bool verbose;
-
-/*
- * Returns true if the file named by its argument is sparse, i.e. if
- * seeking to SEEK_HOLE returns a different value than seeking to
- * SEEK_END.
- */
-static bool
-sparse(const char *filename)
-{
- off_t hole, end;
- int fd;
-
- if ((fd = open(filename, O_RDONLY)) < 0 ||
- (hole = lseek(fd, 0, SEEK_HOLE)) < 0 ||
- (end = lseek(fd, 0, SEEK_END)) < 0)
- err(1, "%s", filename);
- close(fd);
- if (end > hole) {
- if (verbose)
- printf("%s: hole at %zu\n", filename, (size_t)hole);
- return (true);
- }
- return (false);
-}
-
-static void
-usage(void)
-{
-
- fprintf(stderr, "usage: sparse [-v] file [...]\n");
- exit(EX_USAGE);
-}
-
-int
-main(int argc, char *argv[])
-{
- int opt, rv;
-
- while ((opt = getopt(argc, argv, "v")) != -1) {
- switch (opt) {
- case 'v':
- verbose = true;
- break;
- default:
- usage();
- break;
- }
- }
- argc -= optind;
- argv += optind;
- if (argc == 0)
- usage();
- rv = EXIT_SUCCESS;
- while (argc-- > 0)
- if (!sparse(*argv++))
- rv = EXIT_FAILURE;
- exit(rv);
-}