From b9c4fc15fba49cf7ac7c20ebc66f86979cfd2478 Mon Sep 17 00:00:00 2001 From: Vasu Vikram Date: Sat, 16 Mar 2024 14:16:10 -0400 Subject: [PATCH 1/9] Initial condition integration test --- .../cmu/pasta/sfuzz/it/ConditionTest.java | 10 + .../src/test/java/example/ConditionTest.java | 102 ++++++++ .../resources/expected/ConditionTest_T1T2.txt | 8 + .../schedules/ConditionTest_T1T2.json | 225 ++++++++++++++++++ 4 files changed, 345 insertions(+) create mode 100644 integration-tests/src/test/java/cmu/pasta/sfuzz/it/ConditionTest.java create mode 100644 integration-tests/src/test/java/example/ConditionTest.java create mode 100644 integration-tests/src/test/resources/expected/ConditionTest_T1T2.txt create mode 100644 integration-tests/src/test/resources/schedules/ConditionTest_T1T2.json diff --git a/integration-tests/src/test/java/cmu/pasta/sfuzz/it/ConditionTest.java b/integration-tests/src/test/java/cmu/pasta/sfuzz/it/ConditionTest.java new file mode 100644 index 00000000..514a96c1 --- /dev/null +++ b/integration-tests/src/test/java/cmu/pasta/sfuzz/it/ConditionTest.java @@ -0,0 +1,10 @@ +package cmu.pasta.sfuzz.it; + +import org.junit.jupiter.api.Test; + +public class ConditionTest extends IntegrationTestRunner { + @Test + public void testInterleaving1() { + runTest("T1T2"); + } +} diff --git a/integration-tests/src/test/java/example/ConditionTest.java b/integration-tests/src/test/java/example/ConditionTest.java new file mode 100644 index 00000000..b63daa95 --- /dev/null +++ b/integration-tests/src/test/java/example/ConditionTest.java @@ -0,0 +1,102 @@ +package example; + +import java.util.concurrent.locks.Condition; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; +import cmu.pasta.sfuzz.core.GlobalContext; + +public class ConditionTest { + + private static int num; + private static long total; + private static boolean flag; + + private static Lock m = new ReentrantLock(); + private static int N = 3; + private static Condition empty = m.newCondition(); + private static Condition full = m.newCondition(); + + private void log (String format, Object... args) { + GlobalContext.INSTANCE.log(format, args); + } + + public static void main(String[] args) { + ConditionTest t = new ConditionTest(); + t.testConditionAwait(); + } + + public void testConditionAwait() { + + Thread producer = new Thread (() -> { + int i = 0; + while (i < N) { + m.lock(); + log("Acquired lock."); + + try { + while (num > 0) { + log("Beginning await."); + empty.await(); + log("Returned from await."); + } + num++; + full.signal(); + log("Sent signal."); + + System.out.println("produce ...." + i); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + m.unlock(); + log("Released lock."); + } + + + i++; + } + }); + + Thread consumer = new Thread (() -> { + int j = 0; + while (j < N) { + m.lock(); + log("Acquired lock."); + try { + while (num == 0) { + log("Beginning await."); + full.await(); + log("Returned from await."); + } + total = total + j; + System.out.println("total ...." + total); + num--; + empty.signal(); + log("Sent signal."); + System.out.println("consume ...." + j); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + m.unlock(); + log("Released lock."); + } + + j++; + } + total = total + j; + System.out.println("total ...." + total); + flag = true; + }); + + producer.start(); + consumer.start(); + + try { + producer.join(); + consumer.join(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + + assert total == ((N * (N + 1)) / 2); + } +} \ No newline at end of file diff --git a/integration-tests/src/test/resources/expected/ConditionTest_T1T2.txt b/integration-tests/src/test/resources/expected/ConditionTest_T1T2.txt new file mode 100644 index 00000000..64633909 --- /dev/null +++ b/integration-tests/src/test/resources/expected/ConditionTest_T1T2.txt @@ -0,0 +1,8 @@ +[1]: Trying to acquire lock. +[1]: Acquired lock. +[1]: Trying to unlock. +[1]: Unlocked. +[2]: Trying to acquire lock. +[2]: Acquired lock. +[2]: Trying to unlock. +[2]: Unlocked. diff --git a/integration-tests/src/test/resources/schedules/ConditionTest_T1T2.json b/integration-tests/src/test/resources/schedules/ConditionTest_T1T2.json new file mode 100644 index 00000000..eb6a1318 --- /dev/null +++ b/integration-tests/src/test/resources/schedules/ConditionTest_T1T2.json @@ -0,0 +1,225 @@ +{ + "choices": [ + { + "selected": 0, + "threadId": 0, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 0, + "enabled": 3 + }, + { + "selected": 0, + "threadId": 0, + "enabled": 3 + }, + { + "selected": 0, + "threadId": 0, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 2, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 2, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 0, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 0, + "enabled": 2 + } + ], + "fullSchedule": false +} \ No newline at end of file From 5a5e1e0aae4509c61f8eb7ff01500f648064bcab Mon Sep 17 00:00:00 2001 From: Vasu Vikram Date: Sat, 16 Mar 2024 14:38:37 -0400 Subject: [PATCH 2/9] Gradle workflow --- .github/workflows/main.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..8fede2c2 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,23 @@ +name: CI +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: +jobs: + build-and-test: + runs-on: ubuntu-latest + permissions: + contents: read + packages: read + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + cache: 'gradle' + - name: Build and test sfuzz + run: ./gradlew build --no-daemon + From 0d5a6010979b2eed56734d196c06202da9848b73 Mon Sep 17 00:00:00 2001 From: Vasu Vikram Date: Sat, 16 Mar 2024 14:43:41 -0400 Subject: [PATCH 3/9] Add jdk instrumentation --- .github/workflows/main.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8fede2c2..e213ccee 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,6 +18,12 @@ jobs: distribution: 'temurin' java-version: '21' cache: 'gradle' - - name: Build and test sfuzz - run: ./gradlew build --no-daemon + - name: Build sfuzz (no tests) + run: ./gradlew build --no-daemon -x test + - name: Instrument JDK + run: ./gradlew jlink + - name: Build shadow JAR + run: ./gradlew shadowJar + - name: Test sfuzz + run: ./gradlew test From 4a6776c948693bf0f906045192595a40c950ba3e Mon Sep 17 00:00:00 2001 From: Vasu Vikram Date: Mon, 18 Mar 2024 13:28:22 -0400 Subject: [PATCH 4/9] Initial integration tests for condition --- .../src/test/java/cmu/pasta/sfuzz/it/AtomicTest.java | 12 ++++++------ .../test/resources/schedules/ConditionTest_T1T2.json | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/integration-tests/src/test/java/cmu/pasta/sfuzz/it/AtomicTest.java b/integration-tests/src/test/java/cmu/pasta/sfuzz/it/AtomicTest.java index a91692a9..7348ae27 100644 --- a/integration-tests/src/test/java/cmu/pasta/sfuzz/it/AtomicTest.java +++ b/integration-tests/src/test/java/cmu/pasta/sfuzz/it/AtomicTest.java @@ -4,11 +4,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -//public class AtomicTest extends IntegrationTestRunner { -// @Test -// public void testInterleaving1() { -// runTest("T1T2"); -// } +public class AtomicTest extends IntegrationTestRunner { + @Test + public void testInterleaving1() { + runTest("T1T2"); + } // // @Test // public void testInterleaving2() { @@ -19,4 +19,4 @@ // public void testInterleaving3() { // runTest("alternateT2T1"); // } -//} +} diff --git a/integration-tests/src/test/resources/schedules/ConditionTest_T1T2.json b/integration-tests/src/test/resources/schedules/ConditionTest_T1T2.json index eb6a1318..99f35151 100644 --- a/integration-tests/src/test/resources/schedules/ConditionTest_T1T2.json +++ b/integration-tests/src/test/resources/schedules/ConditionTest_T1T2.json @@ -221,5 +221,5 @@ "enabled": 2 } ], - "fullSchedule": false -} \ No newline at end of file + "fullSchedule": true +} From 6bc1264c1c9e7729df571c53ecf50e5fc2c3bb28 Mon Sep 17 00:00:00 2001 From: Vasu Vikram Date: Mon, 25 Mar 2024 14:22:54 -0400 Subject: [PATCH 5/9] Merge main --- .../cmu/pasta/sfuzz/it/scheduler/AtomicTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/integration-tests/src/test/java/cmu/pasta/sfuzz/it/scheduler/AtomicTest.java b/integration-tests/src/test/java/cmu/pasta/sfuzz/it/scheduler/AtomicTest.java index 9f4b9a09..220ba10e 100644 --- a/integration-tests/src/test/java/cmu/pasta/sfuzz/it/scheduler/AtomicTest.java +++ b/integration-tests/src/test/java/cmu/pasta/sfuzz/it/scheduler/AtomicTest.java @@ -4,11 +4,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class AtomicTest extends IntegrationTestRunner { - @Test - public void testInterleaving1() { - runTest("T1T2"); - } +//public class AtomicTest extends IntegrationTestRunner { +// @Test +// public void testInterleaving1() { +// runTest("T1T2"); +// } // // @Test // public void testInterleaving2() { @@ -19,4 +19,4 @@ public void testInterleaving1() { // public void testInterleaving3() { // runTest("alternateT2T1"); // } -} +//} From 8b58fcd0c6e468cbdd5b621e45a96dfd9b73f9d6 Mon Sep 17 00:00:00 2001 From: Vasu Vikram Date: Mon, 25 Mar 2024 14:44:18 -0400 Subject: [PATCH 6/9] Update integration test to use main method --- examples/build.gradle.kts | 2 +- .../sfuzz/it/{ => core}/ConditionTest.java | 5 +- .../src/test/java/example/ConditionTest.java | 62 +++++++++---------- 3 files changed, 32 insertions(+), 37 deletions(-) rename integration-tests/src/test/java/cmu/pasta/sfuzz/it/{ => core}/ConditionTest.java (58%) diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts index 9c74debd..f7efd967 100644 --- a/examples/build.gradle.kts +++ b/examples/build.gradle.kts @@ -58,7 +58,7 @@ tasks.register("runArithmeticProgSfuzz") { classpath = sourceSets["main"].runtimeClasspath executable("${jdk.layout.buildDirectory.get().asFile}/java-inst/bin/java") mainClass.set("cmu.pasta.sfuzz.core.MainKt") - args = listOf("example.ArithmeticProgBad", "-o", "${layout.buildDirectory.get().asFile}/report", "--scheduler", "fifo") + args = listOf("example.ArithmeticProgBad", "main", "-o", "${layout.buildDirectory.get().asFile}/report", "--scheduler", "fifo") jvmArgs("-agentpath:${agentPath}") jvmArgs("-javaagent:${instrumentation.layout.buildDirectory.get().asFile}/libs/${instrumentation.name}-${instrumentation.version}-all.jar") doFirst { diff --git a/integration-tests/src/test/java/cmu/pasta/sfuzz/it/ConditionTest.java b/integration-tests/src/test/java/cmu/pasta/sfuzz/it/core/ConditionTest.java similarity index 58% rename from integration-tests/src/test/java/cmu/pasta/sfuzz/it/ConditionTest.java rename to integration-tests/src/test/java/cmu/pasta/sfuzz/it/core/ConditionTest.java index 514a96c1..047c36ec 100644 --- a/integration-tests/src/test/java/cmu/pasta/sfuzz/it/ConditionTest.java +++ b/integration-tests/src/test/java/cmu/pasta/sfuzz/it/core/ConditionTest.java @@ -1,10 +1,11 @@ -package cmu.pasta.sfuzz.it; +package cmu.pasta.sfuzz.it.core; +import cmu.pasta.sfuzz.it.IntegrationTestRunner; import org.junit.jupiter.api.Test; public class ConditionTest extends IntegrationTestRunner { @Test public void testInterleaving1() { - runTest("T1T2"); + runTest("main"); } } diff --git a/integration-tests/src/test/java/example/ConditionTest.java b/integration-tests/src/test/java/example/ConditionTest.java index b63daa95..723164ec 100644 --- a/integration-tests/src/test/java/example/ConditionTest.java +++ b/integration-tests/src/test/java/example/ConditionTest.java @@ -16,87 +16,81 @@ public class ConditionTest { private static Condition empty = m.newCondition(); private static Condition full = m.newCondition(); - private void log (String format, Object... args) { + private static void log(String format, Object... args) { GlobalContext.INSTANCE.log(format, args); } - public static void main(String[] args) { - ConditionTest t = new ConditionTest(); - t.testConditionAwait(); - } - - public void testConditionAwait() { - - Thread producer = new Thread (() -> { + private static class Thread1 implements Runnable { + public void run() { int i = 0; while (i < N) { m.lock(); - log("Acquired lock."); - try { while (num > 0) { - log("Beginning await."); empty.await(); - log("Returned from await."); } num++; full.signal(); - log("Sent signal."); - System.out.println("produce ...." + i); + log("produce ...." + i); } catch (InterruptedException e) { e.printStackTrace(); } finally { m.unlock(); - log("Released lock."); } i++; - } - }); + } + } + } - Thread consumer = new Thread (() -> { + private static class Thread2 implements Runnable { + public void run() { int j = 0; while (j < N) { m.lock(); - log("Acquired lock."); try { while (num == 0) { - log("Beginning await."); full.await(); - log("Returned from await."); } total = total + j; - System.out.println("total ...." + total); + log("total ...." + total); num--; empty.signal(); - log("Sent signal."); - System.out.println("consume ...." + j); + log("consume ...." + j); } catch (InterruptedException e) { e.printStackTrace(); } finally { m.unlock(); - log("Released lock."); } j++; } total = total + j; - System.out.println("total ...." + total); + log("total ...." + total); flag = true; - }); + } + } - producer.start(); - consumer.start(); + public static void main(String[] args) { + num = 0; + total = 0; + + Thread t1 = new Thread(new Thread1()); + Thread t2 = new Thread(new Thread2()); + + t1.start(); + t2.start(); try { - producer.join(); - consumer.join(); + t1.join(); + t2.join(); } catch (InterruptedException e) { - throw new RuntimeException(e); } - assert total == ((N * (N + 1)) / 2); + if (flag) + assert total == ((N * (N + 1)) / 2); } + } \ No newline at end of file From 6a59a0721ae23719f16e75408fb94b7bbaa3360a Mon Sep 17 00:00:00 2001 From: Vasu Vikram Date: Mon, 25 Mar 2024 14:55:50 -0400 Subject: [PATCH 7/9] Remove prints --- .../pasta/sfuzz/it/core/ConditionTest.java | 2 +- .../src/test/java/example/ConditionTest.java | 59 ++++++++++--------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/integration-tests/src/test/java/cmu/pasta/sfuzz/it/core/ConditionTest.java b/integration-tests/src/test/java/cmu/pasta/sfuzz/it/core/ConditionTest.java index 047c36ec..4292e36d 100644 --- a/integration-tests/src/test/java/cmu/pasta/sfuzz/it/core/ConditionTest.java +++ b/integration-tests/src/test/java/cmu/pasta/sfuzz/it/core/ConditionTest.java @@ -6,6 +6,6 @@ public class ConditionTest extends IntegrationTestRunner { @Test public void testInterleaving1() { - runTest("main"); + System.out.println(runTest("main")); } } diff --git a/integration-tests/src/test/java/example/ConditionTest.java b/integration-tests/src/test/java/example/ConditionTest.java index 723164ec..ba4da8e3 100644 --- a/integration-tests/src/test/java/example/ConditionTest.java +++ b/integration-tests/src/test/java/example/ConditionTest.java @@ -16,81 +16,82 @@ public class ConditionTest { private static Condition empty = m.newCondition(); private static Condition full = m.newCondition(); - private static void log(String format, Object... args) { + private void log (String format, Object... args) { GlobalContext.INSTANCE.log(format, args); } - private static class Thread1 implements Runnable { - public void run() { + public static void main(String[] args) { + ConditionTest t = new ConditionTest(); + t.testConditionAwait(); + } + + public void testConditionAwait() { + + Thread producer = new Thread (() -> { int i = 0; while (i < N) { m.lock(); + log("Acquired lock."); + try { while (num > 0) { + log("Beginning await."); empty.await(); + log("Returned from await."); } num++; full.signal(); + log("Sent signal."); - log("produce ...." + i); } catch (InterruptedException e) { e.printStackTrace(); } finally { m.unlock(); + log("Released lock."); } i++; - } - } - } + } + }); - private static class Thread2 implements Runnable { - public void run() { + Thread consumer = new Thread (() -> { int j = 0; while (j < N) { m.lock(); + log("Acquired lock."); try { while (num == 0) { + log("Beginning await."); full.await(); + log("Returned from await."); } total = total + j; - log("total ...." + total); num--; empty.signal(); - log("consume ...." + j); + log("Sent signal."); } catch (InterruptedException e) { - e.printStackTrace(); } finally { m.unlock(); + log("Released lock."); } j++; } total = total + j; - log("total ...." + total); flag = true; - } - } + }); - public static void main(String[] args) { - num = 0; - total = 0; - - Thread t1 = new Thread(new Thread1()); - Thread t2 = new Thread(new Thread2()); - - t1.start(); - t2.start(); + producer.start(); + consumer.start(); try { - t1.join(); - t2.join(); + producer.join(); + consumer.join(); } catch (InterruptedException e) { + throw new RuntimeException(e); } - if (flag) - assert total == ((N * (N + 1)) / 2); + assert total == ((N * (N + 1)) / 2); } - } \ No newline at end of file From 3d253c533592db9206cc911cf692e515a0c76dd2 Mon Sep 17 00:00:00 2001 From: Vasu Vikram Date: Mon, 25 Mar 2024 15:06:30 -0400 Subject: [PATCH 8/9] Added expected and schedule --- .../pasta/sfuzz/it/core/ConditionTest.java | 2 +- .../src/test/java/example/ConditionTest.java | 21 +- .../resources/expected/ConditionTest_Fifo.txt | 23 ++ .../resources/expected/ConditionTest_T1T2.txt | 8 - .../schedules/ConditionTest_Fifo.json | 110 +++++++++ .../schedules/ConditionTest_T1T2.json | 225 ------------------ 6 files changed, 144 insertions(+), 245 deletions(-) create mode 100644 integration-tests/src/test/resources/expected/ConditionTest_Fifo.txt delete mode 100644 integration-tests/src/test/resources/expected/ConditionTest_T1T2.txt create mode 100644 integration-tests/src/test/resources/schedules/ConditionTest_Fifo.json delete mode 100644 integration-tests/src/test/resources/schedules/ConditionTest_T1T2.json diff --git a/integration-tests/src/test/java/cmu/pasta/sfuzz/it/core/ConditionTest.java b/integration-tests/src/test/java/cmu/pasta/sfuzz/it/core/ConditionTest.java index 4292e36d..047c36ec 100644 --- a/integration-tests/src/test/java/cmu/pasta/sfuzz/it/core/ConditionTest.java +++ b/integration-tests/src/test/java/cmu/pasta/sfuzz/it/core/ConditionTest.java @@ -6,6 +6,6 @@ public class ConditionTest extends IntegrationTestRunner { @Test public void testInterleaving1() { - System.out.println(runTest("main")); + runTest("main"); } } diff --git a/integration-tests/src/test/java/example/ConditionTest.java b/integration-tests/src/test/java/example/ConditionTest.java index ba4da8e3..aebcbd7e 100644 --- a/integration-tests/src/test/java/example/ConditionTest.java +++ b/integration-tests/src/test/java/example/ConditionTest.java @@ -31,23 +31,22 @@ public void testConditionAwait() { int i = 0; while (i < N) { m.lock(); - log("Acquired lock."); + log("Acquired lock.\n"); try { while (num > 0) { - log("Beginning await."); + log("Beginning empty await.\n"); empty.await(); - log("Returned from await."); + log("Returned from empty await.\n"); } num++; full.signal(); - log("Sent signal."); + log("Sent full signal.\n"); } catch (InterruptedException e) { - e.printStackTrace(); } finally { m.unlock(); - log("Released lock."); + log("Released lock.\n"); } @@ -59,21 +58,21 @@ public void testConditionAwait() { int j = 0; while (j < N) { m.lock(); - log("Acquired lock."); + log("Acquired lock.\n"); try { while (num == 0) { - log("Beginning await."); + log("Beginning full await.\n"); full.await(); - log("Returned from await."); + log("Returned from full await.\n"); } total = total + j; num--; empty.signal(); - log("Sent signal."); + log("Sent empty signal.\n"); } catch (InterruptedException e) { } finally { m.unlock(); - log("Released lock."); + log("Released lock.\n"); } j++; diff --git a/integration-tests/src/test/resources/expected/ConditionTest_Fifo.txt b/integration-tests/src/test/resources/expected/ConditionTest_Fifo.txt new file mode 100644 index 00000000..8e8dc5f7 --- /dev/null +++ b/integration-tests/src/test/resources/expected/ConditionTest_Fifo.txt @@ -0,0 +1,23 @@ +[1]: Acquired lock. +[1]: Sent full signal. +[1]: Released lock. +[1]: Acquired lock. +[1]: Beginning empty await. +[2]: Acquired lock. +[2]: Sent empty signal. +[2]: Released lock. +[1]: Returned from empty await. +[1]: Sent full signal. +[1]: Released lock. +[1]: Acquired lock. +[1]: Beginning empty await. +[2]: Acquired lock. +[2]: Sent empty signal. +[2]: Released lock. +[1]: Returned from empty await. +[1]: Sent full signal. +[1]: Released lock. +[2]: Acquired lock. +[2]: Sent empty signal. +[2]: Released lock. + diff --git a/integration-tests/src/test/resources/expected/ConditionTest_T1T2.txt b/integration-tests/src/test/resources/expected/ConditionTest_T1T2.txt deleted file mode 100644 index 64633909..00000000 --- a/integration-tests/src/test/resources/expected/ConditionTest_T1T2.txt +++ /dev/null @@ -1,8 +0,0 @@ -[1]: Trying to acquire lock. -[1]: Acquired lock. -[1]: Trying to unlock. -[1]: Unlocked. -[2]: Trying to acquire lock. -[2]: Acquired lock. -[2]: Trying to unlock. -[2]: Unlocked. diff --git a/integration-tests/src/test/resources/schedules/ConditionTest_Fifo.json b/integration-tests/src/test/resources/schedules/ConditionTest_Fifo.json new file mode 100644 index 00000000..f28e204b --- /dev/null +++ b/integration-tests/src/test/resources/schedules/ConditionTest_Fifo.json @@ -0,0 +1,110 @@ +{ + "choices": [ + { + "selected": 0, + "threadId": 0, + "enabled": 1 + }, + { + "selected": 0, + "threadId": 0, + "enabled": 1 + }, + { + "selected": 0, + "threadId": 0, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 0, + "enabled": 3 + }, + { + "selected": 0, + "threadId": 0, + "enabled": 3 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 2, + "enabled": 1 + }, + { + "selected": 0, + "threadId": 2, + "enabled": 1 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 2, + "enabled": 1 + }, + { + "selected": 0, + "threadId": 1, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 0, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 0, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 0, + "enabled": 2 + }, + { + "selected": 0, + "threadId": 2, + "enabled": 1 + }, + { + "selected": 0, + "threadId": 0, + "enabled": 1 + } + ], + "fullSchedule": true +} \ No newline at end of file diff --git a/integration-tests/src/test/resources/schedules/ConditionTest_T1T2.json b/integration-tests/src/test/resources/schedules/ConditionTest_T1T2.json deleted file mode 100644 index 99f35151..00000000 --- a/integration-tests/src/test/resources/schedules/ConditionTest_T1T2.json +++ /dev/null @@ -1,225 +0,0 @@ -{ - "choices": [ - { - "selected": 0, - "threadId": 0, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 0, - "enabled": 3 - }, - { - "selected": 0, - "threadId": 0, - "enabled": 3 - }, - { - "selected": 0, - "threadId": 0, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 2, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 2, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 1, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 0, - "enabled": 2 - }, - { - "selected": 0, - "threadId": 0, - "enabled": 2 - } - ], - "fullSchedule": true -} From 9ec5812b47bf352973a229bdfd60db2fe617fc9b Mon Sep 17 00:00:00 2001 From: Vasu Vikram Date: Mon, 25 Mar 2024 15:09:47 -0400 Subject: [PATCH 9/9] Update workflow --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e213ccee..a30f2e00 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,7 @@ jobs: java-version: '21' cache: 'gradle' - name: Build sfuzz (no tests) - run: ./gradlew build --no-daemon -x test + run: ./gradlew build -x test - name: Instrument JDK run: ./gradlew jlink - name: Build shadow JAR