gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-schemafuzz] branch master updated: Fixed choosing pa


From: gnunet
Subject: [GNUnet-SVN] [taler-schemafuzz] branch master updated: Fixed choosing patern. Need to cut undo Array in order to inject second half
Date: Thu, 17 May 2018 18:29:43 +0200

This is an automated email from the git hooks/post-receive script.

erwan-ulrich pushed a commit to branch master
in repository schemafuzz.

The following commit(s) were added to refs/heads/master by this push:
     new c51501b  Fixed choosing patern. Need to cut undo Array in order to 
inject second half
c51501b is described below

commit c51501b5da55485ade1ae6824450ef075cebfb78
Author: Feideus <address@hidden>
AuthorDate: Thu May 17 18:29:31 2018 +0200

    Fixed choosing patern. Need to cut undo Array in order to inject second half
---
 evaluator.sh                                       |   2 +-
 src/main/java/org/schemaspy/DBFuzzer.java          |  18 ++--
 src/main/java/org/schemaspy/Main.java              |   5 +-
 .../java/org/schemaspy/model/GenericTreeNode.java  | 101 ++++++++++++++++-----
 4 files changed, 91 insertions(+), 35 deletions(-)

diff --git a/evaluator.sh b/evaluator.sh
index 07929b1..c7f17a2 100644
--- a/evaluator.sh
+++ b/evaluator.sh
@@ -7,7 +7,7 @@ RESULT=$( echo $RESULT | cut -d "-" -f 2 )
 RESULT=$( echo $RESULT | cut -d "(" -f1 )
 IFS=' | ' read -ra array <<< "$RESULT"
 
-SCORE=0
+SCORE=1
 
 if [ "${array[1]}" = "Moy" ]
 then
diff --git a/src/main/java/org/schemaspy/DBFuzzer.java 
b/src/main/java/org/schemaspy/DBFuzzer.java
index eefdc9e..6f26d1e 100644
--- a/src/main/java/org/schemaspy/DBFuzzer.java
+++ b/src/main/java/org/schemaspy/DBFuzzer.java
@@ -73,7 +73,7 @@ public class DBFuzzer
           }
           catch(Exception e)
           {
-              LOGGER.error(e.toString());
+              e.printStackTrace();
               returnStatus = false;
           }
 
@@ -85,17 +85,18 @@ public class DBFuzzer
             mark = Integer.parseInt(getEvaluatorResponse(evaluatorProcess));
             currentMutation.setInterest_mark(mark);
             currentMutation.setWeight(mark);
-            System.out.println("marking here : "+mark);
-            System.out.println("Weight for currentMut 
"+currentMutation.getWeight());
-            mutationTree.printTree(0);
+            currentMutation.propagateWeight();
+            System.out.println("marking : "+mark);
+            System.out.println("Weight : "+currentMutation.getWeight());
           }
           catch(Exception e)
           {
             returnStatus = false;
-            System.out.println("error while recovering marking"+e);
+            e.printStackTrace();
           }
 
-          // CHOOSINGNEXT GenericTreeNode AND SETTING UP FOR NEXT ITERATION
+          // CHOOSINGNEXT GenericTreeNode AND SETTING UP FOR NEXT ITERATION\
+
           currentMutation = chooseNextMutation();
           while(!this.isNewMutation(currentMutation))
           {
@@ -103,7 +104,7 @@ public class DBFuzzer
             currentMutation = chooseNextMutation();
           }
 
-            System.out.println("currentMutation parent 
"+currentMutation.getParent());
+          System.out.println("chosen mutation"+currentMutation);
 
             
if(!currentMutation.getParent().compare(mutationTree.getLastMutation()))
             {
@@ -257,7 +258,7 @@ public class DBFuzzer
       Random rand = new Random();
 
 
-      if(mutationTree.getNumberOfNodes() > 2)
+      if(mutationTree.getNumberOfNodes() > 1)
       {
         markingDiff = 
previousMutation.getInterest_mark()-mutationTree.find(mutationTree.getLastId()).getInterest_mark();
       }
@@ -272,7 +273,6 @@ public class DBFuzzer
         }
         else if(markingDiff == 0 || markingDiff < 0)
         {
-
             SingleChange tmp = 
mutationTree.getRoot().singleChangeBasedOnWeight();
             nextMut = new 
GenericTreeNode(tmp.getattachedToMutation().getPost_change_row(),nextId(),mutationTree.getRoot(),tmp.getattachedToMutation());
             nextMut.setChosenChange(tmp);
diff --git a/src/main/java/org/schemaspy/Main.java 
b/src/main/java/org/schemaspy/Main.java
index bf7a2c5..d981cd1 100644
--- a/src/main/java/org/schemaspy/Main.java
+++ b/src/main/java/org/schemaspy/Main.java
@@ -101,6 +101,7 @@ public class Main implements CommandLineRunner {
         } catch (ProcessExecutionException badLaunch) {
             LOGGER.warn(badLaunch.getMessage(), badLaunch);
         } catch (Exception exc) {
+          exc.printStackTrace();
             LOGGER.error(exc.getMessage(), exc);
         }
 
@@ -120,7 +121,9 @@ public class Main implements CommandLineRunner {
         }
         catch(Exception e)
         {
-          LOGGER.error(e.getMessage(),e);
+          System.out.println("erreur");
+          //LOGGER.error(e.getMessage(),e);
+          e.printStackTrace();
         }
     }
 
diff --git a/src/main/java/org/schemaspy/model/GenericTreeNode.java 
b/src/main/java/org/schemaspy/model/GenericTreeNode.java
index 71345e5..7e435ad 100644
--- a/src/main/java/org/schemaspy/model/GenericTreeNode.java
+++ b/src/main/java/org/schemaspy/model/GenericTreeNode.java
@@ -30,7 +30,7 @@ public class GenericTreeNode {
     private ArrayList<GenericTreeNode> children = new 
ArrayList<GenericTreeNode>();
     private GenericTreeNode parent;
     private boolean cascadingFK;
-    private final int depth;
+    private int depth;
     /**
     * Default GenericTreeNode constructor
     */
@@ -42,6 +42,7 @@ public class GenericTreeNode {
       this.weight = 1;
       this.subTreeWeight = 0;
       this.depth = 0;
+      this.parent = null;
     }
 
     public GenericTreeNode(Row initial_state_row,int id, GenericTreeNode 
rootMutation, GenericTreeNode parentMutation) {
@@ -50,15 +51,7 @@ public class GenericTreeNode {
       this.cascadingFK = false;
       this.rootMutation = rootMutation;
       this.parent = parentMutation;
-      int cpt = 0;
-      GenericTreeNode tmp = this;
-      while(tmp.getParent() != null)
-      {
-        cpt++;
-        tmp = this.getParent();
-      }
-
-      this.depth = cpt;
+      initDepth();
       this.potential_changes = discoverMutationPossibilities();
       this.weight = 1;
       this.subTreeWeight = 0;
@@ -74,15 +67,50 @@ public class GenericTreeNode {
       return this.weight;
     }
 
-    public void addToSubTreeWeight(int childWeight)
+    public void initDepth()
     {
-      this.subTreeWeight += childWeight;
+      GenericTreeNode tmp = this;
+      int cpt = 0;
+      while( tmp.getParent() != null)
+      {
+        tmp = tmp.getParent();
+        cpt++;
+      }
+
+      this.depth = cpt;
     }
 
-    public void setWeight(Integer weight)
+    public boolean checkWeightConsistency()
+    {
+      int tmp = 0;
+      for(GenericTreeNode child : this.getChildren())
+      {
+        tmp += child.getWeight();
+      }
+
+      if(tmp != this.getSubTreeWeight() && !this.getChildren().isEmpty())
+      {
+        System.out.println("Weight inconstistent "+this.getWeight()+"   
"+this.getSubTreeWeight());
+        System.out.println("Mutation concernee = "+this);
+        return false;
+      }
+
+      return true ;
+    }
+
+    public void updateSubTreeWeight()
+    {
+      int tmp = 0;
+      for(GenericTreeNode child : this.getChildren())
+      {
+        tmp += child.getWeight();
+      }
+      this.subTreeWeight = tmp;
+    }
+
+    public void setWeight(int weight)
     {
       this.weight = weight;
-      propagateWeight();
     }
 
     private static final Random r = new Random();
@@ -91,8 +119,9 @@ public class GenericTreeNode {
     */
     public SingleChange singleChangeBasedOnWeight ()
     {
-      if (this.potential_changes.isEmpty())
-        throw new Error("This should be impossible to reach");
+      checkWeightConsistency();
+      if (this.potential_changes.isEmpty() && (0 == subTreeWeight))
+        System.out.println("ERROR PICKING : no potential_changes AND 
subtreeweight = 0");
 
       int rnd = r.nextInt(subTreeWeight + potential_changes.size());
       assert (rnd >= 0);
@@ -101,11 +130,14 @@ public class GenericTreeNode {
       rnd -= potential_changes.size();
       for (GenericTreeNode n : children)
         {
-          int w = n.getSubTreeWeight();
+          int w = n.getWeight();
           if (rnd < w)
+          {
             return n.singleChangeBasedOnWeight();
+          }
           rnd -= w;
         }
+       System.out.println("ici2");
        throw new Error("This should be impossible to reach");
     }
 
@@ -431,9 +463,29 @@ public class GenericTreeNode {
     public boolean undoToMutation(GenericTreeNode target, SchemaAnalyzer 
analyzer) throws Exception
     {
       ArrayList<GenericTreeNode> pathToMutation = findPathToMutation(target);
-      for(int i = 0; i < pathToMutation.size();i++)
+      ArrayList<GenericTreeNode> goingUp;
+      ArrayList<GenericTreeNode> goingDown;
+
+      for(int j = 0; j < pathToMutation.size();j++)
+      {
+        if(j < pathToMutation.size()-1)
+        {
+          if(! 
pathToMutation.get(j).getParent().compare(pathToMutation.get(j+1)))
+          {
+            goingUp = (ArrayList) pathToMutation.subList(0, j);
+            goingDown = (ArrayList) pathToMutation.subList(j+1, 
pathToMutation.size()-1);
+          }
+
+        }
+      }
+
+      for(int i = 0; i < goingUp.size();i++)
       {
-        pathToMutation.get(i).undo(analyzer);
+        goingUp.get(i).undo(analyzer);
+      }
+      for(int i = 0; i < goingDown.size();i++)
+      {
+        goingDown.get(i).inject(analyzer,false);
       }
       return true;
     }
@@ -491,7 +543,7 @@ public class GenericTreeNode {
 
 
     public String toString() {
-      return "[ MUT ID "+this.getId()+" SG "+this.chosenChange+"]";
+        return "[ MUT ID "+this.getId()+" Depth = "+this.getDepth()+" SG 
"+this.chosenChange+"]";
     }
 
     public ArrayList<GenericTreeNode> findPathToMutation(GenericTreeNode 
target)
@@ -535,7 +587,9 @@ public class GenericTreeNode {
       finalPath.addAll(thisPath);
       finalPath.addAll(targetPath);
 
-      System.out.println("final path "+finalPath);
+      System.out.println("this = "+this);
+      System.out.println("target = "+target);
+      System.out.println("final = "+finalPath);
 
       return finalPath;
 
@@ -595,11 +649,10 @@ public class GenericTreeNode {
 
     public void propagateWeight()
     {
+
+      this.updateSubTreeWeight();
       if(this.getParent() != null)
-      {
-        this.getParent().addToSubTreeWeight(this.getWeight());
         this.getParent().propagateWeight();
-      }
     }
 
 }

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]