aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/assert-catgets.sh0
-rw-r--r--tests/c-lint.sh0
-rwxr-xr-xtests/lib.sh29
3 files changed, 25 insertions, 4 deletions
diff --git a/tests/assert-catgets.sh b/tests/assert-catgets.sh
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/assert-catgets.sh
diff --git a/tests/c-lint.sh b/tests/c-lint.sh
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/c-lint.sh
diff --git a/tests/lib.sh b/tests/lib.sh
index 76f22e3..527e645 100755
--- a/tests/lib.sh
+++ b/tests/lib.sh
@@ -16,7 +16,9 @@ ERROR() {
}
print_debug_info() {
- printf 'LINENO: %s\nOUT: %s\n%s: %s\n' "$N" "$OUT" "$(ERROR)" "$ERR" >&2
+ # shellcheck disable=2016
+ printf 'LINENO: %s\n$OUT: %s\n$ERR: %s\n' \
+ "$N" "$OUT" "$ERR" >&2
}
assert_status() {
@@ -39,7 +41,9 @@ assert_usage() {
assert_empty_stream() {
if [ -s "$2" ]; then
- printf '\n%s: Expected %s (%s) to be empty, but has content:\n%s\n' \
+ FMT='\n%s: Expected %s (%s) to be empty, but has content:\n%s\n'
+ # shellcheck disable=2059
+ printf "$FMT" \
"$(ERROR)" "$1" "$2" "$(cat "$2")" >&2
print_debug_info
exit 1
@@ -117,7 +121,24 @@ test_ok() {
uuid() {
# Taken from:
# https://serverfault.com/a/799198
- od -xN20 /dev/urandom | \
- head -1 | \
+ od -xN20 /dev/urandom |
+ head -1 |
awk '{OFS="-"; print $2$3,$4,$5,$6,$7$8$9}'
}
+
+tmpname() {
+ echo 'mkstemp(template)' | m4 -D template="${TMPDIR:-/tmp}/m4-tmpname."
+}
+
+mkstemp() {
+ name="$(tmpname)"
+ touch "$name"
+ echo "$name"
+}
+
+mkdtemp() {
+ name="$(tmpname)"
+ rm -f "$name"
+ mkdir "$name"
+ echo "$name"
+}