Archive-Libarchive-FFI

 view release on metacpan or  search on metacpan

t/common_entry.t  view on Meta::CPAN

$r = archive_entry_set_nlink($e, 5);
is $r, ARCHIVE_OK, 'archive_entry_set_nlink';

is eval { archive_entry_nlink($e) }, 5, 'archive_entry_nlink';
diag $@ if $@;

SKIP: {
  skip 'requires archive_entry_dev_is_set', 1 unless Archive::Libarchive::FFI->can('archive_entry_dev_is_set');
  ok !archive_entry_dev_is_set($e), 'archive_entry_dev_is_set';
};
$r = archive_entry_set_devmajor($e, 0x24);
is $r, ARCHIVE_OK, 'archive_entry_devmajor';
is archive_entry_devmajor($e), 0x24, 'archive_entry_devmajor';
$r = archive_entry_set_devminor($e, 0x67);
is $r, ARCHIVE_OK, 'archive_entry_set_devminor';
is archive_entry_devminor($e), 0x67, 'archive_entry_devminor';
#is sprintf("%x", archive_entry_dev($e)), sprintf("%x", 0x2467), 'archive_entry_dev';
SKIP: {
  skip 'requires archive_entry_dev_is_set', 1 unless Archive::Libarchive::FFI->can('archive_entry_dev_is_set');
  ok archive_entry_dev_is_set($e), 'archive_entry_dev_is_set';
};

$r = archive_entry_set_dev($e, 0x1234);
is $r, ARCHIVE_OK, 'archive_entry_set_dev';
is archive_entry_dev($e), 0x1234, 'archive_entry_dev';

SKIP: {

t/common_entry.t  view on Meta::CPAN

};
$r = archive_entry_set_ino($e, 0x12);
is $r, ARCHIVE_OK, 'archive_entry_set_ino';
is archive_entry_ino($e), 0x12, 'archive_entry_ino';
SKIP: {
  skip 'archive_entry_ino_is_set', 1 unless Archive::Libarchive::FFI->can('archive_entry_ino_is_set');
  ok eval { archive_entry_ino_is_set($e) }, 'archive_entry_ino_is_set';
  diag $@ if $@;
};

$r = archive_entry_set_rdevmajor($e, 0x24);
is $r, ARCHIVE_OK, 'archive_entry_rdevmajor';
is archive_entry_rdevmajor($e), 0x24, 'archive_entry_rdevmajor';
$r = archive_entry_set_rdevminor($e, 0x67);
is $r, ARCHIVE_OK, 'archive_entry_set_rdevminor';
is archive_entry_rdevminor($e), 0x67, 'archive_entry_rdevminor';
#is sprintf("%x", archive_entry_rdev($e)), sprintf("%x", 0x2467), 'archive_entry_rdev';

$r = archive_entry_set_rdev($e, 0x1234);
is $r, ARCHIVE_OK, 'archive_entry_set_rdev';
is archive_entry_rdev($e), 0x1234, 'archive_entry_rdev';

$r = eval { archive_entry_set_atime($e, 123456789, 123456789) };
diag $@ if $@;
is $r, ARCHIVE_OK, 'archive_entry_set_atime';
is eval { archive_entry_atime($e) }, 123456789, 'archive_entry_atime';
diag $@ if $@;

t/common_filenames.t  view on Meta::CPAN

  diag 'archive_error_string = ' . archive_error_string($a) if $r != ARCHIVE_OK;
  is archive_entry_pathname($ae), 'test.txt', 'archive_entry_pathname = test.txt';
  ok eval { archive_entry_mtime($ae) }, 'archive_entry_mtime';
  diag $@ if $@;
  ok eval { archive_entry_ctime($ae) }, 'archive_entry_ctime';
  diag $@ if $@;
  ok eval { archive_entry_atime($ae) }, 'archive_entry_atime';
  diag $@ if $@;
  is archive_entry_size($ae), 20, 'archive_entry_size = 20';
  is archive_entry_mode($ae), 33188, 'archive_entry_mode = 33188';
  my $br = archive_read_data($a, my $buff, 10224);
  is $br, archive_entry_size($ae), 'br = size';
  is $buff, "test text document\015\012", 'buff = test text document';
};

subtest 'Second header.' => sub {
  plan tests => 8;
  $r = archive_read_next_header($a, my $ae);
  is $r, ARCHIVE_OK, 'archive_read_next_header';
  diag 'archive_error_string = ' . archive_error_string($a) if $r != ARCHIVE_OK;
  is archive_entry_pathname($ae), 'testlink', 'archive_entry_pathname = testlink';

t/common_filenames.t  view on Meta::CPAN

  is $r, ARCHIVE_OK, 'archive_read_next_header';
  is archive_entry_pathname($ae), 'testdir/test.txt', 'archive_entry_pathname = testdir/test.txt';
  ok eval { archive_entry_mtime($ae) }, 'archive_entry_mtime';
  diag $@ if $@;
  ok eval { archive_entry_ctime($ae) }, 'archive_entry_ctime';
  diag $@ if $@;
  ok eval { archive_entry_atime($ae) }, 'archive_entry_atime';
  diag $@ if $@;
  is archive_entry_size($ae), 20, 'archive_entry_size = 20';
  is archive_entry_mode($ae), 33188, 'archive_entry_mode = 33188';
  my $br = archive_read_data($a, my $buff, 10224);
  is $br, archive_entry_size($ae), 'br = size';
  is $buff, "test text document\015\012", 'buff = test text document';
};

subtest 'Fourth header.' => sub {
  plan tests => 7;
  $r = archive_read_next_header($a, my $ae);
  is $r, ARCHIVE_OK, 'archive_read_next_header';
  is archive_entry_pathname($ae), 'testdir', 'archive_entry_pathname = testdir';
  ok eval { archive_entry_mtime($ae) }, 'archive_entry_mtime';

t/common_uid_gid_lookup.t  view on Meta::CPAN

  plan tests => 2;
  is archive_write_disk_gid($a, "FOOGROUP",    8), 73, 'gid FOOGROUP    8 = 73';
  is archive_write_disk_gid($a, "NOTFOOGROUP", 8),  1, 'gid NOTFOOGROUP 8 = 1';
};

subtest 'De-register.' => sub {
  plan tests => 2;
  my $r = eval { archive_write_disk_set_group_lookup($a, undef, undef, undef) };
  diag $@ if $@;
  is $r, ARCHIVE_OK, 'archive_write_disk_set_group_lookup';
  is $gmagic, 0x2468, 'Ensure our cleanup function got called.';
};

subtest 'Same thing with uname lookup....' => sub {
  plan tests => 5;
  my $r = eval { archive_write_disk_set_user_lookup($a, \$umagic, \&user_lookup, \&user_cleanup) };
  diag $@ if $@;
  is $r, ARCHIVE_OK, 'archive_write_disk_set_user_lookup';

  is archive_write_disk_uid($a, "FOO",    0),  2, 'uid FOO    0 = 2';
  is archive_write_disk_uid($a, "NOTFOO", 1), 74, 'uid NOTFOO 1 = 74';

t/common_uid_gid_lookup.t  view on Meta::CPAN

subtest 'cleanup' => sub {
  plan tests => 1;
  my $r = archive_write_free($a);
  is $r, ARCHIVE_OK, 'archive_write_free';
};

sub group_cleanup
{
  my($data) = @_;
  die unless $$data == 0x13579;
  $$data = 0x2468;
}

sub group_lookup
{
  my($data, $name, $gid) = @_;
  die unless $$data == 0x13579;
  return 1 if $name ne 'FOOGROUP';
  return 73;
}

t/common_user_group_lookup.t  view on Meta::CPAN


  my $r = eval { archive_read_disk_set_gname_lookup($a, \$gmagic, \&gname_lookup, \&gname_cleanup) };
  diag $@ if $@;
  is $r, ARCHIVE_OK, 'archive_read_disk_set_gname_lookup';
  is archive_read_disk_gname($a, 0), 'NOTFOOGROUP', 'gname 0 = NOTFOOGROUP';
  is archive_read_disk_gname($a, 1), 'FOOGROUP',    'group 1 = FOOGROUP';

  $r = eval { archive_read_disk_set_gname_lookup($a, undef, undef, undef) };
  diag if $@;
  is $r, ARCHIVE_OK, 'De-register.';
  is $gmagic, 0x2468, 'Ensure our cleanup function got called.';
};

subtest 'Same thing with uname lookup....' => sub {
  plan tests => 5;
  my $umagic = 0x1234;
  my $r = eval { archive_read_disk_set_uname_lookup($a, \$umagic, \&uname_lookup, \&uname_cleanup) };
  diag $@ if $@;
  is $r, ARCHIVE_OK, 'archive_read_disk_set_uname_lookup';

  is archive_read_disk_uname($a, 0), "NOTFOO", 'uname 0 = NOTFOO';

t/common_user_group_lookup.t  view on Meta::CPAN

subtest 'cleanup' => sub {
  plan tests => 1;
  my $r = archive_read_free($a);
  is $r, ARCHIVE_OK, 'archive_read_free';
};

sub gname_cleanup
{
  my($data) = @_;
  die unless $$data == 0x13579;
  $$data = 0x2468;
}

sub gname_lookup
{
  my($data, $gid) = @_;
  return "FOOGROUP" if $gid == 1;
  return "NOTFOOGROUP";
}

sub uname_cleanup



( run in 0.415 second using v1.01-cache-2.11-cpan-88abd93f124 )