Fix #20 and added an ATF test-case.

This commit is contained in:
Juan RP
2013-11-05 09:56:36 +01:00
parent 10438e58f8
commit c1fafcd339
6 changed files with 74 additions and 0 deletions

View File

@@ -11,5 +11,6 @@ SUBDIRS += find_pkg_obsoletes
SUBDIRS += find_pkg_orphans
SUBDIRS += pkgdb
SUBDIRS += issue18
SUBDIRS += issue20
include ../../../mk/subdir.mk

View File

@@ -9,5 +9,6 @@ atf_test_program{name="plist_match_test"}
atf_test_program{name="plist_match_virtual_test"}
atf_test_program{name="find_pkg_obsoletes_test"}
atf_test_program{name="issue18_test"}
atf_test_program{name="issue20_test"}
include('find_pkg_orphans/Kyuafile')
include('pkgdb/Kyuafile')

View File

@@ -0,0 +1,7 @@
TOPDIR = ../../../..
-include $(TOPDIR)/config.mk
TEST = issue20_test
include ../Makefile.inc
include $(TOPDIR)/mk/test-shell.mk

View File

@@ -0,0 +1,57 @@
#! /usr/bin/env atf-sh
# xbps issue #20.
# How to reproduce it:
# Create pkg a-0.1_1 containing 1 file and 1 symlink:
#
# /foo
# /blah -> foo
#
# Create pkg a-0.2_1 containing 1 file and 1 symlink (inverted):
#
# /foo -> blah
# /blah
#
# Upgrade pkg a to 0.2.
atf_test_case issue20
issue20_head() {
atf_set "descr" "xbps issue #20 (https://github.com/xtraeme/xbps/issues/18)"
}
issue20_body() {
mkdir repo
cd repo
mkdir pkg_a
touch pkg_a/foo
ln -sr pkg_a/foo pkg_a/blah
xbps-create -A noarch -n a-0.1_1 -s "pkg a" pkg_a
atf_check_equal $? 0
rm -rf pkg_a
xbps-rindex -a *.xbps
atf_check_equal $? 0
xbps-install -r rootdir --repository=$PWD -y a
atf_check_equal $? 0
mkdir pkg_a
touch pkg_a/blah
ln -sr pkg_a/blah pkg_a/foo
xbps-create -A noarch -n a-0.2_1 -s "pkg a" pkg_a
atf_check_equal $? 0
rm -rf pkg_a
xbps-rindex -a *.xbps
atf_check_equal $? 0
xbps-install -r rootdir --repository=$PWD -yu
atf_check_equal $? 0
tgt=$(readlink rootdir/foo)
rval=1
if [ -f rootdir/blah -a "$tgt" = "blah" ]; then
rval=0
fi
atf_check_equal $rval 0
}
atf_init_test_cases() {
atf_add_test_case issue20
}