2020-04-13 02:16:55 +01:00
|
|
|
#!/usr/bin/env perl
|
2011-03-13 14:45:04 +00:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
2020-12-28 19:12:59 +00:00
|
|
|
use lib $ENV{C_TAP_SOURCE} . "/tests-lib/perl5";
|
2011-03-13 14:45:04 +00:00
|
|
|
|
2020-12-28 19:12:59 +00:00
|
|
|
use afstest qw(obj_path);
|
2011-03-13 14:45:04 +00:00
|
|
|
use File::Basename;
|
2020-12-28 18:22:22 +00:00
|
|
|
use File::Temp qw(tempfile);
|
2011-03-13 14:45:04 +00:00
|
|
|
use Test::More tests=>2;
|
|
|
|
|
2020-12-28 19:12:59 +00:00
|
|
|
my $pt_util = obj_path("src/ptserver/pt_util");
|
2011-03-13 14:45:04 +00:00
|
|
|
|
2020-12-28 18:22:22 +00:00
|
|
|
(undef, my $prdbfile) = tempfile("prdbtest.XXXXXX", TMPDIR => 1, UNLINK => 1);
|
2011-03-13 14:45:04 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2020-12-28 19:12:59 +00:00
|
|
|
open $fh, '|-', "$pt_util", '-w', '-p', $prdbfile
|
2011-03-13 14:45:04 +00:00
|
|
|
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";
|
|
|
|
|
2020-12-28 19:12:59 +00:00
|
|
|
open $fh, '-|', "$pt_util", '-p', $prdbfile,
|
2011-03-13 14:45:04 +00:00
|
|
|
'-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");
|