]> git.sur5r.net Git - bacula/bacula/blob - regress/regress/win32/scripts/functions.cmd
0396fe1925bea782682e0acb8d971abe470eb0a7
[bacula/bacula] / regress / regress / win32 / scripts / functions.cmd
1 REM
2 REM A set of useful functions to be sourced in each test
3 REM
4
5 SET routine=%1
6 SHIFT
7
8 GOTO %routine%
9
10 :start_test
11    ECHO.
12    ECHO.
13    ECHO  === Starting %TestName% at %TIME% ===
14    ECHO  === Starting %TestName% at %TIME% === >>working\log
15    ECHO.
16    GOTO :EOF
17
18 :set_debug
19    SET debug=%1
20    IF "%debug%" EQU 1 (
21      SET out=tee
22    ) ELSE (
23      SET out=output
24    )
25    GOTO :EOF
26
27 :run_bacula
28    IF %debug% EQU 1 (
29       CALL scripts\bacula start
30       bin\bconsole -c bin\bconsole.conf <tmp\bconcmds
31    ) ELSE (
32       CALL scripts\bacula start >nul 2>&1
33       bin\bconsole -c bin\bconsole.conf <tmp\bconcmds >nul 2>&1
34    )
35    GOTO :EOF
36
37 :run_bconsole
38    IF %debug% EQU 1 (
39       bin\bconsole -c bin\bconsole.conf <tmp\bconcmds
40    ) ELSE (
41       bin\bconsole -c bin\bconsole.conf <tmp\bconcmds >nul 2>&1
42    )
43    GOTO :EOF
44
45 :run_btape
46    IF %debug% EQU 1 (
47       bin\btape -c bin\bacula-sd.conf DDS-4 <tmp\bconcmds | tee tmp\log1.out
48    ) ELSE (
49       bin\btape -c bin\bacula-sd.conf DDS-4 <tmp\bconcmds >tmp\log1.out 2>&1
50    )
51    GOTO :EOF
52
53 :run_bscan
54    IF %debug% EQU 1 (
55       bin\bscan %1 %2 %3 %4 %5 %6 %7 %8 %9 | tee tmp\log.out
56    ) ELSE (
57       bin\bscan %1 %2 %3 %4 %5 %6 %7 %8 %9 >nul 2>&1
58    )
59    GOTO :EOF
60
61 :stop_bacula
62    CALL scripts\bacula stop >nul 2>&1
63    GOTO :EOF
64
65 :check_for_zombie_jobs
66    CALL scripts\check_for_zombie_jobs %1 %2
67    GOTO :EOF
68
69 :change_jobname
70    IF "%2" == "" (
71       SET oldname=NightlySave
72       SET newname=%1
73    ) ELSE (
74       SET oldname=%1
75       SET newname=%2
76    )
77    IF EXIST bin\1 DEL /f bin\1
78    REN bin\bacula-dir.conf 1
79    sed -e "s;%oldname%;%newname%;g" bin\1 >bin\bacula-dir.conf
80 REM  ECHO Job %oldname% changed to %newname%
81    GOTO :EOF
82
83 :check_two_logs
84    grep "^  Termination: *Backup OK" tmp\log1.out >nul 2>&1
85    SET bstat=%ERRORLEVEL%
86    grep "^  Termination: *Restore OK" tmp\log2.out >nul 2>&1
87    SET rstat=%ERRORLEVEL%
88    GOTO :EOF
89
90 :check_restore_diff
91    diff -r build tmp\bacula-restores\%CD::=%\build >nul 2>&1
92    SET dstat=%ERRORLEVEL%
93    GOTO :EOF
94
95 :check_restore_tmp_build_diff
96    diff -r tmp\build tmp\bacula-restores\%CD::=%\tmp\build >nul 2>&1
97    SET dstat=%ERRORLEVEL%
98    GOTO :EOF
99
100 :end_test
101    SET /a errcount=%bstat% + %rstat% + %dstat%
102    IF %errcount% NEQ 0 (
103       ECHO.
104       ECHO.
105       ECHO   !!!!! %TestName% Bacula source failed!!! !!!!!
106       ECHO   !!!!! %TestName% failed!!! !!!!! >>test.out
107       IF %dstat% NEQ 0 (
108          ECHO   !!!!! Restored files differ          !!!!!
109          ECHO   !!!!! Restored files differ          !!!!! >>test.out
110       ) ELSE (
111          ECHO   !!!!! Bad Job termination status     !!!!!
112          ECHO   !!!!! Bad Job termination status     !!!!! >>test.out
113       )
114       ECHO.
115    ) ELSE (
116       ECHO   ===== %TestName% Bacula source OK %TIME% =====
117       ECHO   ===== %TestName% OK %TIME% ===== >>test.out
118       IF %debug% EQU 0 scripts\cleanup
119    )
120    SET errcount=
121    GOTO :EOF
122
123 :copy_tape_confs
124    CALL scripts\copy-tape-confs >nul 2>&1
125    CALL scripts\cleanup-tape
126    GOTO :EOF
127
128 :copy_test_confs
129    CALL scripts\copy-test-confs >nul 2>&1
130    CALL scripts\cleanup
131    GOTO :EOF