1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517
|
#!/bin/sh
#
# $Id: functions.sh,v 1.108 2004/05/19 14:53:31 mcr Exp $
#
preptest() {
local testdir="$1"
local testtype="$2"
if [ ! -r "$testdir/testparams.sh" ]
then
echo ' ' "Missing configuration file: $testdir/testparams.sh"
exit 1
fi
# make sure no results survive from a past run
if [ ! -z "$testdir" ] ; then
rm -rf "$testdir/OUTPUT"${KLIPS_MODULE}
mkdir -p "$testdir/OUTPUT"${KLIPS_MODULE}
fi
cd $testdir
source ./testparams.sh
if [ "X$TEST_TYPE" != "X$testtype" ]
then
echo "Error: TEST_TYPE differs. Check agreement of TESTLIST and testparams.sh"
exit 1
fi
# get rid of any pluto core files.
if [ -z "$XHOST_LIST" ]
then
XHOST_LIST="EAST WEST JAPAN"
fi
export XHOST_LIST
# Xhost script takes things from the environment.
for host in $XHOST_LIST
do
ROOT=$POOLSPACE/$host/root
rm -f $ROOT/var/tmp/core
done
}
lookforcore() {
local testdir="$1"
if [ -d "$testdir" ]
then
cd $testdir
if [ -f ./testparams.sh ]
then
source ./testparams.sh
fi
# get rid of any pluto core files.
if [ -z "$XHOST_LIST" ]
then
XHOST_LIST="EAST WEST JAPAN"
fi
export XHOST_LIST
# Xhost script takes things from the environment.
for host in $XHOST_LIST
do
ROOT=$POOLSPACE/$host/root
if [ -f $ROOT/var/tmp/core ]
then
mv $ROOT/var/tmp/core OUTPUT${KLIPS_MODULE}/pluto.$host.core
echo "pluto.$host.core "
fi
done
fi
}
verboseecho() {
if [ -n "${NETJIGVERBOSE}" ]
then
echo $@
fi
}
# ??? NOTE:
# This seems to only sometimes set $success.
# Whatever interesting settings are made seem to be lost by the caller :-(
consolediff() {
prefix=$1
output=$2
ref=$3
cleanups="cat $output "
for fixup in `echo $REF_CONSOLE_FIXUPS`
do
if [ -f $FIXUPDIR/$fixup ]
then
case $fixup in
*.sed) cleanups="$cleanups | sed -f $FIXUPDIR/$fixup";;
*.pl) cleanups="$cleanups | perl $FIXUPDIR/$fixup";;
*.awk) cleanups="$cleanups | awk -f $FIXUPDIR/$fixup";;
*) echo Unknown fixup type: $fixup;;
esac
else
echo Fixup $fixup not found.
success="missing fixup"
return
fi
done
fixedoutput=OUTPUT${KLIPS_MODULE}/${prefix}console-fixed.txt
rm -f $fixedoutput OUTPUT${KLIPS_MODULE}/${prefix}console.diff
$CONSOLEDIFFDEBUG && echo Cleanups is $cleanups
eval $cleanups >$fixedoutput
# stick terminating newline in for fun.
echo >>$fixedoutput
if diff -N -u -w -b -B $ref $fixedoutput >OUTPUT${KLIPS_MODULE}/${prefix}console.diff
then
echo "${prefix}Console output matched"
else
echo "${prefix}Console output differed"
case "$success" in
true) failnum=2 ;;
esac
success=false
fi
}
compat_variables() {
if [ -z "$REF_CONSOLE_OUTPUT" ] && [ -n "$REFCONSOLEOUTPUT" ]
then
REF_CONSOLE_OUTPUT=$REFCONSOLEOUTPUT
fi
if [ -z "$REF_CONSOLE_FIXUPS" ] && [ -n "$REFCONSOLEFIXUPS" ]
then
REF_CONSOLE_FIXUPS=$REFCONSOLEFIXUPS
fi
if [ -z "$REF_PUB_OUTPUT" ] && [ -n "$REFPUBOUTPUT" ]
then
REF_PUB_OUTPUT=$REFPUBOUTPUT
fi
if [ -z "$REF_PRIV_OUTPUT" ] && [ -n "$REFPRIVOUTPUT" ]
then
REF_PRIV_OUTPUT=$REFPRIVOUTPUT
fi
if [ -z "$PRIV_INPUT" ] && [ -n "$PRIVINPUT" ]
then
PRIV_INPUT=$PRIVINPUT
fi
if [ -z "$PUB_INPUT" ] && [ -n "$PUBINPUT" ]
then
PUB_INPUT=$PUBINPUT
fi
if [ -z "$INIT_SCRIPT" ] && [ -n "$SCRIPT" ]
then
INIT_SCRIPT=$SCRIPT
fi
if [ -z "$EAST_RUN_SCRIPT" ] && [ -n "$RUN_EAST_SCRIPT" ]
then
EAST_RUN_SCRIPT=$RUN_EAST_SCRIPT
fi
if [ -z "$WEST_RUN_SCRIPT" ] && [ -n "$RUN_WEST_SCRIPT" ]
then
WEST_RUN_SCRIPT=$RUN_WEST_SCRIPT
fi
if [ -z "$EAST_FINAL_SCRIPT" ] && [ -n "$FINAL_EAST_SCRIPT" ]
then
EAST_FINAL_SCRIPT=$FINAL_EAST_SCRIPT
fi
if [ -z "$WEST_FINAL_SCRIPT" ] && [ -n "$FINAL_WEST_SCRIPT" ]
then
WEST_FINAL_SCRIPT=$FINAL_WEST_SCRIPT
fi
}
# this is called to set additional variables that depend upon testparams.sh
prerunsetup() {
if [ -n "$KLIPS_MODULE" ]
then
HOST_START=$POOLSPACE/$TESTHOST/startmodule.sh
EAST_START=$POOLSPACE/$EASTHOST/startmodule.sh
WEST_START=$POOLSPACE/$WESTHOST/startmodule.sh
REPORT_NAME=${TESTNAME}${KLIPS_MODULE}
else
HOST_START=$POOLSPACE/$TESTHOST/start.sh
EAST_START=$POOLSPACE/$EASTHOST/start.sh
WEST_START=$POOLSPACE/$WESTHOST/start.sh
REPORT_NAME=${TESTNAME}
fi
compat_variables;
# export variables that are common.
export PACKETRATE
perl ${OPENSWANSRCDIR}/testing/utils/regress-summarize-results.pl ${REGRESSRESULTS} ${TESTNAME}
}
setup_additional_hosts() {
if [ -n "${ADDITIONAL_HOSTS}" ]
then
SEP=""
HOSTLIST=""
for host in ${ADDITIONAL_HOSTS}
do
HOSTLIST="${HOSTLIST}${SEP}${host}=${POOLSPACE}/${host}/start.sh"
SEP=","
done
echo "-H ${HOSTLIST}"
fi
}
#
# use this function to run some script on each reference output script.
#
# Start this from testing/*, listing all the test names (directories),
# space-separated. The script to run is the first argument.
#
# The script will be provided with three arguments -
# 1) the name of the test
# 2) the name of the console# which is either "", east or west
# 3) and the file where the reference console should be placed.
#
# The current working directory is *NOT* changed before the script is ran.
#
foreach_ref_console() {
script=$1
shift
for i in $*
do
echo $i:
if [ -d $i ]
then
(if [ -f $i/testparams.sh ]
then
. $i/testparams.sh
compat_variables;
if [ -n "$REF_CONSOLE_OUTPUT" ]
then
echo $script $i "" $REF_CONSOLE_OUTPUT
$script $i "" $REF_CONSOLE_OUTPUT
fi
if [ -n "$REF_EAST_CONSOLE_OUTPUT" ]
then
echo $script $i east $REF_EAST_CONSOLE_OUTPUT
$script $i east $REF_EAST_CONSOLE_OUTPUT
fi
if [ -n "$REF_WEST_CONSOLE_OUTPUT" ]
then
echo $script $i west $REF_WEST_CONSOLE_OUTPUT
$script $i west $REF_WEST_CONSOLE_OUTPUT
fi
fi)
fi
done
}
roguekill() {
REPORT_NAME="$1"
local rogue_sighted=""
if [ -n "$REGRESSRESULTS" ]
then
rm -f $REGRESSRESULTS/$REPORT_NAME/roguelist.txt
mkdir -p $REGRESSRESULTS/$REPORT_NAME
fi
# search for rogue UML
local pointless=false
local firstpass=true
local other_rogues=""
verboseecho "UML_BRAND=$UML_BRAND"
for sig in KILL CONT KILL CONT KILL CONT KILL
do
if $pointless
then
break;
fi
pointless=true
for i in `grep -s -l '^'"$POOLSPACE"'/[a-z]*/linux\>' /proc/[1-9]*/cmdline`
do
local pdir=`dirname "$i"`
local badpid=`basename $pdir`
if [ ! -r $pdir/environ ] || strings $pdir/environ | grep "^UML_BRAND=$UML_BRAND"'$' >/dev/null
then
echo "${sig}ING ROGUE UML: $badpid `tr '\000' ' ' <$pdir/cmdline`"
if [ -n "$REGRESSRESULTS" ]
then
echo "UML pid $pdir went ROGUE" >>$REGRESSRESULTS/$REPORT_NAME/roguelist.txt
fi
# the cwd is a good indication of what test was being executed.
rogue_sighted=" rogue"
pointless=false
ls -l $pdir/cwd
kill -$sig $badpid
elif $firstpass
then
other_rogues="$other_rogues $badpid"
fi
done
# might take some realtime for a kill to work
if ! $pointless
then
sleep 2
fi
firstpass=false
done
if [ -n "$other_rogues" ]
then
echo "ROGUES without brand $UML_BRAND:"
ps -f -w -p $other_rogues
fi
stat="$stat$rogue_sighted"
}
#
# record results records the status of each test in
# $REGRESSRESULTS/$REPORT_NAME/status
#
# If the status is negative, then the "OUTPUT${KLIPS_MODULE}" directory of the test is
# copied to $REGRESSRESULTS/$REPORT_NAME/OUTPUT${KLIPS_MODULE} as well.
#
# The file $testname/description.txt if it exists is copied as well.
#
# If $REGRESSRESULTS is not set, then nothing is done.
#
# See testing/utils/regress-summarizeresults.pl for a tool to build a nice
# report from these files.
#
# See testing/utils/regress-nightly.sh and regress-stage2.sh for code
# that sets up $REGRESSRESULTS.
#
# usage: recordresults testname testtype status REPORTNAME
#
recordresults() {
local testname="$1"
local testexpect="$2"
local status="$3"
local REPORT_NAME="$4"
export REGRESSRESULTS
roguekill $REPORT_NAME
if [ -n "$REGRESSRESULTS" ]
then
rm -rf $REGRESSRESULTS/$REPORT_NAME
mkdir -p $REGRESSRESULTS/$REPORT_NAME
console=false
packet=false
# if there was a core file, add that to status
cores=`( lookforcore $testname )`
if [ ! -z "$cores" ]
then
status="$status core"
fi
# if there was a rogue, add that to status
if [ -f $REGRESSRESULTS/$REPORT_NAME/status/roguelist.txt ]
then
status="$status rogue"
fi
# note that 0/1 is shell sense.
case "$status" in
0) success=true;;
1) success=false; console=true;;
2) success=false; console=false; packet=true;;
99) success="missing 99"; console=false; packet=false;;
true) success=true;;
false) sucesss=false;;
succeed) success=true;;
fail) success=false;;
yes) success=true;;
no) success=false;;
skipped) success=skipped;;
missing) success=missing;;
*) success=false;;
esac
echo "Recording "'"'"$success: $status"'"'" to $REGRESSRESULTS/$REPORT_NAME/status"
echo "$success: $status" >$REGRESSRESULTS/$REPORT_NAME/status
echo console=$console >>$REGRESSRESULTS/$REPORT_NAME/status
echo packet=$packet >>$REGRESSRESULTS/$REPORT_NAME/status
echo "$testexpect" >$REGRESSRESULTS/$REPORT_NAME/expected
if [ -f $testname/description.txt ]
then
cp $testname/description.txt $REGRESSRESULTS/$REPORT_NAME
fi
# the following is in a subprocess to protect against certain
# testparams.sh which exit!
(
if [ -r "$testdir/testparams.sh" ]
then
. "$testdir/testparams.sh"
fi
case "${TEST_PURPOSE}" in
regress) echo ${TEST_PROB_REPORT} >$REGRESSRESULTS/$REPORT_NAME/regress.txt;;
goal) echo ${TEST_GOAL_ITEM} >$REGRESSRESULTS/$REPORT_NAME/goal.txt;;
exploit) echo ${TEST_EXPLOIT_URL} >$REGRESSRESULTS/$REPORT_NAME/exploit.txt;;
*) echo "unknown TEST_PURPOSE (${TEST_PURPOSE})" ;;
esac
)
case "$success" in
false)
# ???? why the heck is this code run only when $success is false?
# NOTE: ${KLIPS_MODULE} is part of $REPORT_NAME
rm -rf $REGRESSRESULTS/$REPORT_NAME/OUTPUT
mkdir -p $REGRESSRESULTS/$REPORT_NAME/OUTPUT
tar -C $testname/OUTPUT${KLIPS_MODULE} -c -f - . | (cd $REGRESSRESULTS/$REPORT_NAME/OUTPUT && tar xf - )
;;
esac
fi
case "$status" in
0) echo '******* PASSED '$REPORT_NAME' ********' ;;
skipped) echo '******* SKIPPED '$REPORT_NAME' ********' ;;
*) echo '******* FAILED '$REPORT_NAME' ********' ;;
esac
}
#
# pcap_filter west $REF_OUTPUT $WESTOUTPUT $REF_WEST_FILTER
#
pcap_filter() {
HOST=
OUTPUT=
FILTER=
REF_OUTPUT=
#echo PCAP_FILTER $@
HOST=$1
REF_OUTPUT=$2
OUTPUT=$3
FILTER=$4
if [ -z "$FILTER" ]
then
FILTER=cat
fi
# refilter 3.8 output for 3.7 files unless the case has been updated
if [ -z "$THREEEIGHT" ] && $THREEEIGHT
then
FILTER="$FILTER | sed -f $FIXUPDIR/tcpdump-three-eight.sed"
fi
if [ -n "$OUTPUT" ]
then
rm -f OUTPUT${KLIPS_MODULE}/${OUTPUT}.txt
verboseecho $TCPDUMP -n -t $TCPDUMPFLAGS '|' "$FILTER" '>' OUTPUT${KLIPS_MODULE}/${OUTPUT}.txt
eval "$TCPDUMP -n -t $TCPDUMPFLAGS -r OUTPUT${KLIPS_MODULE}/$OUTPUT.pcap | $FILTER >|OUTPUT${KLIPS_MODULE}/$OUTPUT.txt"
rm -f OUTPUT${KLIPS_MODULE}/$OUTPUT.diff
if diff -u -w -b -B $REF_OUTPUT OUTPUT${KLIPS_MODULE}/$OUTPUT.txt >OUTPUT${KLIPS_MODULE}/$OUTPUT.diff
then
printf "%-8s side output matched\n" $HOST
else
printf "%-8s side output differed\n" $HOST
success=false
fi
fi
}
# netjigtest - invoke a single UML with input/output setup for KLIPS
# testing.
#
# variables are documented in doc/makecheck.html
#
netjigtest() {
prerunsetup
success=true
failnum=1
PRIVOUTPUT=''
PUBOUTPUT=''
NJARGS=''
if [ -n "$PRIV_INPUT" ]
then
NJARGS="$NJARGS -p $PRIV_INPUT"
fi
if [ -n "$PUB_INPUT" ]
then
NJARGS="$NJARGS -P $PUB_INPUT"
fi
if [ -n "$REF_CONSOLE_OUTPUT" ]
then
NJARGS="$NJARGS -c OUTPUT${KLIPS_MODULE}/console.txt"
fi
if [ -n "$REF_PRIV_OUTPUT" ]
then
PRIVOUTPUT=`basename $REF_PRIV_OUTPUT .txt `
NJARGS="$NJARGS -r OUTPUT${KLIPS_MODULE}/$PRIVOUTPUT.pcap"
fi
if [ -n "$REF_PUB_OUTPUT" ]
then
PUBOUTPUT=`basename $REF_PUB_OUTPUT .txt`
NJARGS="$NJARGS -R OUTPUT${KLIPS_MODULE}/$PUBOUTPUT.pcap"
fi
if [ -n "$NETJIGARGS" ]
then
NJARGS="$NJARGS $NETJIGARGS"
fi
if [ "X$ARPREPLY" = "X--arpreply" ]
then
NJARGS="$NJARGS -a"
fi
if [ -n "${RUN_SCRIPT}" ]
then
NJARGS="$NJARGS -s ${RUN_SCRIPT}"
fi
if [ -n "${FINAL_SCRIPT}" ]
then
NJARGS="$NJARGS -I ${FINAL_SCRIPT}"
fi
NJARGS="$NJARGS "`setup_additional_hosts`
# if [ "X$EXITONEMPTY" = "X--exitonempty" ]
# then
# NJARGS="$NJARGS -a"
# fi
rm -f OUTPUT${KLIPS_MODULE}/console.txt
cmd="expect -f $UTILS/host-test.tcl -- -U $TESTHOST -u $HOST_START -i ${INIT_SCRIPT} -n $NJ $NJARGS"
$NETJIGDEBUG && echo $cmd
eval $cmd
#uml_mconsole $TESTHOST halt
pcap_filter private "$REF_PRIV_OUTPUT" "$PRIVOUTPUT" "$REF_PRIV_FILTER"
pcap_filter public "$REF_PUB_OUTPUT" "$PUBOUTPUT" "$REF_PUB_FILTER"
if [ -n "$REF_CONSOLE_OUTPUT" ]
then
consolediff "" OUTPUT${KLIPS_MODULE}/console.txt $REF_CONSOLE_OUTPUT
fi
case "$success" in
true) exit 0 ;;
*) exit $failnum ;;
esac
}
###################################
#
# test type: klipstest
#
###################################
# test entry point:
klipstest() {
testdir=$1
testexpect=$2
echo '******* KLIPS RUNNING' $testdir${KLIPS_MODULE} '*******'
export UML_BRAND="$$"
( preptest $testdir klipstest && netjigtest )
stat=$?
recordresults $testdir "$testexpect" "$stat" $testdir${KLIPS_MODULE}
}
###################################
#
# test type: ctltest - run the UML with no I/O
#
###################################
do_ctl_test() {
success=true
prerunsetup
NJARGS=""
if [ -n "${FINAL_SCRIPT}" ]
then
NJARGS="$NJARGS -I ${FINAL_SCRIPT}"
fi
if [ -n "$REF_CONSOLE_OUTPUT" ]
then
rm -f OUTPUT${KLIPS_MODULE}/console.txt
NJARGS="$NJARGS -c OUTPUT${KLIPS_MODULE}/console.txt"
fi
if [ "X${NEEDS_DNS}" = "Xtrue" ]
then
NJARGS="$NJARGS -D $POOLSPACE/nic/start.sh"
fi
NJARGS="$NJARGS "`setup_additional_hosts`
cmd="expect -f $UTILS/host-test.tcl -- -U $TESTHOST -u $HOST_START -i ${INIT_SCRIPT} -n $NJ $NJARGS"
$NETJIGDEBUG && echo $cmd
eval $cmd
if [ -n "$REF_CONSOLE_OUTPUT" ]
then
consolediff "" OUTPUT${KLIPS_MODULE}/console.txt $REF_CONSOLE_OUTPUT
fi
case "$success" in
true) exit 0 ;;
*) exit 2 ;;
esac
}
# test entry point:
ctltest() {
testdir=$1
testexpect=$2
echo '****** CONTROL RUNNING' $testdir${KLIPS_MODULE} '*******'
export UML_BRAND="$$"
( preptest $testdir ctltest && do_ctl_test )
stat=$?
recordresults $testdir "$testexpect" "$stat" $testdir${KLIPS_MODULE}
}
skiptest() {
testdir=$1
testexpect=$2
export TEST_PURPOSE=regress
UML_BRAND=0 recordresults $testdir "$testexpect" skipped $testdir${KLIPS_MODULE}
}
###################################
#
# test type: mkinsttest
#
###################################
do_make_install_test() {
rm -rf OUTPUT${KLIPS_MODULE}/root
mkdir -p OUTPUT${KLIPS_MODULE}/root
# locale affects sort order.
LC_ALL=C export LC_ALL
success=true
instdir=`cd OUTPUT${KLIPS_MODULE}/root && pwd`
prerunsetup
if [ -n "$INSTALL_FLAGS" ]
then
$MAKE_INSTALL_TEST_DEBUG && echo make --no-print-directory DESTDIR=$instdir $INSTALL_FLAGS
(cd $OPENSWANSRCDIR && eval make OPENSWANSRCDIR=`pwd` --no-print-directory DESTDIR=$instdir $INSTALL_FLAGS ) >OUTPUT${KLIPS_MODULE}/install1.txt 2>&1 || exit 1
fi
if [ -n "$POSTINSTALL_SCRIPT" ]
then
$POSTINSTALL_SCRIPT $OPENSWANSRCDIR $instdir || exit 1
fi
if [ -n "$INSTALL2_FLAGS" ]
then
$MAKE_INSTALL_TEST_DEBUG && echo make --no-print-directory DESTDIR=$instdir $INSTALL2_FLAGS
(cd $OPENSWANSRCDIR && eval make OPENSWANSRCDIR=`pwd` --no-print-directory DESTDIR=$instdir $INSTALL2_FLAGS ) >OUTPUT${KLIPS_MODULE}/install2.txt 2>&1 || exit 1
fi
if [ -n "$UNINSTALL_FLAGS" ]
then
$MAKE_INSTALL_TEST_DEBUG && echo make --no-print-directory DESTDIR=$instdir $UNINSTALL_FLAGS
(cd $OPENSWANSRCDIR && eval make OPENSWANSRCDIR=`pwd` --no-print-directory DESTDIR=$instdir $UNINSTALL_FLAGS ) >OUTPUT${KLIPS_MODULE}/uninstall.txt 2>&1 || exit 1
fi
if [ -n "$REF_MAKE_DOC_OUTPUT" ]
then
rm -f OUTPUT${KLIPS_MODULE}/$REF_MAKE_DOC_OUTPUT.txt
(cd $OPENSWANSRCDIR/doc && eval make OPENSWANSRCDIR=$OPENSWANSRCDIR clean --no-print-directory && eval make OPENSWANSRCDIR=$OPENSWANSRCDIR --no-print-directory ) | sort >OUTPUT${KLIPS_MODULE}/$REF_MAKE_DOC_OUTPUT.txt
if diff -u -w -b -B $REF_MAKE_DOC_OUTPUT.txt OUTPUT${KLIPS_MODULE}/$REF_MAKE_DOC_OUTPUT.txt >OUTPUT${KLIPS_MODULE}/$REF_MAKE_DOC_OUTPUT.diff
then
echo "make doc output matched"
else
echo "make doc output differed"
success=false
fi
fi
if [ -n "$REF_FIND_f_l_OUTPUT" ]
then
rm -f OUTPUT${KLIPS_MODULE}/$REF_FIND_f_l_OUTPUT
(cd OUTPUT${KLIPS_MODULE}/root && find . \( -type f -or -type l \) -print ) | sort >OUTPUT${KLIPS_MODULE}/$REF_FIND_f_l_OUTPUT.txt
if diff -u -w -b -B $REF_FIND_f_l_OUTPUT.txt OUTPUT${KLIPS_MODULE}/$REF_FIND_f_l_OUTPUT.txt >OUTPUT${KLIPS_MODULE}/$REF_FIND_f_l_OUTPUT.diff
then
echo "Install list file list matched"
else
echo "Install list file list differed"
success=false
fi
fi
if [ -n "$REF_FILE_CONTENTS" ]
then
cat $REF_FILE_CONTENTS | while read reffile samplefile
do
if diff -u -w -b -B $reffile $instdir/$samplefile >OUTPUT${KLIPS_MODULE}/$reffile.diff
then
echo "Reffile $samplefile matched"
else
echo "Reffile $samplefile differed"
success=false
fi
done
fi
case "$success" in
true) exit 0 ;;
*) exit 1 ;;
esac
}
# test entry point:
mkinsttest() {
testdir=$1
testexpect=$2
echo '**** Make Install RUNNING' $testdir${KLIPS_MODULE} '****'
OPENSWANSRCDIR=`cd $OPENSWANSRCDIR && pwd` export OPENSWANSRCDIR
export UML_BRAND="$$"
( preptest $testdir mkinsttest && do_make_install_test )
stat=$?
recordresults $testdir "$testexpect" "$stat" $testdir${KLIPS_MODULE}
}
###################################
#
# test type: rpm_build_install_test
#
###################################
do_rpm_install_test() {
rm -rf OUTPUT${KLIPS_MODULE}/root
mkdir -p OUTPUT${KLIPS_MODULE}/root
success=true
instdir=`cd OUTPUT${KLIPS_MODULE}/root && pwd`
prerunsetup
RPM_KERNEL_SOURCE=`eval echo $RPM_KERNEL_SOURCE`
if [ -z "$RPM_KERNEL_SOURCE" ]
then
echo "Test must define \$RPM_KERNEL_SOURCE ($RPM_KERNEL_SOURCE)"
success='missing $RPM_KERNEL_SOURCE'
exit 99
fi
if [ -z "$RPM_OMIT_BUILD" ]
then
echo "Building with kernel source $RPM_KERNEL_SOURCE";
(cd $OPENSWANSRCDIR/packaging/redhat && make clean --no-print-directory && make --no-print-directory RH_KERNELSRC=$RPM_KERNEL_SOURCE OPENSWANSRCDIR=$OPENSWANSRCDIR rpm )
fi
mkdir OUTPUT${KLIPS_MODULE}/rpm
cp $OPENSWANSRCDIR/packaging/redhat/rpms/RPMS/i386/*.rpm OUTPUT${KLIPS_MODULE}/rpm
# while loop below winds up in sub-shell. Argh.
successfile=OUTPUT${KLIPS_MODULE}/success
echo "$success" >$successfile
if [ -n "$REF_RPM_CONTENTS" ]
then
cat $REF_RPM_CONTENTS | while read rpmfile rpmcontents
do
if [ -z "$rpmfile" ]
then
continue;
fi
# expand $rpmfile, which may have wildcards!
realfile=`eval echo OUTPUT${KLIPS_MODULE}/rpm/${rpmfile}`
if [ ! -f $realfile ]
then
echo "RPM production failed to build anything to match $rpmfile"
echo false >$successfile
fi
rpm2cpio $realfile | cpio -it >OUTPUT${KLIPS_MODULE}/$rpmcontents.txt
if diff -u -w -b -B $rpmcontents.txt OUTPUT${KLIPS_MODULE}/$rpmcontents.txt >OUTPUT${KLIPS_MODULE}/$rpmcontents.diff
then
echo "Reffile ($rpmcontents) for $realfile matched"
else
echo "Reffile ($rpmcontents) for $realfile differed"
echo false >$successfile
fi
done
fi
success=`cat $successfile`
case "$success" in
true) exit 0 ;;
*) exit 1 ;;
esac
}
# test entry point:
rpm_build_install_test() {
testdir=$1
testexpect=$2
echo '**** Make Install RUNNING' $testdir${KLIPS_MODULE} '****'
OPENSWANSRCDIR=`cd $OPENSWANSRCDIR && pwd` export OPENSWANSRCDIR
export UML_BRAND="$$"
( preptest $testdir rpm_build_install_test && do_rpm_install_test )
stat=$?
if [ $stat = 99 ]
then
echo Test missing parts.
stat='missing parts'
fi
recordresults $testdir "$testexpect" "$stat" $testdir${KLIPS_MODULE}
}
###################################
#
# test type: libtest
#
###################################
# test entry point:
libtest() {
testobj=$1
testexpect=$2
testsrc=$testobj.c
CC=${CC-cc}
echo '**** make libtest RUNNING' $testsrc '****'
symbol=`echo $testobj | tr 'a-z' 'A-Z'`_MAIN
if [ -f ${LIBOPENSWANDIR}/$testsrc ]
then
FILE=${LIBOPENSWANDIR}/$testsrc
elif [ -f ${OPENSWANSRCDIR}/lib/libopenwan/$testsrc ]
then
FILE=${OPENSWANSRCDIR}/lib/libopenswan/$testsrc
elif [ -f ${OPENSWANSRCDIR}/linux/net/klips/$testsrc ]
then
FILE=${OPENSWANSRCDIR}/linux/net/klips/$testsrc
elif [ -f ${OPENSWANSRCDIR}/linux/lib/libopenswan/$testsrc ]
then
FILE=${OPENSWANSRCDIR}/linux/lib/libopenswan/$testsrc
elif [ -f ${OPENSWANSRCDIR}/linux/lib/libfreeswan/$testsrc ]
then
FILE=${OPENSWANSRCDIR}/linux/lib/libfreeswan/$testsrc
elif [ -f ${OPENSWANSRCDIR}/linux/net/ipsec/$testsrc ]
then
FILE=${OPENSWANSRCDIR}/linux/net/ipsec/$testsrc
fi
stat=99
if [ -n "$FILE" -a -r "$FILE" ]
then
${CC} -g -o $testobj -D$symbol -I${LIBOPENSWANDIR} -I${OPENSWANSRCDIR}/linux/include -I${OPENSWANSRCDIR} ${FILE} ${OPENSWANLIB}
rm -rf lib-$testobj/OUTPUT
mkdir -p lib-$testobj/OUTPUT
export TEST_PURPOSE=regress
( ./$testobj -r >lib-$testobj/OUTPUT${KLIPS_MODULE}/$testobj.txt )
stat=$?
if [ $stat -gt 128 ]
then
stat="$stat core"
fi
fi
TEST_PURPOSE=regress UML_BRAND=0 recordresults lib-$testobj "$testexpect" $stat lib-$testobj
}
###################################
#
# test type: umlplutotest
#
###################################
# If set, then the public and private packet output will be captured,
# turned into ASCII with tcpdump, and diff'ed against these files.
# REF_PUB_OUTPUT - for public side
# REF_EAST_OUTPUT - for east private side
# REF_WEST_OUTPUT - for west private side
# TCPDUMPARGS - extra args for TCPDUMP.
#
# If set, then the console output will be diff'ed against this file:
# REF_EAST_CONSOLE_OUTPUT
# REF_WEST_CONSOLE_OUTPUT
#
# The console output may need to be sanitized. The list of fixups from
# REF_CONSOLE_FIXUPS will be appled from "fixups". The extension is used to
# determine what program to use.
#
# Some additional options to control the network emulator
# ARPREPLY=--arpreply - if ARPs should be answered
# test entry point:
umlplutotest() {
testdir=$1
testexpect=$2
echo '***** UML PLUTO RUNNING' $testdir${KLIPS_MODULE} '*******'
export UML_BRAND="$$"
( export XHOST_LIST="EAST WEST"
preptest $testdir umlplutotest && do_umlX_test )
stat=$?
recordresults $testdir "$testexpect" "$stat" $testdir${KLIPS_MODULE}
}
###################################
#
# test type: kernel_patch_test
#
###################################
do_kernel_patch_test() {
success=true
set -e
if [ -z "${KERNEL_VERSION}" ]
then
exit 0;
fi
if [ -z "${KERNEL_NAME}" ]
then
echo Kernel name not defined.
exit 99
fi
kernelver=`echo ${KERNEL_VERSION} | tr '.' '_'`
kernelname=`echo ${KERNEL_NAME} | tr 'a-z' 'A-Z'`
kernel_var_name=KERNEL_${kernelname}${kernelver}_SRC
echo Looking for kernel source ${kernel_var_name}
KERNEL_SRC=${!kernel_var_name}
echo at location ${KERNEL_SRC}.
if [ -z "${KERNEL_SRC}" ] || [ ! -d "${KERNEL_SRC}" ]
then
echo Kernel source not found.
exit 99
fi
# okay, we got some source code to play with!
mkdir OUTPUT${KLIPS_MODULE}/$kernel_var_name
# get ourselves a kernel source tree.
if (cd OUTPUT${KLIPS_MODULE}/$kernel_var_name && lndir -silent $KERNEL_SRC . )
then
:
else
echo Unable to link in kernel source.
exit 99
fi
env >OUTPUT${KLIPS_MODULE}/env.txt
# now patch it. (set +x turns off any debugging there might have been)
set -x
set -v
# the environment variable OPENSWANSRCDIR should be correct
# but the make macro OPENSWANSRCDIR may be relative, and hence wrong
(cd ${OPENSWANSRCDIR} && make OPENSWANSRCDIR=`pwd` kernelpatch${KERNEL_VERSION} ) | tee OUTPUT${KLIPS_MODULE}/patchfile.patch | (cd OUTPUT${KLIPS_MODULE}/$kernel_var_name && patch -p1 2>&1 ) >OUTPUT${KLIPS_MODULE}/patch-output.txt
# compare the patch.
if [ -n "${REF_PATCH_OUTPUT}" ]
then
consolediff "" OUTPUT${KLIPS_MODULE}/patch-output.txt $REF_PATCH_OUTPUT
fi
# normally, clean up the kernel output, as it is volumnous
if [ -z "${KERNEL_PATCH_LEAVE_SOURCE}" ]
then
rm -rf OUTPUT${KLIPS_MODULE}/$kernel_var_name
fi
case "$success" in
true) exit 0 ;;
*) exit 1 ;;
esac
}
# test entry point:
kernel_patch_test() {
testdir=$1
testexpect=$2
echo '***** KERNEL PATCH RUNNING' $testdir '*******'
export UML_BRAND="$$"
( preptest $testdir kernel_patch_test && do_kernel_patch_test )
stat=$?
if [ $stat = 99 ]
then
echo Test missing parts.
stat='missing parts'
fi
recordresults $testdir "$testexpect" "$stat" $testdir
}
###################################
#
# test type: module_compile
#
###################################
do_module_compile_test() {
rm -rf OUTPUT${KLIPS_MODULE}/module
mkdir -p OUTPUT${KLIPS_MODULE}/module
set -e
success=false
moddir=`cd OUTPUT${KLIPS_MODULE}/module && pwd`
prerunsetup
if [ -z "${KERNEL_VERSION}" ]
then
exit 0;
fi
if [ -z "${KERNEL_NAME}" ]
then
echo Kernel name not defined.
exit 99
fi
kernelver=`echo ${KERNEL_VERSION} | tr '.' '_'`
kernelname=`echo ${KERNEL_NAME} | tr 'a-z' 'A-Z'`
kernel_var_name=KERNEL_${kernelname}${kernelver}_SRC
echo Looking for kernel source ${kernel_var_name}
KERNEL_SRC=${!kernel_var_name}
if [ -z "${KERNEL_SRC}" ]
then
echo Kernel source missing.
exit 99
fi
if [ ! -r ${MODULE_DEF_INCLUDE} ]
then
echo the file ${MODULE_DEF_INCLUDE} is needed to build this test.
exit 99
fi
if [ ! -r ${MODULE_DEFCONFIG} ]
then
echo the file ${MODULE_DEFCONFIG} is needed to build this test.
exit 99
fi
if [ -z "${ARCH}" ]
then
ARCH=`uname -m`
fi
case $ARCH in
i?86) ARCH=i386;;
esac
if [ -z "${SUBARCH}" ]
then
SUBARCH=${ARCH}
fi
case $SUBARCH in
i?86) SUBARCH=i386;;
esac
if [ -n "${KERNEL_CONFIG_FILE}" ]
then
echo "Making local copy of kernel source, for ${KERNEL_CONFIG_FILE}."
# if there is a KERNEL_CONFIG_FILE, then we have to
# lndir, and "make oldconfig" the kernel to get something working.
LOCAL_KERNEL_SRC=`pwd`/OUTPUT${KLIPS_MODULE}/$kernel_var_name
rm -rf ${LOCAL_KERNEL_SRC}
mkdir -p ${LOCAL_KERNEL_SRC}
# get ourselves a kernel source tree, which is configured
(cd ${LOCAL_KERNEL_SRC} && lndir -silent $KERNEL_SRC . )
# this directory needs to really be a symlink.
rm -r ${LOCAL_KERNEL_SRC}/include/asm
cp ${KERNEL_CONFIG_FILE} ${LOCAL_KERNEL_SRC}/.config
(cd ${LOCAL_KERNEL_SRC} && make ARCH=${ARCH} SUBARCH=${SUBARCH} oldconfig ) >OUTPUT${KLIPS_MODULE}/oldconfig.txt
# repoint ourselves here, so we use the just configured sources.
KERNEL_SRC=${LOCAL_KERNEL_SRC}
fi
# make this name absolute.
MODULE_DEF_INCLUDE=`pwd`/$MODULE_DEF_INCLUDE
if [ -z "${MODULE_DEFCONFIG}" ]
then
MODULE_DEFCONFIG=/dev/null
else
MODULE_DEFCONFIG=`pwd`/$MODULE_DEFCONFIG
fi
rm -f OUTPUT${KLIPS_MODULE}/module/ipsec.o
cmd="(cd $OPENSWANSRCDIR && make KERNELSRC=$KERNEL_SRC MODBUILDDIR=$moddir OPENSWANSRCDIR=$OPENSWANSRCDIR MODULE_DEFCONFIG=${MODULE_DEFCONFIG} MODULE_DEF_INCLUDE=${MODULE_DEF_INCLUDE} ARCH=${ARCH} SUBARCH=${SUBARCH} module )"
echo "# run as" >OUTPUT${KLIPS_MODULE}/doit.sh
echo "$cmd" >>OUTPUT${KLIPS_MODULE}/doit.sh
. OUTPUT${KLIPS_MODULE}/doit.sh
if [ -r OUTPUT${KLIPS_MODULE}/module/ipsec.o ]
then
success=true
fi
if [ -n "${KERNEL_CONFIG_FILE}" ]
then
if [ -z "${KERNEL_PATCH_LEAVE_SOURCE}" ]
then
rm -r ${KERNEL_CONFIG_FILE}
fi
fi
case "$success" in
true) exit 0 ;;
*) exit 1 ;;
esac
}
# test entry point:
module_compile() {
testdir=$1
testexpect=$2
echo '****MODULE COMPILE RUNNING' $testdir '*******'
export UML_BRAND="$$"
( preptest $testdir module_compile && do_module_compile_test )
stat=$?
if [ $stat = 99 ]
then
echo Test missing parts.
stat='missing parts'
fi
recordresults $testdir "$testexpect" "$stat" $testdir
}
###################################
#
# test type: umlXhost - a test with many hosts under control
#
###################################
do_umlX_test() {
prerunsetup
success=true
failnum=1
# these are network names
EASTOUTPUT=''
WESTOUTPUT=''
PUBOUTPUT=''
EXP2_ARGS=''
if [ -n "$EAST_INPUT" ]
then
EAST_PLAY=$EAST_INPUT export EAST_PLAY
fi
if [ -n "$WEST_INPUT" ]
then
WEST_PLAY=$WEST_INPUT export WEST_PLAY
fi
export NORTH_PLAY
export SOUTH_PLAY
if [ -n "$PUB_INPUT" ]
then
EXP2_ARGS="$EXP2_ARGS -p $PUB_INPUT"
fi
if [ -z "$XHOST_LIST" ]
then
XHOST_LIST="EAST WEST JAPAN"
fi
export XHOST_LIST
# Xhost script takes things from the environment.
for host in $XHOST_LIST
do
verboseecho "Processing exports for $host"
verboseecho
lhost=`echo $host | tr 'A-Z' 'a-z'`
local startvar
startvar=${host}_START
if [ -z "${!startvar}" ]
then
local startdir
local starthost
starthost=${host}HOST
startdir=$POOLSPACE/${!starthost}
if [ -n "$KLIPS_MODULE" ]
then
eval ${host}_START=$startdir/startmodule.sh
else
eval ${host}_START=$startdir/start.sh
fi
fi
export ${host}_START
eval "REF_${host}_CONSOLE_RAW=OUTPUT${KLIPS_MODULE}/${lhost}console.txt"
export REF_${host}_CONSOLE_RAW
export ${host}_INIT_SCRIPT
export ${host}_RUN_SCRIPT
export ${host}_RUN2_SCRIPT
export ${host}_RUN3_SCRIPT
export ${host}_RUN4_SCRIPT
export ${host}_RUN5_SCRIPT
export ${host}_FINAL_SCRIPT
done
for net in NORTH SOUTH NORTHPUBLIC SOUTHPUBLIC EAST WEST PUBLIC ADMIN
do
export ${net}_PLAY
export ${net}_REC
export ${net}_ARPREPLY
done
if [ -n "$REF_EAST_OUTPUT" ]
then
EASTOUTPUT=`basename $REF_EAST_OUTPUT .txt `
EXP2_ARGS="$EXP2_ARGS -E OUTPUT${KLIPS_MODULE}/$EASTOUTPUT.pcap"
fi
if [ -n "$REF_WEST_OUTPUT" ]
then
WESTOUTPUT=`basename $REF_WEST_OUTPUT .txt `
EXP2_ARGS="$EXP2_ARGS -W OUTPUT${KLIPS_MODULE}/$WESTOUTPUT.pcap"
fi
if [ -n "$REF_NORTH_OUTPUT" ]
then
NORTHOUTPUT=`basename $REF_NORTH_OUTPUT .txt `
NORTH_REC=OUTPUT${KLIPS_MODULE}/$EASTOUTPUT.pcap export NORTH_REC
fi
if [ -n "$REF_SOUTH_OUTPUT" ]
then
SOUTHOUTPUT=`basename $REF_SOUTH_OUTPUT .txt `
SOUTH_REC=OUTPUT${KLIPS_MODULE}/$WESTOUTPUT.pcap export SOUTH_REC
fi
if [ -n "$REF_PUB_OUTPUT" ]
then
PUBOUTPUT=`basename $REF_PUB_OUTPUT .txt`
EXP2_ARGS="$EXP2_ARGS -P OUTPUT${KLIPS_MODULE}/$PUBOUTPUT.pcap"
fi
if [ "X$ARPREPLY" = "X--arpreply" ]
then
EXP2_ARGS="$EXP2_ARGS -a"
fi
if [ -n "$NETJIG_EXTRA" ]
then
EXP2_ARGS="$EXP2_ARGS -N $NETJIG_EXTRA"
fi
EXP2_ARGS="$EXP2_ARGS "`setup_additional_hosts`
rm -f OUTPUT${KLIPS_MODULE}/eastconsole.txt
rm -f OUTPUT${KLIPS_MODULE}/westconsole.txt
rm -f OUTPUT${KLIPS_MODULE}/japanconsole.txt
cmd="expect -f $UTILS/Xhost-test.tcl -- -n $NJ $EXP2_ARGS "
$NETJIGDEBUG && echo $cmd
eval $cmd
pcap_filter west "$REF_WEST_OUTPUT" "$WESTOUTPUT" "$REF_WEST_FILTER"
pcap_filter east "$REF_EAST_OUTPUT" "$EASTOUTPUT" "$REF_EAST_FILTER"
pcap_filter public "$REF_PUB_OUTPUT" "$PUBOUTPUT" "$REF_PUB_FILTER"
for host in $XHOST_LIST
do
local consoleref
consoleref=REF_${host}_CONSOLE_OUTPUT
lhost=`echo $host | tr 'A-Z' 'a-z'`
if [ -n "${!consoleref}" ]
then
consolediff $lhost OUTPUT${KLIPS_MODULE}/${lhost}console.txt ${!consoleref}
fi
done
case "$success" in
true) exit 0 ;;
*) exit 1 ;;
esac
}
# test entry point:
umlXhost() {
testdir=$1
testexpect=$2
echo '***** UML 3HOST RUNNING' $testdir '*******'
export UML_BRAND="$$"
( preptest $testdir umlXhost && do_umlX_test )
stat=$?
recordresults $testdir "$testexpect" "$stat" $testdir
}
#
# $Id: functions.sh,v 1.108 2004/05/19 14:53:31 mcr Exp $
#
# $Log: functions.sh,v $
# Revision 1.108 2004/05/19 14:53:31 mcr
# call summarize results just before each test case.
#
# Revision 1.107 2004/04/16 19:57:29 mcr
# if THREEEIGHT is set to true, then do not run the
# three-eight filter.
#
# Revision 1.106 2004/04/09 18:30:05 mcr
# look in all sorts of places for the library code.
#
# Revision 1.105 2004/04/04 03:57:58 ken
# Change order of options to ps, as newer versions are more strict about order
#
# Revision 1.104 2004/04/03 19:44:52 ken
# FREESWANSRCDIR -> OPENSWANSRCDIR (patch by folken)
#
# Revision 1.103 2004/02/16 04:13:37 mcr
# use new NETWORK_ARPREPLY= to decide how/when to answer arp
# requests.
#
# Revision 1.102 2004/02/03 20:14:39 mcr
# networks are now managed as a list rather than explicitely.
#
# Revision 1.101 2003/11/25 00:22:53 mcr
# have skiptest make up a fake TEST_PURPOSE, so there are
# no complaints from regressrecord.
#
# Revision 1.100 2003/11/05 07:38:30 dhr
#
# make functions.sh more robust
#
# Revision 1.99 2003/11/05 04:35:56 dhr
#
# clarify shell variable export command
#
# Revision 1.98 2003/10/31 02:43:33 mcr
# pull up of port-selector tests
#
# Revision 1.97 2003/10/29 20:52:37 dhr
#
# functions.sh: silence grep; add "rogue" to status if rogue was found
#
# Revision 1.96 2003/10/28 03:03:33 dhr
#
# Refine testing scripts:
# - put timeout and eof handlers in each expect script
# - kill more rogue processes: even those with unreadable(!) /proc entries
# - improve reporting of skipped tests
# - make "recordresults" do more, simplifying every caller
# - speed up UML shutdown by using "halt -p -r" (requires many reference log updates)
#
# Revision 1.95 2003/10/21 15:08:03 dhr
#
# - show more raw detail within braces of testing report
# - make functions.sh clearer
# - silence the "kill" commands in function.sh that probe for successful killing
#
# Revision 1.94 2003/10/16 03:14:56 dhr
#
# Many minor improvements to functions.sh:
# - add quotes for good shell hygiene
# - try harder to kill rogue UML processes
# - use "case" to analyze $success (``if $success'' fails whe $success is "missing")
# The use of $success is still disorganized and confusing. With some work
# it could be used to produce better diagnostics.
#
# Revision 1.93 2003/10/16 02:56:47 dhr
#
# clean up whitespace
#
# Revision 1.92 2003/10/15 15:31:57 dhr
#
# functions.sh: let recordresults survive a testparams.sh that exits
#
# Revision 1.91 2003/10/14 22:07:09 dhr
#
# functions.sh: let recordresults survive a missing testparams.sh
#
# Revision 1.90 2003/10/14 14:23:29 dhr
#
# Fix some problems with "make check" (testing/utils/functions.sh):
# - Make sure that each "source" or "." command uses a pathname with a slash.
# Otherwise the $PATH will be used.
# - Fix the TEST_PURPOSE analysis: source testparams.sh in recordresults.
# Note when TEST_PURPOSE isn't understood.
# - remove redundant "rm -rf" commands
#
# Revision 1.89 2003/10/01 16:13:56 dhr
#
# Make the -modules hack in testing/klips/dotests.sh actually work:
# add ${KLIPS_MODULE} to almost every path with OUTPUT that didn't already have it.
#
# Revision 1.88.2.1 2003/10/29 02:09:56 mcr
# set test purpose to REGRESS for library tests.
#
# Revision 1.88 2003/08/21 22:38:06 mcr
# sense of test was wrong for MODULE_DEFCONFIG
#
# Revision 1.87 2003/08/21 22:35:11 mcr
# if we didn't specify a MODULE_DEFCONFIG, then use /dev/null
#
# Revision 1.86 2003/08/18 16:32:48 mcr
# export 3,4,5 RUN script variables.
#
# Revision 1.85 2003/05/21 14:10:31 mcr
# look for core files produced by pluto, and save them to the
# OUTPUT directory, changing failure state to "core".
#
# Revision 1.84 2003/05/03 23:26:02 mcr
# added RCS Ids.
#
#
|