summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2019-08-02 14:57:54 +0000
committerMarc Espie <espie@cvs.openbsd.org>2019-08-02 14:57:54 +0000
commit733732cd8b8a0939b16f6bd02b4c839fd747879a (patch)
treeac858c2f2c2931ab468cf0cf7eb4a357b3c1ca76
parentc1e8872b5836ced3b1262aad74a1035af9e584d7 (diff)
pass -Dchecksum around so that checksum is exercised.
Also, inject fault and verify that package does indeed not get fully deleted
-rw-r--r--regress/usr.sbin/pkg_add/Makefile21
-rw-r--r--regress/usr.sbin/pkg_add/inject-badsum25
2 files changed, 41 insertions, 5 deletions
diff --git a/regress/usr.sbin/pkg_add/Makefile b/regress/usr.sbin/pkg_add/Makefile
index 4052dc1a4f3..cb93f0a285e 100644
--- a/regress/usr.sbin/pkg_add/Makefile
+++ b/regress/usr.sbin/pkg_add/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.73 2019/07/11 07:15:02 espie Exp $
+# $OpenBSD: Makefile,v 1.74 2019/08/02 14:57:53 espie Exp $
REGRESS_TARGETS=pkgnames pkgpaths signatures depends-check longnames pkgcfl \
collision-check1 collision-check2 collision-check3 \
@@ -11,7 +11,8 @@ REGRESS_TARGETS=pkgnames pkgpaths signatures depends-check longnames pkgcfl \
qttest gstest exotest inter1 manual1 oldlib1 \
usertest-1 usertest-2 usertest-3 cups-bug nettle-bug \
tying-1 tying-2 tag-delete setsprint temp-error1 \
- temp-error2 temp-error2-as-root temp-error3 temp-error4
+ temp-error2 temp-error2-as-root temp-error3 temp-error4 \
+ cksum-error
REGRESS_ROOT_TARGETS = temp-error2-as-root
@@ -20,8 +21,8 @@ REGRESS_EXPECTED_FAILURES = collision-check1 collision-check2 \
collision-check5 collision-check6 collision-check7 \
exotest tying-2
-ADD_PKG=perl -I${.CURDIR} ${.CURDIR}/my add
-DELETE_PKG=perl -I${.CURDIR} ${.CURDIR}/my delete
+ADD_PKG=perl -I${.CURDIR} ${.CURDIR}/my add -Dchecksum
+DELETE_PKG=perl -I${.CURDIR} ${.CURDIR}/my delete -Dchecksum
INFO_PKG=perl -I${.CURDIR} ${.CURDIR}/my info
CREATE_PKG=perl -I${.CURDIR} ${.CURDIR}/mycreate
LONG1=iamareallongfilenamethatcantberepresentedcorrectlyinatararchivebutwewantittohappenanywaysohmygodaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa42
@@ -37,7 +38,7 @@ D$i ?= ${.OBJDIR}/dest$i
DEST$i ?= ${D$i}/usr/local
.endfor
-# current maxes (used): D41, SRC26, plist24, rep5
+# current maxes (used): D44, SRC27, plist24, rep5
pkgnames:
perl ${.CURDIR}/check-name
@@ -799,8 +800,18 @@ temp-error4: rep0/qt-0.tgz rep1/qt-1.tgz
@echo zoinx >${D43}/usr/local/phonon/a
@{ INJECT=inject-temp4 PKG_PATH=${.OBJDIR}/rep1 SILENT=1 ROOT=${D43} ${ADD_PKG} -Dchecksum -u qt || echo $$?; } 2>&1|${SED_PIPE} >temp4.out
+rep5/a-0.tgz: plist19
+ @mkdir -p ${SRC27}
+ @echo "zoinx" > ${SRC27}/a
+ INJECT=inject-badsum ${CREATE_PKG} -B src27 -f plist19 $@
+
.PHONY: ${REGRESS_TARGETS}
+cksum-error: rep5/a-0.tgz
+ @-rm -rf ${D44}
+ @ROOT=${D44} SILENT=1 ${ADD_PKG} rep5/a-0.tgz
+ @ROOT=${D44} SILENT=1 ${DELETE_PKG} a|fgrep 'Not deleting'
+
clean:
-rm -rf rep* dest* plist* src* signatures.out *.ref *.out
-${SUDO} rm -rf rep* dest* plist* src* signatures.out *.ref *.out
diff --git a/regress/usr.sbin/pkg_add/inject-badsum b/regress/usr.sbin/pkg_add/inject-badsum
new file mode 100644
index 00000000000..c97e9867a7a
--- /dev/null
+++ b/regress/usr.sbin/pkg_add/inject-badsum
@@ -0,0 +1,25 @@
+#! /usr/bin/perl
+
+# $OpenBSD: inject-badsum,v 1.1 2019/08/02 14:57:53 espie Exp $
+use strict;
+use warnings;
+
+use OpenBSD::md5;
+
+package OpenBSD::digest;
+use Wrapper;
+
+wrap('digest_file',
+ sub {
+ my $original = shift;
+ if ($_[1] =~ m,/a$,) {
+ my $self = shift;
+ my $d = $self->algo;
+ $d->addfile("/dev/null");
+ return $d->digest;
+ } else {
+ goto &$original;
+ }
+ });
+
+1;