From: Eric Bollengier Date: Fri, 24 Feb 2023 15:36:24 +0000 (+0100) Subject: regress: Add get_client_name() to functions.pm X-Git-Tag: Beta-15.0.0~243 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=143bbcd6f1abef7f70b161d6a189e3ff6a0ee372;p=thirdparty%2Fbacula.git regress: Add get_client_name() to functions.pm --- diff --git a/regress/scripts/functions.pm b/regress/scripts/functions.pm index 4085a2de7..eddca8d23 100644 --- a/regress/scripts/functions.pm +++ b/regress/scripts/functions.pm @@ -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;