Commit f454da70f50862cbcb8d79f4ae795be26cdd9437

Authored by Jürgen Knödlseder
1 parent 3ca62cd8

Avoid using of sh builtin echo command.

On Mac OS X, the /bin/sh shell has a builtin echo command that does not recognize the -n option for linefeed supression. To keep the test script portable, the script now uses the echo command installed on the machine (usually in /bin/echo). The which function is used to make sure that the echo command is correctly located.
test/test_cscripts.sh.in
... ... @@ -20,12 +20,17 @@
20 20 # ==========================================================================
21 21  
22 22 #
  23 +# Get echo command (to circumvent built-in echo on some systems)
  24 +#
  25 +ECHO=`which echo`
  26 +
  27 +#
23 28 # Print Header
24 29 #
25   -echo ""
26   -echo "*****************"
27   -echo "* Test cscripts *"
28   -echo "*****************"
  30 +$ECHO ""
  31 +$ECHO "*****************"
  32 +$ECHO "* Test cscripts *"
  33 +$ECHO "*****************"
29 34  
30 35  
31 36 #
... ... @@ -44,7 +49,7 @@ export PFILES=pfiles
44 49 #
45 50 # Test cspull
46 51 # ===========
47   -echo -n "Test cspull: "
  52 +$ECHO -n "Test cspull: "
48 53 chmod +x @abs_top_srcdir@/scripts/cspull.py
49 54 @abs_top_srcdir@/scripts/cspull.py \
50 55 srcmdl="data/crab.xml" \
... ... @@ -62,15 +67,15 @@ chmod +x @abs_top_srcdir@/scripts/cspull.py
62 67 rad=5.0 \
63 68 npix=200 \
64 69 binsz=0.05 > cspull.log
65   -echo -n "."
  70 +$ECHO -n "."
66 71 if [ -s "pull.dat" ]
67 72 then
68   - echo -n "."
  73 + $ECHO -n "."
69 74 else
70   - echo " pull.dat file is not valid"
  75 + $ECHO " pull.dat file is not valid"
71 76 exit 1
72 77 fi
73   -echo " ok"
  78 +$ECHO " ok"
74 79  
75 80  
76 81 #
... ... @@ -100,7 +105,7 @@ echo " ok"
100 105 #
101 106 # Test cstsdist
102 107 # =============
103   -echo -n "Test cstsdist: "
  108 +$ECHO -n "Test cstsdist: "
104 109 chmod +x @abs_top_srcdir@/scripts/cstsdist.py
105 110 @abs_top_srcdir@/scripts/cstsdist.py \
106 111 outfile="ts.dat" \
... ... @@ -117,12 +122,12 @@ chmod +x @abs_top_srcdir@/scripts/cstsdist.py
117 122 rad=5.0 \
118 123 npix=200 \
119 124 binsz=0.05 > cstsdist.log
120   -echo -n "."
  125 +$ECHO -n "."
121 126 if [ -s "ts.dat" ]
122 127 then
123   - echo -n "."
  128 + $ECHO -n "."
124 129 else
125   - echo " ts.dat file is not valid"
  130 + $ECHO " ts.dat file is not valid"
126 131 exit 1
127 132 fi
128   -echo " ok"
  133 +$ECHO " ok"
... ...
test/test_ctools.sh
... ... @@ -2,7 +2,7 @@
2 2 # ==========================================================================
3 3 # This script tests all ctools
4 4 #
5   -# Copyright (C) 2011-2012 Jurgen Knodlseder
  5 +# Copyright (C) 2011-2012 Juergen Knoedlseder
6 6 #
7 7 # This program is free software: you can redistribute it and/or modify
8 8 # it under the terms of the GNU General Public License as published by
... ... @@ -20,11 +20,16 @@
20 20 # ==========================================================================
21 21  
22 22 #
  23 +# Get echo command (to circumvent built-in echo on some systems)
  24 +#
  25 +ECHO=`which echo`
  26 +
  27 +#
23 28 # Print Header
24 29 #
25   -echo "***************"
26   -echo "* Test ctools *"
27   -echo "***************"
  30 +$ECHO "***************"
  31 +$ECHO "* Test ctools *"
  32 +$ECHO "***************"
28 33  
29 34 #
30 35 # Define executables
... ... @@ -54,7 +59,7 @@ export PFILES=pfiles
54 59 #
55 60 # Test ctobssim
56 61 # =============
57   -echo -n "Test ctobssim: "
  62 +$ECHO -n "Test ctobssim: "
58 63 $ctobssim infile="data/crab.xml" \
59 64 outfile="events.fits" \
60 65 caldb="irf" \
... ... @@ -66,21 +71,21 @@ $ctobssim infile="data/crab.xml" \
66 71 tmax=1800.0 \
67 72 emin=0.1 \
68 73 emax=100.0
69   -echo -n "."
  74 +$ECHO -n "."
70 75 if [ -s "events.fits" ]
71 76 then
72   - echo -n "."
  77 + $ECHO -n "."
73 78 else
74 79 echo " events.fits file is not valid"
75 80 exit 1
76 81 fi
77   -echo " ok"
  82 +$ECHO " ok"
78 83  
79 84  
80 85 #
81 86 # Test ctskymap
82 87 # =============
83   -echo -n "Test ctskymap: "
  88 +$ECHO -n "Test ctskymap: "
84 89 $ctskymap evfile="events.fits" \
85 90 outfile="skymap.fits" \
86 91 emin=0.1 \
... ... @@ -92,21 +97,21 @@ $ctskymap evfile="events.fits" \
92 97 xref=83.63 \
93 98 yref=22.01 \
94 99 proj="CAR"
95   -echo -n "."
  100 +$ECHO -n "."
96 101 if [ -s "skymap.fits" ]
97 102 then
98   - echo -n "."
  103 + $ECHO -n "."
99 104 else
100   - echo " skymap.fits file is not valid"
  105 + $ECHO " skymap.fits file is not valid"
101 106 exit 1
102 107 fi
103   -echo " ok"
  108 +$ECHO " ok"
104 109  
105 110  
106 111 #
107 112 # Test ctbin
108 113 # ==========
109   -echo -n "Test ctbin: "
  114 +$ECHO -n "Test ctbin: "
110 115 $ctbin evfile="events.fits" \
111 116 outfile="cntmap.fits" \
112 117 emin=0.1 \
... ... @@ -119,21 +124,21 @@ $ctbin evfile="events.fits" \
119 124 xref=83.63 \
120 125 yref=22.01 \
121 126 proj="CAR"
122   -echo -n "."
  127 +$ECHO -n "."
123 128 if [ -s "cntmap.fits" ]
124 129 then
125   - echo -n "."
  130 + $ECHO -n "."
126 131 else
127   - echo " cntmap.fits file is not valid"
  132 + $ECHO " cntmap.fits file is not valid"
128 133 exit 1
129 134 fi
130   -echo " ok"
  135 +$ECHO " ok"
131 136  
132 137  
133 138 #
134 139 # Test ctselect
135 140 # =============
136   -echo -n "Test ctselect: "
  141 +$ECHO -n "Test ctselect: "
137 142 $ctselect infile="events.fits" \
138 143 outfile="selected_events.fits" \
139 144 ra=83.63 \
... ... @@ -143,32 +148,32 @@ $ctselect infile="events.fits" \
143 148 tmax=1800.0 \
144 149 emin=0.1 \
145 150 emax=100.0
146   -echo -n "."
  151 +$ECHO -n "."
147 152 if [ -s "selected_events.fits" ]
148 153 then
149   - echo -n "."
  154 + $ECHO -n "."
150 155 else
151   - echo " selected_events.fits file is not valid"
  156 + $ECHO " selected_events.fits file is not valid"
152 157 exit 1
153 158 fi
154   -echo " ok"
  159 +$ECHO " ok"
155 160  
156 161  
157 162 #
158 163 # Test ctlike
159 164 # ===========
160   -echo -n "Test ctlike: "
  165 +$ECHO -n "Test ctlike: "
161 166 $ctlike infile="cntmap.fits" \
162 167 srcmdl="data/crab.xml" \
163 168 outmdl="results_binned.xml" \
164 169 caldb="irf" \
165 170 irf="kb_E_50h_v3"
166   -echo -n "."
  171 +$ECHO -n "."
167 172 if [ -s "results_binned.xml" ]
168 173 then
169   - echo -n "."
  174 + $ECHO -n "."
170 175 else
171   - echo " results_binned.xml file is not valid"
  176 + $ECHO " results_binned.xml file is not valid"
172 177 exit 1
173 178 fi
174 179 $ctlike infile="selected_events.fits" \
... ... @@ -176,12 +181,12 @@ $ctlike infile="selected_events.fits" \
176 181 outmdl="results_unbinned.xml" \
177 182 caldb="irf" \
178 183 irf="kb_E_50h_v3"
179   -echo -n "."
  184 +$ECHO -n "."
180 185 if [ -s "results_unbinned.xml" ]
181 186 then
182   - echo -n "."
  187 + $ECHO -n "."
183 188 else
184   - echo " results_unbinned.xml file is not valid"
  189 + $ECHO " results_unbinned.xml file is not valid"
185 190 exit 1
186 191 fi
187   -echo " ok"
  192 +$ECHO " ok"
... ...