Merge pull request #7062 from singhharsh1708/fix/q23-system-status-newline

fix: systemStatus drops the newline zmdc.pl check prints so zmupdate sees a running zoneminder
This commit is contained in:
Isaac Connor authored and GitHub committed 2026-11-21 21:30:02 -05:00
commit d8538839d7
2 files changed
+43 -2

No files matched your search

+2 -2
View File
@@ -741,9 +741,9 @@ sub systemStatus {
my $command = $Config{ZM_PATH_BIN}.'/zmdc.pl check';
my $output = qx($command);
my $status = $? >> 8;
$output = '' if !defined($output);
chomp($output);
if ( $status || logDebugging() ) {
$output = '' if !defined($output);
chomp($output);
Debug("Command: $command Output: $output");
}
return $output;
+41
View File
@@ -0,0 +1,41 @@
#!/usr/bin/perl
#
# ZoneMinder::General::systemStatus returns what "zmdc.pl check" prints.
# zmupdate.pl compares it with 'running' to offer to stop ZoneMinder before
# upgrading the database, so the trailing newline must be gone whether or
# not debug logging is on.
#
# Run as: perl tests/perl/test_system_status.pl
#
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../../scripts/ZoneMinder/lib";
BEGIN { $ENV{LOG_FILE} = "/tmp/zm_test_system_status_$$.log"; }
use File::Temp qw(tempdir);
use ZoneMinder::Config qw(:all);
use ZoneMinder::General qw(systemStatus);
my $failures = 0;
sub check {
my ($name, $ok) = @_;
print(($ok ? 'ok' : 'NOT OK')." - $name\n");
$failures++ if !$ok;
}
my $dir = tempdir(CLEANUP => 1);
$Config{ZM_PATH_BIN} = $dir;
foreach my $state ('running', 'stopped') {
open(my $fh, '>', "$dir/zmdc.pl") or die "Can't write $dir/zmdc.pl: $!";
print $fh "#!/bin/sh\necho $state\n";
close($fh);
chmod(0755, "$dir/zmdc.pl");
my $status = systemStatus();
check("zmdc.pl check printing '$state' gives '$state'", $status eq $state);
}
print "\n".($failures ? "$failures failed\n" : "all passed\n");
exit($failures ? 1 : 0);