From 55c8acd527bf0b5608e15587be9a9bfad3dc3c6b Mon Sep 17 00:00:00 2001 From: OszkarSemerath Date: Fri, 10 Feb 2023 11:49:47 +0100 Subject: Moved test parametrization to FuzzTestCollections.java --- .../tools/refinery/store/map/tests/fuzz/CommitFuzzTest.java | 8 +++++--- .../refinery/store/map/tests/fuzz/ContentEqualsFuzzTest.java | 7 +++---- .../refinery/store/map/tests/fuzz/DiffCursorFuzzTest.java | 12 +++++------- .../refinery/store/map/tests/fuzz/MultiThreadFuzzTest.java | 7 ++++--- .../tools/refinery/store/map/tests/fuzz/MutableFuzzTest.java | 6 +++--- .../map/tests/fuzz/MutableImmutableCompareFuzzTest.java | 6 +++--- .../tools/refinery/store/map/tests/fuzz/RestoreFuzzTest.java | 6 +++--- .../refinery/store/map/tests/fuzz/SharedStoreFuzzTest.java | 7 ++++--- .../store/map/tests/fuzz/utils/FuzzTestCollections.java | 11 +++++++++++ 9 files changed, 41 insertions(+), 29 deletions(-) create mode 100644 subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/utils/FuzzTestCollections.java (limited to 'subprojects/store/src/test') diff --git a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/CommitFuzzTest.java b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/CommitFuzzTest.java index 9e3f636b..b61152f5 100644 --- a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/CommitFuzzTest.java +++ b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/CommitFuzzTest.java @@ -18,7 +18,10 @@ import tools.refinery.store.map.internal.VersionedMapImpl; import tools.refinery.store.map.tests.fuzz.utils.FuzzTestUtils; import tools.refinery.store.map.tests.utils.MapTestEnvironment; +import static tools.refinery.store.map.tests.fuzz.utils.FuzzTestCollections.*; + class CommitFuzzTest { + private void runFuzzTest(String scenario, int seed, int steps, int maxKey, int maxValue, boolean nullDefault, int commitFrequency, boolean evilHash) { @@ -67,9 +70,8 @@ class CommitFuzzTest { } static Stream parametrizedFastFuzz() { - return FuzzTestUtils.permutationWithSize(new Object[]{FuzzTestUtils.FAST_STEP_COUNT}, new Object[]{3, 32, 32 * 32}, - new Object[]{2, 3}, new Object[]{false, true}, new Object[]{1, 10, 100}, new Object[]{1, 2, 3}, - new Object[]{false, true}); + return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, + commitFrequencyOptions, randomSeedOptions, evilHashOptions); } @ParameterizedTest(name = "Commit {index}/{0} Steps={1} Keys={2} Values={3} nullDefault={4} commit frequency={5} " + diff --git a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/ContentEqualsFuzzTest.java b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/ContentEqualsFuzzTest.java index 71cb3d11..c17b0a95 100644 --- a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/ContentEqualsFuzzTest.java +++ b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/ContentEqualsFuzzTest.java @@ -18,6 +18,7 @@ import java.util.Random; import java.util.stream.Stream; import static org.junit.jupiter.api.Assertions.*; +import static tools.refinery.store.map.tests.fuzz.utils.FuzzTestCollections.*; class ContentEqualsFuzzTest { private void runFuzzTest(String scenario, int seed, int steps, int maxKey, int maxValue, @@ -93,10 +94,8 @@ class ContentEqualsFuzzTest { } static Stream parametrizedFastFuzz() { - return FuzzTestUtils.permutationWithSize(new Object[]{FuzzTestUtils.FAST_STEP_COUNT}, new Object[]{3, 32, - 32 * 32}, - new Object[]{2, 3}, new Object[]{false, true}, new Object[]{1, 10, 100}, new Object[]{1, 2, 3}, - new Object[]{false, true}); + return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, + commitFrequencyOptions, randomSeedOptions, evilHashOptions); } @ParameterizedTest(name = "Compare {index}/{0} Steps={1} Keys={2} Values={3} defaultNull={4} commit frequency={5}" + diff --git a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/DiffCursorFuzzTest.java b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/DiffCursorFuzzTest.java index 8a5576aa..90aa8e01 100644 --- a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/DiffCursorFuzzTest.java +++ b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/DiffCursorFuzzTest.java @@ -1,6 +1,7 @@ package tools.refinery.store.map.tests.fuzz; import static org.junit.jupiter.api.Assertions.fail; +import static tools.refinery.store.map.tests.fuzz.utils.FuzzTestCollections.*; import java.util.Random; import java.util.stream.Stream; @@ -93,16 +94,14 @@ class DiffCursorFuzzTest { @Timeout(value = 10) @Tag("fuzz") void parametrizedFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean nullDefault, int commitFrequency, - int seed, - boolean evilHash) { + int seed, boolean evilHash) { runFuzzTest("MutableImmutableCompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, nullDefault, commitFrequency, evilHash); } static Stream parametrizedFuzz() { - return FuzzTestUtils.permutationWithSize(new Object[]{FuzzTestUtils.FAST_STEP_COUNT}, new Object[]{3, 32, 32 * 32}, - new Object[]{2, 3}, new Object[]{false, true}, new Object[]{1, 10, 100}, new Object[]{1, 2, 3}, - new Object[]{false, true}); + return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, + commitFrequencyOptions, randomSeedOptions, evilHashOptions); } @ParameterizedTest(name = "Mutable-Immutable Compare {index}/{0} Steps={1} Keys={2} Values={3} nullDefault={4} " + @@ -111,8 +110,7 @@ class DiffCursorFuzzTest { @Tag("fuzz") @Tag("slow") void parametrizedSlowFuzz(int ignoredTests, int steps, int noKeys, int noValues, boolean nullDefault, int commitFrequency, - int seed, - boolean evilHash) { + int seed, boolean evilHash) { runFuzzTest("MutableImmutableCompareS" + steps + "K" + noKeys + "V" + noValues + "s" + seed, seed, steps, noKeys, noValues, nullDefault, commitFrequency, evilHash); } diff --git a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MultiThreadFuzzTest.java b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MultiThreadFuzzTest.java index 5d5f3ce3..9325a938 100644 --- a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MultiThreadFuzzTest.java +++ b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MultiThreadFuzzTest.java @@ -2,6 +2,7 @@ package tools.refinery.store.map.tests.fuzz; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; +import static tools.refinery.store.map.tests.fuzz.utils.FuzzTestCollections.*; import java.util.Collections; import java.util.LinkedList; @@ -78,9 +79,9 @@ class MultiThreadFuzzTest { } static Stream parametrizedFastFuzz() { - return FuzzTestUtils.permutationWithSize(new Object[]{FuzzTestUtils.FAST_STEP_COUNT}, new Object[]{3, 32, 32 * 32}, - new Object[]{2, 3}, new Object[]{false, true}, new Object[]{10, 100}, new Object[]{1, 2, 3}, - new Object[]{false, true}); + return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, + new Object[]{10, 100}, randomSeedOptions, + evilHashOptions); } @ParameterizedTest(name = "MultiThread {index}/{0} Steps={1} Keys={2} Values={3} defaultNull={4} commit " + diff --git a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MutableFuzzTest.java b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MutableFuzzTest.java index 2d65ba0c..ab37ef83 100644 --- a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MutableFuzzTest.java +++ b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MutableFuzzTest.java @@ -1,6 +1,7 @@ package tools.refinery.store.map.tests.fuzz; import static org.junit.jupiter.api.Assertions.fail; +import static tools.refinery.store.map.tests.fuzz.utils.FuzzTestCollections.*; import java.util.Random; import java.util.stream.Stream; @@ -64,9 +65,8 @@ class MutableFuzzTest { } static Stream parametrizedFuzz() { - return FuzzTestUtils.permutationWithSize(new Object[]{FuzzTestUtils.FAST_STEP_COUNT}, - new Object[]{3, 32, 32 * 32, 32 * 32 * 32 * 32}, new Object[]{2, 3}, new Object[]{false, true}, - new Object[]{1, 2, 3}, new Object[]{false, true}); + return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, + randomSeedOptions, evilHashOptions); } @ParameterizedTest(name = "Mutable {index}/{0} Steps={1} Keys={2} Values={3} nullDefault={4} seed={5} " + diff --git a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MutableImmutableCompareFuzzTest.java b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MutableImmutableCompareFuzzTest.java index da8a43c2..b58b06f9 100644 --- a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MutableImmutableCompareFuzzTest.java +++ b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/MutableImmutableCompareFuzzTest.java @@ -1,6 +1,7 @@ package tools.refinery.store.map.tests.fuzz; import static org.junit.jupiter.api.Assertions.fail; +import static tools.refinery.store.map.tests.fuzz.utils.FuzzTestCollections.*; import java.util.Random; import java.util.stream.Stream; @@ -69,9 +70,8 @@ class MutableImmutableCompareFuzzTest { } static Stream parametrizedFastFuzz() { - return FuzzTestUtils.permutationWithSize(new Object[]{FuzzTestUtils.FAST_STEP_COUNT}, new Object[]{3, 32, 32 * 32}, - new Object[]{2, 3}, new Object[]{false, true}, new Object[]{1, 10, 100}, new Object[]{1, 2, 3}, - new Object[]{false, true}); + return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, + commitFrequencyOptions, randomSeedOptions, evilHashOptions); } @ParameterizedTest(name = "Mutable-Immutable Compare {index}/{0} Steps={1} Keys={2} Values={3} nullDefault={4} " + diff --git a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/RestoreFuzzTest.java b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/RestoreFuzzTest.java index bd03d1e9..77b26c41 100644 --- a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/RestoreFuzzTest.java +++ b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/RestoreFuzzTest.java @@ -1,6 +1,7 @@ package tools.refinery.store.map.tests.fuzz; import static org.junit.jupiter.api.Assertions.fail; +import static tools.refinery.store.map.tests.fuzz.utils.FuzzTestCollections.*; import java.util.HashMap; import java.util.Map; @@ -90,9 +91,8 @@ class RestoreFuzzTest { } static Stream parametrizedFastFuzz() { - return FuzzTestUtils.permutationWithSize(new Object[]{FuzzTestUtils.FAST_STEP_COUNT}, new Object[]{3, 32, 32 * 32}, - new Object[]{2, 3}, new Object[]{false, true}, new Object[]{1, 10, 100}, new Object[]{1, 2, 3}, - new Object[]{false, true}); + return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, + commitFrequencyOptions, randomSeedOptions, evilHashOptions); } @ParameterizedTest(name = "Restore {index}/{0} Steps={1} Keys={2} Values={3} nullDefault={4} commit frequency={5}" + diff --git a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/SharedStoreFuzzTest.java b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/SharedStoreFuzzTest.java index 0fc9cd38..4462c55b 100644 --- a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/SharedStoreFuzzTest.java +++ b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/SharedStoreFuzzTest.java @@ -20,6 +20,8 @@ import tools.refinery.store.map.internal.VersionedMapImpl; import tools.refinery.store.map.tests.fuzz.utils.FuzzTestUtils; import tools.refinery.store.map.tests.utils.MapTestEnvironment; +import static tools.refinery.store.map.tests.fuzz.utils.FuzzTestCollections.*; + class SharedStoreFuzzTest { private void runFuzzTest(String scenario, int seed, int steps, int maxKey, int maxValue, boolean nullDefault, int commitFrequency, boolean evilHash) { @@ -93,9 +95,8 @@ class SharedStoreFuzzTest { } static Stream parametrizedFastFuzz() { - return FuzzTestUtils.permutationWithSize(new Object[]{FuzzTestUtils.FAST_STEP_COUNT}, new Object[]{3, 32, 32 * 32}, - new Object[]{2, 3}, new Object[]{false, true}, new Object[]{1, 10, 100}, new Object[]{1, 2, 3}, - new Object[]{false, true}); + return FuzzTestUtils.permutationWithSize(stepCounts, keyCounts, valueCounts, nullDefaultOptions, + commitFrequencyOptions, randomSeedOptions, evilHashOptions); } @ParameterizedTest(name = "Shared Store {index}/{0} Steps={1} Keys={2} Values={3} nullDefault={4} commit " + diff --git a/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/utils/FuzzTestCollections.java b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/utils/FuzzTestCollections.java new file mode 100644 index 00000000..add4ca5d --- /dev/null +++ b/subprojects/store/src/test/java/tools/refinery/store/map/tests/fuzz/utils/FuzzTestCollections.java @@ -0,0 +1,11 @@ +package tools.refinery.store.map.tests.fuzz.utils; + +public final class FuzzTestCollections { + public static final Object[] stepCounts = {FuzzTestUtils.FAST_STEP_COUNT}; + public static final Object[] keyCounts = {3, 32, 32 * 32}; + public static final Object[] valueCounts = {2, 3}; + public static final Object[] nullDefaultOptions = {false, true}; + public static final Object[] commitFrequencyOptions = {1, 10, 100}; + public static final Object[] randomSeedOptions = {1, 2, 3}; + public static final Object[] evilHashOptions = {false, true}; +} -- cgit v1.2.3-54-g00ecf