]> git.sur5r.net Git - bacula/bacula/commitdiff
regress: Add get_traces and truncate_traces to regress-win32.pl
authorEric Bollengier <eric@eb.homelinux.org>
Mon, 13 Dec 2010 20:21:38 +0000 (21:21 +0100)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:39:47 +0000 (14:39 +0200)
regress/scripts/regress-win32.pl

index c931bcd7657f5b041302b9f71de8b7e07e6b59cb..6efdb3d65177120042e8e5fd3fa39b54a3582e8c 100644 (file)
@@ -921,6 +921,22 @@ sub remove_dir
     return "OK\n";
 }
 
+sub get_traces
+{
+    my ($file) = <"c:/program files/bacula/working/*.trace">;
+    if (!$file || ! -f $file) {
+        return "ERR\n$!\n";
+    }
+    return $file;
+}
+
+sub truncate_traces
+{
+    my $f = get_traces();
+    unlink($f) or return "ERR\n$!\n";
+    return "OK\n";
+}
+
 # When adding an action, fill this hash with the right function
 my %action_list = (
     nop     => sub { return "OK\n"; },
@@ -945,6 +961,8 @@ my %action_list = (
     create_schedtask => \&create_schedtask,
     del_schedtask => \&del_schedtask,
     check_schedtask => \&check_schedtask,
+    get_traces => \&get_traces,
+    truncate_traces => \&truncate_traces,
 
     check_mssql => \&check_mssql,
     setup_mssql_db => \&setup_mssql_db,
@@ -984,11 +1002,17 @@ sub handle_client
         print "Exec $action:\n";
         
         my $ret = $action_list{$action}($r);
-        my $h = HTTP::Headers->new('Content-Type' => 'text/plain') ;
-        my $r = HTTP::Response->new(HTTP::Status::RC_OK,
-                                    'OK', $h, $ret) ;
-        print $ret;
-        $c->send_response($r) ;
+        if ($action eq 'get_traces' && $ret !~ /ERR/) {
+            print "Sending $ret\n";
+            $c->send_file_response($ret);
+
+        } else {
+            my $h = HTTP::Headers->new('Content-Type' => 'text/plain') ;
+            my $r = HTTP::Response->new(HTTP::Status::RC_OK,
+                                        'OK', $h, $ret) ;
+            print $ret;
+            $c->send_response($r) ;
+        }
     } else {
         print "$action not found, probably a version problem\n";
         $c->send_error(RC_NOT_FOUND) ;