summaryrefslogtreecommitdiffstats
path: root/t/superuser--should-restart.t
blob: 4943e24162fcb509bf548fb3d900e2276266961e (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
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/perl

# "a" provides "should-restart = system"
# "c" provides "should-restart = system"

# this test would fail since the "restart your computer" message was disabled when 
# urpmi is run with --urpmi-root
$ENV{URPMI_TEST_RESTART} = 1;

use strict;
use lib '.', 't';
use helper;
use Test::More;
BEGIN {
    if (-d "/proc/$$") {
	plan 'no_plan';
    } else {
	plan skip_all => "A mounted /proc is required for those tests due to urpm::sys::_launched_time() relying on /proc/uptime";
    }
}

need_root_and_prepare();

my $medium_name = 'should-restart';

urpmi_addmedia("$medium_name $::pwd/media/$medium_name");

test_urpmi('a', 'You should restart your computer for a');
test_urpmi('b', '');
test_urpmi('c', 'You should restart your computer for a, c');

sub test_urpmi {
    my ($para, $wanted) = @_;
    my $s = run_urpm_cmd("urpmi $para");
    print $s;

    my $msg = $s =~ /^(You should restart .*)/m ? $1 : '';

    ok($msg eq $wanted, "wanted:$wanted, got:$msg");
}