From 99a76ea31919747149da67171ac96af4300da435 Mon Sep 17 00:00:00 2001 From: Cristian Mattarei Date: Thu, 23 Mar 2017 14:54:14 -0700 Subject: [PATCH 1/3] Increased number of V8 runs --- tests/test_correctness.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_correctness.py b/tests/test_correctness.py index f8ae06a2..c2302aa1 100644 --- a/tests/test_correctness.py +++ b/tests/test_correctness.py @@ -25,7 +25,7 @@ def run(example): config.command = "bash %s/ext_tools/run_v8.sh"%path config.input_file = "%s/tests/%s"%(path, example) config.threads = 1 - config.number = "1" + config.number = "10" config.silent = True assert litmus(config) == 0 From e855510fd0434f0268c13192e72b25c6cc8ad2f1 Mon Sep 17 00:00:00 2001 From: Cristian Mattarei Date: Thu, 23 Mar 2017 15:40:57 -0700 Subject: [PATCH 2/3] Revised tests definition --- ecmasab/execution.py | 1 - tests/input_tests.py | 4 ++++ tests/test_correctness.py | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ecmasab/execution.py b/ecmasab/execution.py index f69b37b1..588ddd5d 100644 --- a/ecmasab/execution.py +++ b/ecmasab/execution.py @@ -8,7 +8,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import struct import ast import operator import sys diff --git a/tests/input_tests.py b/tests/input_tests.py index c8ce635f..f5ac296f 100644 --- a/tests/input_tests.py +++ b/tests/input_tests.py @@ -25,8 +25,12 @@ if (line == "") or (line[0] == "#"): continue jsprog = line.split(";") jsprogs.append(jsprog[0]) + attr[jsprog[0]] = jsprog[1:] ex_fast = [x for x in tests if FAST in attr[x]] examples = [x for x in tests if INVALID not in attr[x]] invalids = [x for x in tests if INVALID in attr[x]] +jstests = jsprogs +jstests_fast = [x for x in jsprogs if PARAM not in attr[x]] + diff --git a/tests/test_correctness.py b/tests/test_correctness.py index c2302aa1..22d9689b 100644 --- a/tests/test_correctness.py +++ b/tests/test_correctness.py @@ -16,7 +16,7 @@ import os from litmus import Config, litmus -from tests.input_tests import jsprogs +from tests.input_tests import jstests, jstests_fast def run(example): config = Config() @@ -27,14 +27,14 @@ def run(example): config.threads = 1 config.number = "10" config.silent = True - + assert litmus(config) == 0 def test_correctness(): - for example in jsprogs: + for example in jstests_fast: yield run, example if __name__ == "__main__": - for example in jsprogs: + for example in jstests: run(example) From 0d446b7c6938f53a76b2e7b27f23e9a47c6f7268 Mon Sep 17 00:00:00 2001 From: Cristian Mattarei Date: Fri, 24 Mar 2017 13:32:53 -0700 Subject: [PATCH 3/3] Added atomics.sub test --- examples/single_var/sv_simple24.bex | 11 ++++ examples/single_var/sv_simple24/models.txt | 4 ++ examples/single_var/sv_simple24/program.js | 67 ++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 examples/single_var/sv_simple24.bex create mode 100644 examples/single_var/sv_simple24/models.txt create mode 100644 examples/single_var/sv_simple24/program.js diff --git a/examples/single_var/sv_simple24.bex b/examples/single_var/sv_simple24.bex new file mode 100644 index 00000000..6413757c --- /dev/null +++ b/examples/single_var/sv_simple24.bex @@ -0,0 +1,11 @@ +// Single variable, Simple24 +var x = new SharedArrayBuffer(); + +Thread t1 { + Atomics.store(x-I8, 1, 2); + print(Atomics.sub(x-I8, 1, 1)); +} + +Thread t2 { + print(Atomics.load(x-I16, 0)); +} diff --git a/examples/single_var/sv_simple24/models.txt b/examples/single_var/sv_simple24/models.txt new file mode 100644 index 00000000..3a061bf3 --- /dev/null +++ b/examples/single_var/sv_simple24/models.txt @@ -0,0 +1,4 @@ +HB = {(id2_W_t1, id3_M_t1), (id1_W_main, id2_W_t1), (id1_W_main, id4_R_t2), (id1_W_main, id3_M_t1)} AND MO = {(id2_W_t1, id3_M_t1), (id1_W_main, id2_W_t1), (id1_W_main, id4_R_t2), (id2_W_t1, id4_R_t2), (id3_M_t1, id4_R_t2), (id1_W_main, id3_M_t1)} AND RBF = {((id3_M_t1, id2_W_t1), 1), ((id4_R_t2, id1_W_main), 0), ((id4_R_t2, id1_W_main), 1)} AND RF = {(id3_M_t1, id2_W_t1), (id4_R_t2, id1_W_main)} AND SW = {(id2_W_t1, id3_M_t1), (id1_W_main, id4_R_t2)} +HB = {(id2_W_t1, id3_M_t1), (id1_W_main, id2_W_t1), (id1_W_main, id4_R_t2), (id2_W_t1, id4_R_t2), (id1_W_main, id3_M_t1)} AND MO = {(id2_W_t1, id3_M_t1), (id1_W_main, id2_W_t1), (id1_W_main, id4_R_t2), (id2_W_t1, id4_R_t2), (id3_M_t1, id4_R_t2), (id1_W_main, id3_M_t1)} AND RBF = {((id3_M_t1, id2_W_t1), 1), ((id4_R_t2, id1_W_main), 0), ((id4_R_t2, id2_W_t1), 1)} AND RF = {(id3_M_t1, id2_W_t1), (id4_R_t2, id1_W_main), (id4_R_t2, id2_W_t1)} AND SW = {(id2_W_t1, id3_M_t1)} +HB = {(id2_W_t1, id3_M_t1), (id1_W_main, id2_W_t1), (id1_W_main, id4_R_t2), (id2_W_t1, id4_R_t2), (id3_M_t1, id4_R_t2), (id1_W_main, id3_M_t1)} AND MO = {(id2_W_t1, id3_M_t1), (id1_W_main, id2_W_t1), (id1_W_main, id4_R_t2), (id2_W_t1, id4_R_t2), (id3_M_t1, id4_R_t2), (id1_W_main, id3_M_t1)} AND RBF = {((id3_M_t1, id2_W_t1), 1), ((id4_R_t2, id1_W_main), 0), ((id4_R_t2, id3_M_t1), 1)} AND RF = {(id3_M_t1, id2_W_t1), (id4_R_t2, id1_W_main), (id4_R_t2, id3_M_t1)} AND SW = {(id2_W_t1, id3_M_t1)} +DONE diff --git a/examples/single_var/sv_simple24/program.js b/examples/single_var/sv_simple24/program.js new file mode 100644 index 00000000..6b205591 --- /dev/null +++ b/examples/single_var/sv_simple24/program.js @@ -0,0 +1,67 @@ +// Copyright 2017 Cristian Mattarei +// +// Licensed under the modified BSD (3-clause BSD) License. +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +// Thread t1 +$262.agent.start( + `$262.agent.receiveBroadcast(function (data) { + var report = []; + var x = new Int8Array(data.x_sab); Atomics.store(x, 1, 2); + var x = new Int8Array(data.x_sab); id3_M_t1 = Atomics.sub(x, 1, 1); report.push("id3_M_t1: "+id3_M_t1); + $262.agent.report(report); + $262.agent.leaving(); + }) + `); + +// Thread t2 +$262.agent.start( + `$262.agent.receiveBroadcast(function (data) { + var report = []; + var x = new Int16Array(data.x_sab); id4_R_t2 = Atomics.load(x, 0); report.push("id4_R_t2: "+id4_R_t2); + $262.agent.report(report); + $262.agent.leaving(); + }) + `); + +var data = { + x_sab : new SharedArrayBuffer(8), +} +$262.agent.broadcast(data); +var report = []; + +// MAIN Thread + +var thread_report; +var reports = 0; +var i = 0; +while (true) { + thread_report = $262.agent.getReport(); + if (thread_report != null) { + for(i=0; i < thread_report.length; i++){ + report.push(thread_report[i]); + print(thread_report[i]); + } + reports += 1; + if (reports >= 2) break; + } +} + +report.sort(); +report = report.join(";"); +var outputs = []; +outputs[0] = "id3_M_t1: 2;id4_R_t2: 256"; +outputs[1] = "id3_M_t1: 2;id4_R_t2: 0"; +outputs[2] = "id3_M_t1: 2;id4_R_t2: 512"; +assert(-1 != outputs.indexOf(report)); + +// Expected outputs // +//output// id3_M_t1: 2;id4_R_t2: 256 +//output// id3_M_t1: 2;id4_R_t2: 0 +//output// id3_M_t1: 2;id4_R_t2: 512