summaryrefslogtreecommitdiff
path: root/regress/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2011-05-27 12:24:46 +0000
committerMarc Espie <espie@cvs.openbsd.org>2011-05-27 12:24:46 +0000
commite9dfb63f529cd988f18633927399253827771191 (patch)
treeb46e5653b2ce97f5248260c20e1443148a1181cf /regress/usr.sbin/pkg_add
parent61df3aae9f4ef37d5d868d004a45c22fcd83db10 (diff)
unit-test @pkgpath before we add a lot of junk to it
Diffstat (limited to 'regress/usr.sbin/pkg_add')
-rw-r--r--regress/usr.sbin/pkg_add/Makefile8
-rw-r--r--regress/usr.sbin/pkg_add/check-path27
2 files changed, 33 insertions, 2 deletions
diff --git a/regress/usr.sbin/pkg_add/Makefile b/regress/usr.sbin/pkg_add/Makefile
index 3d74a5ace9c..d73c08ff12c 100644
--- a/regress/usr.sbin/pkg_add/Makefile
+++ b/regress/usr.sbin/pkg_add/Makefile
@@ -1,6 +1,7 @@
-# $OpenBSD: Makefile,v 1.42 2011/05/21 21:59:40 landry Exp $
+# $OpenBSD: Makefile,v 1.43 2011/05/27 12:24:45 espie Exp $
-REGRESS_TARGETS=pkgnames signatures depends-check longnames update-check1 \
+REGRESS_TARGETS=pkgnames pkgpaths signatures depends-check longnames \
+ 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 \
@@ -28,6 +29,9 @@ DEST$i ?= ${D$i}/usr/local
pkgnames:
perl ${.CURDIR}/check-name
+pkgpaths:
+ perl ${.CURDIR}/check-path
+
signatures:
-rm -f signatures.out
perl ${.CURDIR}/check-sig 2>signatures.out
diff --git a/regress/usr.sbin/pkg_add/check-path b/regress/usr.sbin/pkg_add/check-path
new file mode 100644
index 00000000000..1900c8e6ace
--- /dev/null
+++ b/regress/usr.sbin/pkg_add/check-path
@@ -0,0 +1,27 @@
+#! /usr/bin/perl
+
+# $OpenBSD: check-path,v 1.1 2011/05/27 12:24:45 espie Exp $
+use Test::Simple tests => 4;
+use OpenBSD::PackingList;
+
+sub make_plist
+{
+ my $p = OpenBSD::PackingList->new;
+ OpenBSD::PackingElement::ExtraInfo->add($p, shift, '', '');
+ for my $path (@_) {
+ OpenBSD::PackingElement::PkgPath->add($p, $path);
+ }
+ return $p;
+}
+
+
+my $p1 = make_plist('path1');
+my $p1bis = make_plist('path1');
+my $p2 = make_plist('path2');
+my $p2bis = make_plist('path2', 'path1');
+my $p3 = make_plist('path3', 'path1');
+
+ok($p1->match_pkgpath($p1bis), "same path matches");
+ok(!$p1->match_pkgpath($p2), "different paths don't");
+ok($p1->match_pkgpath($p2bis), "look into the list too");
+ok(!$p2bis->match_pkgpath($p3), "extra elements can't match by themselves");