# Last edited on 2008-01-14 23:41:41 by stolfi

PROG := fni_hist

PROGDIR := ..

include ${STOLFIHOME}/programs/c/GENERIC-PROGS-TEST.make

# NAME:CHANNEL:STEP:VMIN:VMAX

TESTS := \
  test-6:0:0.005:NONE:NONE

ALL_TESTS := \
  test-1:0:0.100:NONE:NONE \
  test-1:1:0.100:NONE:NONE \
  test-1:2:0.100:NONE:NONE \
  \
  test-3:0:0.250:NONE:NONE \
  test-3:1:0.250:NONE:NONE \
  test-3:1:0.250:-20.0:+3.7 \
  \
  test-4:0:0.250:NONE:NONE \
  test-5:0:0.250:NONE:NONE \
  test-6:0:0.005:NONE:NONE

.PHONY:: \
  runalltests runtest

# all:
all: runalltests

# ====================================================================
# Cleanup

clean::
	-/bin/rm -f *.sys *.fgi

# ====================================================================
# Running tests

runalltests: 
	for t in ${TESTS} ; do \
          ${MAKE} TESTARGS=$$t runtest ; \
        done

TESTARGS := TESTARGS.IS.UNDEFINED
ifneq "/${TESTARGS}" "/TESTARGS.IS.UNDEFINED"
#######################################################################
# Recursive "make" to run the test ${TESTARGS}

TESTFIELDS  := ${subst  :, ,${TESTARGS}}
NAME    := ${word 1,${TESTFIELDS}}
CHANNEL := ${word 2,${TESTFIELDS}}
STEP    := ${word 3,${TESTFIELDS}}
VMIN    := ${word 4,${TESTFIELDS}}
VMAX    := ${word 5,${TESTFIELDS}}

ifneq "/${VMIN}" "/NONE"
  RANGE_OPT := -range ${VMIN} ${VMAX}
else
  RANGE_OPT := 
endif

IN_FNI := ${NAME}.fni
OUT_EPS := ${NAME}-${CHANNEL}.eps

runtest: ${PROGDIR}/${PROG} ${IN_FNI}
	${PROGDIR}/${PROG} \
            -channel ${CHANNEL} \
            -step ${STEP} ${RANGE_OPT} \
            -title "${NAME}:${CHANNEL}" \
          < ${IN_FNI} \
          > ${OUT_EPS}
	ghostview ${OUT_EPS}

# 
# End make ${TESTARGS}
######################################################################
endif
