diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/assert-clean.sh | 40 | ||||
-rwxr-xr-x | tests/assert-deps.sh | 10 | ||||
-rwxr-xr-x | tests/assert-install.sh | 28 | ||||
-rwxr-xr-x | tests/assert-uninstall.sh | 29 | ||||
-rwxr-xr-x | tests/c-lint.sh | 65 | ||||
-rw-r--r-- | tests/slurp.c | 69 | ||||
-rw-r--r-- | tests/slurp.h | 11 | ||||
-rw-r--r-- | tests/tests-lib.c | 28 | ||||
-rw-r--r-- | tests/tests-lib.h | 15 |
9 files changed, 0 insertions, 295 deletions
diff --git a/tests/assert-clean.sh b/tests/assert-clean.sh deleted file mode 100755 index 540cea6..0000000 --- a/tests/assert-clean.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -set -eu - -if [ ! -e .git ]; then - echo "Not in a Git repository, skipping \"$0\"" >&2 - exit -fi - - -. tools/lib.sh - -R="$(mkdtemp)" -trap 'rm -rf "$R"' EXIT - -cp -pR ./ "$R" -cd "$R" - - -{ - make -s clean - - printf '%s: "clean" target deletes all derived assets...' \ - "$(yellow "$0")" - - if [ -n "$(git status -s)" ]; then - printf ' ERR.\n' - echo 'Repository left dirty:' - git status - exit 1 - fi - - if [ -n "$(git clean -nffdx)" ]; then - printf ' ERR.\n' - echo 'Untracked files left:' - git clean -ffdx --dry-run - exit 1 - fi - - printf ' %s\n' "$(green 'OK')" -} >&2 diff --git a/tests/assert-deps.sh b/tests/assert-deps.sh deleted file mode 100755 index b73933d..0000000 --- a/tests/assert-deps.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -set -eu - -. tools/lib.sh - -{ - printf '%s: all deps.mk is up-to-date...' "$(yellow "$0")" - sh mkdeps.sh | diff -U10 deps.mk - - printf ' %s\n' "$(green 'OK')" -} >&2 diff --git a/tests/assert-install.sh b/tests/assert-install.sh deleted file mode 100755 index fd1e037..0000000 --- a/tests/assert-install.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -set -eu - -. tools/lib.sh - -D="$(mkdtemp)" -R="$(mkdtemp)" -trap 'rm -rf "$D" "$R"' EXIT - -cp -pR ./ "$R" -cd "$R" - - -{ - PATH="$D/usr/bin:$PATH" - NODE_PATH="$D/usr/lib/node:$NODE_PATH" - make -s DESTDIR="$D" install - - printf '%s: that the papo(3js) library is installed correctly...' \ - "$(yellow "$0")" - node -e 'require("papo");' - printf ' %s\n' "$(green 'OK')" - - printf '%s: that the papo(1) command is installed correctly...' \ - "$(yellow "$0")" - papo -V | grep -q '^papo ' - printf ' %s\n' "$(green 'OK')" -} >&2 diff --git a/tests/assert-uninstall.sh b/tests/assert-uninstall.sh deleted file mode 100755 index 247d723..0000000 --- a/tests/assert-uninstall.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -set -eu - -. tools/lib.sh - -D="$(mkdtemp)" -R="$(mkdtemp)" -trap 'rm -rf "$D" "$R"' EXIT - -cp -pR ./ "$R" -cd "$R" - - -{ - make -s DESTDIR="$D" install - make -s DESTDIR="$D" uninstall - printf '%s: that the "uninstall" target removes everything...' \ - "$(yellow "$0")" - if [ "$(find "$D" -not -type d | wc -l)" != 0 ]; then - printf ' ERR.\n' - cat <<-EOF - Leftover files not removed by "make uninstall": - - $(find "$D" -not -type d) - EOF - exit 1 - fi - printf ' %s\n' "$(green 'OK')" -} >&2 diff --git a/tests/c-lint.sh b/tests/c-lint.sh deleted file mode 100755 index 37822f3..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" && fn_name != "LLVMFuzzerTestOneInput") { - 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/slurp.c b/tests/slurp.c deleted file mode 100644 index 683a126..0000000 --- a/tests/slurp.c +++ /dev/null @@ -1,69 +0,0 @@ -#include "slurp.h" - -#include <stdio.h> -#include <stdlib.h> - -int -slurp_for_tests(const char *const FNAME, char **strref) { - int rc = 0; - - FILE *file = NULL; - char *str = NULL; - - file = fopen(FNAME, "r"); - if (!file) { - perror("fopen(FNAME, \"r\")"); - rc = -1; - goto out; - } - - if (fseek(file, 0L, SEEK_END)) { - perror("fseek(file, 0L, SEEK_END)"); - rc = -1; - goto out; - } - - const long lsize = ftell(file); - if (lsize == -1) { - perror("ftell(file)"); - rc = -1; - goto out; - } - const size_t size = (size_t)lsize + sizeof(char); - - if (fseek(file, 0L, SEEK_SET)) { - perror("fseek(file, 0L, SEEK_SET)"); - rc = -1; - goto out; - } - - str = malloc(size); - if (!str) { - perror("malloc(...)"); - rc = -1; - goto out; - } - - if (fread(str, sizeof(char), size - 1, file) != size - 1) { - perror("fread(...)"); - rc = -1; - goto out; - } - str[size - 1] = '\0'; - *strref = str; - -out: - if (file) { - if (fclose(file)) { - perror("flcose(file"); - rc = -1; - } - } - - if (rc) { - if (str) { - free(str); - } - } - return rc; -} diff --git a/tests/slurp.h b/tests/slurp.h deleted file mode 100644 index 056c77d..0000000 --- a/tests/slurp.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef SLURP_H -#define SLURP_H - -#include "../src/config.h" - - -int -slurp_for_tests(const char *const FNAME, char **strref); - - -#endif diff --git a/tests/tests-lib.c b/tests/tests-lib.c deleted file mode 100644 index e46fb2d..0000000 --- a/tests/tests-lib.c +++ /dev/null @@ -1,28 +0,0 @@ -#include "tests-lib.h" -#include <stdio.h> -#include <assert.h> - -#define COLOUR_RESET "\033[0m" -#define COLOUR_GREEN "\033[0;32m" -#define COLOUR_YELLOW "\033[0;33m" - -void -test_start(const char *const name) { - assert(fprintf(stdout, "%s:\n", name) > 0); -} - -void -testing(const char *const message) { - assert( - fprintf( - stdout, - COLOUR_YELLOW "testing" COLOUR_RESET ": %s...", - message - ) > 0 - ); -} - -void -test_ok(void) { - assert(fprintf(stdout, " " COLOUR_GREEN "OK" COLOUR_RESET ".\n") > 0); -} diff --git a/tests/tests-lib.h b/tests/tests-lib.h deleted file mode 100644 index a1e67ba..0000000 --- a/tests/tests-lib.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef TESTS_LIB_H -#define TESTS_LIB_H - -#include "../src/config.h" - -void -test_start(const char *const name); - -void -testing(const char *const message); - -void -test_ok(void); - -#endif |