File Coverage

check_qemu_oom
Criterion Covered Total %
statement 19 23 82.6
total 19 23 82.6


line stmt code
1   #!/usr/bin/perl -w
2   # Copyright 2021 SUSE LLC
3   # SPDX-License-Identifier: GPL-2.0-or-later
4   #
5    
6   =head1 check_qemu_oom
7    
8   check_qemu_oom - check if qemu is killed due to system being out of memory
9    
10   =head1 SYNOPSIS
11    
12   check_qemu_oom qemu_pid
13    
14   =cut
15    
16 1 use Mojo::Base -strict, -signatures;
  1  
  1  
17 1 use Getopt::Long;
  1  
  1  
18    
19 1 Getopt::Long::Configure("no_ignore_case");
20    
21 1 my %options;
22    
23 1 eval { require Pod::Usage; Pod::Usage::pod2usage($r) };
  1  
  1  
24 1 die "cannot display help, install perl(Pod::Usage)\n" if $@;
  1  
  1  
25 0 }
26    
27   GetOptions(\%options, 'help|h|?') or usage(1);
28 1 usage(0) if $options{help};
29 1 usage(1) unless @ARGV;
30 0 my $qemu_pid = $ARGV[0] or usage(1);
31 0  
32   exit(index(qx{dmesg} // '', "Out of memory: Killed process $qemu_pid") != -1 ? 0 : 1);