From 97e13d167e5ccdc02e2c1ac34b9179cbe316db14 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sat, 13 Oct 2018 23:06:27 +0200 Subject: Fix two tasks --- .../tasks/edit_find_grep_compile_convert/task.py | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'kpov_judge/tasks/edit_find_grep_compile_convert') diff --git a/kpov_judge/tasks/edit_find_grep_compile_convert/task.py b/kpov_judge/tasks/edit_find_grep_compile_convert/task.py index 48b713b..deaac4f 100644 --- a/kpov_judge/tasks/edit_find_grep_compile_convert/task.py +++ b/kpov_judge/tasks/edit_find_grep_compile_convert/task.py @@ -192,7 +192,7 @@ def task(testip, testuser, passwd, magicstr, dstfile, progname, pubseed): tests += [('tita-{:02}'.format(i), 'echo -e "\\{}" | ~/{} {}'.format(x, progname, b))] results = kpov_util.ssh_test(testip, testuser, passwd, tests) - results['tita_return'] = ''.join(val for key, val in results.items() if key.startswith('tita-')) + results['tita_return'] = ''.join(results['tita-{:02}'.format(i)] for i in range(N_TITA)) return results @@ -220,8 +220,13 @@ def task_check(results, params): N_TITA = 40 hints = [] score = 0 - hidden_contents = params['magicstr'] r = random.Random(params['rndseed']) + + if results['ssh'] is not True: + hints += ['ssh failed: ' + results['ssh']] + return score, hints + + expected_contents = params['magicstr'] for i in range(1000): start = "".join([r.choice(["po", "p0", "no", "ko", "fo", "qo"]) for i in range(20)]) mid = "".join([r.choice("uiasdfghjkyxcvbnm1234567890ASDFGHJKYZXCVBNM") for i in range(60)]) @@ -230,20 +235,15 @@ def task_check(results, params): start = "po" mid = "kaka" x = start + mid + end - hidden_contents += x + "\r\n" - expected_contents = hidden_contents + expected_contents += x + "\r\n" if results["dst_file_contents"] == expected_contents: score += 3 else: - diff_pos = "" - for i, c in enumerate(results["dst_file_contents"]): - if len(expected_contents) < i or c != expected_contents[i]: - start = max(0, i-10) - end = min(len(expected_contents), len(results["dst_file_contents"]), i+20) - diff_pos = (i, results["dst_file_contents"][start:end]) + for i, (a, b) in enumerate(zip(expected_contents, results['dst_file_contents'])): + if a != b: break - hints += ["wrong file contents\n" + str(diff_pos[1])] - #hints += ["wrong file contents"] + hints += ['wrong file {} at position {}'.format(params['dstfile'], i)] + expected_ls = "-rw--w---- 1 {testuser} bilbo .*{dstfile}.*\r\n".format(**params) if re.match(expected_ls, results["dst_ls"]): score += 3 @@ -253,20 +253,20 @@ def task_check(results, params): score += 2 else: hints += ["missing program"] + expected_tita = "" r = random.Random(params['pubseed']) for i in range(N_TITA): b = r.randint(0, 7) x_i = r.randint(37, 127) - x = oct(x_i).replace('o', '') if x_i & (1 << b): - expected_tita += "ta\r\n" + expected_tita += "ta" else: - expected_tita += "ti\r\n" + expected_tita += "ti" if results["tita_return"] == expected_tita: score += 2 else: - hints += ["program output incorrect\n" + results["tita_return"]] + hints += ['program output incorrect:\nwanted:\t{}\ngot:\t{}'.format(expected_tita, results["tita_return"])] return score, hints -- cgit v1.2.1