~sircmpwn/ctools

16cab053e27d4a7046c005b5becae9b0564d8211 — Christopher Vittal 1 year, 29 days ago 0e9f63c
Make test scripts POSIX compliant

"." with argument is not POSIX compliant, so it must be removed.
Instead, set tool directly in the test scripts.
M test/basename => test/basename +2 -1
@@ 1,5 1,6 @@
#!/bin/sh
. "$HARNESS" basename
tool="basename"
. "$HARNESS"

should_handle_null_string() (
	bn="$(basename '')"

M test/cat => test/cat +2 -1
@@ 1,5 1,6 @@
#!/bin/sh
. "$HARNESS" cat
tool="cat"
. "$HARNESS"

echo "this is a test file" >"$TMPDIR"/test-file-1
echo "this is another test file" >"$TMPDIR"/test-file-2

M test/chgrp => test/chgrp +2 -1
@@ 1,5 1,6 @@
#!/bin/sh
. "$HARNESS" chgrp
tool="chgrp"
. "$HARNESS"

auxgroup=${AUXGROUP:-}
maingroup="$(id -gn)"

M test/chmod => test/chmod +2 -1
@@ 1,5 1,6 @@
#!/bin/sh
. "$HARNESS" chmod
tool="chmod"
. "$HARNESS"

# TODO:
# - setuid/setguid/sticky

M test/chown => test/chown +2 -1
@@ 1,5 1,6 @@
#!/bin/sh
. "$HARNESS" chown
tool="chown"
. "$HARNESS"

auxgroup=${AUXGROUP:-}
mainuser=$(id -un)

M test/cksum => test/cksum +2 -1
@@ 1,5 1,6 @@
#!/bin/sh
. "$HARNESS" cksum
tool="cksum"
. "$HARNESS"

should_handle_empty_stdin() (
	[ "$(cksum </dev/null)" = "4294967295 0" ]

M test/cmp => test/cmp +2 -1
@@ 1,5 1,6 @@
#!/bin/sh
. "$HARNESS" cmp
tool="cmp"
. "$HARNESS"

should_handle_samefile() (
	[ "$(cmp "$HARNESS" "$HARNESS")" = "" ]

M test/comm => test/comm +2 -1
@@ 1,5 1,6 @@
#!/bin/sh
. "$HARNESS" comm
tool="comm"
. "$HARNESS"

compare_with_ref() (
	ref=$(cat "$TMPDIR"/"$1")

M test/dirname => test/dirname +2 -1
@@ 1,5 1,6 @@
#!/bin/sh
. "$HARNESS" dirname
tool="dirname"
. "$HARNESS"

should_handle_null_string() (
	dn="$(dirname '')"

M test/false => test/false +2 -1
@@ 1,5 1,6 @@
#!/bin/sh
. "$HARNESS" false
tool="false"
. "$HARNESS"

should_return_nonzero() {
	! false

M test/harness.sh => test/harness.sh +0 -1
@@ 1,5 1,4 @@
set -eu
tool="$1"

export PATH="$BUILDDIR/..:$PATH"
TMPDIR=${TMPDIR:-/tmp}

M test/head => test/head +2 -1
@@ 1,5 1,6 @@
#!/bin/sh
. "$HARNESS" head
tool="head"
. "$HARNESS"

should_read_from_stdin() (
	[ "$(echo Test Statement | head)" = "Test Statement" ]

M test/link => test/link +2 -1
@@ 1,5 1,6 @@
#!/bin/sh
. "$HARNESS" link
tool="link"
. "$HARNESS"

should_make_link() {
	echo "hello world" >"$TMPDIR"/foo

M test/logname => test/logname +2 -1
@@ 1,5 1,6 @@
#!/bin/sh
. "$HARNESS" logname
tool="logname"
. "$HARNESS"

should_give_logname() {
	# These are not necessarily the same, but are usually so

M test/nice => test/nice +2 -1
@@ 1,5 1,6 @@
#!/bin/sh
. "$HARNESS" cmp
tool="cmp"
. "$HARNESS"

should_set_niceness() {
	if [ "$(uname)" != "Linux" ]

M test/rmdir => test/rmdir +2 -1
@@ 1,5 1,6 @@
#!/bin/sh
. "$HARNESS" link
tool="rmdir"
. "$HARNESS"

should_remove_dirs() {
	mkdir foo bar

M test/true => test/true +2 -1
@@ 1,5 1,6 @@
#!/bin/sh
. "$HARNESS" false
tool="true"
. "$HARNESS"

should_return_zero() {
	true

M test/tty => test/tty +2 -1
@@ 1,5 1,6 @@
#!/bin/sh
. "$HARNESS" cmp
tool="tty"
. "$HARNESS"

should_print_tty() {
	if [ "$(uname)" != "Linux" ]

M test/uname => test/uname +2 -1
@@ 1,5 1,6 @@
#!/bin/sh
. "$HARNESS" cmp
tool="uname"
. "$HARNESS"

sysname() {
	cat /proc/sys/kernel/ostype

M test/unlink => test/unlink +2 -1
@@ 1,5 1,6 @@
#!/bin/sh
. "$HARNESS" unlink
tool="unlink"
. "$HARNESS"

should_remove_link() {
	touch "$TMPDIR"/file