~nabijaczleweli/voreutils

d3e7cdb461bb511033a7e03254d9549964d0dd3a — наб 21 days ago a48ab81
FreeBSD port
5 files changed, 18 insertions(+), 7 deletions(-)

M cmd/basename.cpp
M tests/dd/sweepsize.c
M tests/expr
M tests/tee
M tests/truncate
M cmd/basename.cpp => cmd/basename.cpp +2 -1
@@ 59,7 59,8 @@ int main(int argc, char * const * argv) {
				return std::fprintf(stderr, USAGE_BASENAME("basename")), 1;

			*single_path = *(argv + optind);
			suffix       = *(argv + optind + 1);
			if(*(argv + optind + 1))
				suffix = *(argv + optind + 1);
		}
	} else if(self == "dirname") {
		op = op_t::dirname;

M tests/dd/sweepsize.c => tests/dd/sweepsize.c +4 -1
@@ 13,7 13,10 @@

int main(int argc, char ** argv) {
	int todd[2];
	pipe2(todd, O_DIRECT | O_CLOEXEC);
	if(pipe2(todd, O_DIRECT | O_CLOEXEC) == -1) {
		write(2, "dd: sweepsize: O_DIRECT not available for pipes\n", 48);  // FreeBSD
		pipe2(todd, O_CLOEXEC);
	}
	switch(fork()) {
		case -1:
			abort();

M tests/expr => tests/expr +2 -2
@@ 4,8 4,8 @@
tmpdir="$(mktemp -dt "expr.XXXXXXXXXX")/"
expr="${CMDDIR}expr"
seq="${CMDDIR}seq"
localedef -i cs_CZ -c -f UTF-8 "${tmpdir}/cs_CZ.UTF-8" &
localedef -i en_GB -c -f UTF-8 "${tmpdir}/en_GB.UTF-8" &
localedef -i cs_CZ -c -f UTF-8 "${tmpdir}cs_CZ.UTF-8" &
localedef -i en_GB -c -f UTF-8 "${tmpdir}en_GB.UTF-8" &


[ "$(  "$expr" 2 + 2 \* 2)" = '6' ] || echo "expr: expr.1-1.1 wrong" >&3

M tests/tee => tests/tee +1 -1
@@ 3,7 3,7 @@

tmpdir="$(mktemp -dt "tee.XXXXXXXXXX")/"
tee="${CMDDIR}tee"
data="$(tr -cd '[:alpha:]' < /dev/urandom | dd bs=20w count=1 2>/dev/null)"
data="$({ tr -cd '[:alpha:]' < /dev/urandom 2>/dev/null || cat "$0"; } | dd bs=20w count=1 2>/dev/null)"  # FreeBSD tr explodes when presented with random data because it doesn't operate on bytes for some reason


[ "$(echo "$data" | "$tee")" = "$data" ] || echo "tee: no files wrong" >&3

M tests/truncate => tests/truncate +9 -2
@@ 4,7 4,15 @@
tmpdir="$(mktemp -dt "truncate.XXXXXXXXXX")/"
truncate="${CMDDIR}truncate"

stat -c"%i" /dev/null > /dev/null 2>&1 && { sc='-c'; ss='%s'; } || { sc='-f'; ss='%z'; }
if stat -c"%i" /dev/null > /dev/null 2>&1; then
	sc='-c'
	ss='%s'
	tmpdir_bs="$(stat -f "${sc}%S" "${tmpdir}")"
else
	sc='-f'
	ss='%z'
	tmpdir_bs="$(stat "${sc}%k" "${tmpdir}")"  # suboptimal, but FreeBSD stat doesn't have fsstat() fields
fi

"$truncate"  -s409600 "${tmpdir}null" >&3 2>&3
"$truncate"  -s409600 "${tmpdir}add"  >&3 2>&3


@@ 32,7 40,6 @@ stat -c"%i" /dev/null > /dev/null 2>&1 && { sc='-c'; ss='%s'; } || { sc='-f'; ss
[ "$(stat "${sc}$ss" "${tmpdir}set")"  = 39     ] || echo "truncate: set  wrong" >&3


tmpdir_bs="$(stat -f "${sc}%S" "${tmpdir}")"
"$truncate" -os2k  "${tmpdir}o2k"  >&3 2>&3
"$truncate" -os2kB "${tmpdir}o2kB" >&3 2>&3
[ "$(stat "${sc}$ss" "${tmpdir}o2k" )" = "$(( tmpdir_bs * 2048 ))" ] || echo "truncate: o2k  wrong" >&3