Changeset View
Changeset View
Standalone View
Standalone View
bin/cp/tests/cp_test.sh
Show First 20 Lines • Show All 195 Lines • ▼ Show 20 Lines | atf_check test -d foo-mirror/foo/baz -a \ | ||||
'(' ! -L foo-mirror/foo/baz ')' | '(' ! -L foo-mirror/foo/baz ')' | ||||
atf_check cp -RL foo foo-mirror | atf_check cp -RL foo foo-mirror | ||||
atf_check test -d foo-mirror/foo/baz -a \ | atf_check test -d foo-mirror/foo/baz -a \ | ||||
'(' ! -L foo-mirror/foo/baz ')' | '(' ! -L foo-mirror/foo/baz ')' | ||||
} | } | ||||
file_is_sparse() | file_is_sparse() | ||||
{ | { | ||||
atf_check test "$(stat -f "%b" "$1")" != "$(stat -f "%z" "$1")" | atf_check ${0%/*}/sparse "$1" | ||||
markj: Hmm, I think this is a bit too simplistic. On ZFS I see:
```
markj@nuc> jot 4096 1 1 > 1… | |||||
Done Inline ActionsThat's a good point. I suppose I could write a hole detection tool in C. It's still better than the previous version (which would report every file as sparse). des: That's a good point. I suppose I could write a hole detection tool in C. It's still better than… | |||||
} | } | ||||
files_are_equal() | files_are_equal() | ||||
{ | { | ||||
atf_check test "$(stat -f "%d %i" "$1")" != "$(stat -f "%d %i" "$2")" | atf_check test "$(stat -f "%d %i" "$1")" != "$(stat -f "%d %i" "$2")" | ||||
atf_check cmp "$1" "$2" | atf_check cmp "$1" "$2" | ||||
} | } | ||||
atf_test_case sparse_leading_hole | atf_test_case sparse_leading_hole | ||||
sparse_leading_hole_body() | sparse_leading_hole_body() | ||||
{ | { | ||||
# A one-megabyte hole followed by one megabyte of data | # A 16-megabyte hole followed by one megabyte of data | ||||
truncate -s 1M foo | truncate -s 16M foo | ||||
seq -f%015g 65536 >>foo | seq -f%015g 65536 >>foo | ||||
file_is_sparse foo | file_is_sparse foo | ||||
atf_check cp foo bar | atf_check cp foo bar | ||||
files_are_equal foo bar | files_are_equal foo bar | ||||
file_is_sparse bar | file_is_sparse bar | ||||
} | } | ||||
atf_test_case sparse_multiple_holes | atf_test_case sparse_multiple_holes | ||||
sparse_multiple_holes_body() | sparse_multiple_holes_body() | ||||
{ | { | ||||
# Three one-megabyte blocks of data preceded, separated, and | # Three one-megabyte blocks of data preceded, separated, and | ||||
# followed by one-megabyte holes | # followed by 16-megabyte holes | ||||
truncate -s 1M foo | truncate -s 16M foo | ||||
seq -f%015g >>foo | seq -f%015g 65536 >>foo | ||||
truncate -s 3M foo | truncate -s 33M foo | ||||
seq -f%015g >>foo | seq -f%015g 65536 >>foo | ||||
truncate -s 5M foo | truncate -s 50M foo | ||||
seq -f%015g >>foo | seq -f%015g 65536 >>foo | ||||
truncate -s 7M foo | truncate -s 67M foo | ||||
file_is_sparse foo | file_is_sparse foo | ||||
atf_check cp foo bar | atf_check cp foo bar | ||||
files_are_equal foo bar | files_are_equal foo bar | ||||
file_is_sparse bar | file_is_sparse bar | ||||
} | } | ||||
atf_test_case sparse_only_hole | atf_test_case sparse_only_hole | ||||
sparse_only_hole_body() | sparse_only_hole_body() | ||||
{ | { | ||||
# A one-megabyte hole | # A 16-megabyte hole | ||||
truncate -s 1M foo | truncate -s 16M foo | ||||
file_is_sparse foo | file_is_sparse foo | ||||
atf_check cp foo bar | atf_check cp foo bar | ||||
files_are_equal foo bar | files_are_equal foo bar | ||||
file_is_sparse bar | file_is_sparse bar | ||||
} | } | ||||
atf_test_case sparse_to_dev | atf_test_case sparse_to_dev | ||||
sparse_to_dev_body() | sparse_to_dev_body() | ||||
{ | { | ||||
# Three one-megabyte blocks of data preceded, separated, and | # Three one-megabyte blocks of data preceded, separated, and | ||||
# followed by one-megabyte holes | # followed by 16-megabyte holes | ||||
truncate -s 1M foo | truncate -s 16M foo | ||||
seq -f%015g >>foo | seq -f%015g 65536 >>foo | ||||
truncate -s 3M foo | truncate -s 33M foo | ||||
seq -f%015g >>foo | seq -f%015g 65536 >>foo | ||||
truncate -s 5M foo | truncate -s 50M foo | ||||
seq -f%015g >>foo | seq -f%015g 65536 >>foo | ||||
truncate -s 7M foo | truncate -s 67M foo | ||||
file_is_sparse foo | file_is_sparse foo | ||||
atf_check -o file:foo cp foo /dev/stdout | atf_check -o file:foo cp foo /dev/stdout | ||||
} | } | ||||
atf_test_case sparse_trailing_hole | atf_test_case sparse_trailing_hole | ||||
sparse_trailing_hole_body() | sparse_trailing_hole_body() | ||||
{ | { | ||||
# One megabyte of data followed by a one-megabyte hole | # One megabyte of data followed by a 16-megabyte hole | ||||
seq -f%015g 65536 >foo | seq -f%015g 65536 >foo | ||||
truncate -s 2M foo | truncate -s 17M foo | ||||
file_is_sparse foo | file_is_sparse foo | ||||
atf_check cp foo bar | atf_check cp foo bar | ||||
files_are_equal foo bar | files_are_equal foo bar | ||||
file_is_sparse bar | file_is_sparse bar | ||||
} | } | ||||
atf_test_case standalone_Pflag | atf_test_case standalone_Pflag | ||||
Show All 28 Lines |
Hmm, I think this is a bit too simplistic. On ZFS I see:
Neither of these files is sparse obviously, and it looks like ZFS is reporting the size of the dnode as well as a compressed size.
I can't think of a way to check for holes from the shell.