├── good ├── good.exe ├── goodmac ├── output_pop.txt ├── output_sum.txt ├── output_put.txt ├── input_sum.txt ├── output_mov_w.txt ├── output_set_l.txt ├── output_set.txt ├── input_put.txt ├── input_pop.txt ├── input_set_l.txt ├── input_mov_w.txt ├── output_fill.txt ├── input_set.txt ├── input_fill.txt ├── README.md └── check.py /good: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wmii-cs-2017/f-sprawdzarka/HEAD/good -------------------------------------------------------------------------------- /good.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wmii-cs-2017/f-sprawdzarka/HEAD/good.exe -------------------------------------------------------------------------------- /goodmac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wmii-cs-2017/f-sprawdzarka/HEAD/goodmac -------------------------------------------------------------------------------- /output_pop.txt: -------------------------------------------------------------------------------- 1 | 4 2 | 2 3 | 1 4 | 1 5 | 1 6 | 1 7 | 1 8 | 1 9 | 0 10 | 0 11 | 0 12 | 0 13 | 0 14 | 0 15 | 0 16 | 0 17 | -------------------------------------------------------------------------------- /output_sum.txt: -------------------------------------------------------------------------------- 1 | 17594073448320 2 | 137445244800 3 | 1073725440 4 | 1073725440 5 | 8388480 6 | 8388480 7 | 8388480 8 | 8388480 9 | -------------------------------------------------------------------------------- /output_put.txt: -------------------------------------------------------------------------------- 1 | 262140 2 | 131070 3 | 65535 4 | 65535 5 | 65535 6 | 65535 7 | 65535 8 | 65535 9 | error 10 | error 11 | error 12 | error 13 | -------------------------------------------------------------------------------- /input_sum.txt: -------------------------------------------------------------------------------- 1 | FILL 128 128 128 128 65535 2 | GET-E 3 | GET-W 0 4 | GET-RW 0 0 5 | GET-RH 6 | GET-SW 0 0 0 7 | GET-SH 0 8 | GET-SR 0 9 | GET-S 10 | END -------------------------------------------------------------------------------- /output_mov_w.txt: -------------------------------------------------------------------------------- 1 | 65535 2 | 65535 3 | 65535 4 | 393210 5 | 0 6 | 200 7 | 65525 8 | 65535 9 | error 10 | 90000 11 | 24465 12 | 65535 13 | 90000 14 | -------------------------------------------------------------------------------- /output_set_l.txt: -------------------------------------------------------------------------------- 1 | -- 2 | -- 3 | -- 4 | -- 5 | 01 6 | 02 7 | 30 8 | 04 9 | error 10 | error 11 | error 12 | error 13 | -- 14 | -- 15 | -- 16 | -- 17 | -------------------------------------------------------------------------------- /output_set.txt: -------------------------------------------------------------------------------- 1 | 65535 2 | error 3 | error 4 | 0 5 | 131070 6 | 65535 7 | 65535 8 | 65535 9 | 0 10 | 65535 11 | error 12 | error 13 | error 14 | error 15 | error 16 | error 17 | error 18 | error 19 | error 20 | error 21 | error 22 | error 23 | -------------------------------------------------------------------------------- /input_put.txt: -------------------------------------------------------------------------------- 1 | FILL 1 1 1 1 0 2 | PUT-W 0 0 0 0 65535 3 | PUT-H 0 0 65535 4 | PUT-R 0 0 65535 5 | PUT-S 0 65535 6 | 7 | GET-E 8 | GET-W 0 9 | GET-RW 0 0 10 | GET-RH 11 | GET-SW 0 0 0 12 | GET-SH 0 13 | GET-SR 0 14 | GET-S 15 | 16 | FILL 1 1 1 1 0 17 | 18 | PUT-W 0 0 0 0 70000 19 | PUT-H 0 0 70000 20 | PUT-R 0 0 70000 21 | PUT-S 0 70000 22 | 23 | PUT-W 130 130 130 130 70000 24 | PUT-H 130 130 70000 25 | PUT-R 130 130 70000 26 | PUT-S 130 70000 27 | 28 | END -------------------------------------------------------------------------------- /input_pop.txt: -------------------------------------------------------------------------------- 1 | FILL 1 1 1 1 65535 2 | POP-W 0 0 0 0 65534 3 | POP-H 0 0 65534 4 | POP-R 0 0 65534 5 | POP-S 0 65534 6 | 7 | GET-E 8 | GET-W 0 9 | GET-RW 0 0 10 | GET-RH 11 | GET-SW 0 0 0 12 | GET-SH 0 13 | GET-SR 0 14 | GET-S 15 | 16 | FILL 1 1 1 1 100 17 | POP-W 0 0 0 0 99999 18 | POP-H 0 0 99999 19 | POP-R 0 0 99999 20 | POP-S 0 99999 21 | 22 | GET-E 23 | GET-W 0 24 | GET-RW 0 0 25 | GET-RH 26 | GET-SW 0 0 0 27 | GET-SH 0 28 | GET-SR 0 29 | GET-S 30 | 31 | END -------------------------------------------------------------------------------- /input_set_l.txt: -------------------------------------------------------------------------------- 1 | FILL 1 1 1 1 1 2 | 3 | GET-LW 0 0 0 0 4 | GET-LH 0 0 5 | GET-LR 0 0 6 | GET-LS 0 7 | 8 | SET-LW 0 0 0 0 01 9 | SET-LH 0 0 02 10 | SET-LR 0 0 30 11 | SET-LS 0 04 12 | 13 | GET-LW 0 0 0 0 14 | GET-LH 0 0 15 | GET-LR 0 0 16 | GET-LS 0 17 | 18 | FILL 0 0 0 0 0 19 | 20 | GET-LW 0 0 0 0 21 | GET-LH 0 0 22 | GET-LR 0 0 23 | GET-LS 0 24 | 25 | FILL 10 10 10 10 10 26 | 27 | GET-LW 0 0 0 0 28 | GET-LH 0 0 29 | GET-LR 0 0 30 | GET-LS 0 31 | 32 | END 33 | -------------------------------------------------------------------------------- /input_mov_w.txt: -------------------------------------------------------------------------------- 1 | FILL 1 1 2 1 65535 2 | MOV-W 0 0 0 0 0 1 0 70000 3 | GET-SW 0 0 0 4 | GET-SW 0 0 1 5 | 6 | MOV-W 0 0 0 0 0 0 0 100 7 | GET-SW 0 0 0 8 | GET-E 9 | 10 | FILL 1 1 2 1 100 11 | MOV-W 0 0 0 0 0 1 0 100 12 | GET-SW 0 0 0 13 | GET-SW 0 0 1 14 | 15 | FILL 1 1 2 1 65530 16 | MOV-W 0 0 0 0 0 1 0 100 17 | GET-SW 0 0 0 18 | GET-SW 0 0 1 19 | 20 | FILL 2 2 2 2 0 21 | MOV-W 130 130 130 130 130 130 130 100 22 | 23 | PUT-W 0 0 0 0 50000 24 | PUT-W 1 0 0 0 40000 25 | GET-E 26 | MOV-W 0 0 0 1 0 0 0 60000 27 | GET-W 0 28 | GET-W 1 29 | GET-E 30 | 31 | 32 | END -------------------------------------------------------------------------------- /output_fill.txt: -------------------------------------------------------------------------------- 1 | 17594073448320 2 | 137445244800 3 | 1073725440 4 | 1073725440 5 | 8388480 6 | 8388480 7 | 8388480 8 | 8388480 9 | 0 10 | error 11 | error 12 | 0 13 | error 14 | error 15 | error 16 | 0 17 | 12082000 18 | error 19 | error 20 | 60000 21 | error 22 | error 23 | error 24 | 2000 25 | 1320000 26 | error 27 | error 28 | 360000 29 | error 30 | error 31 | error 32 | 120000 33 | error 34 | 1320000 35 | error 36 | error 37 | 360000 38 | error 39 | error 40 | error 41 | 120000 42 | error 43 | 0 44 | error 45 | error 46 | 0 47 | error 48 | error 49 | error 50 | 0 51 | 220 52 | 140 53 | 60 54 | 60 55 | 20 56 | 20 57 | 20 58 | 20 59 | -------------------------------------------------------------------------------- /input_set.txt: -------------------------------------------------------------------------------- 1 | SET-AW 1 2 3 4 2 | PUT-W 0 0 0 0 65535 3 | GET-W 0 4 | GET-W 1 5 | 6 | SET-AW 0 0 0 0 7 | GET-W 0 8 | SET-AW 5 6 7 8 9 | GET-W 0 10 | 11 | SET-AW 2 1 1 100 12 | PUT-W 0 0 0 0 65535 13 | 14 | SET-AP 0 0 0 128 15 | PUT-W 0 0 0 127 65535 16 | GET-SW 0 0 0 17 | 18 | SET-AS 0 0 100 100 19 | PUT-W 0 0 1 1 65535 20 | GET-SW 0 0 1 21 | 22 | SET-AR 0 100 100 100 23 | PUT-W 0 1 1 1 65535 24 | GET-SW 0 1 1 25 | 26 | SET-HW 0 100 27 | PUT-H 0 0 65535 28 | GET-SH 0 29 | 30 | SET-HR 0 100 31 | PUT-H 0 0 65535 32 | GET-RH 33 | 34 | SET-HS 100 35 | PUT-S 0 65535 36 | GET-S 37 | 38 | SET-AW 130 130 130 130 39 | SET-AP 130 130 130 1 40 | SET-AS 130 130 1 1 41 | SET-AR 130 1 1 1 42 | SET-HW 130 1 43 | SET-HR 1 1 44 | SET-HS 1 45 | 46 | FILL 1 2 3 4 5 47 | 48 | SET-AW 130 130 130 130 49 | SET-AP 0 0 0 130 50 | SET-AS 0 0 130 130 51 | SET-AR 0 130 130 130 52 | SET-HW 0 130 53 | SET-HR 130 130 54 | SET-HS 130 55 | 56 | 57 | END 58 | -------------------------------------------------------------------------------- /input_fill.txt: -------------------------------------------------------------------------------- 1 | FILL 128 128 128 128 65535 2 | GET-E 3 | GET-W 127 4 | GET-RW 127 127 5 | GET-RH 6 | GET-SW 127 127 127 7 | GET-SH 127 8 | GET-SR 127 9 | GET-S 10 | 11 | FILL 0 0 0 0 0 12 | GET-E 13 | GET-W 127 14 | GET-RW 127 127 15 | GET-RH 16 | GET-SW 127 127 127 17 | GET-SH 127 18 | GET-SR 127 19 | GET-S 20 | 21 | FILL 10 20 30 40 50 22 | GET-E 23 | GET-W 127 24 | GET-RW 127 127 25 | GET-RH 26 | GET-SW 127 127 127 27 | GET-SH 127 28 | GET-SR 127 29 | GET-S 30 | 31 | FILL 1 2 3 4 30000 32 | GET-E 33 | GET-W 127 34 | GET-RW 127 127 35 | GET-RH 36 | GET-SW 127 127 127 37 | GET-SH 127 38 | GET-SR 127 39 | GET-S 40 | 41 | FILL 1 2 3 130 50000 42 | GET-E 43 | GET-W 127 44 | GET-RW 127 127 45 | GET-RH 46 | GET-SW 127 127 127 47 | GET-SH 127 48 | GET-SR 127 49 | GET-S 50 | 51 | FILL 130 130 130 130 130 52 | 53 | FILL 0 0 0 0 0 54 | GET-E 55 | GET-W 0 56 | GET-RW 0 0 57 | GET-RH 58 | GET-SW 0 0 0 59 | GET-SH 0 60 | GET-SR 0 61 | GET-S 62 | 63 | FILL 1 2 3 4 5 64 | GET-E 65 | GET-W 0 66 | GET-RW 0 0 67 | GET-RH 68 | GET-SW 0 0 0 69 | GET-SH 0 70 | GET-SR 0 71 | GET-S 72 | 73 | END -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tester zadania F 2 | 3 | Skrypt odpala dwa programy ( twój i taki co przechodzi na 100% ) i porównuje wyjścia ich obu. 4 | 5 | ## Użycie: 6 | * Clonujemy repozytorium z githuba: 7 | ``` 8 | git clone https://github.com/wmii-cs-2017/f-sprawdzarka.git 9 | ``` 10 | lub za pomocą ssh: 11 | ``` 12 | git clone git@github.com:wmii-cs-2017/f-sprawdzarka.git 13 | ``` 14 | 15 | * Przenosimy nasz skompilowany program w c++, do sklonowanego folderu `f-sprawdzarka` 16 | * Odpalamy skrypt `check.py` z nazwą naszego programu jako argument wraz z ewentualnym rozszerzeniem. Wpisując w terminal: 17 | ``` 18 | python3 check.py [nazwa programu] 19 | ``` 20 | lub python zamiast python3, jeśli coś nie działa. 21 | 22 | 23 | ## Częste problemy: 24 | * sprawdzcie czy macie zainstalowanego pythona 25 | * sprawdzcie czy na pewno odpalacie pythonem3 a nie pythonem2 26 | * podajemy skompilowany program jako argument a nie .cpp 27 | * może wystąpic problem z uprawnieniami wykonywania dla binarek z prawidłowym wynikiem, musimy nadać im uprawnienie 28 | na linuxie możemy nadać uprawnienie używając chmod: 29 | ``` 30 | chmod +x good 31 | ``` 32 | * na macu dodajemy uprawnienie wykonywania do `goodmac`, na windowsie do `good` 33 | 34 | ## Wymagania: 35 | * python 3.6 36 | -------------------------------------------------------------------------------- /check.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import io 4 | import os 5 | import sys 6 | import subprocess 7 | import time 8 | import platform 9 | from subprocess import run, PIPE 10 | 11 | 12 | class bcolors: 13 | if os.name == 'posix': 14 | HEADER = '\033[95m' 15 | OKBLUE = '\033[94m' 16 | OKGREEN = '\033[92m' 17 | WARNING = '\033[93m' 18 | FAIL = '\033[91m' 19 | ENDC = '\033[0m' 20 | BOLD = '\033[1m' 21 | UNDERLINE = '\033[4m' 22 | else: 23 | HEADER = '' 24 | OKBLUE = '' 25 | OKGREEN = '' 26 | WARNING = '' 27 | FAIL = '' 28 | ENDC = '' 29 | BOLD = '' 30 | UNDERLINE = '' 31 | 32 | 33 | def check(): 34 | inputString = io.StringIO( yourInput ) 35 | 36 | try: 37 | if platform.system().lower() in ('windows'): 38 | system_format = '.exe' 39 | elif platform.system().lower() in ('darwin'): 40 | system_format = 'mac' 41 | else: # linux 42 | system_format = '' 43 | 44 | startGood = time.time() 45 | goodProcess = run( [ './good' + system_format ], stdout = PIPE, input = yourInput, encoding = 'ascii' ) 46 | endGood = time.time() 47 | 48 | goodOutput = io.StringIO( goodProcess.stdout ) 49 | 50 | startBad = time.time() 51 | badProcess = run( [ './' + fileName], stdout = PIPE, input = yourInput, encoding = 'ascii' ) 52 | endBad = time.time() 53 | 54 | badOutput = io.StringIO( badProcess.stdout ) 55 | 56 | 57 | for line in goodOutput: 58 | str = inputString.readline() 59 | badLine = badOutput.readline() 60 | 61 | if line == badLine: 62 | print( bcolors.OKGREEN + '[DOBRZE] ' + bcolors.ENDC + '{}'.format( badLine ), end = '' ) 63 | else: 64 | print( bcolors.FAIL + '[ŹLE] ' + bcolors.ENDC + '{} ->'.format( badLine.rstrip() ) + bcolors.OKGREEN + ' {}'.format( line ) + bcolors.ENDC, end = '' ) 65 | 66 | print( "Czas: {}".format( endGood - startGood ) ) 67 | print( "Twój czas: {}".format( endBad - startBad ) ) 68 | 69 | goodOutput.close() 70 | badOutput.close() 71 | 72 | except FileNotFoundError: 73 | print( bcolors.FAIL + 'Nie znaleziono pliku!' + bcolors.ENDC ) 74 | 75 | 76 | try: 77 | fileName = sys.argv[ 1 ] 78 | except IndexError: 79 | print( bcolors.WARNING + 'Brak nazwy pliku! Ustawiam domyślnie: main' + bcolors.ENDC ) 80 | fileName = 'main' 81 | 82 | tests = [ 'set', 'put', 'pop', 'mov_w', 'set_l', 'fill', 'sum', 'custom' ] 83 | 84 | print( bcolors.BOLD + 'ZADANIE F - TESTER' + bcolors.ENDC ) 85 | print( '[1] Testuj wszystkie' ) 86 | print( '[2] Wprowadź własne\n' ) 87 | 88 | i = 3; 89 | 90 | for test in tests: 91 | print( '[{}] {}'.format( i, test ) ) 92 | i = i + 1 93 | 94 | 95 | choice = int( input( ' >> ' ) ) 96 | 97 | if choice == 1: 98 | for test in tests: 99 | try: 100 | print( bcolors.ENDC + bcolors.BOLD + '\nSPRAWDZAM: ' + bcolors.ENDC + '{}'.format( test ) ) 101 | inputFile = open( 'input_' + test + '.txt', 'r' ) 102 | yourInput = inputFile.read() 103 | 104 | check() 105 | 106 | except FileNotFoundError: 107 | print( bcolors.FAIL + 'Nie znaleziono pliku!' + bcolors.ENDC ) 108 | 109 | elif choice == 2: 110 | command = '' 111 | yourInput = '' 112 | 113 | while command != 'END': 114 | command = input( '' ) 115 | yourInput += command + '\n' 116 | 117 | print( bcolors.ENDC + bcolors.BOLD + '\nSPRAWDZAM: ' + bcolors.ENDC ) 118 | check() 119 | 120 | choice = input( "Zapisać input? [y/n] " ) 121 | 122 | if choice == 'y': 123 | customInputFile = open( 'input_custom.txt', 'w' ) 124 | customInputFile.write( yourInput ) 125 | 126 | elif choice >= 3 and choice <= 10: 127 | try: 128 | print( bcolors.ENDC + bcolors.BOLD + '\nSPRAWDZAM: ' + bcolors.ENDC + '{}'.format( tests[ choice - 3 ] ) ) 129 | inputFile = open( 'input_' + tests[ choice - 3 ] + '.txt', 'r' ) 130 | yourInput = inputFile.read() 131 | check() 132 | 133 | except FileNotFoundError: 134 | print( bcolors.FAIL + 'Nie znaleziono pliku!' + bcolors.ENDC ) 135 | 136 | else: 137 | print( '>:(' ) 138 | 139 | 140 | exit() 141 | --------------------------------------------------------------------------------