summaryrefslogtreecommitdiff
path: root/regress/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2014-01-31 10:13:14 +0000
committerMarc Espie <espie@cvs.openbsd.org>2014-01-31 10:13:14 +0000
commitc97d4ad901c0f7aff7d8c5b82c82ab47a0630c5b (patch)
treebc3cc7f578d184d177ce2cd7dd274fc8a5fad095 /regress/usr.sbin
parent909fddd550d35514072e95edc68b394e48875138 (diff)
basic check for pkg names conflicts, to be augmented
Diffstat (limited to 'regress/usr.sbin')
-rw-r--r--regress/usr.sbin/pkg_add/Makefile11
-rw-r--r--regress/usr.sbin/pkg_add/check-cfl53
2 files changed, 62 insertions, 2 deletions
diff --git a/regress/usr.sbin/pkg_add/Makefile b/regress/usr.sbin/pkg_add/Makefile
index 670c930cbed..e6e9c0d52e3 100644
--- a/regress/usr.sbin/pkg_add/Makefile
+++ b/regress/usr.sbin/pkg_add/Makefile
@@ -1,7 +1,7 @@
-# $OpenBSD: Makefile,v 1.50 2012/08/17 23:40:02 espie Exp $
+# $OpenBSD: Makefile,v 1.51 2014/01/31 10:13:13 espie Exp $
REGRESS_TARGETS=pkgnames pkgpaths signatures depends-check longnames \
- update-check1 \
+ pkgcfl update-check1 \
collision-check3 collision-check5 partial-update-test conflict-update \
merge-update split-update big-merge family-circus missing \
lib-report1 lib-report2 lib-report3 loop1 \
@@ -34,6 +34,9 @@ DEST$i ?= ${D$i}/usr/local
pkgnames:
perl ${.CURDIR}/check-name
+pkgcfl:
+ perl ${.CURDIR}/check-cfl
+
pkgpaths:
perl ${.CURDIR}/check-path
@@ -613,6 +616,10 @@ rep1/ol-1.tgz: plist21
@touch ${SRC23}/lib/subdir/libol.so.1.0
@${CREATE_PKG} -B src23 -DLIBol_VERSION=1.0 -f plist21 $@
+keys:
+ mkdir signify
+ signify -G -n -s signify/test-pkg.sec -p signify/test-pkg.pub
+
# some extra tests do not yet pass correctly
.PHONY: ${REGRESS_TARGETS} \
collision-check1 collision-check2 collision-check4 collision-check5
diff --git a/regress/usr.sbin/pkg_add/check-cfl b/regress/usr.sbin/pkg_add/check-cfl
new file mode 100644
index 00000000000..238e5df9b7a
--- /dev/null
+++ b/regress/usr.sbin/pkg_add/check-cfl
@@ -0,0 +1,53 @@
+#! /usr/bin/perl
+# $OpenBSD: check-cfl,v 1.1 2014/01/31 10:13:13 espie Exp $
+# Written by Marc Espie
+# Public domain
+
+use strict;
+use warnings;
+use Test::Simple tests => 2;
+
+use OpenBSD::PkgCfl;
+use OpenBSD::PackingList;
+use OpenBSD::PackingElement;
+
+sub check_list
+{
+ my $expected = shift;
+ @_ = sort(@_);
+ if (@$expected != @_) {
+ print STDERR "length: ", scalar(@$expected)," vs. ",
+ scalar(@_), "\n";
+ print STDERR join(',', @$expected), "\n";
+ print STDERR join(',', @_), "\n";
+ return 0;
+ }
+ for my $i (0 .. @_ -1) {
+ if ($expected->[$i] ne $_[$i]) {
+ print STDERR "$expected->[$i] vs. $_[$i]\n";
+ return 0;
+ }
+ }
+ return 1;
+}
+
+sub check_conflict
+{
+ my ($plist, @list) = @_;
+ my $cfl = OpenBSD::PkgCfl->make_conflict_list($plist);
+ return $cfl->conflicts_with(@list);
+}
+
+
+my $p1 = OpenBSD::PackingList->new;
+OpenBSD::PackingElement::Name->add($p1, "foo-1.0");
+
+my @l1 = qw(foo-2.0 partial-foo-2.5 bar-2.0 bar-1.5);
+my @r1 = qw(foo-2.0 partial-foo-2.5);
+ok(check_list(\@r1, check_conflict($p1, @l1)));
+
+my $p2 = OpenBSD::PackingList->new;
+OpenBSD::PackingElement::Name->add($p2, "bar-2.0");
+OpenBSD::PackingElement::NoDefaultConflict->add($p2);
+my @r2 = qw(bar-2.0);
+ok(check_list(\@r2, check_conflict($p2, @l1)));