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,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 # Print Header 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,7 +49,7 @@ export PFILES=pfiles
44 # 49 #
45 # Test cspull 50 # Test cspull
46 # =========== 51 # ===========
47 -echo -n "Test cspull: " 52 +$ECHO -n "Test cspull: "
48 chmod +x @abs_top_srcdir@/scripts/cspull.py 53 chmod +x @abs_top_srcdir@/scripts/cspull.py
49 @abs_top_srcdir@/scripts/cspull.py \ 54 @abs_top_srcdir@/scripts/cspull.py \
50 srcmdl="data/crab.xml" \ 55 srcmdl="data/crab.xml" \
@@ -62,15 +67,15 @@ chmod +x @abs_top_srcdir@/scripts/cspull.py @@ -62,15 +67,15 @@ chmod +x @abs_top_srcdir@/scripts/cspull.py
62 rad=5.0 \ 67 rad=5.0 \
63 npix=200 \ 68 npix=200 \
64 binsz=0.05 > cspull.log 69 binsz=0.05 > cspull.log
65 -echo -n "." 70 +$ECHO -n "."
66 if [ -s "pull.dat" ] 71 if [ -s "pull.dat" ]
67 then 72 then
68 - echo -n "." 73 + $ECHO -n "."
69 else 74 else
70 - echo " pull.dat file is not valid" 75 + $ECHO " pull.dat file is not valid"
71 exit 1 76 exit 1
72 fi 77 fi
73 -echo " ok" 78 +$ECHO " ok"
74 79
75 80
76 # 81 #
@@ -100,7 +105,7 @@ echo " ok" @@ -100,7 +105,7 @@ echo " ok"
100 # 105 #
101 # Test cstsdist 106 # Test cstsdist
102 # ============= 107 # =============
103 -echo -n "Test cstsdist: " 108 +$ECHO -n "Test cstsdist: "
104 chmod +x @abs_top_srcdir@/scripts/cstsdist.py 109 chmod +x @abs_top_srcdir@/scripts/cstsdist.py
105 @abs_top_srcdir@/scripts/cstsdist.py \ 110 @abs_top_srcdir@/scripts/cstsdist.py \
106 outfile="ts.dat" \ 111 outfile="ts.dat" \
@@ -117,12 +122,12 @@ chmod +x @abs_top_srcdir@/scripts/cstsdist.py @@ -117,12 +122,12 @@ chmod +x @abs_top_srcdir@/scripts/cstsdist.py
117 rad=5.0 \ 122 rad=5.0 \
118 npix=200 \ 123 npix=200 \
119 binsz=0.05 > cstsdist.log 124 binsz=0.05 > cstsdist.log
120 -echo -n "." 125 +$ECHO -n "."
121 if [ -s "ts.dat" ] 126 if [ -s "ts.dat" ]
122 then 127 then
123 - echo -n "." 128 + $ECHO -n "."
124 else 129 else
125 - echo " ts.dat file is not valid" 130 + $ECHO " ts.dat file is not valid"
126 exit 1 131 exit 1
127 fi 132 fi
128 -echo " ok" 133 +$ECHO " ok"
test/test_ctools.sh
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 # ========================================================================== 2 # ==========================================================================
3 # This script tests all ctools 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 # This program is free software: you can redistribute it and/or modify 7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by 8 # it under the terms of the GNU General Public License as published by
@@ -20,11 +20,16 @@ @@ -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 # Print Header 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 # Define executables 35 # Define executables
@@ -54,7 +59,7 @@ export PFILES=pfiles @@ -54,7 +59,7 @@ export PFILES=pfiles
54 # 59 #
55 # Test ctobssim 60 # Test ctobssim
56 # ============= 61 # =============
57 -echo -n "Test ctobssim: " 62 +$ECHO -n "Test ctobssim: "
58 $ctobssim infile="data/crab.xml" \ 63 $ctobssim infile="data/crab.xml" \
59 outfile="events.fits" \ 64 outfile="events.fits" \
60 caldb="irf" \ 65 caldb="irf" \
@@ -66,21 +71,21 @@ $ctobssim infile="data/crab.xml" \ @@ -66,21 +71,21 @@ $ctobssim infile="data/crab.xml" \
66 tmax=1800.0 \ 71 tmax=1800.0 \
67 emin=0.1 \ 72 emin=0.1 \
68 emax=100.0 73 emax=100.0
69 -echo -n "." 74 +$ECHO -n "."
70 if [ -s "events.fits" ] 75 if [ -s "events.fits" ]
71 then 76 then
72 - echo -n "." 77 + $ECHO -n "."
73 else 78 else
74 echo " events.fits file is not valid" 79 echo " events.fits file is not valid"
75 exit 1 80 exit 1
76 fi 81 fi
77 -echo " ok" 82 +$ECHO " ok"
78 83
79 84
80 # 85 #
81 # Test ctskymap 86 # Test ctskymap
82 # ============= 87 # =============
83 -echo -n "Test ctskymap: " 88 +$ECHO -n "Test ctskymap: "
84 $ctskymap evfile="events.fits" \ 89 $ctskymap evfile="events.fits" \
85 outfile="skymap.fits" \ 90 outfile="skymap.fits" \
86 emin=0.1 \ 91 emin=0.1 \
@@ -92,21 +97,21 @@ $ctskymap evfile="events.fits" \ @@ -92,21 +97,21 @@ $ctskymap evfile="events.fits" \
92 xref=83.63 \ 97 xref=83.63 \
93 yref=22.01 \ 98 yref=22.01 \
94 proj="CAR" 99 proj="CAR"
95 -echo -n "." 100 +$ECHO -n "."
96 if [ -s "skymap.fits" ] 101 if [ -s "skymap.fits" ]
97 then 102 then
98 - echo -n "." 103 + $ECHO -n "."
99 else 104 else
100 - echo " skymap.fits file is not valid" 105 + $ECHO " skymap.fits file is not valid"
101 exit 1 106 exit 1
102 fi 107 fi
103 -echo " ok" 108 +$ECHO " ok"
104 109
105 110
106 # 111 #
107 # Test ctbin 112 # Test ctbin
108 # ========== 113 # ==========
109 -echo -n "Test ctbin: " 114 +$ECHO -n "Test ctbin: "
110 $ctbin evfile="events.fits" \ 115 $ctbin evfile="events.fits" \
111 outfile="cntmap.fits" \ 116 outfile="cntmap.fits" \
112 emin=0.1 \ 117 emin=0.1 \
@@ -119,21 +124,21 @@ $ctbin evfile="events.fits" \ @@ -119,21 +124,21 @@ $ctbin evfile="events.fits" \
119 xref=83.63 \ 124 xref=83.63 \
120 yref=22.01 \ 125 yref=22.01 \
121 proj="CAR" 126 proj="CAR"
122 -echo -n "." 127 +$ECHO -n "."
123 if [ -s "cntmap.fits" ] 128 if [ -s "cntmap.fits" ]
124 then 129 then
125 - echo -n "." 130 + $ECHO -n "."
126 else 131 else
127 - echo " cntmap.fits file is not valid" 132 + $ECHO " cntmap.fits file is not valid"
128 exit 1 133 exit 1
129 fi 134 fi
130 -echo " ok" 135 +$ECHO " ok"
131 136
132 137
133 # 138 #
134 # Test ctselect 139 # Test ctselect
135 # ============= 140 # =============
136 -echo -n "Test ctselect: " 141 +$ECHO -n "Test ctselect: "
137 $ctselect infile="events.fits" \ 142 $ctselect infile="events.fits" \
138 outfile="selected_events.fits" \ 143 outfile="selected_events.fits" \
139 ra=83.63 \ 144 ra=83.63 \
@@ -143,32 +148,32 @@ $ctselect infile="events.fits" \ @@ -143,32 +148,32 @@ $ctselect infile="events.fits" \
143 tmax=1800.0 \ 148 tmax=1800.0 \
144 emin=0.1 \ 149 emin=0.1 \
145 emax=100.0 150 emax=100.0
146 -echo -n "." 151 +$ECHO -n "."
147 if [ -s "selected_events.fits" ] 152 if [ -s "selected_events.fits" ]
148 then 153 then
149 - echo -n "." 154 + $ECHO -n "."
150 else 155 else
151 - echo " selected_events.fits file is not valid" 156 + $ECHO " selected_events.fits file is not valid"
152 exit 1 157 exit 1
153 fi 158 fi
154 -echo " ok" 159 +$ECHO " ok"
155 160
156 161
157 # 162 #
158 # Test ctlike 163 # Test ctlike
159 # =========== 164 # ===========
160 -echo -n "Test ctlike: " 165 +$ECHO -n "Test ctlike: "
161 $ctlike infile="cntmap.fits" \ 166 $ctlike infile="cntmap.fits" \
162 srcmdl="data/crab.xml" \ 167 srcmdl="data/crab.xml" \
163 outmdl="results_binned.xml" \ 168 outmdl="results_binned.xml" \
164 caldb="irf" \ 169 caldb="irf" \
165 irf="kb_E_50h_v3" 170 irf="kb_E_50h_v3"
166 -echo -n "." 171 +$ECHO -n "."
167 if [ -s "results_binned.xml" ] 172 if [ -s "results_binned.xml" ]
168 then 173 then
169 - echo -n "." 174 + $ECHO -n "."
170 else 175 else
171 - echo " results_binned.xml file is not valid" 176 + $ECHO " results_binned.xml file is not valid"
172 exit 1 177 exit 1
173 fi 178 fi
174 $ctlike infile="selected_events.fits" \ 179 $ctlike infile="selected_events.fits" \
@@ -176,12 +181,12 @@ $ctlike infile="selected_events.fits" \ @@ -176,12 +181,12 @@ $ctlike infile="selected_events.fits" \
176 outmdl="results_unbinned.xml" \ 181 outmdl="results_unbinned.xml" \
177 caldb="irf" \ 182 caldb="irf" \
178 irf="kb_E_50h_v3" 183 irf="kb_E_50h_v3"
179 -echo -n "." 184 +$ECHO -n "."
180 if [ -s "results_unbinned.xml" ] 185 if [ -s "results_unbinned.xml" ]
181 then 186 then
182 - echo -n "." 187 + $ECHO -n "."
183 else 188 else
184 - echo " results_unbinned.xml file is not valid" 189 + $ECHO " results_unbinned.xml file is not valid"
185 exit 1 190 exit 1
186 fi 191 fi
187 -echo " ok" 192 +$ECHO " ok"