view mk/testprog-defs.sh @ 8:ec2b657edf13

Add explicit lint-comment-style fallthrough annotations. GCC now assumes that if you don't have these you're making a mistake, which is annoying. XXX: This changeset updates the AG output files only (by hand) and is XXX: abusive - rebuilding them will erase the change. However, I need XXX: to get things to build before I can try to get AG to issue the XXX: annotations itself, so this seems like a reasonable expedient.
author David A. Holland
date Mon, 30 May 2022 23:51:43 -0400
parents 13d2b8934445
children
line wrap: on
line source

#!/bin/sh
# testprog-defs.sh - generate make rules for testprog.mk
# usage: testprog-defs.sh "tests" "diffonly-tests" > rules.mk

if [ $# != 2 ]; then
    echo "$0: usage: $0 'tests' 'diffonly-tests'" 1>&2
    exit 1
fi

TESTS="$1"
DIFFONLY="$2"

(
    for T in $TESTS; do
	echo 1 "$T"
    done
    for T in $DIFFONLY; do
	echo 0 "$T";
    done
) | awk '
    {
	dorun=$1;
	file=$2;
	if (file ~ "/") {
	    srcdir = file;
	    sub("^.*/", "", file);
	    sub("/[^/]*$", "", srcdir);
	    srcdir = "$(TOP)/" srcdir;
	}
	else {
	    srcdir = "$(SRCDIR)"
	}
	base=file;
	sub("\\.[a-z][0-9]*$", "", base);
	out = base ".out";
	err = base ".err";
	diff = base ".diff";

	printf "run-tests: %s\n", diff;
	printf "%s: $(SRCDIR)/good/%s %s\n", diff, out, out;
	printf "%s: $(SRCDIR)/good/%s %s\n", diff, err, err;
	printf "\t@echo \"        [DIFF]    %s\"\n", file;
	printf "\t@diff -uN $(SRCDIR)/good/%s %s > $@ || true\n", out, out;
	printf "\t@diff -uN $(SRCDIR)/good/%s %s >> $@ || true\n", err, err;
	printf "\n";

	if (dorun) {
	    printf "%s %s: $(SRCDIR)/%s $(RUNPROG)\n", out, err, file;
	    printf "\t@echo \"        [TEST]    %s\"\n", file;
	    printf "\t@($(CROSSRUN) $(RUNPROG) %s/%s;", srcdir, file;
	    printf " echo Exit $$? 1>&2) \\\n"
	    printf "\t > %s 2> %s; \\\n", out, err;
	    printf "\n";
	}
    }
'