Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F103958781
D38290.id116097.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D38290.id116097.diff
View Options
diff --git a/bin/cp/tests/cp_test.sh b/bin/cp/tests/cp_test.sh
--- a/bin/cp/tests/cp_test.sh
+++ b/bin/cp/tests/cp_test.sh
@@ -209,6 +209,110 @@
atf_check -o inline:'Symbolic Link\n' stat -f %SHT baz
}
+file_is_sparse()
+{
+ atf_check test "$(stat -f "%b" "$1")" != "$(stat -f "%z" "$1")"
+}
+
+files_are_equal()
+{
+ atf_check test "$(stat -f "%d %i" "$1")" != "$(stat -f "%d %i" "$2")"
+ atf_check cmp "$1" "$2"
+}
+
+atf_test_case sparse_empty
+sparse_empty_body()
+{
+ # Empty file
+ touch foo
+ atf_check cp foo bar
+
+ files_are_equal foo bar
+}
+
+atf_test_case sparse_no_holes
+sparse_no_holes_body()
+{
+ # One megabyte of data
+ seq -f%015g 65536 >foo
+
+ atf_check cp foo bar
+ files_are_equal foo bar
+}
+
+atf_test_case sparse_only_hole
+sparse_only_hole_body()
+{
+ # A one-megabyte hole
+ truncate -s 1M foo
+
+ atf_check cp foo bar
+ files_are_equal foo bar
+ file_is_sparse bar
+}
+
+atf_test_case sparse_leading_hole
+sparse_leading_hole_body()
+{
+ # A one-megabyte hole followed by one megabyte of data
+ truncate -s 1M foo
+ seq -f%015g 65536 >>foo
+ file_is_sparse foo
+
+ atf_check cp foo bar
+ files_are_equal foo bar
+ file_is_sparse bar
+}
+
+atf_test_case sparse_trailing_hole
+sparse_trailing_hole_body()
+{
+ # One megabyte of data followed by a one-megabyte hole
+ seq -f%015g 65536 >foo
+ truncate -s 2M foo
+ file_is_sparse foo
+
+ atf_check cp foo bar
+ files_are_equal foo bar
+ file_is_sparse bar
+}
+
+atf_test_case sparse_multiple_holes
+sparse_multiple_holes_body()
+{
+ # Three one-megabyte blocks of data preceded, separated, and
+ # followed by one-megabyte holes
+ truncate -s 1M foo
+ seq -f%015g >>foo
+ truncate -s 3M foo
+ seq -f%015g >>foo
+ truncate -s 5M foo
+ seq -f%015g >>foo
+ truncate -s 7M foo
+ file_is_sparse foo
+
+ atf_check cp foo bar
+ files_are_equal foo bar
+ file_is_sparse bar
+}
+
+atf_test_case sparse_to_dev
+sparse_to_dev_body()
+{
+ # Three one-megabyte blocks of data preceded, separated, and
+ # followed by one-megabyte holes
+ truncate -s 1M foo
+ seq -f%015g >>foo
+ truncate -s 3M foo
+ seq -f%015g >>foo
+ truncate -s 5M foo
+ seq -f%015g >>foo
+ truncate -s 7M foo
+ file_is_sparse foo
+
+ atf_check -o file:foo cp foo /dev/stdout
+}
+
atf_init_test_cases()
{
atf_add_test_case basic
@@ -222,4 +326,11 @@
atf_add_test_case recursive_link_Hflag
atf_add_test_case recursive_link_Lflag
atf_add_test_case standalone_Pflag
+ atf_add_test_case sparse_empty
+ atf_add_test_case sparse_no_holes
+ atf_add_test_case sparse_only_hole
+ atf_add_test_case sparse_leading_hole
+ atf_add_test_case sparse_trailing_hole
+ atf_add_test_case sparse_multiple_holes
+ atf_add_test_case sparse_to_dev
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 2, 6:47 PM (15 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14986138
Default Alt Text
D38290.id116097.diff (2 KB)
Attached To
Mode
D38290: cp: Add tests involving sparse files.
Attached
Detach File
Event Timeline
Log In to Comment