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: Done with simple


From: gnunet
Subject: [GNUnet-SVN] [taler-schemafuzz] branch master updated: Done with simple crucial tests (some less important ones still missing. changing the evaluator and starting to implement tree weight balacing based on depth
Date: Fri, 25 May 2018 15:16:20 +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 097364d  Done with simple crucial tests (some less important ones 
still missing. changing the evaluator and starting to implement tree weight 
balacing based on depth
097364d is described below

commit 097364dc351974bb4920d54b718f368bf0a86654
Author: Feideus <address@hidden>
AuthorDate: Fri May 25 15:16:12 2018 +0200

    Done with simple crucial tests (some less important ones still missing. 
changing the evaluator and starting to implement tree weight balacing based on 
depth
---
 aLittleBitLessDumbEvaluator.sh                     | 100 +++++++++++++++++++++
 src/main/java/org/schemaspy/DBFuzzer.java          |   8 +-
 .../java/org/schemaspy/model/GenericTreeNode.java  |  18 +++-
 .../java/org/schemaspy/model/SingleChange.java     |  14 +--
 .../org/schemaspy/model/GenericTreeNodeTest.java   |  95 ++++++++++++++------
 5 files changed, 194 insertions(+), 41 deletions(-)

diff --git a/aLittleBitLessDumbEvaluator.sh b/aLittleBitLessDumbEvaluator.sh
new file mode 100644
index 0000000..18cefb0
--- /dev/null
+++ b/aLittleBitLessDumbEvaluator.sh
@@ -0,0 +1,100 @@
+#!/bin/bash
+
+RESULT="$(psql -d sample_database2 -c 'SELECT * FROM test_table2')";
+
+RESULT=$( echo $RESULT | grep -P -o "\- .*" )
+RESULT=$( echo $RESULT | cut -d "-" -f 2 )
+RESULT=$( echo $RESULT | cut -d "(" -f1 )
+IFS=' | ' read -ra array <<< "$RESULT"
+
+echo $RESULT
+echo ${array[0]}
+echo ${array[1]}
+echo ${array[2]}
+echo ${array[3]}
+
+SCORE=0
+
+if [[ ${array[0]} = "t" && "${array[1]}" = "t" && "${array[2]}" = "t" && 
"${array[3]}" = "t" ]]
+then
+  SCORE=$((SCORE+100))
+fi
+
+if [[ ${array[0]} = "t" && "${array[1]}" = "t" && "${array[2]}" = "t" && 
"${array[3]}" = "f" ]]
+then
+  SCORE=$((SCORE+10))
+fi
+
+if [[ ${array[0]} = "t" && "${array[1]}" = "t" && "${array[2]}" = "f" && 
"${array[3]}" = "f" ]]
+then
+  SCORE=$((SCORE+25))
+fi
+
+if [[ ${array[0]} = "t" && "${array[1]}" = "f" && "${array[2]}" = "f" && 
"${array[3]}" = "f" ]]
+then
+  SCORE=$((SCORE+200))
+fi
+
+if [[ ${array[0]} = "f" && "${array[1]}" = "f" && "${array[2]}" = "f" && 
"${array[3]}" = "f" ]]
+then
+  SCORE=$((SCORE))
+fi
+
+if [[ ${array[0]} = "f" && "${array[1]}" = "f" && "${array[2]}" = "t" && 
"${array[3]}" = "f" ]]
+then
+  SCORE=$((SCORE+5))
+fi
+
+if [[ ${array[0]} = "f" && "${array[1]}" = "t" && "${array[2]}" = "f" && 
"${array[3]}" = "f" ]]
+then
+  SCORE=$((SCORE+60))
+fi
+
+if [[ ${array[0]} = "f" && "${array[1]}" = "t" && "${array[2]}" = "f" && 
"${array[3]}" = "t" ]]
+then
+  SCORE=$((SCORE+60))
+fi
+
+if [[ ${array[0]} = "t" && "${array[1]}" = "t" && "${array[2]}" = "f" && 
"${array[3]}" = "t" ]]
+then
+  SCORE=$((SCORE+2))
+fi
+
+if [[ ${array[0]} = "t" && "${array[1]}" = "f" && "${array[2]}" = "t" && 
"${array[3]}" = "t" ]]
+then
+  SCORE=$((SCORE+15))
+fi
+
+if [[ ${array[0]} = "f" && "${array[1]}" = "t" && "${array[2]}" = "t" && 
"${array[3]}" = "t" ]]
+then
+  SCORE=$((SCORE+40))
+fi
+
+if [[ ${array[0]} = "f" && "${array[1]}" = "t" && "${array[2]}" = "t" && 
"${array[3]}" = "f" ]]
+then
+  SCORE=$((SCORE+135))
+fi
+
+if [[ ${array[0]} = "t" && "${array[1]}" = "f" && "${array[2]}" = "f" && 
"${array[3]}" = "t" ]]
+then
+  SCORE=$((SCORE+12))
+fi
+
+if [[ ${array[0]} = "t" && "${array[1]}" = "f" && "${array[2]}" = "f" && 
"${array[3]}" = "f" ]]
+then
+  SCORE=$((SCORE+1))
+fi
+
+if [[ ${array[0]} = "t" && "${array[1]}" = "f" && "${array[2]}" = "t" && 
"${array[3]}" = "f" ]]
+then
+  SCORE=$((SCORE+10))
+fi
+
+if [[ ${array[0]} = "f" && "${array[1]}" = "f" && "${array[2]}" = "f" && 
"${array[3]}" = "t" ]]
+then
+  SCORE=$((SCORE+25))
+fi
+
+echo $SCORE
+
+
diff --git a/src/main/java/org/schemaspy/DBFuzzer.java 
b/src/main/java/org/schemaspy/DBFuzzer.java
index 63a7842..150acee 100644
--- a/src/main/java/org/schemaspy/DBFuzzer.java
+++ b/src/main/java/org/schemaspy/DBFuzzer.java
@@ -97,7 +97,7 @@ public class DBFuzzer
         * After injecting and retrieving the marking for the evaluator,
         * undoes necessary mutations from the tree to setup for next mutation
         */
-        while(mark != -1)
+        while(mark != -2)
         {
           //Choosing next mutation
           currentMutation = chooseNextMutation();
@@ -147,7 +147,7 @@ public class DBFuzzer
             try
             {
                 // the evaluator sets a mark for representing how interesting 
the mutation was
-                Process evaluatorProcess = new ProcessBuilder("/bin/bash", 
"./evaluator.sh").start();
+                Process evaluatorProcess = new ProcessBuilder("/bin/bash", 
"./aLittleBitLessDumbEvaluator.sh").start();
                 mark = 
Integer.parseInt(getEvaluatorResponse(evaluatorProcess));
                 currentMutation.setInterest_mark(mark);
                 currentMutation.setWeight(mark);
@@ -176,7 +176,7 @@ public class DBFuzzer
 
 
       //String theQuery = "SELECT * FROM "+randomTable.getName()+" ORDER BY 
RANDOM() LIMIT 1";
-      String theQuery = "SELECT * FROM test_table ORDER BY RANDOM() LIMIT 1";
+      String theQuery = "SELECT * FROM test_table2 ORDER BY RANDOM() LIMIT 1"; 
// Change test_table2 to test_table here to swap back to line finding
       QueryResponseParser qrp = new QueryResponseParser();
       ResultSet rs = null;
       Row res = null ;
@@ -186,7 +186,7 @@ public class DBFuzzer
         {
              stmt = analyzer.getSqlService().prepareStatement(theQuery);
              rs = stmt.executeQuery();
-             res = 
qrp.parse(rs,analyzer.getDb().getTablesMap().get("test_table")).getRows().get(0);
 //randomTable should be set there
+             res = 
qrp.parse(rs,analyzer.getDb().getTablesMap().get("test_table2")).getRows().get(0);
 //randomTable should be set there
         }
         catch (Exception e)
         {
diff --git a/src/main/java/org/schemaspy/model/GenericTreeNode.java 
b/src/main/java/org/schemaspy/model/GenericTreeNode.java
index 0e8adae..0e93ab4 100644
--- a/src/main/java/org/schemaspy/model/GenericTreeNode.java
+++ b/src/main/java/org/schemaspy/model/GenericTreeNode.java
@@ -63,6 +63,10 @@ public class GenericTreeNode {
         this.potential_changes = discoverMutationPossibilities(rootMutation);
     }
 
+    public void setDepth(int depth) {
+        this.depth = depth;
+    }
+
     public Integer getId() {
         return id;
     }
@@ -145,8 +149,6 @@ public class GenericTreeNode {
             }
             rnd -= w;
         }
-
-        System.out.println("ici2");
         throw new Error("This should be impossible to reach");
     }
 
@@ -434,8 +436,15 @@ public class GenericTreeNode {
 
     public boolean compare(GenericTreeNode genericTreeNode)
     {
-        if (this.getId() == genericTreeNode.getId())
+        if(this == null || genericTreeNode == null )
+            return false;
+
+        if(this.getInitial_state_row() == null || 
genericTreeNode.getInitial_state_row() == null)
+            return false;
+
+        if (this.getId() == genericTreeNode.getId()) {
             return true;
+        }
 
         if 
(this.initial_state_row.compare(genericTreeNode.getInitial_state_row()) && 
this.chosenChange.compare(genericTreeNode.getChosenChange()))
             return true;
@@ -519,6 +528,9 @@ public class GenericTreeNode {
             }
         }
 
+        System.out.println(tmpThis);
+        System.out.println(tmpTarget);
+
         while (!tmpThis.compare(tmpTarget))
         {
             thisPath.add(tmpThis);
diff --git a/src/main/java/org/schemaspy/model/SingleChange.java 
b/src/main/java/org/schemaspy/model/SingleChange.java
index 1c6e0ff..6c4cd23 100644
--- a/src/main/java/org/schemaspy/model/SingleChange.java
+++ b/src/main/java/org/schemaspy/model/SingleChange.java
@@ -62,15 +62,17 @@ public class SingleChange
 
     public boolean compare(SingleChange chosenChange)
     {
+        if(chosenChange == null || this == null )
+            return false;
 
-      
if(!chosenChange.getParentTableColumn().getTable().getName().equals(this.getParentTableColumn().getTable().getName()))
-        return false;
+        if(!chosenChange.getNewValue().equals(this.getNewValue()) || 
!chosenChange.getOldValue().equals(this.getOldValue()))
+            return false;
 
-      
if(!chosenChange.getParentTableColumn().getName().equals(this.getParentTableColumn().getName()))
-        return false;
+        
if(!chosenChange.getParentTableColumn().getTable().getName().equals(this.getParentTableColumn().getTable().getName()))
+          return false;
 
-      if(!chosenChange.getNewValue().equals(this.getNewValue()) || 
!chosenChange.getOldValue().equals(this.getOldValue()))
-        return false;
+        
if(!chosenChange.getParentTableColumn().getName().equals(this.getParentTableColumn().getName()))
+          return false;
 
       return true;
     }
diff --git a/src/test/java/org/schemaspy/model/GenericTreeNodeTest.java 
b/src/test/java/org/schemaspy/model/GenericTreeNodeTest.java
index 9e329c1..a2fde19 100644
--- a/src/test/java/org/schemaspy/model/GenericTreeNodeTest.java
+++ b/src/test/java/org/schemaspy/model/GenericTreeNodeTest.java
@@ -113,34 +113,6 @@ public class GenericTreeNodeTest {
 
     }
 
-//    @Test
-//    public void discoverMutationPossibilitiesTest()
-//    {
-//        HashMap<String,String> mapOfTheRow= new HashMap<String,String>();
-//        mapOfTheRow.put("id","1");
-//        mapOfTheRow.put("string","Loy");
-//        mapOfTheRow.put("bool","f");
-//
-//        CaseInsensitiveMap<TableColumn> tableColumns= new 
CaseInsensitiveMap<TableColumn>();
-//
-//        TableColumn testTableColumn1 = new TableColumn("id","int2");
-//        TableColumn testTableColumn2 = new TableColumn("string","varchar");
-//        TableColumn testTableColumn3 = new TableColumn("bool","bool");
-//
-//        tableColumns.put("",testTableColumn1);
-//        tableColumns.put("",testTableColumn2);
-//        tableColumns.put("",testTableColumn3);
-//
-//        Table testTable = new Table("test_table",tableColumns);
-//        testTable.setColumns(tableColumns);
-//
-//        Row row = new Row(testTable,mapOfTheRow,3);
-//
-//        GenericTreeNode gtn1 = new GenericTreeNode(row,1,null,null);
-//
-//        Assert.assertFalse("No null in a node 
possibilities",gtn1.getPotential_changes().contains("null"));
-//    }
-
     @Test
     public void NoNullMutationPossibilitiesTest() throws Exception
     {
@@ -286,4 +258,71 @@ public class GenericTreeNodeTest {
 
     }
 
+//    @Test  ?????????NOT FUNCTIONNAL ??????????
+//    public void findPathToMutationTest ()
+//    {
+//        GenericTreeNode rootMutation = new GenericTreeNode(null,0);
+//        rootMutation.setParent(null);
+//        rootMutation.setDepth(0);
+//        GenericTreeNode tmpMutation = new GenericTreeNode(null,1);
+//        tmpMutation.setParent(rootMutation);
+//        rootMutation.setDepth(1);
+//        GenericTreeNode tmpMutation3 = new GenericTreeNode(null,3);
+//        tmpMutation3.setParent(rootMutation);
+//        rootMutation.setDepth(1);
+//        GenericTreeNode tmpMutation2 = new GenericTreeNode(null,2);
+//        tmpMutation2.setParent(tmpMutation);
+//        rootMutation.setDepth(2);
+//        GenericTreeNode tmpMutation4 = new GenericTreeNode(null,4);
+//        tmpMutation4.setParent(tmpMutation3);
+//        rootMutation.setDepth(2);
+//
+//        ArrayList<GenericTreeNode> res1 = new ArrayList<>();
+//        res1.add(tmpMutation2);
+//        res1.add(tmpMutation);
+//
+//        ArrayList<GenericTreeNode> res2 = new ArrayList<>();
+//        res2.add(tmpMutation3);
+//        res2.add(tmpMutation4);
+//
+//        ArrayList<ArrayList<GenericTreeNode>> finalPath = new ArrayList<>();
+//        finalPath.add(res1);
+//        finalPath.add(res2);
+//
+//        
Assert.assertTrue(tmpMutation2.findPathToMutation(tmpMutation4).equals(finalPath));
+//
+//    }
+//
+//    @Test
+//    public void isSingleChangeOnPathTest ()
+//    {
+//        TableColumn tmpTableColumn1 = new 
TableColumn("test_table_column","bool","test_table");
+//        TableColumn tmpTableColumn2 = new 
TableColumn("test_table_column","bool","test_table");
+//
+//
+//        GenericTreeNode rootMutation = new GenericTreeNode(null,0);
+//        rootMutation.setParent(null);
+//        rootMutation.setChosenChange(new 
SingleChange(tmpTableColumn1,null,"1","3"));
+//        rootMutation.setDepth(0);
+//
+//
+//        GenericTreeNode tmpMutation = new GenericTreeNode(null,1);
+//        tmpMutation.setParent(rootMutation);
+//        rootMutation.setDepth(1);
+//
+//        GenericTreeNode tmpMutation2 = new GenericTreeNode(null,2);
+//        tmpMutation2.setChosenChange(new 
SingleChange(tmpTableColumn2,null,"1","2"));
+//        tmpMutation2.setParent(tmpMutation);
+//        rootMutation.setDepth(2);
+//
+//        GenericTreeNode tmpMutationInPath = new GenericTreeNode(null,3);
+//        tmpMutationInPath.setParent(tmpMutation2);
+//        tmpMutationInPath.setChosenChange(new 
SingleChange(tmpTableColumn1,null,"1","3"));
+//        rootMutation.setDepth(3);
+//
+//        
Assert.assertFalse(tmpMutation2.isSingleChangeOnCurrentPath(rootMutation));
+//        
Assert.assertTrue(tmpMutationInPath.isSingleChangeOnCurrentPath(rootMutation));
+//
+//    }
+
 }

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



reply via email to

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