|
@@ -26,25 +26,25 @@ my $tmpdir = 't.tmp/900_update_alternatives';
|
|
|
my $admindir = File::Spec->rel2abs("$tmpdir/admindir"),
|
|
my $admindir = File::Spec->rel2abs("$tmpdir/admindir"),
|
|
|
my $altdir = File::Spec->rel2abs("$tmpdir/alternatives");
|
|
my $altdir = File::Spec->rel2abs("$tmpdir/alternatives");
|
|
|
my $bindir = File::Spec->rel2abs("$tmpdir/bin");
|
|
my $bindir = File::Spec->rel2abs("$tmpdir/bin");
|
|
|
-my @ua = ("$ENV{builddir}/update-alternatives", "--log", "/dev/null",
|
|
|
|
|
- "--quiet", "--admindir", "$admindir", "--altdir", "$altdir");
|
|
|
|
|
|
|
+my @ua = ("$ENV{builddir}/update-alternatives", '--log', '/dev/null',
|
|
|
|
|
+ '--quiet', '--admindir', "$admindir", '--altdir', "$altdir");
|
|
|
|
|
|
|
|
my %paths = (
|
|
my %paths = (
|
|
|
- true => find_command("true"),
|
|
|
|
|
- false => find_command("false"),
|
|
|
|
|
- yes => find_command("yes"),
|
|
|
|
|
- cat => find_command("cat"),
|
|
|
|
|
- date => find_command("date"),
|
|
|
|
|
- sleep => find_command("sleep"),
|
|
|
|
|
|
|
+ true => find_command('true'),
|
|
|
|
|
+ false => find_command('false'),
|
|
|
|
|
+ yes => find_command('yes'),
|
|
|
|
|
+ cat => find_command('cat'),
|
|
|
|
|
+ date => find_command('date'),
|
|
|
|
|
+ sleep => find_command('sleep'),
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
if (! -x "$ENV{builddir}/update-alternatives") {
|
|
if (! -x "$ENV{builddir}/update-alternatives") {
|
|
|
- plan skip_all => "update-alternatives not available";
|
|
|
|
|
|
|
+ plan skip_all => 'update-alternatives not available';
|
|
|
exit(0);
|
|
exit(0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
my $main_link = "$bindir/generic-test";
|
|
my $main_link = "$bindir/generic-test";
|
|
|
-my $main_name = "generic-test";
|
|
|
|
|
|
|
+my $main_name = 'generic-test';
|
|
|
my @choices = (
|
|
my @choices = (
|
|
|
{
|
|
{
|
|
|
path => $paths{true},
|
|
path => $paths{true},
|
|
@@ -52,22 +52,22 @@ my @choices = (
|
|
|
slaves => [
|
|
slaves => [
|
|
|
{
|
|
{
|
|
|
link => "$bindir/slave2",
|
|
link => "$bindir/slave2",
|
|
|
- name => "slave2",
|
|
|
|
|
|
|
+ name => 'slave2',
|
|
|
path => $paths{cat},
|
|
path => $paths{cat},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
link => "$bindir/slave3",
|
|
link => "$bindir/slave3",
|
|
|
- name => "slave3",
|
|
|
|
|
|
|
+ name => 'slave3',
|
|
|
path => $paths{cat},
|
|
path => $paths{cat},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
link => "$bindir/slave1",
|
|
link => "$bindir/slave1",
|
|
|
- name => "slave1",
|
|
|
|
|
|
|
+ name => 'slave1',
|
|
|
path => $paths{yes},
|
|
path => $paths{yes},
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
link => "$bindir/slave4",
|
|
link => "$bindir/slave4",
|
|
|
- name => "slave4",
|
|
|
|
|
|
|
+ name => 'slave4',
|
|
|
path => $paths{cat},
|
|
path => $paths{cat},
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
@@ -78,7 +78,7 @@ my @choices = (
|
|
|
slaves => [
|
|
slaves => [
|
|
|
{
|
|
{
|
|
|
link => "$bindir/slave1",
|
|
link => "$bindir/slave1",
|
|
|
- name => "slave1",
|
|
|
|
|
|
|
+ name => 'slave1',
|
|
|
path => $paths{date},
|
|
path => $paths{date},
|
|
|
},
|
|
},
|
|
|
],
|
|
],
|
|
@@ -101,8 +101,8 @@ sub cleanup {
|
|
|
sub call_ua {
|
|
sub call_ua {
|
|
|
my ($params, %opts) = @_;
|
|
my ($params, %opts) = @_;
|
|
|
spawn(exec => [ @ua, @$params ], nocheck => 1,
|
|
spawn(exec => [ @ua, @$params ], nocheck => 1,
|
|
|
- wait_child => 1, env => { LC_ALL => "C" }, %opts);
|
|
|
|
|
- my $test_id = "";
|
|
|
|
|
|
|
+ wait_child => 1, env => { LC_ALL => 'C' }, %opts);
|
|
|
|
|
+ my $test_id = '';
|
|
|
$test_id = "$opts{test_id}: " if defined $opts{test_id};
|
|
$test_id = "$opts{test_id}: " if defined $opts{test_id};
|
|
|
if ($opts{expect_failure}) {
|
|
if ($opts{expect_failure}) {
|
|
|
ok($? != 0, "${test_id}update-alternatives @$params should fail.") or
|
|
ok($? != 0, "${test_id}update-alternatives @$params should fail.") or
|
|
@@ -118,10 +118,10 @@ sub install_choice {
|
|
|
my $alt = $choices[$id];
|
|
my $alt = $choices[$id];
|
|
|
my @params;
|
|
my @params;
|
|
|
push @params, @{$opts{params}} if exists $opts{params};
|
|
push @params, @{$opts{params}} if exists $opts{params};
|
|
|
- push @params, "--install", "$main_link", "$main_name",
|
|
|
|
|
|
|
+ push @params, '--install', "$main_link", "$main_name",
|
|
|
$alt->{path}, $alt->{priority};
|
|
$alt->{path}, $alt->{priority};
|
|
|
foreach my $slave (@{ $alt->{slaves} }) {
|
|
foreach my $slave (@{ $alt->{slaves} }) {
|
|
|
- push @params, "--slave", $slave->{link}, $slave->{name}, $slave->{path};
|
|
|
|
|
|
|
+ push @params, '--slave', $slave->{link}, $slave->{name}, $slave->{path};
|
|
|
}
|
|
}
|
|
|
call_ua(\@params, %opts);
|
|
call_ua(\@params, %opts);
|
|
|
}
|
|
}
|
|
@@ -131,7 +131,7 @@ sub remove_choice {
|
|
|
my $alt = $choices[$id];
|
|
my $alt = $choices[$id];
|
|
|
my @params;
|
|
my @params;
|
|
|
push @params, @{$opts{params}} if exists $opts{params};
|
|
push @params, @{$opts{params}} if exists $opts{params};
|
|
|
- push @params, "--remove", $main_name, $alt->{path};
|
|
|
|
|
|
|
+ push @params, '--remove', $main_name, $alt->{path};
|
|
|
call_ua(\@params, %opts);
|
|
call_ua(\@params, %opts);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -139,7 +139,7 @@ sub remove_all_choices {
|
|
|
my (%opts) = @_;
|
|
my (%opts) = @_;
|
|
|
my @params;
|
|
my @params;
|
|
|
push @params, @{$opts{params}} if exists $opts{params};
|
|
push @params, @{$opts{params}} if exists $opts{params};
|
|
|
- push @params, "--remove-all", $main_name;
|
|
|
|
|
|
|
+ push @params, '--remove-all', $main_name;
|
|
|
call_ua(\@params, %opts);
|
|
call_ua(\@params, %opts);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -148,25 +148,25 @@ sub set_choice {
|
|
|
my $alt = $choices[$id];
|
|
my $alt = $choices[$id];
|
|
|
my @params;
|
|
my @params;
|
|
|
push @params, @{$opts{params}} if exists $opts{params};
|
|
push @params, @{$opts{params}} if exists $opts{params};
|
|
|
- push @params, "--set", $main_name, $alt->{path};
|
|
|
|
|
|
|
+ push @params, '--set', $main_name, $alt->{path};
|
|
|
call_ua(\@params, %opts);
|
|
call_ua(\@params, %opts);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
sub config_choice {
|
|
sub config_choice {
|
|
|
my ($id, %opts) = @_;
|
|
my ($id, %opts) = @_;
|
|
|
- my ($input, $output) = ("", "");
|
|
|
|
|
|
|
+ my ($input, $output) = ('', '');
|
|
|
if ($id >= 0) {
|
|
if ($id >= 0) {
|
|
|
my $alt = $choices[$id];
|
|
my $alt = $choices[$id];
|
|
|
$input = $alt->{path};
|
|
$input = $alt->{path};
|
|
|
} else {
|
|
} else {
|
|
|
- $input = "0";
|
|
|
|
|
|
|
+ $input = '0';
|
|
|
}
|
|
}
|
|
|
$input .= "\n";
|
|
$input .= "\n";
|
|
|
$opts{from_string} = \$input;
|
|
$opts{from_string} = \$input;
|
|
|
$opts{to_string} = \$output;
|
|
$opts{to_string} = \$output;
|
|
|
my @params;
|
|
my @params;
|
|
|
push @params, @{$opts{params}} if exists $opts{params};
|
|
push @params, @{$opts{params}} if exists $opts{params};
|
|
|
- push @params, "--config", $main_name;
|
|
|
|
|
|
|
+ push @params, '--config', $main_name;
|
|
|
call_ua(\@params, %opts);
|
|
call_ua(\@params, %opts);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -204,7 +204,7 @@ sub check_no_link {
|
|
|
my ($link, $msg) = @_;
|
|
my ($link, $msg) = @_;
|
|
|
lstat($link);
|
|
lstat($link);
|
|
|
ok(!-e _, "$msg: $link still exists.");
|
|
ok(!-e _, "$msg: $link still exists.");
|
|
|
- ok(1, "fake test"); # Same number of tests as check_link
|
|
|
|
|
|
|
+ ok(1, 'fake test'); # Same number of tests as check_link
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
sub check_slaves {
|
|
sub check_slaves {
|
|
@@ -225,7 +225,7 @@ sub check_choice {
|
|
|
my $output;
|
|
my $output;
|
|
|
if (defined $id) {
|
|
if (defined $id) {
|
|
|
# Check status
|
|
# Check status
|
|
|
- call_ua([ "--query", "$main_name" ], to_string => \$output, test_id => $msg);
|
|
|
|
|
|
|
+ call_ua([ '--query', "$main_name" ], to_string => \$output, test_id => $msg);
|
|
|
$output =~ /^Status: (.*)$/im;
|
|
$output =~ /^Status: (.*)$/im;
|
|
|
is($1, $mode, "$msg: status is not $mode.");
|
|
is($1, $mode, "$msg: status is not $mode.");
|
|
|
# Check links
|
|
# Check links
|
|
@@ -234,7 +234,7 @@ sub check_choice {
|
|
|
check_link($main_link, "$altdir/$main_name", $msg);
|
|
check_link($main_link, "$altdir/$main_name", $msg);
|
|
|
check_slaves($id, $msg);
|
|
check_slaves($id, $msg);
|
|
|
} else {
|
|
} else {
|
|
|
- call_ua([ "--query", "$main_name" ], error_to_string => \$output,
|
|
|
|
|
|
|
+ call_ua([ '--query', "$main_name" ], error_to_string => \$output,
|
|
|
expect_failure => 1, test_id => $msg);
|
|
expect_failure => 1, test_id => $msg);
|
|
|
ok($output =~ /no alternatives/, "$msg: bad error message for --query.");
|
|
ok($output =~ /no alternatives/, "$msg: bad error message for --query.");
|
|
|
# Check that all links have disappeared
|
|
# Check that all links have disappeared
|
|
@@ -250,16 +250,16 @@ cleanup();
|
|
|
remove_choice(0);
|
|
remove_choice(0);
|
|
|
# successive install in auto mode
|
|
# successive install in auto mode
|
|
|
install_choice(1);
|
|
install_choice(1);
|
|
|
-check_choice(1, "auto", "initial install 1");
|
|
|
|
|
|
|
+check_choice(1, 'auto', 'initial install 1');
|
|
|
install_choice(2); # 2 is lower prio, stays at 1
|
|
install_choice(2); # 2 is lower prio, stays at 1
|
|
|
-check_choice(1, "auto", "initial install 2");
|
|
|
|
|
|
|
+check_choice(1, 'auto', 'initial install 2');
|
|
|
install_choice(0); # 0 is higher priority
|
|
install_choice(0); # 0 is higher priority
|
|
|
-check_choice(0, "auto", "initial install 3");
|
|
|
|
|
|
|
+check_choice(0, 'auto', 'initial install 3');
|
|
|
|
|
|
|
|
# verify that the administrative file is sorted properly
|
|
# verify that the administrative file is sorted properly
|
|
|
{
|
|
{
|
|
|
local $/ = undef;
|
|
local $/ = undef;
|
|
|
- open(my $db_fh, "<", "$admindir/generic-test") or die $!;
|
|
|
|
|
|
|
+ open(my $db_fh, '<', "$admindir/generic-test") or die $!;
|
|
|
my $content = <$db_fh>;
|
|
my $content = <$db_fh>;
|
|
|
close($db_fh);
|
|
close($db_fh);
|
|
|
|
|
|
|
@@ -290,69 +290,69 @@ $bindir/slave4
|
|
|
$expected .= $alt->{path} . "\n";
|
|
$expected .= $alt->{path} . "\n";
|
|
|
$expected .= $alt->{priority} . "\n";
|
|
$expected .= $alt->{priority} . "\n";
|
|
|
foreach my $slave_name (sort keys %slaves) {
|
|
foreach my $slave_name (sort keys %slaves) {
|
|
|
- $expected .= $slaves{$slave_name}{$alt->{path}}{path} || "";
|
|
|
|
|
|
|
+ $expected .= $slaves{$slave_name}{$alt->{path}}{path} || '';
|
|
|
$expected .= "\n";
|
|
$expected .= "\n";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
$expected .= "\n";
|
|
$expected .= "\n";
|
|
|
|
|
|
|
|
- is($content, $expected, "administrative file is as expected");
|
|
|
|
|
|
|
+ is($content, $expected, 'administrative file is as expected');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
# manual change with --set-selections
|
|
# manual change with --set-selections
|
|
|
my $input = "doesntexist auto $paths{date}\ngeneric-test manual $paths{false}\n";
|
|
my $input = "doesntexist auto $paths{date}\ngeneric-test manual $paths{false}\n";
|
|
|
-my $output = "";
|
|
|
|
|
-call_ua(["--set-selections"], from_string => \$input,
|
|
|
|
|
- to_string => \$output, test_id => "manual update with --set-selections");
|
|
|
|
|
-check_choice(1, "manual", "manual update with --set-selections");
|
|
|
|
|
|
|
+my $output = '';
|
|
|
|
|
+call_ua(['--set-selections'], from_string => \$input,
|
|
|
|
|
+ to_string => \$output, test_id => 'manual update with --set-selections');
|
|
|
|
|
+check_choice(1, 'manual', 'manual update with --set-selections');
|
|
|
$input = "generic-test auto $paths{true}\n";
|
|
$input = "generic-test auto $paths{true}\n";
|
|
|
-call_ua(["--set-selections"], from_string => \$input,
|
|
|
|
|
- to_string => \$output, test_id => "auto update with --set-selections");
|
|
|
|
|
-check_choice(0, "auto", "auto update with --set-selections");
|
|
|
|
|
|
|
+call_ua(['--set-selections'], from_string => \$input,
|
|
|
|
|
+ to_string => \$output, test_id => 'auto update with --set-selections');
|
|
|
|
|
+check_choice(0, 'auto', 'auto update with --set-selections');
|
|
|
# manual change with set
|
|
# manual change with set
|
|
|
-set_choice(2, test_id => "manual update with --set");
|
|
|
|
|
-check_choice(2, "manual", "manual update with --set"); # test #388313
|
|
|
|
|
-remove_choice(2, test_id => "remove manual, back to auto");
|
|
|
|
|
-check_choice(0, "auto", "remove manual, back to auto");
|
|
|
|
|
-remove_choice(0, test_id => "remove best");
|
|
|
|
|
-check_choice(1, "auto", "remove best");
|
|
|
|
|
-remove_choice(1, test_id => "no alternative left");
|
|
|
|
|
-check_choice(undef, "", "no alternative left");
|
|
|
|
|
|
|
+set_choice(2, test_id => 'manual update with --set');
|
|
|
|
|
+check_choice(2, 'manual', 'manual update with --set'); # test #388313
|
|
|
|
|
+remove_choice(2, test_id => 'remove manual, back to auto');
|
|
|
|
|
+check_choice(0, 'auto', 'remove manual, back to auto');
|
|
|
|
|
+remove_choice(0, test_id => 'remove best');
|
|
|
|
|
+check_choice(1, 'auto', 'remove best');
|
|
|
|
|
+remove_choice(1, test_id => 'no alternative left');
|
|
|
|
|
+check_choice(undef, '', 'no alternative left');
|
|
|
# single choice in manual mode, to be removed
|
|
# single choice in manual mode, to be removed
|
|
|
install_choice(1);
|
|
install_choice(1);
|
|
|
set_choice(1);
|
|
set_choice(1);
|
|
|
-check_choice(1, "manual", "single manual choice");
|
|
|
|
|
|
|
+check_choice(1, 'manual', 'single manual choice');
|
|
|
remove_choice(1);
|
|
remove_choice(1);
|
|
|
-check_choice(undef, "", "removal single manual");
|
|
|
|
|
|
|
+check_choice(undef, '', 'removal single manual');
|
|
|
# test --remove-all
|
|
# test --remove-all
|
|
|
install_choice(0);
|
|
install_choice(0);
|
|
|
install_choice(1);
|
|
install_choice(1);
|
|
|
install_choice(2);
|
|
install_choice(2);
|
|
|
-remove_all_choices(test_id => "remove all");
|
|
|
|
|
-check_choice(undef, "", "no alternative left");
|
|
|
|
|
|
|
+remove_all_choices(test_id => 'remove all');
|
|
|
|
|
+check_choice(undef, '', 'no alternative left');
|
|
|
# check auto-recovery of user mistakes (#100135)
|
|
# check auto-recovery of user mistakes (#100135)
|
|
|
install_choice(1);
|
|
install_choice(1);
|
|
|
-ok(unlink("$bindir/generic-test"), "failed removal");
|
|
|
|
|
-ok(unlink("$bindir/slave1"), "failed removal");
|
|
|
|
|
|
|
+ok(unlink("$bindir/generic-test"), 'failed removal');
|
|
|
|
|
+ok(unlink("$bindir/slave1"), 'failed removal');
|
|
|
install_choice(1);
|
|
install_choice(1);
|
|
|
-check_choice(1, "auto", "recreate links in auto mode");
|
|
|
|
|
|
|
+check_choice(1, 'auto', 'recreate links in auto mode');
|
|
|
set_choice(1);
|
|
set_choice(1);
|
|
|
-ok(unlink("$bindir/generic-test"), "failed removal");
|
|
|
|
|
-ok(unlink("$bindir/slave1"), "failed removal");
|
|
|
|
|
|
|
+ok(unlink("$bindir/generic-test"), 'failed removal');
|
|
|
|
|
+ok(unlink("$bindir/slave1"), 'failed removal');
|
|
|
install_choice(1);
|
|
install_choice(1);
|
|
|
-check_choice(1, "manual", "recreate links in manual mode");
|
|
|
|
|
|
|
+check_choice(1, 'manual', 'recreate links in manual mode');
|
|
|
# check recovery of /etc/alternatives/*
|
|
# check recovery of /etc/alternatives/*
|
|
|
install_choice(0);
|
|
install_choice(0);
|
|
|
-ok(unlink("$altdir/generic-test"), "failed removal");
|
|
|
|
|
|
|
+ok(unlink("$altdir/generic-test"), 'failed removal');
|
|
|
install_choice(1);
|
|
install_choice(1);
|
|
|
-check_choice(0, "auto", "<altdir>/generic-test lost, back to auto");
|
|
|
|
|
|
|
+check_choice(0, 'auto', '<altdir>/generic-test lost, back to auto');
|
|
|
# test --config
|
|
# test --config
|
|
|
config_choice(0);
|
|
config_choice(0);
|
|
|
-check_choice(0, "manual", "config to best but manual");
|
|
|
|
|
|
|
+check_choice(0, 'manual', 'config to best but manual');
|
|
|
config_choice(1);
|
|
config_choice(1);
|
|
|
-check_choice(1, "manual", "config to manual");
|
|
|
|
|
|
|
+check_choice(1, 'manual', 'config to manual');
|
|
|
config_choice(-1);
|
|
config_choice(-1);
|
|
|
-check_choice(0, "auto", "config auto");
|
|
|
|
|
|
|
+check_choice(0, 'auto', 'config auto');
|
|
|
|
|
|
|
|
# test rename of links
|
|
# test rename of links
|
|
|
install_choice(0);
|
|
install_choice(0);
|
|
@@ -361,30 +361,30 @@ my $old_link = $main_link;
|
|
|
$choices[0]{slaves}[0]{link} = "$bindir/more/generic-slave";
|
|
$choices[0]{slaves}[0]{link} = "$bindir/more/generic-slave";
|
|
|
$main_link = "$bindir/more/mytest";
|
|
$main_link = "$bindir/more/mytest";
|
|
|
install_choice(0);
|
|
install_choice(0);
|
|
|
-check_choice(0, "auto", "test rename of links");
|
|
|
|
|
-check_no_link($old_link, "test rename of links");
|
|
|
|
|
-check_no_link($old_slave, "test rename of links");
|
|
|
|
|
|
|
+check_choice(0, 'auto', 'test rename of links');
|
|
|
|
|
+check_no_link($old_link, 'test rename of links');
|
|
|
|
|
+check_no_link($old_slave, 'test rename of links');
|
|
|
# rename with installing other alternatives
|
|
# rename with installing other alternatives
|
|
|
$old_link = $main_link;
|
|
$old_link = $main_link;
|
|
|
$main_link = "$bindir/generic-test";
|
|
$main_link = "$bindir/generic-test";
|
|
|
install_choice(1);
|
|
install_choice(1);
|
|
|
-check_choice(0, "auto", "rename link");
|
|
|
|
|
-check_no_link($old_link, "rename link");
|
|
|
|
|
|
|
+check_choice(0, 'auto', 'rename link');
|
|
|
|
|
+check_no_link($old_link, 'rename link');
|
|
|
# rename with lost file
|
|
# rename with lost file
|
|
|
unlink($old_slave);
|
|
unlink($old_slave);
|
|
|
$old_slave = $choices[0]{slaves}[0]{link};
|
|
$old_slave = $choices[0]{slaves}[0]{link};
|
|
|
$choices[0]{slaves}[0]{link} = "$bindir/generic-slave-bis";
|
|
$choices[0]{slaves}[0]{link} = "$bindir/generic-slave-bis";
|
|
|
install_choice(0);
|
|
install_choice(0);
|
|
|
-check_choice(0, "auto", "rename lost file");
|
|
|
|
|
-check_no_link($old_slave, "rename lost file");
|
|
|
|
|
|
|
+check_choice(0, 'auto', 'rename lost file');
|
|
|
|
|
+check_no_link($old_slave, 'rename lost file');
|
|
|
# update of alternative with many slaves not currently installed
|
|
# update of alternative with many slaves not currently installed
|
|
|
# and the link of the renamed slave exists while it should not
|
|
# and the link of the renamed slave exists while it should not
|
|
|
set_choice(1);
|
|
set_choice(1);
|
|
|
symlink("$paths{cat}", "$bindir/generic-slave-bis");
|
|
symlink("$paths{cat}", "$bindir/generic-slave-bis");
|
|
|
$choices[0]{slaves}[0]{link} = "$bindir/slave2";
|
|
$choices[0]{slaves}[0]{link} = "$bindir/slave2";
|
|
|
-install_choice(0, test_id => "update with non-installed slaves");
|
|
|
|
|
|
|
+install_choice(0, test_id => 'update with non-installed slaves');
|
|
|
check_no_link("$bindir/generic-slave-bis",
|
|
check_no_link("$bindir/generic-slave-bis",
|
|
|
- "drop renamed symlink that should not be installed");
|
|
|
|
|
|
|
+ 'drop renamed symlink that should not be installed');
|
|
|
|
|
|
|
|
# test install with empty admin file (#457863)
|
|
# test install with empty admin file (#457863)
|
|
|
cleanup();
|
|
cleanup();
|
|
@@ -393,56 +393,56 @@ install_choice(0);
|
|
|
# test install with garbage admin file
|
|
# test install with garbage admin file
|
|
|
cleanup();
|
|
cleanup();
|
|
|
system("echo garbage > $admindir/generic-test");
|
|
system("echo garbage > $admindir/generic-test");
|
|
|
-install_choice(0, error_to_file => "/dev/null", expect_failure => 1);
|
|
|
|
|
|
|
+install_choice(0, error_to_file => '/dev/null', expect_failure => 1);
|
|
|
|
|
|
|
|
# test invalid usages
|
|
# test invalid usages
|
|
|
cleanup();
|
|
cleanup();
|
|
|
install_choice(0);
|
|
install_choice(0);
|
|
|
# try to install a slave alternative as new master
|
|
# try to install a slave alternative as new master
|
|
|
-call_ua(["--install", "$bindir/testmaster", "slave1", "$paths{date}", "10"],
|
|
|
|
|
- expect_failure => 1, to_file => "/dev/null", error_to_file => "/dev/null");
|
|
|
|
|
|
|
+call_ua(['--install', "$bindir/testmaster", 'slave1', "$paths{date}", '10'],
|
|
|
|
|
+ expect_failure => 1, to_file => '/dev/null', error_to_file => '/dev/null');
|
|
|
# try to install a master alternative as slave
|
|
# try to install a master alternative as slave
|
|
|
-call_ua(["--install", "$bindir/testmaster", "testmaster", "$paths{date}", "10",
|
|
|
|
|
- "--slave", "$bindir/testslave", "generic-test", "$paths{true}" ],
|
|
|
|
|
- expect_failure => 1, to_file => "/dev/null", error_to_file => "/dev/null");
|
|
|
|
|
|
|
+call_ua(['--install', "$bindir/testmaster", 'testmaster', "$paths{date}", '10',
|
|
|
|
|
+ '--slave', "$bindir/testslave", 'generic-test', "$paths{true}" ],
|
|
|
|
|
+ expect_failure => 1, to_file => '/dev/null', error_to_file => '/dev/null');
|
|
|
# try to reuse master link in slave
|
|
# try to reuse master link in slave
|
|
|
-call_ua(["--install", "$bindir/testmaster", "testmaster", "$paths{date}", "10",
|
|
|
|
|
- "--slave", "$bindir/testmaster", "testslave", "$paths{true}" ],
|
|
|
|
|
- expect_failure => 1, to_file => "/dev/null", error_to_file => "/dev/null");
|
|
|
|
|
|
|
+call_ua(['--install', "$bindir/testmaster", 'testmaster', "$paths{date}", '10',
|
|
|
|
|
+ '--slave', "$bindir/testmaster", 'testslave', "$paths{true}" ],
|
|
|
|
|
+ expect_failure => 1, to_file => '/dev/null', error_to_file => '/dev/null');
|
|
|
# try to reuse links in master alternative
|
|
# try to reuse links in master alternative
|
|
|
-call_ua(["--install", "$bindir/slave1", "testmaster", "$paths{date}", "10"],
|
|
|
|
|
- expect_failure => 1, to_file => "/dev/null", error_to_file => "/dev/null");
|
|
|
|
|
|
|
+call_ua(['--install', "$bindir/slave1", 'testmaster', "$paths{date}", '10'],
|
|
|
|
|
+ expect_failure => 1, to_file => '/dev/null', error_to_file => '/dev/null');
|
|
|
# try to reuse links in slave alternative
|
|
# try to reuse links in slave alternative
|
|
|
-call_ua(["--install", "$bindir/testmaster", "testmaster", "$paths{date}", "10",
|
|
|
|
|
- "--slave", "$bindir/generic-test", "testslave", "$paths{true}" ],
|
|
|
|
|
- expect_failure => 1, to_file => "/dev/null", error_to_file => "/dev/null");
|
|
|
|
|
|
|
+call_ua(['--install', "$bindir/testmaster", 'testmaster', "$paths{date}", '10',
|
|
|
|
|
+ '--slave', "$bindir/generic-test", 'testslave', "$paths{true}" ],
|
|
|
|
|
+ expect_failure => 1, to_file => '/dev/null', error_to_file => '/dev/null');
|
|
|
# try to reuse slave link in another slave alternative of another choice of
|
|
# try to reuse slave link in another slave alternative of another choice of
|
|
|
# the same main alternative
|
|
# the same main alternative
|
|
|
-call_ua(["--install", $main_link, $main_name, "$paths{date}", "10",
|
|
|
|
|
- "--slave", "$bindir/slave1", "testslave", "$paths{true}" ],
|
|
|
|
|
- expect_failure => 1, to_file => "/dev/null", error_to_file => "/dev/null");
|
|
|
|
|
|
|
+call_ua(['--install', $main_link, $main_name, "$paths{date}", '10',
|
|
|
|
|
+ '--slave', "$bindir/slave1", 'testslave', "$paths{true}" ],
|
|
|
|
|
+ expect_failure => 1, to_file => '/dev/null', error_to_file => '/dev/null');
|
|
|
# lack of absolute filenames in links or file path, non-existing path,
|
|
# lack of absolute filenames in links or file path, non-existing path,
|
|
|
-call_ua(["--install", "../testmaster", "testmaster", "$paths{date}", "10"],
|
|
|
|
|
- expect_failure => 1, to_file => "/dev/null", error_to_file => "/dev/null");
|
|
|
|
|
-call_ua(["--install", "$bindir/testmaster", "testmaster", "./update-alternatives.pl", "10"],
|
|
|
|
|
- expect_failure => 1, to_file => "/dev/null", error_to_file => "/dev/null");
|
|
|
|
|
|
|
+call_ua(['--install', '../testmaster', 'testmaster', "$paths{date}", '10'],
|
|
|
|
|
+ expect_failure => 1, to_file => '/dev/null', error_to_file => '/dev/null');
|
|
|
|
|
+call_ua(['--install', "$bindir/testmaster", 'testmaster', './update-alternatives.pl', '10'],
|
|
|
|
|
+ expect_failure => 1, to_file => '/dev/null', error_to_file => '/dev/null');
|
|
|
# non-existing alternative path
|
|
# non-existing alternative path
|
|
|
-call_ua(["--install", "$bindir/testmaster", "testmaster", "$bindir/doesntexist", "10"],
|
|
|
|
|
- expect_failure => 1, to_file => "/dev/null", error_to_file => "/dev/null");
|
|
|
|
|
|
|
+call_ua(['--install', "$bindir/testmaster", 'testmaster', "$bindir/doesntexist", '10'],
|
|
|
|
|
+ expect_failure => 1, to_file => '/dev/null', error_to_file => '/dev/null');
|
|
|
# invalid alternative name in master
|
|
# invalid alternative name in master
|
|
|
-call_ua(["--install", "$bindir/testmaster", "test/master", "$paths{date}", "10"],
|
|
|
|
|
- expect_failure => 1, to_file => "/dev/null", error_to_file => "/dev/null");
|
|
|
|
|
|
|
+call_ua(['--install', "$bindir/testmaster", 'test/master', "$paths{date}", '10'],
|
|
|
|
|
+ expect_failure => 1, to_file => '/dev/null', error_to_file => '/dev/null');
|
|
|
# invalid alternative name in slave
|
|
# invalid alternative name in slave
|
|
|
-call_ua(["--install", "$bindir/testmaster", "testmaster", "$paths{date}", "10",
|
|
|
|
|
- "--slave", "$bindir/testslave", "test slave", "$paths{true}" ],
|
|
|
|
|
- expect_failure => 1, to_file => "/dev/null", error_to_file => "/dev/null");
|
|
|
|
|
|
|
+call_ua(['--install', "$bindir/testmaster", 'testmaster', "$paths{date}", '10',
|
|
|
|
|
+ '--slave', "$bindir/testslave", 'test slave', "$paths{true}" ],
|
|
|
|
|
+ expect_failure => 1, to_file => '/dev/null', error_to_file => '/dev/null');
|
|
|
# install in non-existing dir should fail
|
|
# install in non-existing dir should fail
|
|
|
-call_ua(["--install", "$bindir/doesntexist/testmaster", "testmaster", "$paths{date}", "10",
|
|
|
|
|
- "--slave", "$bindir/testslave", "testslave", "$paths{true}" ],
|
|
|
|
|
- expect_failure => 1, to_file => "/dev/null", error_to_file => "/dev/null");
|
|
|
|
|
-call_ua(["--install", "$bindir/testmaster", "testmaster", "$paths{date}", "10",
|
|
|
|
|
- "--slave", "$bindir/doesntexist/testslave", "testslave", "$paths{true}" ],
|
|
|
|
|
- expect_failure => 1, to_file => "/dev/null", error_to_file => "/dev/null");
|
|
|
|
|
|
|
+call_ua(['--install', "$bindir/doesntexist/testmaster", 'testmaster', "$paths{date}", '10',
|
|
|
|
|
+ '--slave', "$bindir/testslave", 'testslave', "$paths{true}" ],
|
|
|
|
|
+ expect_failure => 1, to_file => '/dev/null', error_to_file => '/dev/null');
|
|
|
|
|
+call_ua(['--install', "$bindir/testmaster", 'testmaster', "$paths{date}", '10',
|
|
|
|
|
+ '--slave', "$bindir/doesntexist/testslave", 'testslave', "$paths{true}" ],
|
|
|
|
|
+ expect_failure => 1, to_file => '/dev/null', error_to_file => '/dev/null');
|
|
|
|
|
|
|
|
# non-existing alternative path in slave is not a failure
|
|
# non-existing alternative path in slave is not a failure
|
|
|
my $old_path = $choices[0]{slaves}[0]{path};
|
|
my $old_path = $choices[0]{slaves}[0]{path};
|
|
@@ -452,51 +452,51 @@ $choices[0]{slaves}[0]{link} = "$bindir/baddir/slave2";
|
|
|
# test rename of slave link that existed but that doesn't anymore
|
|
# test rename of slave link that existed but that doesn't anymore
|
|
|
# and link is moved into non-existing dir at the same time
|
|
# and link is moved into non-existing dir at the same time
|
|
|
install_choice(0);
|
|
install_choice(0);
|
|
|
-check_choice(0, "auto", "optional renamed slave2 in non-existing dir");
|
|
|
|
|
|
|
+check_choice(0, 'auto', 'optional renamed slave2 in non-existing dir');
|
|
|
# same but on fresh install
|
|
# same but on fresh install
|
|
|
cleanup();
|
|
cleanup();
|
|
|
install_choice(0);
|
|
install_choice(0);
|
|
|
-check_choice(0, "auto", "optional slave2 in non-existing dir");
|
|
|
|
|
|
|
+check_choice(0, 'auto', 'optional slave2 in non-existing dir');
|
|
|
$choices[0]{slaves}[0]{link} = $old_slave;
|
|
$choices[0]{slaves}[0]{link} = $old_slave;
|
|
|
# test fresh install with a non-existing slave file
|
|
# test fresh install with a non-existing slave file
|
|
|
cleanup();
|
|
cleanup();
|
|
|
install_choice(0);
|
|
install_choice(0);
|
|
|
-check_choice(0, "auto", "optional slave2");
|
|
|
|
|
|
|
+check_choice(0, 'auto', 'optional slave2');
|
|
|
$choices[0]{slaves}[0]{path} = $old_path;
|
|
$choices[0]{slaves}[0]{path} = $old_path;
|
|
|
|
|
|
|
|
# test management of pre-existing files
|
|
# test management of pre-existing files
|
|
|
cleanup();
|
|
cleanup();
|
|
|
system("touch $main_link $bindir/slave1");
|
|
system("touch $main_link $bindir/slave1");
|
|
|
install_choice(0);
|
|
install_choice(0);
|
|
|
-ok(!-l $main_link, "install preserves files that should be links");
|
|
|
|
|
-ok(!-l "$bindir/slave1", "install preserves files that should be slave links");
|
|
|
|
|
|
|
+ok(!-l $main_link, 'install preserves files that should be links');
|
|
|
|
|
+ok(!-l "$bindir/slave1", 'install preserves files that should be slave links');
|
|
|
remove_choice(0);
|
|
remove_choice(0);
|
|
|
-ok(-f $main_link, "removal keeps real file installed as master link");
|
|
|
|
|
-ok(-f "$bindir/slave1", "removal keeps real files installed as slave links");
|
|
|
|
|
-install_choice(0, params => ["--force"]);
|
|
|
|
|
-check_choice(0, "auto", "install --force replaces files with links");
|
|
|
|
|
|
|
+ok(-f $main_link, 'removal keeps real file installed as master link');
|
|
|
|
|
+ok(-f "$bindir/slave1", 'removal keeps real files installed as slave links');
|
|
|
|
|
+install_choice(0, params => ['--force']);
|
|
|
|
|
+check_choice(0, 'auto', 'install --force replaces files with links');
|
|
|
|
|
|
|
|
# test management of pre-existing files #2
|
|
# test management of pre-existing files #2
|
|
|
cleanup();
|
|
cleanup();
|
|
|
system("touch $main_link $bindir/slave2");
|
|
system("touch $main_link $bindir/slave2");
|
|
|
install_choice(0);
|
|
install_choice(0);
|
|
|
install_choice(1);
|
|
install_choice(1);
|
|
|
-ok(!-l $main_link, "inactive install preserves files that should be links");
|
|
|
|
|
-ok(!-l "$bindir/slave2", "inactive install preserves files that should be slave links");
|
|
|
|
|
-ok(-f $main_link, "inactive install keeps real file installed as master link");
|
|
|
|
|
-ok(-f "$bindir/slave2", "inactive install keeps real files installed as slave links");
|
|
|
|
|
|
|
+ok(!-l $main_link, 'inactive install preserves files that should be links');
|
|
|
|
|
+ok(!-l "$bindir/slave2", 'inactive install preserves files that should be slave links');
|
|
|
|
|
+ok(-f $main_link, 'inactive install keeps real file installed as master link');
|
|
|
|
|
+ok(-f "$bindir/slave2", 'inactive install keeps real files installed as slave links');
|
|
|
set_choice(1);
|
|
set_choice(1);
|
|
|
-ok(!-l $main_link, "manual switching preserves files that should be links");
|
|
|
|
|
-ok(!-l "$bindir/slave2", "manual switching preserves files that should be slave links");
|
|
|
|
|
-ok(-f $main_link, "manual switching keeps real file installed as master link");
|
|
|
|
|
-ok(-f "$bindir/slave2", "manual switching keeps real files installed as slave links");
|
|
|
|
|
|
|
+ok(!-l $main_link, 'manual switching preserves files that should be links');
|
|
|
|
|
+ok(!-l "$bindir/slave2", 'manual switching preserves files that should be slave links');
|
|
|
|
|
+ok(-f $main_link, 'manual switching keeps real file installed as master link');
|
|
|
|
|
+ok(-f "$bindir/slave2", 'manual switching keeps real files installed as slave links');
|
|
|
remove_choice(1);
|
|
remove_choice(1);
|
|
|
-ok(!-l $main_link, "auto switching preserves files that should be links");
|
|
|
|
|
-ok(!-l "$bindir/slave2", "auto switching preserves files that should be slave links");
|
|
|
|
|
-ok(-f $main_link, "auto switching keeps real file installed as master link");
|
|
|
|
|
-ok(-f "$bindir/slave2", "auto switching keeps real files installed as slave links");
|
|
|
|
|
-remove_all_choices(params => ["--force"]);
|
|
|
|
|
-ok(!-e "$bindir/slave2", "forced removeall drops real files installed as slave links");
|
|
|
|
|
|
|
+ok(!-l $main_link, 'auto switching preserves files that should be links');
|
|
|
|
|
+ok(!-l "$bindir/slave2", 'auto switching preserves files that should be slave links');
|
|
|
|
|
+ok(-f $main_link, 'auto switching keeps real file installed as master link');
|
|
|
|
|
+ok(-f "$bindir/slave2", 'auto switching keeps real files installed as slave links');
|
|
|
|
|
+remove_all_choices(params => ['--force']);
|
|
|
|
|
+ok(!-e "$bindir/slave2", 'forced removeall drops real files installed as slave links');
|
|
|
|
|
|
|
|
# test management of pre-existing files #3
|
|
# test management of pre-existing files #3
|
|
|
cleanup();
|
|
cleanup();
|
|
@@ -504,15 +504,15 @@ system("touch $main_link $bindir/slave2");
|
|
|
install_choice(0);
|
|
install_choice(0);
|
|
|
install_choice(1);
|
|
install_choice(1);
|
|
|
remove_choice(0);
|
|
remove_choice(0);
|
|
|
-ok(!-l $main_link, "removal + switching preserves files that should be links");
|
|
|
|
|
-ok(!-l "$bindir/slave2", "removal + switching preserves files that should be slave links");
|
|
|
|
|
-ok(-f $main_link, "removal + switching keeps real file installed as master link");
|
|
|
|
|
-ok(-f "$bindir/slave2", "removal + switching keeps real files installed as slave links");
|
|
|
|
|
|
|
+ok(!-l $main_link, 'removal + switching preserves files that should be links');
|
|
|
|
|
+ok(!-l "$bindir/slave2", 'removal + switching preserves files that should be slave links');
|
|
|
|
|
+ok(-f $main_link, 'removal + switching keeps real file installed as master link');
|
|
|
|
|
+ok(-f "$bindir/slave2", 'removal + switching keeps real files installed as slave links');
|
|
|
install_choice(0);
|
|
install_choice(0);
|
|
|
-ok(!-l $main_link, "install + switching preserves files that should be links");
|
|
|
|
|
-ok(!-l "$bindir/slave2", "install + switching preserves files that should be slave links");
|
|
|
|
|
-ok(-f $main_link, "install + switching keeps real file installed as master link");
|
|
|
|
|
-ok(-f "$bindir/slave2", "install + switching keeps real files installed as slave links");
|
|
|
|
|
-set_choice(1, params => ["--force"]);
|
|
|
|
|
-ok(!-e "$bindir/slave2", "forced switching w/o slave drops real files installed as slave links");
|
|
|
|
|
-check_choice(1, "manual", "set --force replaces files with links");
|
|
|
|
|
|
|
+ok(!-l $main_link, 'install + switching preserves files that should be links');
|
|
|
|
|
+ok(!-l "$bindir/slave2", 'install + switching preserves files that should be slave links');
|
|
|
|
|
+ok(-f $main_link, 'install + switching keeps real file installed as master link');
|
|
|
|
|
+ok(-f "$bindir/slave2", 'install + switching keeps real files installed as slave links');
|
|
|
|
|
+set_choice(1, params => ['--force']);
|
|
|
|
|
+ok(!-e "$bindir/slave2", 'forced switching w/o slave drops real files installed as slave links');
|
|
|
|
|
+check_choice(1, 'manual', 'set --force replaces files with links');
|