From 39cdf84b3dc81ededafe221b47820277a940220a Mon Sep 17 00:00:00 2001 From: Enrico Pozzobon Date: Tue, 31 Mar 2020 01:56:51 +0200 Subject: [PATCH] small changes made on tester pc --- compile_all.py | 2 ++ index.html | 33 +++++++++++++++++++++++++-------- process_zip.sh | 2 +- test-dude.py | 34 ++++++++++++++++++++++++++++++---- test_common.py | 2 +- 5 files changed, 59 insertions(+), 14 deletions(-) diff --git a/compile_all.py b/compile_all.py index 5d8cbca..2db7c82 100755 --- a/compile_all.py +++ b/compile_all.py @@ -139,6 +139,8 @@ def main(argv): for variant in os.listdir(variants_dir): implementations_dir = os.path.join( variants_dir, variant) + if not os.path.isdir(implementations_dir): + continue for implementation in os.listdir(implementations_dir): implementation_dir = os.path.join( implementations_dir, implementation) diff --git a/index.html b/index.html index 89cfa52..90c857b 100644 --- a/index.html +++ b/index.html @@ -142,7 +142,8 @@ function onStatusGet(status) { // Find out correct placement in table let ids = Object.keys(schedule); - ids.sort(); + ids.sort(i => i | 0); + const idx = ids.indexOf(s.id); if (idx == -1) { throw new Error(s.id + " NOT FOUND"); @@ -172,11 +173,11 @@ function onStatusGet(status) { } const row = schedule[s.id].row; - row.cells[1].innerText = s.added.substr(0, 16) - + '\n' + s.added.substr(17); - row.cells[2].innerText = s.path; - row.cells[3].innerText = s.template; - row.cells[4].innerText = s.state; + updateInnerText(row.cells[1], s.added.substr(0, 16) + + '\n' + s.added.substr(17)); + updateInnerText(row.cells[2], s.path); + updateInnerText(row.cells[3], s.template); + updateInnerText(row.cells[4], s.state); if (s.state == 'FAILED') { row.style.backgroundColor = '#fcc'; } else if (s.state == 'SUCCESSFUL') { @@ -191,6 +192,13 @@ function onStatusGet(status) { } +function updateInnerText(element, text) { + if (element.innerText !== text) { + element.innerText = text; + } +} + + function showJobMenu(event, jobId) { closeJobMenu(); @@ -204,7 +212,7 @@ function showJobMenu(event, jobId) { const button = document.createElement('a'); button.innerHTML = label; button.onclick = (e) => {closeJobMenu(); onClick(e);}; - button.href = '#'; + button.href = 'javascript:;'; button.className = 'menuEntry'; return button; } @@ -269,6 +277,15 @@ function restartJob(jobId) { } +function deleteJob(jobId) { + if (confirm("Confirm deleting job " + jobId + "?")) { + const xhttp = new XMLHttpRequest(); + xhttp.open("GET", "/delete_test/" + jobId, true); + xhttp.send(); + } +} + + function cancelJob(jobId) { const xhttp = new XMLHttpRequest(); xhttp.open("GET", "/cancel_test/" + jobId, true); @@ -397,4 +414,4 @@ requestStatus(); })(); - \ No newline at end of file + diff --git a/process_zip.sh b/process_zip.sh index e67ae49..1e380ac 100755 --- a/process_zip.sh +++ b/process_zip.sh @@ -94,7 +94,7 @@ function run() { done - #rm -rf "$TMPDIR" + rm -rf "$TMPDIR" } if [[ $1 == "run" ]]; then diff --git a/test-dude.py b/test-dude.py index 9316867..6ab48c4 100644 --- a/test-dude.py +++ b/test-dude.py @@ -56,6 +56,13 @@ class ScheduledTest: res[k] = getattr(self, k) return res + def from_dict(dict): + a = ScheduledTest() + for k in ScheduledTest.__slots__: + if k not in ScheduledTest._unserialized_slots: + setattr(a, k, dict[k]) + return a + class Runner(threading.Thread): _next_id = 1 @@ -136,12 +143,13 @@ class Runner(threading.Thread): except subprocess.TimeoutExpired: pass - if self.process.returncode == 0: - self.job.state = 'SUCCESSFUL' - else: - self.job.state = 'FAILED' + returncode = self.process.returncode self.process = None + if returncode != 0: + raise Exception( + "Test has failed with return code", returncode) + pack_results( self.job, self.platform) @@ -156,7 +164,9 @@ class Runner(threading.Thread): try: self.do_job() + self.job.state = 'SUCCESSFUL' except Exception as ex: + self.job.state = 'FAILED' print(ex) print("Job %s has finished" % self.job.id) @@ -173,6 +183,21 @@ class Status(Resource): }) +class DeleteJob(Resource): + def get(self, job_id): + job = [job for job in schedule if job.id == job_id] + job = job[0] if len(job) > 0 else None + if job is None: + return 'Job not found', 404 + + with job.lock: + if job.state != 'RUNNING': + schedule.remove(job) + return jsonify({'success': True}) + else: + return 'Job is already running', 400 + + class RestartJob(Resource): def get(self, job_id): job = [job for job in schedule if job.id == job_id] @@ -211,6 +236,7 @@ class ScheduleJob(Resource): api.add_resource(Status, '/status') api.add_resource(ScheduleJob, '/schedule_test') api.add_resource(RestartJob, '/restart_test/') +api.add_resource(DeleteJob, '/delete_test/') @app.route('/') diff --git a/test_common.py b/test_common.py index 2d9166a..bfb3351 100644 --- a/test_common.py +++ b/test_common.py @@ -652,4 +652,4 @@ def run_nist_lws_aead_test(dut, vectors_file, build_dir, with open(path, 'wt') as f: print("TIME,VALUE", file=f) for t, v in logic_trace: - print("%f,0x%x" % (t, v), file=f) + print("%.10f,0x%x" % (t, v), file=f) -- libgit2 0.26.0