Contrary to the NYT profiler, which works like a charm
Devel::Cover is a tricky beast.

Right now, I've isolated two issues:
- OpenBSD::MkTemp (subject to a separate mail)
- identity changes on the fly.  Even with looseperms, Devel::Cover
doesn't cope too well with multiple processes and multiple identities

Leading to hilarious errors like:

http://cdn.openbsd.org/pub/OpenBSD/snapshots/packages/amd64/: Devel::Cover: 
Oops, it looks like something went wrong writing the coverage.
              It's possible that more bad things may happen but we'll try to
              carry on anyway as if nothing happened.  At a minimum you'll
              probably find that you are missing coverage.  If you're
              interested, the problem was:

Can't open /tmp/cover_db/structure/177bda0715eb6b804bab8afc36107d32.lock: 
Permission denied



So I have the following fairly icky patch in my tree to be able to try
and get some coverage data and keep going

(note that the dynamic call to OpenBSD::MkTemp in pkg_create is probably
not affected since it gets run only with DEPENDS_CACHE set)


I consider dpb to be somewhat hopeless for now in its standard privsep'd
mode. I've tried it, and not only does Devel::Cover break, but dpb itself
gets confused with getpwuid somehow not even finding its own parameters.

(update-plist is going to be a bit annoying as well, but probably not too
much as identity change can be managed as long as we don't try to write
the lists)


Anyways, as I was saying to kn@, I want to make some kind of progress towards
figuring out pkg_* code coverage, and probably adding some regression tests.

So, in case someone else wants to play:

Index: OpenBSD/PackageRepository.pm
===================================================================
RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm,v
retrieving revision 1.176
diff -u -p -r1.176 PackageRepository.pm
--- OpenBSD/PackageRepository.pm        13 Jun 2023 09:07:17 -0000      1.176
+++ OpenBSD/PackageRepository.pm        8 Jul 2023 09:21:42 -0000
@@ -753,13 +753,13 @@ sub ftp_cmd($self)
 sub drop_privileges_and_setup_env($self)
 {
        my ($uid, $gid, $user) = $self->fetch_id;
-       if (defined $uid) {
-               # we happen right before exec, so change id permanently
-               $( = $gid;
-               $) = "$gid $gid";
-               $< = $uid;
-               $> = $uid;
-       }
+#      if (defined $uid) {
+#              # we happen right before exec, so change id permanently
+#              $( = $gid;
+#              $) = "$gid $gid";
+#              $< = $uid;
+#              $> = $uid;
+#      }
        # create sanitized env for ftp
        my %newenv = (
                HOME => '/var/empty',
Index: OpenBSD/Temp.pm
===================================================================
RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/Temp.pm,v
retrieving revision 1.39
diff -u -p -r1.39 Temp.pm
--- OpenBSD/Temp.pm     13 Jun 2023 09:07:17 -0000      1.39
+++ OpenBSD/Temp.pm     8 Jul 2023 09:21:42 -0000
@@ -19,7 +19,7 @@ use v5.36;
 
 package OpenBSD::Temp;
 
-use OpenBSD::MkTemp;
+use File::Temp;
 use OpenBSD::Paths;
 use OpenBSD::Error;
 
@@ -112,7 +112,7 @@ sub permanent_file($dir, $stem)
        if (defined $dir) {
                $template = "$dir/$template";
        }
-       if (my @l = OpenBSD::MkTemp::mkstemp($template)) {
+       if (my @l = File::Temp::tempfile($template)) {
                return @l;
        }
        ($lastname, $lasttype, $lasterror) = ($template, 'file', $!);
@@ -125,7 +125,7 @@ sub permanent_dir($dir, $stem)
        if (defined $dir) {
                $template = "$dir/$template";
        }
-       if (my $d = OpenBSD::MkTemp::mkdtemp($template)) {
+       if (my $d = File::Temp::tempdir($template)) {
                return $d;
        }
        ($lastname, $lasttype, $lasterror) = ($template, 'dir', $!);

Reply via email to