tests: Use real tempfile in pt_util-t 99/14799/2
authorAndrew Deason <adeason@sinenomine.net>
Mon, 28 Dec 2020 18:22:22 +0000 (12:22 -0600)
committerBenjamin Kaduk <kaduk@mit.edu>
Sun, 19 Sep 2021 05:42:47 +0000 (01:42 -0400)
Use a real call to File::Temp::tempfile to generate our temporary
filename, instead of creating a somewhat predictable filename based on
our pid.

Change-Id: Icb585c04e088b1fa37dffb6d92fc41cdb14874c7
Reviewed-on: https://gerrit.openafs.org/14799
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

tests/ptserver/pt_util-t

index 553b2be..0f5c84a 100755 (executable)
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 
 use File::Basename;
+use File::Temp qw(tempfile);
 use Test::More tests=>2;
 
 my $builddir = $ENV{C_TAP_BUILD};
@@ -13,7 +14,7 @@ if (!$builddir) {
 
 $builddir.="/..";
 
-my $prdbfile = "/tmp/prdbtest.$$";
+(undef, my $prdbfile) = tempfile("prdbtest.XXXXXX", TMPDIR => 1, UNLINK => 1);
 
 my $instructions = <<EOF;
 admin 128/20 1 -204 -204
@@ -49,5 +50,3 @@ close($fh)
     or die "pt_util failed while reading from DB\n";
 is($output, $expected, "pt_util produced expected output");
 ok(1, "Completed sucessfully");
-
-unlink($prdbfile);