]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
regress: Add get_client_name() to functions.pm
authorEric Bollengier <eric@baculasystems.com>
Fri, 24 Feb 2023 15:36:24 +0000 (16:36 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:57:01 +0000 (13:57 +0200)
regress/scripts/functions.pm

index 4085a2de7508668b6032bfc1579bae4d40f23ad5..eddca8d23f2e5d3a6b5f8939cc657f8c7033185e 100644 (file)
@@ -53,7 +53,7 @@ our @EXPORT = qw(update_some_files create_many_files check_multiple_copies
                   check_tls_traces println add_virtual_changer check_events check_events_json
                   create_many_hardlinks check_dot_status parse_fuse_trace generate_random_seek
                  check_storage_selection check_json get_perm check_protect
-                 get_running_jobs
+                 get_running_jobs get_client_name
 );
 
 
@@ -2659,4 +2659,17 @@ sub get_running_jobs
     print "$count\n";
 }
 
+sub get_client_name
+{
+    my $line = `$bin/bdirjson -r client -l Name -D`;
+    my $test_json;
+    eval 'use JSON qw/decode_json/; $test_json = JSON->new;';
+    if ($@) {
+        print "ERROR: json test skipped\n";
+        return;
+    }
+    my $r = $test_json->decode($line);
+    print "$r->[0]->{Name}\n";
+}
+
 1;