]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
pt_util: Initialise empty database correctly
authorSimon Wilkinson <sxw@inf.ed.ac.uk>
Sun, 13 Mar 2011 14:45:04 +0000 (14:45 +0000)
committerDerrick Brashear <shadow@dementia.org>
Mon, 14 Mar 2011 17:08:48 +0000 (10:08 -0700)
Commit dc8f18d6f5003712bc9ef989363137a84953df07 broke pt_util's
initialisation of empty databases. This is because Initdb was changed
to call Initdb_check through the ubik_CheckCache wrapper. However, that
wrapper was defined as a no-op in pt_util's ubik-shim.

Modify pt_util's ubik_CheckCache so that it always calls into the
wrapper routine - this mimics the old behaviour.

Add a trival test for pt_util - check that we can build the database,
using the example from the manpage, and then that the built database
matches what we expect.

(cherry picked from commit 4953ce8070497bc494e624d72271bcbc5dc1dbe7)
Reviewed-on: http://gerrit.openafs.org/4211
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Change-Id: If4cfbda25f8d1c5e1da4c1e42982c74becf386e3
Reviewed-on: http://gerrit.openafs.org/4217
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
src/ptserver/ubik.c
tests/TESTS
tests/ptserver/pt_util-t [new file with mode: 0755]

index b8c772c0937d90588de1e8d33dbec87a7ea10c2c..53c8bcfc0be42ab525f9503f7375dc25d1f4941a 100644 (file)
@@ -101,7 +101,7 @@ ubik_WaitVersion(struct ubik_dbase *adatabase,
 int
 ubik_CheckCache(struct ubik_trans *atrans, ubik_updatecache_func cbf, void *rock)
 {
-    return (0);
+    return (*cbf)(atrans, rock);
 }
 
 void
index 03b038e9337a8ecb5a33f90d22b272982088aa84..df59887ab99a7593b9a28bccd0e85a868ffed078 100644 (file)
@@ -1,2 +1,3 @@
 util/ktime
 util/exec-alt
+ptserver/pt_util
diff --git a/tests/ptserver/pt_util-t b/tests/ptserver/pt_util-t
new file mode 100755 (executable)
index 0000000..8d3cdcb
--- /dev/null
@@ -0,0 +1,53 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use File::Basename;
+use Test::More tests=>2;
+
+my $builddir = $ENV{BUILD};
+if (!$builddir) {
+  $builddir = dirname($0)."/..";
+}
+
+$builddir.="/..";
+
+my $prdbfile = "/tmp/prdbtest.$$";
+
+my $instructions = <<EOF;
+admin 128/20 1 -204 -204
+system:administrators 130/20 -204 -204 -204
+ admin 1
+EOF
+
+my $expected = <<EOF;
+admin      128/20 1 -204 -204
+anonymous  128/20 32766 -204 -204
+system:backup 2/0 -205 -204 -204
+system:administrators 130/20 -204 -204 -204
+   admin    1
+system:ptsviewers 2/0 -203 -204 -204
+system:authuser 2/0 -102 -204 -204
+system:anyuser 2/0 -101 -204 -204
+EOF
+
+my $fh;
+
+open $fh, '|-', "$builddir/src/ptserver/pt_util", '-w', '-p', $prdbfile
+   or die "Failed to start pt_util for DB creation\n";
+print $fh $instructions;
+close($fh)
+   or die "pt util failed while creating DB\n";
+
+open $fh, '-|', "$builddir/src/ptserver/pt_util", '-p', $prdbfile,
+                                    '-user', '-group', '-members'
+    or die "Failed to start pt_util for DB reading\n";
+
+my $output = join('', readline($fh));
+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);