1#!/usr/bin/env bash 2 3# Uncomment to get core dumps if segfaults are happening. 4ulimit -c unlimited 5 6myscript=$(basename $0) 7if [ ! -f "$myscript" ] ; then 8 echo "Please run $myscript whilst standing in the same directory" 1>&2 9 exit 1 10fi 11 12target="$1" 13burpbin="$2" 14clientconf="$3" 15clientconfarg="$4" 16includedir="$5" 17restoredir="$6" 18serveraddress="$7" 19sshclient="$8" 20scpclient="$9" 21clientaddress="${10}" 22 23if [ -z "$target" ] ; then 24 echo "target directory not given." 25 exit 1 26fi 27if [ -z "$burpbin" ] ; then 28 echo "location of burp binary not given." 29 exit 1 30fi 31if [ -z "$clientconf" ] ; then 32 echo "location of client config file not given." 33 exit 1 34fi 35if [ -z "$clientconfarg" ] ; then 36 echo "client config arg not given." 37 exit 1 38fi 39if [ -z "$includedir" ] ; then 40 echo "location of directory to backup not given ." 41 exit 1 42fi 43if [ -z "$restoredir" ] ; then 44 echo "location of directory to restore to not given ." 45 exit 1 46fi 47if [ -z "$serveraddress" ] ; then 48 echo "server address not given ." 49 exit 1 50fi 51 52# The Windows build symlinks cock things for 'diff -ur' on the restore later, 53# so delete them first. 54rm -f ../burp-depkgs 55rm -f ../burp-cross-tools 56 57excludedir="$includedir/src" 58logs="$PWD/logs" 59serverlog="$logs/server.log" 60clientlog="$logs/client.log" 61difflog="$logs/diff.log" 62serverpid= 63serverconf=etc/burp/burp-server.conf 64serverscript="$PWD/serverscript" 65clientscript="$PWD/clientscript" 66num=0 # Test number. Incremented for each test. 67bno=0 # Backup number. Incremented for each backup. 68pre=0 # Previous backup number. 69res=0 # Restore number. Incremented for each restore. 70test_includes_backup=0 71test_includes_restore=0 72protocol=2 73 74if stat --version 2>/dev/null | grep GNU &>/dev/null ; then 75 # GNU style 76 stat_args="-c '%g:%u %A %N'" 77else 78 # FreeBSD style 79 stat_args="-f '%g:%u %p %N %Y'" 80fi 81 82kill_server() 83{ 84 if [ -n "$serverpid" ] ; then 85 echo "Killing test server" 86 kill -9 $serverpid 87 serverpid= 88 fi 89} 90 91trap "kill_server" 0 1 2 3 15 92 93fail() 94{ 95 backup_and_restore_nums=$(get_backup_and_restore_nums) 96 echo 97 echo "Test $num failed: $@ $backup_and_restore_nums" 98 echo 99 kill_server 100 exit 1 101} 102 103makedir_server() 104{ 105 rm -rf "$1" 106 mkdir -p "$1" || fail "could not mkdir $1" 107} 108 109makedir_client() 110{ 111 cat >> "$clientscript" << EOF 112rm -rf "$1" 113mkdir -p "$1" || fail "could not mkdir $1" 114EOF 115} 116 117cdir() 118{ 119 cd "$1" || fail "could not cd to $1" 120} 121 122sed_rep_server() 123{ 124 conf="$serverconf" 125 [ -n "$2" ] && conf="$2" 126 cat >> "$serverscript" << EOF 127sed -i -e "$1" "$conf" || fail "sed $1 failed $2" 128EOF 129} 130 131append_server() 132{ 133 conf="$serverconf" 134 [ -n "$2" ] && conf="$2" 135 cat >> "$serverscript" << EOF 136echo "$1" >> "$conf" || fail "echo $1 failed" 137EOF 138 139} 140sed_rep_client() 141{ 142 cat >> "$clientscript" << EOF 143sed -i -e "$1" "$clientconf" || fail "sed $1 failed $2" 144EOF 145} 146 147append_client() 148{ 149 conf="$clientconf" 150 [ -n "$2" ] && conf="$2" 151 cat >> "$clientscript" << EOF 152echo "$1" >> "$conf" || fail "echo $1 failed" 153EOF 154} 155 156wait_for_backup_to_finish() 157{ 158 local waited=0 159 local lockfile="$target/var/spool/burp/testclient/lockfile" 160 [ "$protocol" = "2" ] && \ 161 lockfile="$target/var/spool/burp/global/clients/testclient/lockfile" 162 163 SLEEPTIME=2 164 # Repeatedly check to see whether the server has finished, rather 165 # than just sleeping some length of time. 166 while true ; do 167 sleep $SLEEPTIME 168 [ ! -e "$lockfile" ] && break 169 read pid < "$lockfile" 170 [ -z "$pid" -o ! -d "/proc/$pid" ] && break 171 waited=$((waited+$SLEEPTIME)) 172 [ "$waited" -gt 120 ] && \ 173 fail "client backup seemed to be complete after 2 minutes" 174 done 175} 176 177add_run_list() 178{ 179cat >> "$clientscript" <<EOF 180echo "Starting test client list" 181"$burpbin" -c "$clientconfarg" -a l -b "$1" || fail "client list returned \$?" 182 183EOF 184} 185 186add_run_list_expect_fail() 187{ 188cat >> "$clientscript" <<EOF 189echo "Starting test client list" 190"$burpbin" -c "$clientconfarg" -a l -b "$1" && fail "client list returned \$?" 191 192EOF 193} 194 195add_run_backup_no_increment() 196{ 197cat >> "$clientscript" <<EOF 198echo "Starting test client backup" 199"$burpbin" -c "$clientconfarg" -a b || fail "client backup returned \$?" 200 201EOF 202} 203 204increment() 205{ 206 pre=$bno 207 bno=$((bno+1)) 208} 209 210add_run_backup() 211{ 212 increment 213 test_includes_backup=1 214 add_run_backup_no_increment 215} 216 217add_run_backup_expect_fail_no_increment() 218{ 219cat >> "$clientscript" <<EOF 220echo "Starting test client backup" 221"$burpbin" -c "$clientconfarg" -a b && fail "client backup returned \$? (expected non-zero)" 222 223EOF 224} 225 226add_run_backup_expect_fail() 227{ 228 increment 229 add_run_backup_expect_fail_no_increment 230} 231 232add_run_verify() 233{ 234 local bno="all" 235cat >> "$clientscript" <<EOF 236echo "Starting test client verify of backup $bno" 237"$burpbin" -c "$clientconfarg" -a v -b "$bno" \ 238 || fail "client verify returned \$?" 239EOF 240} 241 242add_run_restore() 243{ 244 local bno="$1" 245 local dir 246 res=$((res+1)) 247 dir="$2$res" 248 test_includes_restore=1 249 makedir_client "$dir" 250# If vss has been stripped, need to add the '-X' option to the restore. 251 nowinapi= 252 [ -n "$STRIP_VSS" -a "$protocol" = 1 ] && nowinapi='-X' 253cat >> "$clientscript" << EOF 254echo "Starting test client restore of backup $bno" 255rm -rf "$dir" || fail 256 257"$burpbin" -c "$clientconfarg" -a r -b "$bno" -d "$dir" $nowinapi \ 258 || fail "client restore returned \$?" 259EOF 260} 261 262add_run_restore_server_initiated() 263{ 264 local bno="$1" 265 local dir 266 res=$((res+1)) 267 dir="$2$res" 268 test_includes_restore=1 269 local srestore="$target/var/spool/burp/testclient/restore" 270 271 append_client 'restoreprefix = /' 272 273 [ "$PROTOCOL" = "2" ] && \ 274 srestore="$target/var/spool/burp/global/clients/testclient/restore" 275 276 echo "backup=$bno 277restoreprefix=$dir" > "$srestore" 278 makedir_client "$dir" 279cat >> "$clientscript" << EOF 280echo "Starting test server initiated restore of backup $bno" 281rm -rf "$dir" || fail 282 283"$burpbin" -c "$clientconfarg" -a l \ 284 || fail "server initiated restore returned \$?" 285EOF 286} 287 288add_run_snapshot() 289{ 290 cat >> "$clientscript" <<EOF 291[ -d "/cygdrive" ] \ 292 && echo "Status snapshot not supported on Windows" && exit 0 293"$burpbin" -c "$clientconfarg" -a S | grep testclient \ 294 || fail "Status snapshot did not show testclient" 295"$burpbin" -c "$clientconfarg" -a S -C testclient | grep 0000001 \ 296 || fail "Status snapshot did not show backup 0000001" 297EOF 298} 299 300do_diff_server() 301{ 302 diff -ur "$1" "$2" >>"$difflog" 2>&1 || fail "$3" 303} 304 305add_do_diff_client() 306{ 307 # On Windows, /C:/ gets converted to /C_/, so tweak the path for diff. 308 rpath1=$(echo "$1" | sed -e 's/\/C:\//\/C_\//g') 309 rpath2=$(echo "$2" | sed -e 's/\/C:\//\/C_\//g') 310 # Protocol 2 directory permissions are messed up on windows, so 311 # exclude them for now. 312 extra_find_arg= 313 if [ "$protocol" = "2" ] \ 314 && [ "$restoredir" = "C:/Program Files/Burp/restore" ] ; then 315 extra_find_arg="-type f" 316 fi 317 318 # FIX THIS: On windows, the builders directory is being EFS 319 # encrypted. But, for some reason, the permissions come out 320 # wrong on restore. Exclude them from the permission check 321 # for now. 322 exclude_dir= 323 if [ "$restoredir" = "C:/Program Files/Burp/restore" ] ; then 324 exclude_dir="| grep -v builders" 325 fi 326 327cat >> "$clientscript" << EOF 328diff -ur "$rpath1" "$rpath2" || fail "$3" 329EOF 330 331 # Stripping vss in protocol 1 will of course cause permissions to be 332 # wrong on restore on Windows, so do not do this check in that case. 333[ -z "$STRIP_VSS" -o "$protocol" = 2 ] && cat >> "$clientscript" << EOF 334diff -u \ 335 <( cd "$rpath1" ; find . $extra_find_arg -print0 | xargs -0 stat $stat_args | sort $exclude_dir) \ 336 <( cd "$rpath2" ; find . $extra_find_arg -print0 | xargs -0 stat $stat_args | sort $exclude_dir) \ 337 || fail "$3 (permissions)" 338 339 rm -rf "$rpath2" 340EOF 341} 342 343add_chown() 344{ 345 cat >> "$clientscript" << EOF 346chmod "$1" "$2" || fail "chown $1 $2 failed" 347EOF 348} 349 350write_message() 351{ 352 message="$1" 353 echo "$message" 354 echo "$message" >> $serverlog 355 echo "$message" >> $clientlog 356 echo "$message" >> $difflog 357} 358 359start_test() 360{ 361 msg="$1" 362 num=$((num+1)) 363 test_includes_backup=0 364 test_includes_restore=0 365 write_message " 366Test $num 367$msg" 368 add_normal_settings 369} 370 371add_change_source_files() 372{ 373cat >> "$clientscript" <<EOF 374cp -r "$includedir/src" "$includedir/src-new" \ 375 || fail "could not cp $includedir/src to $includedir/src-new" 376 377# Move a directory, which simulates deleting and adding new files. 378if [ -d "$includedir/configs" ] \ 379 && [ ! -e "$includedir/configs-new" ] ; then 380 mv "$includedir/configs" "$includedir/configs-new" \ 381 || fail "could not move $includedir/configs to $includedir/configs-new" 382elif [ ! -e "$includedir/configs" ] \ 383 && [ -d "$includedir/configs-new" ] ; then 384 mv "$includedir/configs-new" "$includedir/configs" \ 385 || fail "could not move $includedir/configs-new to $includedir/configs" 386else 387 fail "could not move directory to simulate deletion/addition" 388fi 389 390# Scramble a whole bunch of files 391# On Windows, need to specify the whole path to find and sort, or the Windows 392# versions are picked up instead. 393sortprog="sort --random-sort" 394which shuffle >/dev/null 2>&1 && sortprog=shuffle 395/usr/bin/find "$includedir/autoconf" -type f | while read f ; do 396 LC_ALL='C' \$sortprog "\$f" > tmpfile 397 [ "$?" != "0" ] && exit 1 398 mv tmpfile "\$f" || exit 1 399done || fail "randomise files failed" 400EOF 401} 402 403add_compression_off() 404{ 405 sed_rep_server '/^compression = .*/d' 406 append_server 'compression = 0' 407} 408 409add_compression_on() 410{ 411 sed_rep_server '/^compression = .*/d' 412 append_server 'compression = 9' 413} 414 415add_encryption_off() 416{ 417 sed_rep_client '/^encryption_password = .*/d' 418} 419 420add_encryption_on() 421{ 422 add_encryption_off 423 append_client 'encryption_password = 012345678901234567890123456789' 424} 425 426add_include_off() 427{ 428 sed_rep_client '/^include = .*/d' 429} 430 431add_include_on() 432{ 433 add_include_off 434 append_client "include = $includedir" 435} 436 437add_split_vss_off() 438{ 439 sed_rep_client '/^split_vss = .*/d' "$clientconf" 440} 441 442add_split_vss_on() 443{ 444 add_split_vss_off 445 append_client "split_vss = 1" 446} 447 448add_strip_vss_off() 449{ 450 sed_rep_client '/^strip_vss = .*/d' "$clientconf" 451} 452 453add_strip_vss_on() 454{ 455 add_strip_vss_off 456 append_client "strip_vss = 1" 457} 458 459add_protocol_off() 460{ 461 sed_rep_client '/^protocol = .*/d' "$clientconf" 462} 463 464maybe_add_protocol2_on() 465{ 466 add_protocol_off 467 [ "$protocol" = 2 ] && \ 468 append_client 'protocol = 2' 469} 470 471add_server_listen_status_off() 472{ 473 sed_rep_server '/^listen_status = .*/d' "$serverconf" 474} 475 476add_server_listen_status_on() 477{ 478 add_server_listen_status_off 479 append_server "listen_status = 127.0.0.1:4999" 480} 481 482add_server_breakpoint_off() 483{ 484 sed_rep_server '/^breakpoint = .*/d' "$serverconf" 485} 486 487add_server_breakpoint_on() 488{ 489 add_server_breakpoint_off 490 append_server "breakpoint = $1" 491} 492 493add_client_breakpoint_off() 494{ 495 sed_rep_client '/^breakpoint = .*/d' "$clientconf" 496} 497 498add_client_breakpoint_on() 499{ 500 add_client_breakpoint_off 501 append_client "breakpoint = $1" 502} 503 504add_client_server_can_restore_off() 505{ 506 sed_rep_client '/^server_can_restore = .*/d' "$clientconf" 507} 508 509add_client_server_can_restore_on() 510{ 511 add_client_server_can_restore_off 512 append_client "server_can_restore = 1" 513} 514 515add_recovery_method_delete() 516{ 517 sed_rep_server 's/^working_dir_recovery_method = .*/working_dir_recovery_method = delete/g' 518} 519 520add_recovery_method_resume() 521{ 522 sed_rep_server 's/^working_dir_recovery_method = .*/working_dir_recovery_method = resume/g' 523} 524 525makedir_server "$logs" 526 527cdir "$target" 528 529start_script() 530{ 531 cat > "$1" << EOF 532#!/usr/bin/env bash 533 534fail() 535{ 536 echo 537 echo "Test $num failed: \$@" 538 echo 539 exit 1 540} 541 542EOF 543} 544 545start_script_server() 546{ 547 start_script "$serverscript" 548} 549 550start_script_client() 551{ 552 start_script "$clientscript" 553} 554 555# Tweak the example configuration files by removing the leading '/' from all 556# the paths, and changing the port numbers. 557pre_tweaks_server() 558{ 559 start_script_server 560 sed_rep_server 's#= /#= '"$target"'/#g' 561 sed_rep_server 's/listen = 0.0.0.0:4971/listen = 0.0.0.0:4998/g' 562 sed_rep_server 's#^CA_DIR.*#CA_DIR = '"$target"'/etc/burp/CA#g' "$target/etc/burp/CA.cnf" 563 sed_rep_server 's/^stdout = .*/stdout = 1/g' 564 sed_rep_server 's/^syslog = .*/syslog = 0/g' 565} 566 567pre_tweaks_client() 568{ 569 start_script_client 570 sed_rep_client 's#= /#= '"$target"'/#g' 571 sed_rep_client 's/port = 4972/port = 4999/g' 572 sed_rep_client 's/^stdout = .*/stdout = 1/g' 573 sed_rep_client 's/^syslog = .*/syslog = 0/g' 574 sed_rep_client 's/^server = .*/server = '"$serveraddress":4998'/g' "$clientconf" 575 sed_rep_client 's/^cname = .*/cname = testclient/g' "$clientconf" 576 sed_rep_client 's/^password = .*/password = abcdefgh/g' "$clientconf" 577} 578 579run_script_server() 580{ 581 echo 'exit 0' >> "$serverscript" 582 chmod 755 "$serverscript" \ 583 || fail "chmod 755 $serverscript failed" 584 "$serverscript" >> "$serverlog" \ 585 || fail "$serverscript failed" 586 rm -f "$serverscript" 587} 588 589run_script_client() 590{ 591 echo 'exit 0' >> "$clientscript" 592 if [ -n "$sshclient" ] ; then 593 bname=$(basename "$clientscript") 594 $scpclient "$clientscript" "$clientaddress:" \ 595 || fail "Could not copy $clientscript to client" 596 $sshclient $clientaddress chmod 755 "$bname" \ 597 || fail "Could not chmod 755 $clientscript on client" 598 $sshclient $clientaddress "./$bname" >> "$clientlog" \ 599 || fail "$clientscript failed on client" 600 $sshclient $clientaddress rm -f "$clientscript" 601 else 602 chmod 755 "$clientscript" \ 603 || fail "chmod 755 $clientscript failed" 604 "$clientscript" >> "$clientlog" \ 605 || fail "$clientscript failed" 606 fi 607 rm -f "$clientscript" 608} 609 610get_backup_and_restore_nums() 611{ 612 if [ $test_includes_backup != 0 ] ; then 613 if [ $test_includes_restore != 0 ] ; then 614 echo "(backup $bno, restore $res)" 615 else 616 echo "(backup $bno)" 617 fi 618 else 619 if [ $test_includes_restore != 0 ] ; then 620 echo "(restore $res)" 621 fi 622 fi 623} 624 625end_test() 626{ 627 run_script_client 628 backup_and_restore_nums=$(get_backup_and_restore_nums) 629 write_message "Test $num OK $backup_and_restore_nums" 630 sleep 3 631} 632 633run_scripts() 634{ 635 run_script_server 636 run_script_client 637} 638 639add_backup_run_scripts_setup_verify_restore() 640{ 641 add_run_backup 642 run_scripts 643 wait_for_backup_to_finish 644 start_script_client 645 add_run_verify 646 add_run_restore $bno "$restoredir" 647} 648 649add_normal_settings() 650{ 651 start_script_server 652 start_script_client 653 maybe_add_protocol2_on 654 add_compression_on 655 add_encryption_off 656 add_include_on 657 add_server_breakpoint_off 658 add_client_breakpoint_off 659 add_recovery_method_resume 660 add_server_listen_status_on 661 662 # Windows options 663 if [ -n "$SPLIT_VSS" ] ; then 664 add_split_vss_on 665 else 666 add_split_vss_off 667 fi 668 if [ -n "$STRIP_VSS" ] ; then 669 add_strip_vss_on 670 else 671 add_strip_vss_off 672 fi 673} 674 675add_restore_diff() 676{ 677 add_do_diff_client \ 678 "$includedir" \ 679 "$restoredir"$res/"$includedir" \ 680 "client restore differed from the original!" 681} 682 683if [ -z "$NO_CA_GEN" ] ; then 684 pre_tweaks_server 685 pre_tweaks_client 686 run_scripts 687fi 688 689echo 690echo "Starting tests" 691echo " Server log: $serverlog" 692echo " Client log: $clientlog" 693echo " Diff log: $difflog" 694echo "More logs can be found in:" 695echo "$target/var/spool/burp/testclient/<backup number>" 696echo 697 698if [ -z "$NO_CA_GEN" ] ; then 699 echo "Initialising server certificate authority" 700 # Need to do this outside of the server, 701 # because it might take a long time. 702 ./usr/sbin/burp -c "$serverconf" -g >> "$serverlog" 2>&1 \ 703 || fail "Initialising server certificate authority failed" 704 echo 705fi 706 707restart_server() 708{ 709 kill_server 710 # Start up the server 711 echo "Starting test server" 712 ./usr/sbin/burp -c "$serverconf" -F >> "$serverlog" 2>&1 & 713 serverpid=$! 714 715 # Be kind, and wait a little for it to start. 716 sleep 5 717} 718 719sighup_server() 720{ 721 kill -1 $serverpid 722} 723 724comp_enc_change_test() 725{ 726 local comp="$1" 727 local encr="$2" 728 local change="$3" 729 730 start_test "Compression $comp, encryption $encr, change files $change" 731 add_compression_$comp 732 add_encryption_$encr 733 [ "$change" = "on" ] && add_change_source_files 734 add_chown 644 "$includedir/utest/test_cmd.c" 735 add_backup_run_scripts_setup_verify_restore 736 add_restore_diff 737 end_test 738} 739 740check_for_working_dir() 741{ 742 [ -h "$workingdir" ] || fail "$workingdir is not a symlink" 743 [ -d "$workingdir/" ] || fail "$workingdir/ is not a directory" 744 [ -e "$finishingdir" ] && fail "$finishingdir should not exist" 745} 746 747check_for_finishing_dir() 748{ 749 [ -h "$finishingdir" ] || fail "$finishingdir is not a symlink" 750 [ -d "$finishingdir/" ] || fail "$finishingdir/ is not a directory" 751 [ -e "$workingdir" ] && fail "$workingdir should not exist" 752} 753 754all_tests() 755{ 756 start_test "Interrupt server phase1" 757 add_server_breakpoint_on 1 758 add_run_backup_expect_fail_no_increment 759 run_scripts 760 check_for_working_dir 761 end_test 762 763 start_test "Interrupt client phase1" 764 add_client_breakpoint_on 1 765 add_run_backup_expect_fail_no_increment 766 run_scripts 767 check_for_working_dir 768 end_test 769 770 comp_enc_change_test on off off 771 772 # Server should come back after a sighup reload. 773 sighup_server 774 775 start_test "Interrupt server phase2" 776 add_server_breakpoint_on 2 777 add_run_backup_expect_fail_no_increment 778 run_scripts 779 wait_for_backup_to_finish 780 check_for_working_dir 781 end_test 782 783 start_test "Interrupt server phase3" 784 add_server_breakpoint_on 3 785 add_run_backup_no_increment 786 run_scripts 787 wait_for_backup_to_finish 788 check_for_working_dir 789 end_test 790 791 start_test "Complete phase3" 792 add_server_breakpoint_off 793 if [ "$protocol" -eq "1" ] ; then 794 # Client gives an error on protocol1, while the server does 795 # the resume. 796 add_run_backup_expect_fail 797 else 798 add_run_backup 799 fi 800 test_includes_backup=1 801 run_scripts 802 wait_for_backup_to_finish 803 start_script_client 804 add_run_verify 805 add_run_restore $bno "$restoredir" 806 add_restore_diff 807 end_test 808 809 start_test "List" 810 add_run_list $bno 811 add_run_list_expect_fail 99999 812 run_scripts 813 end_test 814 815 # Currently no way to pass '-x' via server initiated restore, so skip 816 # this test for $STRIP_VSS. 817 if [ -z "$STRIP_VSS" ] ; then 818 start_test "Server-initiated restore" 819 start_script_server 820 start_script_client 821 add_client_server_can_restore_on 822 add_run_restore_server_initiated $bno "$restoredir" 823 add_restore_diff 824 run_scripts 825 end_test 826 fi 827 828 start_test "Status monitor snapshot" 829 add_run_snapshot 830 end_test 831 832 start_test "Interrupt server phase4" 833 add_server_breakpoint_on 4 834 add_run_backup_no_increment 835 run_scripts 836 wait_for_backup_to_finish 837 check_for_finishing_dir 838 end_test 839 840 start_test "Complete phase4" 841 add_server_breakpoint_off 842 add_run_backup_expect_fail 843 test_includes_backup=1 844 run_scripts 845 wait_for_backup_to_finish 846 start_script_client 847 add_run_verify 848 add_run_restore $bno "$restoredir" 849 add_restore_diff 850 end_test 851 852 start_test "Interrupt server middle of phase2" 853 add_server_breakpoint_on 2010 854 add_change_source_files 855 add_run_backup_expect_fail_no_increment 856 run_scripts 857 wait_for_backup_to_finish 858 check_for_working_dir 859 end_test 860 861 start_test "Interrupt server middle of phase2" 862 add_server_breakpoint_on 2100 863 add_run_backup_expect_fail_no_increment 864 run_scripts 865 wait_for_backup_to_finish 866 check_for_working_dir 867 end_test 868 869 start_test "Interrupt server middle of phase2" 870 add_server_breakpoint_on 2200 871 add_run_backup_expect_fail_no_increment 872 run_scripts 873 wait_for_backup_to_finish 874 check_for_working_dir 875 end_test 876 877 start_test "Complete phase2" 878 add_server_breakpoint_off 879 add_backup_run_scripts_setup_verify_restore 880 add_restore_diff 881 end_test 882 883 comp_enc_change_test on off off 884 comp_enc_change_test on off on 885 comp_enc_change_test off off on 886 if [ "$PROTOCOL" != "2" ] ; then 887 # Encryption not supported in protocol 2. 888 comp_enc_change_test off on on 889 comp_enc_change_test on on on 890 fi 891 892 start_test "Permissions" 893 add_chown 755 "$includedir/utest/test_cmd.c" 894 add_backup_run_scripts_setup_verify_restore 895 add_restore_diff 896 end_test 897} 898 899run_tests() 900{ 901 protocol="$1" 902 num=0 903 bno=0 904 pre=0 905 res=0 906 echo 907 echo "Running protocol $protocol tests" 908 all_tests 909} 910 911restart_server 912 913if [ "$PROTOCOL" = 1 ] ; then 914 workingdir="$target/var/spool/burp/testclient/working" 915 finishingdir="$target/var/spool/burp/testclient/finishing" 916elif [ "$PROTOCOL" = 2 ] ; then 917 workingdir="$target/var/spool/burp/global/clients/testclient/working" 918 finishingdir="$target/var/spool/burp/global/clients/testclient/finishing" 919else 920 echo "Unknown protocol: $PROTOCOL" 921 exit 1 922fi 923 924run_tests "$PROTOCOL" 925 926echo 927echo "All tests succeeded" 928echo 929 930exit 0 931