changeset 17:f75f7e373d65

generator: omit the tests having only SC executions, #2
author shade
date Mon, 08 Jul 2013 22:05:50 +0400
parents cd4458f8d6b9
children f31f7fbb7bdb
files generator/src/main/java/org/openjdk/jcstress/generator/Utils.java generator/src/main/java/org/openjdk/jcstress/tracer/TraceGen.java
diffstat 2 files changed, 28 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/generator/src/main/java/org/openjdk/jcstress/generator/Utils.java	Mon Jul 08 21:43:13 2013 +0400
+++ b/generator/src/main/java/org/openjdk/jcstress/generator/Utils.java	Mon Jul 08 22:05:50 2013 +0400
@@ -25,6 +25,8 @@
 package org.openjdk.jcstress.generator;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
 
 public class Utils {
     public static String ensureDir(String path) {
@@ -34,4 +36,28 @@
         }
         return file.getAbsolutePath();
     }
+
+    public static <T> List<List<T>> permutate(List<T> src) {
+        if (src.size() <= 1) {
+            List<List<T>> al = new ArrayList<List<T>>();
+            al.add(src);
+            return al;
+        }
+
+        List<List<T>> result = new ArrayList<List<T>>();
+        for (int i = 0; i < src.size(); i++) {
+            List<T> copy = new ArrayList<T>(src);
+            T el = copy.remove(i);
+
+            for (List<T> perm : permutate(copy)) {
+                List<T> c = new ArrayList<T>(perm);
+                c.add(0, el);
+                result.add(c);
+            }
+        }
+
+        return result;
+    }
+
+
 }
\ No newline at end of file
--- a/generator/src/main/java/org/openjdk/jcstress/tracer/TraceGen.java	Mon Jul 08 21:43:13 2013 +0400
+++ b/generator/src/main/java/org/openjdk/jcstress/tracer/TraceGen.java	Mon Jul 08 22:05:50 2013 +0400
@@ -123,6 +123,7 @@
 
             // regardless of the reorderings, all results appear SC.
             //    => the violations are undetectable
+            assert allResults.containsAll(scResults);
             if (scResults.equals(allResults)) continue;
 
             List<String> mappedResult = new ArrayList<String>();
@@ -344,30 +345,9 @@
             return resValues;
         }
 
-        private <T> List<List<T>> permutate(List<T> src) {
-            if (src.size() <= 1) {
-                List<List<T>> al = new ArrayList<List<T>>();
-                al.add(src);
-                return al;
-            }
-
-            List<List<T>> result = new ArrayList<List<T>>();
-            for (int i = 0; i < src.size(); i++) {
-                List<T> copy = new ArrayList<T>(src);
-                T el = copy.remove(i);
-
-                for (List<T> perm : permutate(copy)) {
-                    perm.add(i, el);
-                    result.add(perm);
-                }
-            }
-
-            return result;
-        }
-
         public List<Trace> allPermutations() {
             List<Trace> traces = new ArrayList<Trace>();
-            for (List<Op> perm : permutate(ops)) {
+            for (List<Op> perm : Utils.permutate(ops)) {
                 traces.add(new Trace(perm));
             }
             return traces;