02-get_functions.t 1002 B

12345678910111213141516
  1. use warnings;
  2. use strict;
  3. use Test::More 'tests' => 8;
  4. use Disk::SMART;
  5. my $disk = '/dev/sda';
  6. my $smart = Disk::SMART->new($disk);
  7. ok( $smart->get_disk_temp($disk), 'get_disk_temp() returns drive temperature or N/A' );
  8. is( eval{$smart->get_disk_temp('/dev/sdz')}, undef, 'get_disk_temp() returns failure when passed invalid device' );
  9. like( $smart->get_disk_health($disk), qr/PASSED|FAILED|N\/A/, 'get_disk_health() returns health status or N/A' );
  10. is( eval{$smart->get_disk_health('/dev/sdz')}, undef, 'get_disk_health() returns failure when passed invalid device' );
  11. like( $smart->get_disk_model($disk), qr/\w+/, 'get_disk_model() returns disk model or N/A' );
  12. is( eval{$smart->get_disk_errors('/dev/sdz')}, undef, 'get_disk_model() returns failure when passed invalid device' );
  13. like( $smart->get_disk_errors($disk), qr/\w+/, 'get_disk_errors() returns proper string' );
  14. is( eval{$smart->get_disk_errors('/dev/sdz')}, undef, 'get_disk_errors() returns failure when passed invalid device' );