aboutsummaryrefslogtreecommitdiffstats
path: root/t/Utils.pm
blob: eef81874d6995272a68aa918942b560a696aeba0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package Utils;

use strict;
use warnings;
use base qw(Exporter);
use FindBin qw/$Bin/;
use Digest::MD5;

our @EXPORT_OK = qw(run get_md5);


sub run {
    my ($buildroot, $program) = @_;

    $ENV{RPM_BUILD_ROOT} = $buildroot;
    system("$Bin/../$program");
}


sub get_md5 {
    my ($file) = @_;
    open(my $in, '<', $file) or die "can't read $file: $!";
    binmode($in);
    my $md5 = Digest::MD5->new();
    $md5->addfile($in);
    close($in);
    return $md5->hexdigest();
}

1;