Changeset 3082 for box/trunk/test
- Timestamp:
- 02/02/2012 22:20:29 (4 months ago)
- File:
-
- 1 edited
-
box/trunk/test/bbackupd/testbbackupd.cpp (modified) (70 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/test/bbackupd/testbbackupd.cpp
r2983 r3082 63 63 #include "FileModificationTime.h" 64 64 #include "FileStream.h" 65 #include "intercept.h" 65 66 #include "IOStreamGetLine.h" 66 67 #include "LocalProcessStream.h" … … 73 74 #include "Timer.h" 74 75 #include "Utils.h" 75 76 #include "intercept.h"77 #include "ServerControl.h"78 76 79 77 #include "MemLeakFindOn.h" … … 524 522 // Test the restoration 525 523 TEST_THAT(BackupClientRestore(protocol, restoredirid, 526 "Test1", "testfiles/restore-interrupt", 527 true /* print progress dots */) 528 == Restore_Complete); 524 "testfiles/restore-interrupt", /* remote */ 525 "testfiles/restore-interrupt", /* local */ 526 true /* print progress dots */, 527 false /* restore deleted */, 528 false /* undelete after */, 529 false /* resume */, 530 false /* keep going */) == Restore_Complete); 529 531 530 532 // Log out … … 651 653 } 652 654 655 Daemon* spDaemon = NULL; 656 653 657 int start_internal_daemon() 654 658 { … … 664 668 665 669 BackupDaemon daemon; 670 spDaemon = &daemon; // to propagate into child 666 671 int result; 667 672 … … 674 679 result = daemon.Main("testfiles/bbackupd.conf", 1, argv); 675 680 } 681 682 spDaemon = NULL; // to ensure not used by parent 676 683 677 684 TEST_EQUAL_LINE(0, result, "Daemon exit code"); … … 711 718 712 719 TEST_THAT(pid > 0); 720 spDaemon = &daemon; 713 721 return pid; 714 722 } … … 751 759 extern "C" struct dirent *readdir_test_hook_2(DIR *dir) 752 760 { 761 if (spDaemon->IsTerminateWanted()) 762 { 763 // force daemon to crash, right now 764 return NULL; 765 } 766 753 767 time_t time_now = time(NULL); 754 768 … … 838 852 } 839 853 854 bool compare_all(BackupQueries::ReturnCode::Type expected_status, 855 std::string config_file = "testfiles/bbackupd.conf") 856 { 857 std::string cmd = BBACKUPQUERY; 858 cmd += " "; 859 cmd += (expected_status == BackupQueries::ReturnCode::Compare_Same) 860 ? "-Werror" : "-Wwarning"; 861 cmd += " -c "; 862 cmd += config_file; 863 cmd += " \"compare -acQ\" quit"; 864 865 int returnValue = ::system(cmd.c_str()); 866 867 int expected_system_result = (int) expected_status; 868 869 #ifndef WIN32 870 expected_system_result <<= 8; 871 #endif 872 873 TEST_EQUAL_LINE(expected_system_result, returnValue, "compare return value"); 874 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 875 return (returnValue == expected_system_result); 876 } 877 878 #define TEST_COMPARE(...) \ 879 TEST_THAT(compare_all(BackupQueries::ReturnCode::__VA_ARGS__)); 880 840 881 int test_bbackupd() 841 882 { … … 980 1021 TEST_LINE(comp2 != sub, line); 981 1022 } 1023 1024 Timers::Init(); 982 1025 983 1026 if (failures > 0) 984 1027 { 985 1028 // stop early to make debugging easier 986 Timers::Init();987 1029 return 1; 988 1030 } … … 994 1036 intercept_setup_delay("testfiles/TestDir1/spacetest/f1", 995 1037 0, 4000, SYS_read, 1); 996 pid = start_internal_daemon(); 997 intercept_clear_setup(); 998 999 fd = open("testfiles/TestDir1/spacetest/f1", O_WRONLY); 1000 TEST_THAT(fd > 0); 1001 // write again, to update the file's timestamp 1002 TEST_EQUAL_LINE(sizeof(buffer), 1003 write(fd, buffer, sizeof(buffer)), 1004 "Buffer write"); 1005 TEST_THAT(close(fd) == 0); 1006 1007 wait_for_backup_operation("internal daemon to sync " 1008 "spacetest/f1 again"); 1009 // can't test whether intercept was triggered, because 1010 // it's in a different process. 1011 // TEST_THAT(intercept_triggered()); 1012 TEST_THAT(stop_internal_daemon(pid)); 1038 1039 { 1040 BackupDaemon bbackupd; 1041 bbackupd.Configure("testfiles/bbackupd.conf"); 1042 bbackupd.InitCrypto(); 1043 1044 fd = open("testfiles/TestDir1/spacetest/f1", O_WRONLY); 1045 TEST_THAT(fd > 0); 1046 // write again, to update the file's timestamp 1047 TEST_EQUAL_LINE(1, write(fd, "z", 1), "Buffer write"); 1048 TEST_THAT(close(fd) == 0); 1049 1050 // wait long enough to put file into sync window 1051 wait_for_operation(5, "locally modified file to " 1052 "mature for sync"); 1053 1054 bbackupd.RunSyncNow(); 1055 TEST_THAT(intercept_triggered()); 1056 intercept_clear_setup(); 1057 Timers::Cleanup(); 1058 } 1013 1059 1014 1060 // check that the diff was aborted, i.e. upload was not a diff … … 1316 1362 1317 1363 BOX_TRACE("Compare to check that there are differences"); 1318 int compareReturnValue = ::system(BBACKUPQUERY " " 1319 "-c testfiles/bbackupd.conf " 1320 "-l testfiles/query0a.log " 1321 "-Werror \"compare -acQ\" quit"); 1322 TEST_RETURN(compareReturnValue, 1323 BackupQueries::ReturnCode::Compare_Different); 1324 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1364 TEST_COMPARE(Compare_Different); 1325 1365 BOX_TRACE("Compare finished."); 1326 1366 … … 1384 1424 1385 1425 BackupDaemon bbackupd; 1426 1427 { 1428 const char* argv[] = { "bbackupd", 1429 bbackupd_args.c_str() }; 1430 TEST_EQUAL_LINE(0, bbackupd.ProcessOptions(2, argv), 1431 "processing command-line options"); 1432 } 1433 1386 1434 bbackupd.Configure("testfiles/bbackupd-exclude.conf"); 1387 1435 bbackupd.InitCrypto(); … … 1554 1602 // Run another backup, now there should be enough space 1555 1603 // for everything we want to upload. 1556 { 1557 Logging::Guard guard(Log::ERROR); 1558 bbackupd.RunSyncNow(); 1559 } 1604 bbackupd.RunSyncNow(); 1560 1605 TEST_THAT(!bbackupd.StorageLimitExceeded()); 1561 1606 1562 1607 // Check that the contents of the store are the same 1563 1608 // as the contents of the disc 1564 // (-a = all, -c = give result in return code) 1565 BOX_TRACE("Check that all files were uploaded successfully"); 1566 compareReturnValue = ::system(BBACKUPQUERY " " 1567 "-c testfiles/bbackupd-exclude.conf " 1568 "-l testfiles/query1.log " 1569 "-Wwarning \"compare -acQ\" quit"); 1570 TEST_RETURN(compareReturnValue, 1571 BackupQueries::ReturnCode::Compare_Same); 1572 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1609 TEST_COMPARE(Compare_Same, "testfiles/bbackupd-exclude.conf"); 1573 1610 BOX_TRACE("done."); 1574 1611 … … 1634 1671 // (-a = all, -c = give result in return code) 1635 1672 BOX_TRACE("Check that all files were uploaded successfully"); 1636 compareReturnValue = ::system(BBACKUPQUERY " " 1637 "-c testfiles/bbackupd.conf " 1638 "-l testfiles/query1.log " 1639 "-Wwarning \"compare -acQ\" quit"); 1640 TEST_RETURN(compareReturnValue, 1641 BackupQueries::ReturnCode::Compare_Same); 1642 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1673 TEST_COMPARE(Compare_Same); 1643 1674 BOX_TRACE("done."); 1644 1675 … … 1827 1858 1828 1859 // Check that the backup was successful, i.e. no differences 1829 int compareReturnValue = ::system(BBACKUPQUERY " " 1830 "-c testfiles/bbackupd.conf " 1831 "-l testfiles/query1.log " 1832 "-Wwarning \"compare -acQ\" quit"); 1833 TEST_RETURN(compareReturnValue, 1834 BackupQueries::ReturnCode::Compare_Same); 1835 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 1860 TEST_COMPARE(Compare_Same); 1836 1861 1837 1862 // now stop bbackupd and update the test file, … … 1849 1874 1850 1875 // check that we can restore it 1851 compareReturnValue = ::system(BBACKUPQUERY " " 1852 "-c testfiles/bbackupd.conf " 1853 "-Wwarning \"restore Test1 testfiles/restore-symlink\" " 1854 "quit"); 1855 TEST_RETURN(compareReturnValue, 1856 BackupQueries::ReturnCode::Command_OK); 1876 { 1877 int returnValue = ::system(BBACKUPQUERY " " 1878 "-c testfiles/bbackupd.conf " 1879 "-Wwarning \"restore Test1 testfiles/restore-symlink\" " 1880 "quit"); 1881 TEST_RETURN(returnValue, 1882 BackupQueries::ReturnCode::Command_OK); 1883 } 1857 1884 1858 1885 // make it accessible again … … 1922 1949 #endif // !WIN32 1923 1950 1924 // Check that no read error has been reported yet 1925 TEST_THAT(!TestFileExists("testfiles/notifyran.read-error.1")); 1926 1927 printf("\n==== Testing that redundant locations are deleted on time\n"); 1928 1929 // unpack the files for the redundant location test 1951 printf("\n==== Testing that nonexistent locations are backed up " 1952 "if they are created later\n"); 1953 1954 // ensure that the directory does not exist at the start 1930 1955 TEST_THAT(::system("rm -rf testfiles/TestDir2") == 0); 1956 1957 // BLOCK 1958 { 1959 // Kill the daemon 1960 terminate_bbackupd(bbackupd_pid); 1961 1962 // Delete any old result marker files 1963 TEST_RETURN(0, system("rm -f testfiles/notifyran.*")); 1964 1965 // Start it with a config that has a temporary location 1966 // whose path does not exist yet 1967 std::string cmd = BBACKUPD " " + bbackupd_args + 1968 " testfiles/bbackupd-temploc.conf"; 1969 1970 bbackupd_pid = LaunchServer(cmd, "testfiles/bbackupd.pid"); 1971 TEST_THAT(bbackupd_pid != -1 && bbackupd_pid != 0); 1972 1973 TEST_THAT(ServerIsAlive(bbackupd_pid)); 1974 TEST_THAT(ServerIsAlive(bbstored_pid)); 1975 if (!ServerIsAlive(bbackupd_pid)) return 1; 1976 if (!ServerIsAlive(bbstored_pid)) return 1; 1977 1978 TEST_THAT(!TestFileExists("testfiles/notifyran.backup-start.1")); 1979 TEST_THAT(!TestFileExists("testfiles/notifyran.backup-start.2")); 1980 TEST_THAT(!TestFileExists("testfiles/notifyran.read-error.1")); 1981 TEST_THAT(!TestFileExists("testfiles/notifyran.read-error.2")); 1982 TEST_THAT(!TestFileExists("testfiles/notifyran.backup-ok.1")); 1983 TEST_THAT(!TestFileExists("testfiles/notifyran.backup-finish.1")); 1984 TEST_THAT(!TestFileExists("testfiles/notifyran.backup-finish.2")); 1985 1986 sync_and_wait(); 1987 TEST_COMPARE(Compare_Same); 1988 1989 TEST_THAT( TestFileExists("testfiles/notifyran.backup-start.1")); 1990 TEST_THAT(!TestFileExists("testfiles/notifyran.backup-start.2")); 1991 TEST_THAT( TestFileExists("testfiles/notifyran.read-error.1")); 1992 TEST_THAT(!TestFileExists("testfiles/notifyran.read-error.2")); 1993 TEST_THAT(!TestFileExists("testfiles/notifyran.backup-ok.1")); 1994 TEST_THAT( TestFileExists("testfiles/notifyran.backup-finish.1")); 1995 TEST_THAT(!TestFileExists("testfiles/notifyran.backup-finish.2")); 1996 1997 // Did it actually get created? Should not have been! 1998 std::auto_ptr<BackupProtocolClient> client = 1999 ConnectAndLogin(context, 2000 BackupProtocolLogin::Flags_ReadOnly); 2001 2002 std::auto_ptr<BackupStoreDirectory> dir = 2003 ReadDirectory(*client); 2004 int64_t testDirId = SearchDir(*dir, "Test2"); 2005 TEST_THAT(testDirId == 0); 2006 client->QueryFinished(); 2007 sSocket.Close(); 2008 } 2009 2010 // create the location directory and unpack some files into it 1931 2011 TEST_THAT(::mkdir("testfiles/TestDir2", 0777) == 0); 1932 2012 … … 1939 2019 #endif 1940 2020 2021 // check that the files are backed up now 2022 sync_and_wait(); 2023 TEST_COMPARE(Compare_Same); 2024 2025 TEST_THAT( TestFileExists("testfiles/notifyran.backup-start.2")); 2026 TEST_THAT(!TestFileExists("testfiles/notifyran.backup-start.3")); 2027 TEST_THAT( TestFileExists("testfiles/notifyran.read-error.1")); 2028 TEST_THAT(!TestFileExists("testfiles/notifyran.read-error.2")); 2029 TEST_THAT( TestFileExists("testfiles/notifyran.backup-ok.1")); 2030 TEST_THAT(!TestFileExists("testfiles/notifyran.backup-ok.2")); 2031 TEST_THAT( TestFileExists("testfiles/notifyran.backup-finish.2")); 2032 TEST_THAT(!TestFileExists("testfiles/notifyran.backup-finish.3")); 2033 2034 // BLOCK 2035 { 2036 std::auto_ptr<BackupProtocolClient> client = 2037 ConnectAndLogin(context, 2038 BackupProtocolLogin::Flags_ReadOnly); 2039 2040 std::auto_ptr<BackupStoreDirectory> dir = 2041 ReadDirectory(*client, 2042 BackupProtocolListDirectory::RootDirectory); 2043 int64_t testDirId = SearchDir(*dir, "Test2"); 2044 TEST_THAT(testDirId != 0); 2045 2046 client->QueryFinished(); 2047 sSocket.Close(); 2048 } 2049 2050 printf("\n==== Testing that redundant locations are deleted on time\n"); 2051 1941 2052 // BLOCK 1942 2053 { … … 1944 2055 terminate_bbackupd(bbackupd_pid); 1945 2056 1946 // Start it with a config that has a temporary location 1947 // that will be created on the server 1948 std::string cmd = BBACKUPD " " + bbackupd_args + 1949 " testfiles/bbackupd-temploc.conf"; 1950 2057 // Start it again with the normal config (no Test2) 2058 cmd = BBACKUPD " " + bbackupd_args + " testfiles/bbackupd.conf"; 1951 2059 bbackupd_pid = LaunchServer(cmd, "testfiles/bbackupd.pid"); 2060 1952 2061 TEST_THAT(bbackupd_pid != -1 && bbackupd_pid != 0); 2062 1953 2063 ::safe_sleep(1); 1954 2064 … … 1958 2068 if (!ServerIsAlive(bbstored_pid)) return 1; 1959 2069 1960 sync_and_wait(); 2070 // Test2 should be deleted after 10 seconds (4 runs) 2071 wait_for_sync_end(); 2072 wait_for_sync_end(); 2073 wait_for_sync_end(); 2074 2075 // not yet! should still be there 1961 2076 1962 2077 { … … 1974 2089 } 1975 2090 1976 // Kill the daemon1977 terminate_bbackupd(bbackupd_pid);1978 1979 // Start it again with the normal config (no Test2)1980 cmd = BBACKUPD " " + bbackupd_args +1981 " testfiles/bbackupd.conf";1982 bbackupd_pid = LaunchServer(cmd, "testfiles/bbackupd.pid");1983 1984 TEST_THAT(bbackupd_pid != -1 && bbackupd_pid != 0);1985 1986 ::safe_sleep(1);1987 1988 TEST_THAT(ServerIsAlive(bbackupd_pid));1989 TEST_THAT(ServerIsAlive(bbstored_pid));1990 if (!ServerIsAlive(bbackupd_pid)) return 1;1991 if (!ServerIsAlive(bbstored_pid)) return 1;1992 1993 // Test2 should be deleted after 10 seconds (4 runs)1994 wait_for_sync_end();1995 wait_for_sync_end();1996 wait_for_sync_end();1997 1998 // not yet! should still be there1999 2000 {2001 std::auto_ptr<BackupProtocolClient> client =2002 ConnectAndLogin(context,2003 BackupProtocolLogin::Flags_ReadOnly);2004 2005 std::auto_ptr<BackupStoreDirectory> dir =2006 ReadDirectory(*client);2007 int64_t testDirId = SearchDir(*dir, "Test2");2008 TEST_THAT(testDirId != 0);2009 2010 client->QueryFinished();2011 sSocket.Close();2012 }2013 2014 2091 wait_for_sync_end(); 2015 2092 … … 2038 2115 if(bbackupd_pid > 0) 2039 2116 { 2040 // Check that no read error has been reported yet2041 TEST_ THAT(!TestFileExists("testfiles/notifyran.read-error.1"));2117 // Delete any old result marker files 2118 TEST_RETURN(0, system("rm -f testfiles/notifyran.*")); 2042 2119 2043 2120 printf("\n==== Check that read-only directories and " … … 2252 2329 2253 2330 // Compare to check that the file was uploaded 2254 compareReturnValue = ::system(BBACKUPQUERY " -Wwarning " 2255 "-c testfiles/bbackupd.conf \"compare -acQ\" quit"); 2256 TEST_RETURN(compareReturnValue, 2257 BackupQueries::ReturnCode::Compare_Same); 2258 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2331 TEST_COMPARE(Compare_Same); 2259 2332 2260 2333 // Check that we can find it in directory listing … … 2508 2581 2509 2582 // check that no backup has run (compare fails) 2510 compareReturnValue = ::system(BBACKUPQUERY " " 2511 "-Werror " 2512 "-c testfiles/bbackupd.conf " 2513 "-l testfiles/query3.log " 2514 "\"compare -acQ\" quit"); 2515 TEST_RETURN(compareReturnValue, 2516 BackupQueries::ReturnCode::Compare_Different); 2517 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2583 TEST_COMPARE(Compare_Different); 2518 2584 2519 2585 TEST_THAT(unlink(sync_control_file) == 0); … … 2534 2600 2535 2601 wait_for_sync_end(); 2602 2536 2603 // check that backup has run (compare succeeds) 2537 compareReturnValue = ::system(BBACKUPQUERY " " 2538 "-Wwarning " 2539 "-c testfiles/bbackupd.conf " 2540 "-l testfiles/query3a.log " 2541 "\"compare -acQ\" quit"); 2542 TEST_RETURN(compareReturnValue, 2543 BackupQueries::ReturnCode::Compare_Same); 2544 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2604 TEST_COMPARE(Compare_Same); 2545 2605 2546 2606 if (failures > 0) … … 2594 2654 2595 2655 // compare to make sure that it worked 2596 compareReturnValue = ::system(BBACKUPQUERY " -Wwarning " 2597 "-c testfiles/bbackupd.conf " 2598 "-l testfiles/query2.log " 2599 "\"compare -acQ\" quit"); 2600 TEST_RETURN(compareReturnValue, 2601 BackupQueries::ReturnCode::Compare_Same); 2602 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2656 TEST_COMPARE(Compare_Same); 2603 2657 2604 2658 // Try a quick compare, just for fun … … 2675 2729 // Check that we DO get errors on compare (cannot do this 2676 2730 // until after we fix the store, which creates a race) 2677 compareReturnValue = ::system(BBACKUPQUERY " " 2678 "-c testfiles/bbackupd.conf " 2679 "-l testfiles/query3b.log " 2680 "-Werror \"compare -acQ\" quit"); 2681 TEST_RETURN(compareReturnValue, 2682 BackupQueries::ReturnCode::Compare_Different); 2683 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2731 TEST_COMPARE(Compare_Different); 2684 2732 2685 2733 // Test initial state … … 2706 2754 2707 2755 // Should not have backed up, should still get errors 2708 compareReturnValue = ::system(BBACKUPQUERY " " 2709 "-c testfiles/bbackupd.conf " 2710 "-l testfiles/query3b.log " 2711 "-Werror \"compare -acQ\" quit"); 2712 TEST_RETURN(compareReturnValue, 2713 BackupQueries::ReturnCode::Compare_Different); 2714 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2756 TEST_COMPARE(Compare_Different); 2715 2757 2716 2758 // wait another 10 seconds, bbackup should have run … … 2720 2762 2721 2763 // Check that it did get uploaded, and we have no more errors 2722 compareReturnValue = ::system(BBACKUPQUERY " " 2723 "-c testfiles/bbackupd.conf " 2724 "-l testfiles/query3b.log " 2725 "-Wwarning \"compare -acQ\" quit"); 2726 TEST_RETURN(compareReturnValue, 2727 BackupQueries::ReturnCode::Compare_Same); 2728 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2764 TEST_COMPARE(Compare_Same); 2729 2765 2730 2766 TEST_THAT(::unlink("testfiles/notifyscript.tag") == 0); … … 2775 2811 // Check that we DO get errors on compare (cannot do this 2776 2812 // until after we fix the store, which creates a race) 2777 compareReturnValue = ::system(BBACKUPQUERY " " 2778 "-c testfiles/bbackupd.conf " 2779 "-l testfiles/query3b.log " 2780 "-Werror \"compare -acQ\" quit"); 2781 TEST_RETURN(compareReturnValue, 2782 BackupQueries::ReturnCode::Compare_Different); 2783 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2813 TEST_COMPARE(Compare_Different); 2784 2814 2785 2815 // Test initial state … … 2806 2836 2807 2837 // Should not have backed up, should still get errors 2808 compareReturnValue = ::system(BBACKUPQUERY " " 2809 "-c testfiles/bbackupd.conf " 2810 "-l testfiles/query3b.log " 2811 "-Werror \"compare -acQ\" quit"); 2812 TEST_RETURN(compareReturnValue, 2813 BackupQueries::ReturnCode::Compare_Different); 2814 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2838 TEST_COMPARE(Compare_Different); 2815 2839 2816 2840 // wait another 10 seconds, bbackup should have run … … 2820 2844 2821 2845 // Check that it did get uploaded, and we have no more errors 2822 compareReturnValue = ::system(BBACKUPQUERY " " 2823 "-c testfiles/bbackupd.conf " 2824 "-l testfiles/query3b.log " 2825 "-Wwarning \"compare -acQ\" quit"); 2826 TEST_RETURN(compareReturnValue, 2827 BackupQueries::ReturnCode::Compare_Same); 2828 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2846 TEST_COMPARE(Compare_Same); 2829 2847 2830 2848 TEST_THAT(::unlink("testfiles/notifyscript.tag") == 0); … … 2859 2877 2860 2878 wait_for_backup_operation("bbackupd to sync the changes"); 2861 compareReturnValue = ::system(BBACKUPQUERY " " 2862 "-c testfiles/bbackupd.conf " 2863 "-l testfiles/query3c.log " 2864 "-Wwarning \"compare -acQ\" quit"); 2865 TEST_RETURN(compareReturnValue, 2866 BackupQueries::ReturnCode::Compare_Same); 2867 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2879 TEST_COMPARE(Compare_Same); 2868 2880 2869 2881 TEST_THAT(ServerIsAlive(bbackupd_pid)); … … 2889 2901 wait_for_backup_operation("bbackupd to sync the changes"); 2890 2902 2891 compareReturnValue = ::system(BBACKUPQUERY " " 2892 "-c testfiles/bbackupd.conf " 2893 "-l testfiles/query3d.log " 2894 "-Wwarning \"compare -acQ\" quit"); 2895 TEST_RETURN(compareReturnValue, 2896 BackupQueries::ReturnCode::Compare_Same); 2897 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2903 TEST_COMPARE(Compare_Same); 2898 2904 2899 2905 TEST_THAT(ServerIsAlive(bbackupd_pid)); … … 2922 2928 wait_for_backup_operation("bbackupd to sync the changes"); 2923 2929 2924 compareReturnValue = ::system(BBACKUPQUERY " " 2925 "-c testfiles/bbackupd.conf " 2926 "-l testfiles/query3e.log " 2927 "-Wwarning \"compare -acQ\" quit"); 2928 TEST_RETURN(compareReturnValue, 2929 BackupQueries::ReturnCode::Compare_Same); 2930 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2930 TEST_COMPARE(Compare_Same); 2931 2931 2932 2932 TEST_THAT(ServerIsAlive(bbackupd_pid)); … … 2955 2955 wait_for_backup_operation("bbackupd to sync the changes"); 2956 2956 2957 compareReturnValue = ::system(BBACKUPQUERY " " 2958 "-c testfiles/bbackupd.conf " 2959 "-l testfiles/query3f.log " 2960 "-Wwarning \"compare -acQ\" quit"); 2961 TEST_RETURN(compareReturnValue, 2962 BackupQueries::ReturnCode::Compare_Same); 2963 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2957 TEST_COMPARE(Compare_Same); 2964 2958 2965 2959 TEST_THAT(ServerIsAlive(bbackupd_pid)); … … 2990 2984 "untracked files"); 2991 2985 2992 compareReturnValue = ::system(BBACKUPQUERY " " 2993 "-c testfiles/bbackupd.conf " 2994 "-l testfiles/query3g.log " 2995 "-Wwarning \"compare -acQ\" quit"); 2996 TEST_RETURN(compareReturnValue, 2997 BackupQueries::ReturnCode::Compare_Same); 2998 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 2986 TEST_COMPARE(Compare_Same); 2999 2987 3000 2988 #ifdef WIN32 … … 3011 2999 "files again"); 3012 3000 3013 compareReturnValue = ::system(BBACKUPQUERY " " 3014 "-c testfiles/bbackupd.conf " 3015 "-l testfiles/query3g.log " 3016 "-Wwarning \"compare -acQ\" quit"); 3017 TEST_RETURN(compareReturnValue, 3018 BackupQueries::ReturnCode::Compare_Same); 3019 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3001 TEST_COMPARE(Compare_Same); 3020 3002 3021 3003 TEST_THAT(ServerIsAlive(bbackupd_pid)); … … 3051 3033 3052 3034 // compare to make sure that it worked 3053 compareReturnValue = ::system(BBACKUPQUERY " " 3054 "-c testfiles/bbackupd.conf " 3055 "-l testfiles/query3h.log " 3056 "-Wwarning \"compare -acQ\" quit"); 3057 TEST_RETURN(compareReturnValue, 3058 BackupQueries::ReturnCode::Compare_Same); 3059 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3035 TEST_COMPARE(Compare_Same); 3060 3036 3061 3037 #ifdef WIN32 … … 3072 3048 "files again"); 3073 3049 3074 compareReturnValue = ::system(BBACKUPQUERY " " 3075 "-c testfiles/bbackupd.conf " 3076 "-l testfiles/query3i.log " 3077 "-Wwarning \"compare -acQ\" quit"); 3078 TEST_RETURN(compareReturnValue, 3079 BackupQueries::ReturnCode::Compare_Same); 3080 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3050 TEST_COMPARE(Compare_Same); 3081 3051 3082 3052 TEST_THAT(ServerIsAlive(bbackupd_pid)); … … 3094 3064 wait_for_backup_operation("bbackupd to sync"); 3095 3065 3096 compareReturnValue = ::system(BBACKUPQUERY " " 3097 "-c testfiles/bbackupd.conf " 3098 "-l testfiles/query3j.log " 3099 "-Wwarning \"compare -acQ\" quit"); 3100 TEST_RETURN(compareReturnValue, 3101 BackupQueries::ReturnCode::Compare_Same); 3102 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3066 TEST_COMPARE(Compare_Same); 3103 3067 3104 3068 // Check that no read error has been reported yet … … 3133 3097 wait_for_backup_operation("bbackupd to sync old files"); 3134 3098 3135 compareReturnValue = ::system(BBACKUPQUERY " " 3136 "-c testfiles/bbackupd.conf " 3137 "-l testfiles/query3k.log " 3138 "-Wwarning \"compare -acQ\" quit"); 3139 TEST_RETURN(compareReturnValue, 3140 BackupQueries::ReturnCode::Compare_Same); 3141 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3099 TEST_COMPARE(Compare_Same); 3142 3100 3143 3101 TEST_THAT(ServerIsAlive(bbackupd_pid)); … … 3195 3153 wait_for_sync_end(); // should (not) be backed up this time 3196 3154 3197 compareReturnValue = ::system(BBACKUPQUERY " " 3198 "-c testfiles/bbackupd.conf " 3199 "-l testfiles/query3l.log " 3200 "-Wwarning \"compare -acQ\" quit"); 3201 TEST_RETURN(compareReturnValue, 3202 BackupQueries::ReturnCode::Compare_Same); 3203 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3155 TEST_COMPARE(Compare_Same); 3204 3156 3205 3157 TEST_THAT(ServerIsAlive(bbackupd_pid)); … … 3227 3179 3228 3180 // compare with exclusions, should not find differences 3229 compareReturnValue = ::system(BBACKUPQUERY " " 3230 "-c testfiles/bbackupd.conf " 3231 "-l testfiles/query3m.log " 3232 "-Wwarning \"compare -acQ\" quit"); 3233 TEST_RETURN(compareReturnValue, 3234 BackupQueries::ReturnCode::Compare_Same); 3235 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3181 TEST_COMPARE(Compare_Same); 3236 3182 3237 3183 // compare without exclusions, should find differences … … 3259 3205 BackupProtocolLogin::Flags_ReadOnly); 3260 3206 3261 std::auto_ptr<BackupStoreDirectory> dir = ReadDirectory(3262 *client);3207 std::auto_ptr<BackupStoreDirectory> dir = 3208 ReadDirectory(*client); 3263 3209 3264 3210 int64_t testDirId = SearchDir(*dir, "Test1"); … … 3316 3262 wait_for_backup_operation("bbackupd to try to sync " 3317 3263 "unreadable file"); 3318 compareReturnValue = ::system(BBACKUPQUERY " " 3319 "-c testfiles/bbackupd.conf " 3320 "-l testfiles/query3o.log " 3321 "-Werror \"compare -acQ\" quit"); 3322 3323 // should find differences 3324 TEST_RETURN(compareReturnValue, 3325 BackupQueries::ReturnCode::Compare_Error); 3326 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3264 3265 // should fail with an error due to unreadable file 3266 TEST_COMPARE(Compare_Error); 3327 3267 3328 3268 // Check that it was reported correctly … … 3422 3362 "of directory"); 3423 3363 3424 compareReturnValue = ::system(BBACKUPQUERY " " 3425 "-c testfiles/bbackupd.conf " 3426 "-l testfiles/query4.log " 3427 "-Werror \"compare -acQ\" quit"); 3428 TEST_RETURN(compareReturnValue, 3429 BackupQueries::ReturnCode::Compare_Same); 3430 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3364 TEST_COMPARE(Compare_Same); 3431 3365 3432 3366 printf("\n==== Restore files and directories\n"); … … 3437 3371 std::auto_ptr<BackupProtocolClient> client = 3438 3372 ConnectAndLogin(context, 3439 BackupProtocolLogin::Flags_ReadOnly);3373 BackupProtocolLogin::Flags_ReadOnly); 3440 3374 3441 3375 // Find the ID of the Test1 directory … … 3446 3380 // Test the restoration 3447 3381 TEST_THAT(BackupClientRestore(*client, restoredirid, 3448 "Test1", "testfiles/restore-Test1", 3449 true /* print progress dots */) 3382 "Test1" /* remote */, 3383 "testfiles/restore-Test1" /* local */, 3384 true /* print progress dots */, 3385 false /* restore deleted */, 3386 false /* undelete after */, 3387 false /* resume */, 3388 false /* keep going */) 3450 3389 == Restore_Complete); 3451 3390 … … 3456 3395 TEST_THAT(BackupClientRestore(*client, restoredirid, 3457 3396 "Test1", "testfiles/restore-Test1", 3458 true /* print progress dots */) 3397 true /* print progress dots */, 3398 false /* restore deleted */, 3399 false /* undelete after */, 3400 false /* resume */, 3401 false /* keep going */) 3459 3402 == Restore_TargetExists); 3460 3403 … … 3466 3409 // properly later (when bbackupd is stopped) 3467 3410 TEST_THAT(BackupClientRestore(*client, deldirid, 3468 "Test1", "testfiles/restore-Test1-x1", 3411 "Test1", "testfiles/restore-Test1-x1", 3469 3412 true /* print progress dots */, 3470 true /* deleted files */) 3413 true /* restore deleted */, 3414 false /* undelete after */, 3415 false /* resume */, 3416 false /* keep going */) 3471 3417 == Restore_Complete); 3472 3418 … … 3481 3427 restoredirid, "Test1", 3482 3428 "testfiles/no-such-path/subdir", 3483 true /* print progress dots */) 3429 true /* print progress dots */, 3430 true /* restore deleted */, 3431 false /* undelete after */, 3432 false /* resume */, 3433 false /* keep going */) 3484 3434 == Restore_TargetPathNotFound); 3485 3435 } … … 3491 3441 3492 3442 // Compare the restored files 3493 compareReturnValue = ::system(BBACKUPQUERY " " 3494 "-c testfiles/bbackupd.conf " 3495 "-l testfiles/query10.log " 3496 "-Wwarning " 3497 "\"compare -cEQ Test1 testfiles/restore-Test1\" " 3498 "quit"); 3499 TEST_RETURN(compareReturnValue, 3500 BackupQueries::ReturnCode::Compare_Same); 3501 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3443 TEST_COMPARE(Compare_Same); 3502 3444 3503 3445 TEST_THAT(ServerIsAlive(bbackupd_pid)); … … 3512 3454 TEST_RETURN(compareReturnValue, 0); 3513 3455 3514 compareReturnValue = ::system(BBACKUPQUERY " " 3515 "-c testfiles/bbackupd.conf " 3516 "-l testfiles/query10a.log " 3517 "-Werror " 3518 "\"compare -cEQ Test1 testfiles/restore-Test1\" " 3519 "quit"); 3520 TEST_RETURN(compareReturnValue, 3521 BackupQueries::ReturnCode::Compare_Different); 3522 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3456 TEST_COMPARE(Compare_Different); 3523 3457 3524 3458 // set it back, expect no failures … … 3527 3461 TEST_RETURN(compareReturnValue, 0); 3528 3462 3529 compareReturnValue = ::system(BBACKUPQUERY " " 3530 "-c testfiles/bbackupd.conf -l testfiles/query10a.log " 3531 "-Wwarning " 3532 "\"compare -cEQ Test1 testfiles/restore-Test1\" " 3533 "quit"); 3534 TEST_RETURN(compareReturnValue, 3535 BackupQueries::ReturnCode::Compare_Same); 3536 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3463 TEST_COMPARE(Compare_Same); 3537 3464 3538 3465 // change the timestamp on a file, expect a compare failure … … 3553 3480 TEST_THAT(set_file_time(testfile, dummyTime, lastModTime, 3554 3481 lastAccessTime)); 3555 compareReturnValue = ::system(BBACKUPQUERY " " 3556 "-c testfiles/bbackupd.conf " 3557 "-l testfiles/query10a.log " 3558 "-Werror " 3559 "\"compare -cEQ Test1 testfiles/restore-Test1\" " 3560 "quit"); 3561 TEST_RETURN(compareReturnValue, 3562 BackupQueries::ReturnCode::Compare_Different); 3563 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3482 3483 TEST_COMPARE(Compare_Different); 3564 3484 3565 3485 // last access time is not backed up, so it cannot be compared 3566 3486 TEST_THAT(set_file_time(testfile, creationTime, lastModTime, 3567 3487 dummyTime)); 3568 compareReturnValue = ::system(BBACKUPQUERY " " 3569 "-c testfiles/bbackupd.conf " 3570 "-l testfiles/query10a.log " 3571 "-Wwarning " 3572 "\"compare -cEQ Test1 testfiles/restore-Test1\" " 3573 "quit"); 3574 TEST_RETURN(compareReturnValue, 3575 BackupQueries::ReturnCode::Compare_Same); 3576 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3488 TEST_COMPARE(Compare_Same); 3577 3489 3578 3490 // last write time is backed up, so changing it should cause … … 3580 3492 TEST_THAT(set_file_time(testfile, creationTime, dummyTime, 3581 3493 lastAccessTime)); 3582 compareReturnValue = ::system(BBACKUPQUERY " " 3583 "-c testfiles/bbackupd.conf " 3584 "-l testfiles/query10a.log " 3585 "-Werror " 3586 "\"compare -cEQ Test1 testfiles/restore-Test1\" " 3587 "quit"); 3588 TEST_RETURN(compareReturnValue, 3589 BackupQueries::ReturnCode::Compare_Different); 3590 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3494 TEST_COMPARE(Compare_Different); 3591 3495 3592 3496 // set back to original values, check that compare succeeds 3593 3497 TEST_THAT(set_file_time(testfile, creationTime, lastModTime, 3594 3498 lastAccessTime)); 3595 compareReturnValue = ::system(BBACKUPQUERY " " 3596 "-c testfiles/bbackupd.conf " 3597 "-l testfiles/query10a.log " 3598 "-Wwarning " 3599 "\"compare -cEQ Test1 testfiles/restore-Test1\" " 3600 "quit"); 3601 TEST_RETURN(compareReturnValue, 3602 BackupQueries::ReturnCode::Compare_Same); 3603 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3499 TEST_COMPARE(Compare_Same); 3604 3500 #endif // WIN32 3605 3501 … … 3624 3520 wait_for_backup_operation("bbackupd to sync new files"); 3625 3521 3626 compareReturnValue = ::system(BBACKUPQUERY " " 3627 "-c testfiles/bbackupd.conf " 3628 "-l testfiles/query5.log " 3629 "-Wwarning \"compare -acQ\" quit"); 3630 TEST_RETURN(compareReturnValue, 3631 BackupQueries::ReturnCode::Compare_Same); 3632 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3522 TEST_COMPARE(Compare_Same); 3633 3523 3634 3524 TEST_THAT(ServerIsAlive(bbackupd_pid)); … … 3644 3534 wait_for_backup_operation("bbackupd to sync renamed directory"); 3645 3535 3646 compareReturnValue = ::system(BBACKUPQUERY " " 3647 "-c testfiles/bbackupd.conf " 3648 "-l testfiles/query6.log " 3649 "-Wwarning \"compare -acQ\" quit"); 3650 TEST_RETURN(compareReturnValue, 3651 BackupQueries::ReturnCode::Compare_Same); 3652 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3536 TEST_COMPARE(Compare_Same); 3653 3537 3654 3538 // and again, but with quick flag … … 3672 3556 wait_for_backup_operation("bbackupd to sync renamed files"); 3673 3557 3674 compareReturnValue = ::system(BBACKUPQUERY " " 3675 "-c testfiles/bbackupd.conf " 3676 "-l testfiles/query6.log " 3677 "-Wwarning \"compare -acQ\" quit"); 3678 TEST_RETURN(compareReturnValue, 3679 BackupQueries::ReturnCode::Compare_Same); 3680 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3558 TEST_COMPARE(Compare_Same); 3681 3559 3682 3560 TEST_THAT(ServerIsAlive(bbackupd_pid)); … … 3715 3593 // Wait and test 3716 3594 wait_for_backup_operation("bbackup to sync future file"); 3717 compareReturnValue = ::system(BBACKUPQUERY " " 3718 "-c testfiles/bbackupd.conf " 3719 "-l testfiles/query3e.log " 3720 "-Wwarning \"compare -acQ\" quit"); 3721 TEST_RETURN(compareReturnValue, 3722 BackupQueries::ReturnCode::Compare_Same); 3723 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3595 TEST_COMPARE(Compare_Same); 3724 3596 3725 3597 TEST_THAT(ServerIsAlive(bbackupd_pid)); … … 3786 3658 3787 3659 // Test that there *are* differences 3788 compareReturnValue = ::system(BBACKUPQUERY " " 3789 "-c testfiles/bbackupd.conf " 3790 "-l testfiles/query6.log " 3791 "-Werror \"compare -acQ\" quit"); 3792 TEST_RETURN(compareReturnValue, 3793 BackupQueries::ReturnCode::Compare_Different); 3794 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3660 TEST_COMPARE(Compare_Different); 3795 3661 3796 3662 TEST_THAT(ServerIsAlive(bbackupd_pid)); … … 3828 3694 TEST_THAT(BackupClientRestore(*client, restoredirid, 3829 3695 "Test1", "testfiles/restore-interrupt", 3830 true /* print progress dots */) 3696 true /* print progress dots */, 3697 false /* restore deleted */, 3698 false /* undelete after */, 3699 false /* resume */, 3700 false /* keep going */) 3831 3701 == Restore_ResumePossible); 3832 3702 … … 3835 3705 "Test1", "testfiles/restore-interrupt", 3836 3706 true /* print progress dots */, 3837 false /* deleted files */, 3838 false /* undelete server */, 3839 true /* resume */) 3707 false /* restore deleted */, 3708 false /* undelete after */, 3709 true /* resume */, 3710 false /* keep going */) 3840 3711 == Restore_Complete); 3841 3712 … … 3871 3742 true /* print progress dots */, 3872 3743 true /* deleted files */, 3873 true /* undelete on server */) 3744 true /* undelete after */, 3745 false /* resume */, 3746 false /* keep going */) 3874 3747 == Restore_Complete); 3875 3748 … … 3961 3834 // compare, and check that it works 3962 3835 // reports the correct error message (and finishes) 3963 compareReturnValue = ::system(BBACKUPQUERY " " 3964 "-c testfiles/bbackupd.conf " 3965 "-l testfiles/query15a.log " 3966 "-Wwarning \"compare -acQ\" quit"); 3967 TEST_RETURN(compareReturnValue, 3968 BackupQueries::ReturnCode::Compare_Same); 3969 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3836 TEST_THAT(compare_all(false)); 3970 3837 } 3971 3838 … … 3983 3850 TEST_THAT(handle != INVALID_HANDLE_VALUE); 3984 3851 3985 compareReturnValue = ::system(BBACKUPQUERY " " 3986 "-c testfiles/bbackupd.conf " 3987 "-l testfiles/query15.log " 3988 "-Werror \"compare -acQ\" quit"); 3989 TEST_RETURN(compareReturnValue, 3990 BackupQueries::ReturnCode::Compare_Error); 3991 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3852 TEST_COMPARE(Compare_Error); 3992 3853 3993 3854 // close the file again, check that compare … … 4003 3864 if (handle != 0) 4004 3865 { 4005 compareReturnValue = ::system(BBACKUPQUERY " " 4006 "-c testfiles/bbackupd.conf " 4007 "-l testfiles/query15a.log " 4008 "-Wwarning \"compare -acQ\" quit"); 4009 TEST_RETURN(compareReturnValue, 4010 BackupQueries::ReturnCode::Compare_Same); 4011 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3866 TEST_COMPARE(Compare_Same); 4012 3867 } 4013 3868 #endif … … 4034 3889 (TIME_TO_WAIT_FOR_BACKUP_OPERATION*3) / 2, 4035 3890 "bbackupd to sync everything"); 4036 compareReturnValue = ::system(BBACKUPQUERY " " 4037 "-c testfiles/bbackupd.conf " 4038 "-l testfiles/query4a.log " 4039 "-Wwarning \"compare -acQ\" quit"); 4040 TEST_RETURN(compareReturnValue, 4041 BackupQueries::ReturnCode::Compare_Same); 4042 TestRemoteProcessMemLeaks("bbackupquery.memleaks"); 3891 TEST_COMPARE(Compare_Same); 4043 3892 4044 3893 // Kill it again
Note: See TracChangeset
for help on using the changeset viewer.
