aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/assert-catgets.sh67
-rwxr-xr-xtests/c-lint.sh65
-rwxr-xr-xtests/dev-integration.sh19
-rw-r--r--[-rwxr-xr-x]tests/lib.sh4
4 files changed, 2 insertions, 153 deletions
diff --git a/tests/assert-catgets.sh b/tests/assert-catgets.sh
deleted file mode 100755
index 885e186..0000000
--- a/tests/assert-catgets.sh
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/bin/sh
-set -eu
-
-assert_sequential_ids() {
- awk '
- BEGIN {
- n = 0
- }
-
- /^#define MSG_/ {
- if (++n != $3) {
- print "Bad sequential ID:"
- printf "%s:%s:%s\n", FILENAME, NR, $0
- printf "expected: %s\ngot: %s\n", n, $3
- exit 1
- }
- }
- ' "$1"
-}
-
-assert_consistent_msg_definitions() {
- awk '
- BEGIN {
- i = 0
- j = 0
- }
-
- /^#define MSG_/ {
- defines[i++] = $2
- }
-
- /^\t\[MSG_/ {
- msgs[j++] = substr($0, 3, index($0, "]") - 3)
- }
-
- END {
- for (n in defines) {
- if (defines[n] != msgs[n]) {
- printf "Order mismatch between #define"
- printf " and usage in MSGS[]:\n"
- printf "#define: %s\nMSGS[]: %s\n",
- defines[n], msgs[n]
- exit 1
- }
- }
- }
- ' "$1"
-}
-
-assert_no_unused_msgs() {
- DEFINES="$(mktemp)"
- USAGES="$(mktemp)"
- awk '/^#define MSG_/ { print $2 }' "$f" | sort > "$DEFINES"
- awk -F'_\\(' '
- /_\(MSG_/ { print substr($2, 0, index($2, ")") - 1) }
- ' "$f" | sort | uniq > "$USAGES"
- if ! diff "$DEFINES" "$USAGES"; then
- echo 'Some defined MSG_ items not being used' >&2
- exit 1
- fi
-}
-
-for f in "$@"; do
- assert_sequential_ids "$f"
- assert_consistent_msg_definitions "$f"
- assert_no_unused_msgs "$f"
-done
diff --git a/tests/c-lint.sh b/tests/c-lint.sh
deleted file mode 100755
index 0fa0b01..0000000
--- a/tests/c-lint.sh
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/bin/sh
-set -eu
-
-awk '
-BEGIN {
- ret = 0
- msg = "function not on the start of the line:"
-}
-
-/^[a-zA-Z0-9_]+ .+\(/ {
- if (ret == 0) {
- print msg
- }
- printf "%s:%s:%s\n", FILENAME, FNR, $0
- ret = 1
-}
-
-END {
- exit ret
-}
-' "$@"
-
-
-awk '
-BEGIN {
- ret = 0
- static = 1
- msg = "non-static function is not declared in a header:"
-}
-
-/^[a-zA-Z0-9_]+\(.*$/ && static == 0 {
- split($0, line, /\(/)
- fn_name = line[1]
- if (fn_name != "main") {
- header = substr(FILENAME, 0, length(FILENAME) - 2) ".h"
- if (system("grep -q ^\"" fn_name "\" \"" header "\"")) {
- if (ret == 0) {
- print msg
- }
- printf "%s:%s:%s\n", FILENAME, FNR, $0
- ret = 1
- }
- }
-}
-
-/^static / {
- static = 1
-}
-
-!/^static / {
- static = 0
-}
-
-END {
- exit ret
-}
-' "$@"
-
-
-RE='[a-z]+\(\) {'
-if grep -Eq "$RE" "$@"; then
- echo 'Functions with no argument without explicit "void" parameter:' >&2
- grep -En "$RE" "$@"
- exit 1
-fi
diff --git a/tests/dev-integration.sh b/tests/dev-integration.sh
deleted file mode 100755
index c920a2d..0000000
--- a/tests/dev-integration.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-# shellcheck disable=2086
-set -eu
-
-. tests/lib.sh
-
-VALGRIND_FLAGS='
---show-error-list=yes
---show-leak-kinds=all
---leak-check=full
---track-origins=yes
---error-exitcode=1
-'
-
-valgrind $VALGRIND_FLAGS ./gistatic-tests
-valgrind $VALGRIND_FLAGS ./gistatic -o "$(mkdtemp)" \
- -u 'https://example.com' tests/resources/repositories/repo-1
-valgrind $VALGRIND_FLAGS ./gistatic -o "$(mkdtemp)" \
- -i tests/resources/repositories/*
diff --git a/tests/lib.sh b/tests/lib.sh
index 527e645..750cb68 100755..100644
--- a/tests/lib.sh
+++ b/tests/lib.sh
@@ -122,12 +122,12 @@ uuid() {
# Taken from:
# https://serverfault.com/a/799198
od -xN20 /dev/urandom |
- head -1 |
+ head -n1 |
awk '{OFS="-"; print $2$3,$4,$5,$6,$7$8$9}'
}
tmpname() {
- echo 'mkstemp(template)' | m4 -D template="${TMPDIR:-/tmp}/m4-tmpname."
+ echo "${TMPDIR:-/tmp}/uuid-tmpname with spaces.$(uuid)"
}
mkstemp() {