Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 3.22 KB | None | 0 0
  1. @echo off
  2. if "%1" == "" goto help
  3.  
  4. set C=
  5. set I=
  6. set T=
  7. call cfg.bat %1 %2
  8.  
  9. if "%I%" == "" goto unk
  10. if "%1" == "_chk_" goto check
  11. if "%1" == "_gen_" goto generate
  12. if "%2" == "gen" goto gen
  13. goto test
  14.  
  15. :unk
  16. echo.
  17. echo %T% - NIEZNANE ZADANIE!
  18. echo.
  19. goto end
  20.  
  21.  
  22. :help
  23. echo.
  24. echo Sposob uzycia:
  25. echo   ocen.bat id_zadania [ nr_testu ]
  26. echo.
  27. goto end
  28.  
  29. :generate
  30. set I=%2
  31. set N=%3
  32. set N=%3
  33. if not exist %I%.exe goto err_exe
  34. if not exist %DIR%IN\%I%%N%.in goto err_in
  35. if exist %I%.in  del %I%.in
  36. rem if exist %I%.out del %I%.out
  37. copy %DIR%IN\%I%%N%.in %I%.in > nul
  38. break on
  39. %DIR%BIN\timer.exe %I%.exe
  40. echo.
  41. if errorlevel 1 goto err_3
  42. rem if not exist %I%.out goto err_2
  43. copy %I%.out %DIR%OUT\%I%%N%.out > nul
  44. if exist %I%.in del %I%.in
  45. if exist %I%.out del %I%.out
  46. goto end
  47.  
  48. :check
  49. set I=%2
  50. set N=%3
  51. set RES=
  52.  
  53. rem Sprawdzenie czy sa wszystkie potrzebne pliki
  54. if not exist %I%.exe goto err_exe
  55. if not exist %DIR%IN\%I%%N%.in goto err_in
  56. if not exist %DIR%OUT\%I%%N%.out goto err_out
  57.  
  58. rem Czy jes sprawdzaczka
  59. if exist %DIR%%C% goto chk_ok
  60. :chk_no
  61. echo *** BRAK PROGRAMU SPRAWDZAJACEGO: %C%!!! (uzywam: bin\cmp.exe) ***
  62. set C=BIN\cmp.exe
  63. :chk_ok
  64.  
  65. rem Kasowanie niepotrzebnych plikow in/out
  66. if exist %I%.out del %I%.out
  67.  
  68. if exist %DIR%BIN\res.exe %DIR%BIN\res.exe
  69. break on
  70. if "%W32%"=="1" goto w32
  71. %DIR%BIN\timer.exe %I%.exe < %DIR%IN\%I%%N%.in > %I%%N%.out
  72. goto run_ok
  73. :w32
  74. %DIR%BIN\timer.exe %DIR%BIN\start.exe /w %I%.exe < %DIR%IN\%I%%N%.in > %I%.out
  75. :run_ok
  76. type timer.out
  77. if exist timer.out del timer.out
  78. if errorlevel 1 goto err_3
  79. rem if not exist %I%.out goto err_2
  80.  
  81. if exist %DIR%BIN\res.exe %DIR%BIN\res.exe
  82.  
  83. if "%V%"=="1" goto v
  84. rem Interesuje na tylko wynik
  85. %DIR%%C% %I%%N%.out %DIR%OUT\%I%%N%.out %I%.in  > nul
  86. goto chk
  87. :v
  88. rem Pozwalamy sprawdzaczce wypisywac cos na ekran
  89. %DIR%%C% %I%%N%.out %DIR%OUT\%I%%N%.out %I%.in
  90. :chk
  91. if errorlevel 1 goto err_1
  92.  
  93. :err_0
  94. set RES=OK
  95. set R_OK=1
  96. if exist %I%.in  del %I%.in
  97. if exist %I%.out del %I%.out
  98. goto check_end
  99. :err_1
  100. set RES=ZLA ODPOWIEDZ
  101. set R_ZLE=1
  102. goto check_end
  103. :err_2
  104. set RES=BRAK PLIKU %I%.out
  105. set R_BRAK=1
  106. goto check_end
  107. :err_3
  108. set RES=RUNTIME ERROR
  109. set R_RUNERR=1
  110. goto check_end
  111.  
  112. :check_end
  113. echo TEST NR %N%, WYNIK=%RES%
  114. if exist %DIR%BIN\res.exe %DIR%BIN\res.exe
  115.  
  116. goto end
  117.  
  118. :test
  119. set R_ZLE=
  120. set R_BRAK=
  121. set R_RUNERR=
  122. if not exist "%I%.exe" goto err_exe
  123. if "%2" == "" goto test_all
  124. set V=1
  125. call ocen.bat _chk_ %I% %2
  126. if "%R_ZLE%"=="1" goto rpt
  127. if "%R_BRAK%"=="1" goto rpt
  128. if "%R_RUNERR%"=="1" goto rpt
  129. goto end
  130.  
  131. :gen
  132. shift
  133. if not exist "%I%.exe" goto err_exe
  134. if "%2" == "" goto gen_all
  135. call ocen.bat _gen_ %I% %2
  136. goto end
  137.  
  138. :test_all
  139. set R_OK=
  140. set R_ZLE=
  141. set R_BRAK=
  142. set R_RUNERR=
  143. set V=0
  144.  
  145. FOR %%i IN (%T%) DO call ocen.bat _chk_ %I% %%i
  146.  
  147. if "%R_ZLE%"=="1" goto rpt
  148. if "%R_BRAK%"=="1" goto rpt
  149. if "%R_RUNERR%"=="1" goto rpt
  150. if "%R_OK%"=="1" goto rpt
  151. goto end
  152.  
  153. :gen_all
  154. FOR %%i IN (%T%) DO call ocen.bat _gen_ %I% %%i
  155. goto end
  156.  
  157. :rpt
  158. call rpt.bat
  159. goto end
  160.  
  161. rem
  162. rem Komunikaty o bledach
  163. rem
  164.  
  165. :err_exe
  166. echo * Brak pliku %I%.exe *
  167. goto end
  168.  
  169. :err_in
  170. echo * TEST NR %N%: Brak pliku IN\%I%%N%.in *
  171. goto end
  172.  
  173. :err_out
  174. echo * TEST NR %N%: Brak pliku OUT\%I%%N%.out *
  175. goto end
  176.  
  177. :end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement