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 20:14:54 +00:00
|
|
|
use afstest qw(src_path 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);
|
2020-12-28 20:14:54 +00:00
|
|
|
use Test::More tests=>3;
|
2011-03-13 14:45:04 +00:00
|
|
|
|
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 20:14:54 +00:00
|
|
|
(undef, my $prdb_tmp) = tempfile("prdbtest.XXXXXX", TMPDIR => 1, UNLINK => 1);
|
|
|
|
my $prdb_test = src_path("tests/ptserver/db.prtiny/prdb.DB0");
|
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 20:14:54 +00:00
|
|
|
my $output;
|
2011-03-13 14:45:04 +00:00
|
|
|
|
2020-12-28 20:14:54 +00:00
|
|
|
open $fh, '|-', "$pt_util", '-w', '-p', $prdb_tmp
|
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 20:14:54 +00:00
|
|
|
open $fh, '-|', "$pt_util", '-p', $prdb_tmp,
|
2011-03-13 14:45:04 +00:00
|
|
|
'-user', '-group', '-members'
|
|
|
|
or die "Failed to start pt_util for DB reading\n";
|
2020-12-28 20:14:54 +00:00
|
|
|
$output = join('', readline($fh));
|
|
|
|
close($fh)
|
|
|
|
or die "pt_util failed while reading from $prdb_tmp\n";
|
|
|
|
is($output, $expected, "pt_util produced expected output for generated db");
|
2011-03-13 14:45:04 +00:00
|
|
|
|
2020-12-28 20:14:54 +00:00
|
|
|
open $fh, '-|', "$pt_util", '-p', $prdb_test,
|
|
|
|
'-user', '-group', '-members'
|
|
|
|
or die "Failed to start pt_util for DB reading\n";
|
|
|
|
$output = join('', readline($fh));
|
2011-03-13 14:45:04 +00:00
|
|
|
close($fh)
|
2020-12-28 20:14:54 +00:00
|
|
|
or die "pt_util failed while reading from $prdb_test\n";
|
|
|
|
is($output, $expected, "pt_util produced expected output for test db");
|
|
|
|
|
2011-03-13 14:45:04 +00:00
|
|
|
ok(1, "Completed sucessfully");
|