1#!/bin/sh 2# 3# aegis - project change supervisor 4# Copyright (C) 1994-1999, 2005-2008 Peter Miller 5# 6# This program is free software; you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 3 of the License, or 9# (at your option) any later version. 10# 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program. If not, see 18# <http://www.gnu.org/licenses/>. 19# 20 21unset AEGIS_PROJECT 22unset AEGIS_CHANGE 23unset AEGIS_PATH 24unset AEGIS 25umask 022 26 27USER=${USER:-${LOGNAME:-`whoami`}} 28 29work=${AEGIS_TMP:-/tmp}/$$ 30PAGER=cat 31export PAGER 32 33AEGIS_FLAGS="delete_file_preference = no_keep; \ 34 lock_wait_preference = always; \ 35 diff_preference = automatic_merge; \ 36 pager_preference = never; \ 37 persevere_preference = all; \ 38 log_file_preference = never;" 39export AEGIS_FLAGS 40AEGIS_THROTTLE=-1 41export AEGIS_THROTTLE 42 43here=`pwd` 44if test $? -ne 0 ; then exit 2; fi 45 46if test "$1" != "" ; then bin="$here/$1/bin"; else bin="$here/bin"; fi 47 48no_result() 49{ 50 set +x 51 echo "NO RESULT for test of basic report language ($activity)" 1>&2 52 cd $here 53 find $work -type d -user $USER -exec chmod u+w {} \; 54 rm -rf $work 55 exit 2 56} 57fail() 58{ 59 set +x 60 echo "FAILED test of basic report language ($activity)" 1>&2 61 cd $here 62 find $work -type d -user $USER -exec chmod u+w {} \; 63 rm -rf $work 64 exit 1 65} 66pass() 67{ 68 set +x 69 echo PASSED 1>&2 70 cd $here 71 find $work -type d -user $USER -exec chmod u+w {} \; 72 rm -rf $work 73 exit 0 74} 75trap \"no_result\" 1 2 3 15 76 77activity="working directory 81" 78mkdir $work 79if test $? -ne 0 ; then no_result; fi 80cd $work 81if test $? -ne 0 ; then no_result; fi 82 83mkdir $work/lib $work/lib/report 84if test $? -ne 0 ; then no_result; fi 85chmod 777 $work/lib 86if test $? -ne 0 ; then no_result; fi 87 88AEGIS_PATH=$work/lib 89export AEGIS_PATH 90 91LINES=66 92export LINES 93COLS=65 94export COLS 95 96# 97# create a project for later tests 98# 99$bin/aegis -new_proj foo -dir $work/proj -v > log 2>&1 100if test $? -ne 0 ; then cat log; no_result; fi 101 102# 103# test the basic report language 104# 105activity="basic report language 109" 106cat > test.in << 'fubar' 107title("Just A Test", "delete this line"); 108columns({name = "First"; width = 15;}, {name = "Second"; }); 109print(1, "two"); 110print(2.3); 111print(3.4e-2); 112print(); 113print("hello", "world"); 114fubar 115if test $? -ne 0 ; then no_result; fi 116$bin/aegis -report -file test.in -o test.out.raw -pw=64 117if test $? -ne 0 ; then fail; fi 118 119sed '/delete this line/d' < test.out.raw > test.out 120if test $? -ne 0 ; then no_result; fi 121 122cat > test.ok << 'fubar' 123 124 125 126Just A Test Page 1 127 128First Second 1291 two 1302.3 1310.034 132 133hello world 134fubar 135if test $? -ne 0 ; then no_result; fi 136 137diff test.ok test.out 138if test $? -ne 0 ; then fail; fi 139 140# 141# test the binary + operator 142# 143activity="binary + operator 147" 144cat > test.in << 'fubar' 145title("Binary Plus", "delete this line"); 146columns("r+r\n-------", "r+i\n-------", "i+r\n-------", "i+i\n-------"); 147print("6.1" + 7.2, 3.4 + 5, "1" + 0.2, 1 + 2 + 3); 148print("6.1" * 7.2, 3.4 * 5, "12" * 0.2, 2 * 3); 149fubar 150if test $? -ne 0 ; then no_result; fi 151$bin/aegis -report -file test.in -o test.out.raw -pw=64 152if test $? -ne 0 ; then fail; fi 153 154sed '/delete this line/d' < test.out.raw > test.out 155if test $? -ne 0 ; then no_result; fi 156 157cat > test.ok << 'fubar' 158 159 160 161Binary Plus Page 1 162 163r+r r+i i+r i+i 164------- ------- ------- ------- 16513.3 8.4 1.2 6 16643.92 17 2.4 6 167fubar 168if test $? -ne 0 ; then no_result; fi 169 170diff test.ok test.out 171if test $? -ne 0 ; then fail; fi 172 173# 174# test the variable functionality 175# 176activity="variables 180" 177cat > test.in << 'fubar' 178title("Variables", "delete this line"); 179columns("N\n-------", "N^2\n-------", "<", "<=", ">", ">=", "==", "!=", 180 { name = "~~"; width = 9;}); 181auto j; 182for (j = -16; j < 10; j = j + 1) 183 print(j, j * j, j < 3, j <= 3, j > 3, j >= 3, j == 3, j != 3, j ~~ "A1"); 184fubar 185if test $? -ne 0 ; then no_result; fi 186$bin/aegis -report -file test.in -o test.out.raw -pw=64 187if test $? -ne 0 ; then fail; fi 188 189sed '/delete this line/d' < test.out.raw > test.out 190if test $? -ne 0 ; then no_result; fi 191 192cat > test.ok << 'fubar' 193 194 195 196Variables Page 1 197 198N N^2 < <= > >= == != ~~ 199------- ------- 200-16 256 true true false false false true 0.4 201-15 225 true true false false false true 0.4 202-14 196 true true false false false true 0.4 203-13 169 true true false false false true 0.4 204-12 144 true true false false false true 0.4 205-11 121 true true false false false true 0.4 206-10 100 true true false false false true 0.4 207-9 81 true true false false false true 0 208-8 64 true true false false false true 0 209-7 49 true true false false false true 0 210-6 36 true true false false false true 0 211-5 25 true true false false false true 0 212-4 16 true true false false false true 0 213-3 9 true true false false false true 0 214-2 4 true true false false false true 0 215-1 1 true true false false false true 0.5 2160 0 true true false false false true 0 2171 1 true true false false false true 0.666667 2182 4 true true false false false true 0 2193 9 false true false true true false 0 2204 16 false false true true false true 0 2215 25 false false true true false true 0 2226 36 false false true true false true 0 2237 49 false false true true false true 0 2248 64 false false true true false true 0 2259 81 false false true true false true 0 226fubar 227if test $? -ne 0 ; then no_result; fi 228 229diff test.ok test.out 230if test $? -ne 0 ; then fail; fi 231 232# 233# test the sprintf functionality 234# 235activity="sprintf function 239" 236cat > test.in << 'fubar' 237title("sprintf", "delete this line"); 238columns("%2d", "%c", "%5.2f", { name = "%.5e"; width = 15;}, "%-2s%2s", "%2X"); 239auto j; 240for (j = 1; j < 32; j = j + 1) 241 print 242 ( 243 sprintf("%2d", j), 244 sprintf("%c", j + 64), 245 sprintf("%5.2f", j), 246 sprintf("%.5e", (j * j) * (j * j)), 247 sprintf("%-2s%2s", j, j-5), 248 sprintf("%2X", j) 249 ); 250fubar 251if test $? -ne 0 ; then no_result; fi 252$bin/aegis -report -file test.in -o test.out.raw -pw=64 253if test $? -ne 0 ; then fail; fi 254 255sed '/delete this line/d' < test.out.raw > test.out 256if test $? -ne 0 ; then no_result; fi 257 258cat > test.ok << 'fubar' 259 260 261 262sprintf Page 1 263 264%2d %c %5.2f %.5e %-2s%2s %2X 265 1 A 1.00 1.00000e+00 1 -4 1 266 2 B 2.00 1.60000e+01 2 -3 2 267 3 C 3.00 8.10000e+01 3 -2 3 268 4 D 4.00 2.56000e+02 4 -1 4 269 5 E 5.00 6.25000e+02 5 0 5 270 6 F 6.00 1.29600e+03 6 1 6 271 7 G 7.00 2.40100e+03 7 2 7 272 8 H 8.00 4.09600e+03 8 3 8 273 9 I 9.00 6.56100e+03 9 4 9 27410 J 10.00 1.00000e+04 10 5 A 27511 K 11.00 1.46410e+04 11 6 B 27612 L 12.00 2.07360e+04 12 7 C 27713 M 13.00 2.85610e+04 13 8 D 27814 N 14.00 3.84160e+04 14 9 E 27915 O 15.00 5.06250e+04 1510 F 28016 P 16.00 6.55360e+04 1611 10 28117 Q 17.00 8.35210e+04 1712 11 28218 R 18.00 1.04976e+05 1813 12 28319 S 19.00 1.30321e+05 1914 13 28420 T 20.00 1.60000e+05 2015 14 28521 U 21.00 1.94481e+05 2116 15 28622 V 22.00 2.34256e+05 2217 16 28723 W 23.00 2.79841e+05 2318 17 28824 X 24.00 3.31776e+05 2419 18 28925 Y 25.00 3.90625e+05 2520 19 29026 Z 26.00 4.56976e+05 2621 1A 29127 [ 27.00 5.31441e+05 2722 1B 29228 \ 28.00 6.14656e+05 2823 1C 29329 ] 29.00 7.07281e+05 2924 1D 29430 ^ 30.00 8.10000e+05 3025 1E 29531 _ 31.00 9.23521e+05 3126 1F 296fubar 297if test $? -ne 0 ; then no_result; fi 298 299diff test.ok test.out 300if test $? -ne 0 ; then fail; fi 301 302# 303# test the passwd functionality 304# 305activity="passwd array 309" 306cat > test.in << 'fubar' 307title("The Password File", ""); 308columns 309( 310 { name = "Login\n--------"; width = 8; }, 311 { name = "Full Name\n----------"; width = 18; }, 312 { name = "Directory\n-----------"; width = 23; }, 313 { name = "Shell\n-------"; width = 11; }, 314 { name = "Weight\n------"; } 315); 316auto j, p, w; 317for (j in sort(keys(passwd))) 318{ 319 try 320 p = passwd[j]; 321 catch (p) 322 continue; 323 w = p.pw_name ~~ "pmiller"; 324 if (w < 0.8) 325 continue; 326 print 327 ( 328 p.pw_name, 329 p.pw_comment, 330 p.pw_dir, 331 p.pw_shell, 332 sprintf("%4.2f", w) 333 ); 334} 335fubar 336if test $? -ne 0 ; then no_result; fi 337$bin/aegis -report -file test.in > log 2>&1 338if test $? -ne 0 ; then cat log; fail; fi 339 340# 341# test the "projects variable" functionality 342# 343activity="projects variable 347" 344cat > test.in << 'fubar' 345title("List of Projects", ""); 346columns 347( 348 { name = "Name\n------"; width = 11; }, 349 { name = "Directory\n-----------"; width = 19; }, 350 { name = "Description\n-------------"; width = 23; } 351); 352auto j, p, n; 353for (j in sort(keys(project))) 354{ 355 p = project[j]; 356 print(p.name, p.directory, p.state.description); 357 n = n + 1; 358} 359if (n == 0) 360 print("", "", "Found no projects."); 361fubar 362if test $? -ne 0 ; then no_result; fi 363$bin/aegis -report -file test.in > log 2>&1 364if test $? -ne 0 ; then cat log; fail; fi 365 366# 367# Only definite negatives are possible. 368# The functionality exercised by this test appears to work, 369# no other guarantees are made. 370# 371pass 372