From 79a9cfca4f9e46fcb121194b8db5bcb8d528547d Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Thu, 5 Jul 2007 15:10:00 +0000 Subject: add test on rpmnew creation for %config files --- t/data/SPECS/rpmnew/a-1.spec | 28 ++++++++++++++++++++++ t/data/SPECS/rpmnew/a-2.spec | 28 ++++++++++++++++++++++ t/data/SPECS/rpmnew/a-3.spec | 28 ++++++++++++++++++++++ t/superuser--rpmnew.t | 57 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 141 insertions(+) create mode 100644 t/data/SPECS/rpmnew/a-1.spec create mode 100644 t/data/SPECS/rpmnew/a-2.spec create mode 100644 t/data/SPECS/rpmnew/a-3.spec create mode 100644 t/superuser--rpmnew.t (limited to 't') diff --git a/t/data/SPECS/rpmnew/a-1.spec b/t/data/SPECS/rpmnew/a-1.spec new file mode 100644 index 00000000..7fc44f13 --- /dev/null +++ b/t/data/SPECS/rpmnew/a-1.spec @@ -0,0 +1,28 @@ +%define content orig + +Summary: x +Name: a +Version: 1 +Release: 1 +License: x +Group: x +Url: x +BuildArch: noarch + +%description +tee + +%install +rm -rf $RPM_BUILD_ROOT +install -d $RPM_BUILD_ROOT/etc +echo %{content} > $RPM_BUILD_ROOT/etc/config-noreplace +echo %{content} > $RPM_BUILD_ROOT/etc/config +echo %{content} > $RPM_BUILD_ROOT/etc/normal + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%verify(not md5 size mtime) %config(noreplace) /etc/config-noreplace +%config /etc/config +/etc/normal diff --git a/t/data/SPECS/rpmnew/a-2.spec b/t/data/SPECS/rpmnew/a-2.spec new file mode 100644 index 00000000..60f45dc2 --- /dev/null +++ b/t/data/SPECS/rpmnew/a-2.spec @@ -0,0 +1,28 @@ +%define content orig + +Summary: x +Name: a +Version: 2 +Release: 1 +License: x +Group: x +Url: x +BuildArch: noarch + +%description +tee + +%install +rm -rf $RPM_BUILD_ROOT +install -d $RPM_BUILD_ROOT/etc +echo %{content} > $RPM_BUILD_ROOT/etc/config-noreplace +echo %{content} > $RPM_BUILD_ROOT/etc/config +echo %{content} > $RPM_BUILD_ROOT/etc/normal + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%verify(not md5 size mtime) %config(noreplace) /etc/config-noreplace +%config /etc/config +/etc/normal diff --git a/t/data/SPECS/rpmnew/a-3.spec b/t/data/SPECS/rpmnew/a-3.spec new file mode 100644 index 00000000..cdec3d00 --- /dev/null +++ b/t/data/SPECS/rpmnew/a-3.spec @@ -0,0 +1,28 @@ +%define content changed + +Summary: x +Name: a +Version: 3 +Release: 1 +License: x +Group: x +Url: x +BuildArch: noarch + +%description +tee + +%install +rm -rf $RPM_BUILD_ROOT +install -d $RPM_BUILD_ROOT/etc +echo %{content} > $RPM_BUILD_ROOT/etc/config-noreplace +echo %{content} > $RPM_BUILD_ROOT/etc/config +echo %{content} > $RPM_BUILD_ROOT/etc/normal + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%verify(not md5 size mtime) %config(noreplace) /etc/config-noreplace +%config /etc/config +/etc/normal diff --git a/t/superuser--rpmnew.t b/t/superuser--rpmnew.t new file mode 100644 index 00000000..9714d143 --- /dev/null +++ b/t/superuser--rpmnew.t @@ -0,0 +1,57 @@ +#!/usr/bin/perl + +use strict; +use lib '.', 't'; +use helper; +use Test::More 'no_plan'; + +my $medium_name = 'rpmnew'; + +my @names = ('config-noreplace', 'config', 'normal'); + +need_root_and_prepare(); + +urpmi_addmedia("$medium_name $::pwd/media/$medium_name"); + +test(['orig', 'orig', 'orig'], + ['orig', 'orig', 'orig'], + ['changed', 'changed', 'changed']); + +system("echo foo > $::pwd/root/etc/$_") foreach @names; + +test(['foo', 'foo', 'orig'], + ['foo', 'foo', 'orig'], + ['foo', 'foo', 'changed']); + +sub check_content { + my ($rpm, $config_noreplace, $config, $normal) = @_; + + check_one_content($rpm, 'config-noreplace', $config_noreplace); + check_one_content($rpm, 'config', $config); + check_one_content($rpm, 'normal', $normal); +} + +sub check_one_content { + my ($rpm, $name, $val) = @_; + my $s = `cat $::pwd/root/etc/$name`; + chomp $s; + is($s, $val, "$name for $rpm"); +} + +sub test { + my ($v1, $v2, $v3) = @_; + + system_("rpm --root $::pwd/root -i media/$medium_name/a-1-*.rpm"); + is(`rpm -qa --root $::pwd/root`, "a-1-1\n"); + check_content('a-1', @$v1); + + system_("rpm --root $::pwd/root -U media/$medium_name/a-2-*.rpm"); + is(`rpm -qa --root $::pwd/root`, "a-2-1\n"); + check_content('a-2', @$v2); + + system_("rpm --root $::pwd/root -U media/$medium_name/a-3-*.rpm"); + is(`rpm -qa --root $::pwd/root`, "a-3-1\n"); + check_content('a-3', @$v3); + + system_("rpm --root $::pwd/root -e a"); +} -- cgit v1.2.1