1 | # | |
---|
2 | # o---------------------------------------------------------------------o |
---|
3 | # | |
---|
4 | # | MAD makefile - numdiff tester settings |
---|
5 | # | |
---|
6 | # o---------------------------------------------------------------------o |
---|
7 | # | |
---|
8 | # | Methodical Accelerator Design |
---|
9 | # | |
---|
10 | # | Copyright (c) 2011+ CERN, mad@cern.ch |
---|
11 | # | |
---|
12 | # | For more information, see http://cern.ch/mad |
---|
13 | # | |
---|
14 | # o---------------------------------------------------------------------o |
---|
15 | # | |
---|
16 | # | $Id$ |
---|
17 | # | |
---|
18 | |
---|
19 | # |
---|
20 | # numdiff paths |
---|
21 | # |
---|
22 | ifndef NDIFF |
---|
23 | NDIFFCMD := $(firstword $(wildcard \ |
---|
24 | $(ND)_dev$(ARCH)$(BINARY_EXT) $(ND)_dev$(BINARY_EXT) \ |
---|
25 | $(ND)-dev$(ARCH)$(BINARY_EXT) $(ND)-dev$(BINARY_EXT) \ |
---|
26 | $(ND)$(ARCH)$(BINARY_EXT) $(ND)$(BINARY_EXT) )) |
---|
27 | NDIFF_R := $(if $(NDIFFCMD),..$/..$/$(NDIFFCMD),$(ND)$(BINARY_EXT)) |
---|
28 | NDIFF_I := $(if $(NDIFFCMD),.$/$(NDIFFCMD),$(ND)$(BINARY_EXT)) |
---|
29 | else |
---|
30 | NDIFF_R := $(NDIFF) |
---|
31 | NDIFF_I := $(NDIFF) |
---|
32 | endif |
---|
33 | |
---|
34 | # |
---|
35 | # numdiff summary |
---|
36 | # |
---|
37 | NDSUM = tests-summary.txt |
---|
38 | |
---|
39 | # |
---|
40 | # numdiff flags |
---|
41 | # quiet, ingore blanks, check constraints, list mode, serie mode, debug mode, test title |
---|
42 | NDFLAGS = -q -b -c -l -n $(if $(call eq,$(NDDEBUG),yes),-debug,) \ |
---|
43 | $(if $(call eq,$(NDTRACE),yes),-trace,) -a ..$/$(NDSUM) -t $@ |
---|
44 | |
---|
45 | # |
---|
46 | # init-test macro |
---|
47 | # |
---|
48 | define init-test |
---|
49 | $_ $(RM) tests$/$(NDSUM) \ |
---|
50 | $(if $(call eq,$(OSTYPE),Windows),2> _err.txt && $(RM) _err.txt,) && \ |
---|
51 | $(call ND_tr,$(NDIFF_I) -q -a tests$/$(NDSUM)) |
---|
52 | endef |
---|
53 | |
---|
54 | # |
---|
55 | # fini-test macro |
---|
56 | # |
---|
57 | define fini-test |
---|
58 | $_ $(CAT) tests$/$(NDSUM) |
---|
59 | endef |
---|
60 | |
---|
61 | # |
---|
62 | # run-test macro |
---|
63 | # |
---|
64 | # $@ = test name & directory |
---|
65 | NDFILES = $(basename $(NDFILES_REF)) |
---|
66 | NDFILES_OUT = $(addsuffix .out,$(NDFILES)) $(NDFILES) |
---|
67 | NDFILES_REF = $(wildcard tests/$@/$@.ref) \ |
---|
68 | $(filter-out tests/$@/$@.ref, $(sort $(wildcard tests/$@/*.ref))) |
---|
69 | |
---|
70 | # Remarks line-by-line |
---|
71 | # check for .ref files unless NREF=yes |
---|
72 | # check for testsuite name ; go to test directory |
---|
73 | # delete generated files + cleanup output on Windows (case file not found) |
---|
74 | # run the test command (generate outputs) |
---|
75 | # for each reference file, diff with the generated file + constraints |
---|
76 | define run-test |
---|
77 | $(if $(call eq,$(NREF),yes),,$(call exists,$(NDFILES_REF),invalid test $@ -- no reference file found)) |
---|
78 | -$_ $(if $(TESTSUITE),echo [ $(TESTSUITE) ] &&,) cd tests$/$@ && \ |
---|
79 | $(RM) $(notdir $(NDFILES_OUT)) \ |
---|
80 | $(if $(call eq,$(OSTYPE),Windows),2> _err.txt && $(RM) _err.txt,) && \ |
---|
81 | $(TESTCMD) > $@.out && \ |
---|
82 | $(call ND_tr,$(NDIFF_R) $(NDFLAGS)) $(notdir $(NDFILES)) || \ |
---|
83 | echo "error: $@ failed, check tests$/$@$/$@.out for details" |
---|
84 | endef |
---|
85 | |
---|
86 | # end of makefile |
---|