[Pkg-privacy-commits] [libgsecuredelete] 30/168: Updated test application.

Ulrike Uhlig u-guest at moszumanska.debian.org
Thu Jul 7 20:06:35 UTC 2016


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

u-guest pushed a commit to branch master
in repository libgsecuredelete.

commit f4dd366c96591950704b772988b7457c6a222fa3
Author: Colomban Wendling <ban at herbesfolles.org>
Date:   Mon Oct 5 18:41:32 2009 +0200

    Updated test application.
---
 gsecuredelete/main.vala | 75 +++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 66 insertions(+), 9 deletions(-)

diff --git a/gsecuredelete/main.vala b/gsecuredelete/main.vala
index cc74119..5584971 100644
--- a/gsecuredelete/main.vala
+++ b/gsecuredelete/main.vala
@@ -23,6 +23,22 @@ public class Test
 {
   private MainLoop main_loop;
   
+  public enum Operation {
+    DELETE,
+    FILL,
+    MEM,
+    SWAP
+  }
+  
+  private delegate SecureDelete.SecureDeleteOperation? OperationProvider (string[] args);
+  
+  private OperationProvider[] operations = {
+    prepare_delop,
+    prepare_fillop,
+    prepare_memop,
+    prepare_swapop
+  };
+  
   public Test ()
   {
     this.main_loop = new MainLoop (null, false);
@@ -51,23 +67,64 @@ public class Test
     stdout.printf ("%.0f%%\n", progress * 100);
   }
   
-  public bool run (string[] args)
+  private static SecureDelete.SecureDeleteOperation? prepare_delop (string[] args)
   {
-    if (args.length < 2) {
-      return false;
-    }
-    
     var op = new SecureDelete.DeleteOperation ();
     
-    op.finished.connect (finished_handler);
-    op.progress.connect (progress_handler);
+    /*op.mode = SecureDelete.SecureDeleteOperation.Mode.VERY_FAST;*/
     foreach (var arg in args) {
       /* hack to skip the first argument */
       if (arg != args[0])
         op.add_path (arg);
     }
+    foreach (string i in op.paths) {
+      stdout.printf ("Will delete: %s\n", i);
+    }
+    
+    return op;
+  }
+  
+  private static SecureDelete.SecureDeleteOperation? prepare_fillop (string[] args)
+  {
+    var op = new SecureDelete.FillOperation ();
+    
+    if (args.length != 2) {
+      return null;
+    }
+    op.directory = args[1];
+    
+    return op;
+  }
+  
+  private static SecureDelete.SecureDeleteOperation? prepare_memop (string[] args)
+  {
+    var op = new SecureDelete.MemOperation ();
+    op.mode = SecureDelete.SecureDeleteOperation.Mode.VERY_VERY_FAST;
+    
+    return op;
+  }
+  
+  private static SecureDelete.SecureDeleteOperation? prepare_swapop (string[] args)
+  {
+    var op = new SecureDelete.SwapOperation ();
+    op.device = "/dev/sda1";
+    op.mode = SecureDelete.SecureDeleteOperation.Mode.VERY_FAST;
+    
+    return op;
+  }
+  
+  public bool run (string[]   args,
+                   Operation  operation)
+  {
+    var op = this.operations[operation] (args);
+    
+    if (op == null) {
+      return false;
+    }
+    op.finished.connect (finished_handler);
+    op.progress.connect (progress_handler);
     try {
-      op.run ();
+      op.run (10);
       
       this.main_loop = new MainLoop (null, false);
       main_loop.run ();
@@ -83,5 +140,5 @@ public static int main (string[] args)
 {
   var test = new Test ();
   
-  return test.run (args) ? 0 : 1;
+  return test.run (args, Test.Operation.DELETE) ? 0 : 1;
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/libgsecuredelete.git



More information about the Pkg-privacy-commits mailing list