default: diag

TEST = meshtool
TODELETE = $(TEST).export jobid mesh_in mesh_out

include ../Makefile.inc

mesh_in:
	@cp $(ASTER_ROOT)/$(ASTER_VERSION)/astest/forma01a.mmed $@

jobid: $(TEST).export mesh_in
	$(as_run) --serv $< > output.1.$@ 2> error.1.$@
	@head -1 output.1.$@ | sed -e 's/^JOBID=//g' -e 's/ QUEUE.*//g' > jobid

mesh_out: jobid
	@echo 'ETAT=RUN' > output.2.$@
	while [ `grep -c 'ETAT=ENDED DIAG=' output.2.$@` -ne 1 ]; do \
	   $(as_run) --actu `cat jobid` unittest_meshtool_mesh interactif > output.2.$@ 2> error.2.$@; \
	   sleep 1; \
	done
	@if [ `grep -c -E 'DIAG=OK|DIAG.*ALARM' output.2.$@` -ne 1 ]; then \
	   echo 'DIAG != OK / ALARM'; \
	   echo "EXIT_CODE=304" > $@; \
   fi

unittest: mesh_out
	@if [ `grep -c FINSF mesh_out` -lt 1 ]; then \
	   echo "EXIT_CODE=104" > exit_code.tmp; \
	else \
	   echo "EXIT_CODE=0" > exit_code.tmp; \
	fi
	@mv -f exit_code.tmp $@

jobclean = oui

