App-LXC-Container

 view release on metacpan or  search on metacpan

t/05-mounts.t  view on Meta::CPAN

is(ref($obj), 'App::LXC::Container::Mounts',
   'App::LXC::Container::Mounts object has been created correctly');
is($obj->mount_point('/'), NO_MERGE, 'got correct state for entry of /');

is($obj->mount_point('/usr/lib', NO_MERGE), NO_MERGE,
   'correct state could be set for /usr/lib');
is($obj->mount_point('/usr/lib'), NO_MERGE,
   'got correct state for entry of /usr/lib');
is($obj->mount_point('/usr'), NO_MERGE, 'got correct state for entry of /usr');

is($obj->mount_point('/tmp', EXPLICIT), EXPLICIT,
   'correct state could be set for /tmp');
is($obj->mount_point('/tmp'), EXPLICIT, 'got correct state for entry of /tmp');
is($obj->mount_point('/tmp/sub'), EXPLICIT,
   'got correct state for entry of /tmp/sub');

is($obj->mount_point('/var/log', EMPTY), EMPTY,
   'correct state could be set for /var/log');
is($obj->mount_point('/var/log'), EMPTY,
   'got correct state for entry of /var/log');
is($obj->mount_point('/var'), NO_MERGE, 'got correct state for entry of /var');

is($obj->mount_point('/var/spool', UNDEFINED), UNDEFINED,
   'correct state could be set for /var/log');
is($obj->mount_point('/var/spool'), UNDEFINED,
   'got correct state for entry of /var/log');

is($obj->mount_point('/var/cache', IGNORE), IGNORE,
   'correct state could be set for /var/cache');
is($obj->mount_point('/var/cache'), IGNORE,
   'got correct state for entry of /var/cache');

is($obj->mount_point('/usr/bin/chromium', IMPLICIT), IMPLICIT,
   'correct state could be set for /usr/bin/chromium');
is($obj->mount_point('/usr/bin/chromium'), IMPLICIT,
   'got correct state for entry of /usr/bin/chromium');
is($obj->mount_point('/usr/bin'), UNDEFINED,
   'got correct state for entry of /usr/bin');
is($obj->mount_point('/usr'), NO_MERGE, 'got correct state for entry of /usr');

is($obj->mount_point('/usr/bin/chromium', IMPLICIT), IMPLICIT,
   'setting state again returned correct value for /usr/bin/chromium');

is($obj->mount_point('/usr/lib/sub-directory/symbolic-link', IMPLICIT_LINK),
   IMPLICIT_LINK,
   'correct state could be set for /usr/lib/sub-directory/symbolic-link');
is($obj->mount_point('/usr/lib/sub-directory/symbolic-link'), IMPLICIT_LINK,
   'got correct state for /usr/lib/sub-directory/symbolic-link');
is($obj->mount_point('/usr/lib/sub-directory'), UNDEFINED,
   'got correct state for /usr/lib/sub-directory');
is($obj->mount_point('/usr/lib'), NO_MERGE,
   'still got correct state for entry of /usr/lib');

my @sizes =
    (8, 16, 22, 24, 32, 36, 42, 64, 72, 96, 128, 192, 256, 480, 512, 1024);
my @sub_dirs = ();
foreach (@sizes)
{
    $_ = '/usr/share/icons/hicolor/' . $_ . 'x' . $_;
    push @sub_dirs, $_;
    $_ = $_ . '/apps/some-icon.png';
    is($obj->mount_point($_, IMPLICIT), IMPLICIT,
       'correct state could be set for ' . $_);
}
is($obj->mount_point('/usr/share/icons/hicolor/8x8/apps/some-icon.png'),
   IMPLICIT,
   'got correct state for entry of /usr/share/icons/hicolor/.../some-icon.png');
is($obj->mount_point('/usr/share/icons/hicolor/8x8/apps'), UNDEFINED,
   'got correct state for entry of /usr/share/icons/hicolor/8x8/apps');
is($obj->mount_point('/usr/share/icons/hicolor/8x8'), UNDEFINED,
   'got correct state for entry of /usr/share/icons/hicolor/8x8');
is($obj->mount_point('/usr/share/icons/hicolor'), UNDEFINED,
   'got correct state for entry of /usr/share/icons/hicolor');
is($obj->mount_point('/usr/share/icons'), UNDEFINED,
   'got correct state for entry of /usr/share/icons');
is($obj->mount_point('/usr/share'), UNDEFINED,
   'got correct state for entry of /usr/share');
@sub_dirs = sort @sub_dirs;
is_deeply([$obj->sub_directories('/usr/share/icons/hicolor')], \@sub_dirs,
	  'got correct sub-directories for /usr/share/icons/hicolor');

is_deeply([$obj->sub_directories('/usr/share/icons/hicolor/16x16/apps')],
	  ['/usr/share/icons/hicolor/16x16/apps/some-icon.png'],
	  'child found for /usr/share/icons/hicolor/16x16/apps');
is($obj->mount_point('/usr/share/icons/hicolor/16x16/apps', IMPLICIT), IMPLICIT,
   'correct state could be set for /usr/share/icons/hicolor/16x16/apps');
is_deeply([$obj->sub_directories('/usr/share/icons/hicolor/16x16/apps')], [],
	  'I* state of parent correctly removed child for .../16x16/apps');
is($obj->mount_point('/usr/share/icons/hicolor/16x16/apps'), IMPLICIT,
   'got correct state for entry of /usr/share/icons/hicolor/16x16/apps');
is($obj->mount_point('/usr/share/icons/hicolor/16x16'), UNDEFINED,
   'got correct state for entry of /usr/share/icons/hicolor/16x16');
is($obj->mount_point('/usr/share/icons/hicolor'), UNDEFINED,
   'got correct state for entry of /usr/share/icons/hicolor');

is($obj->mount_point('/usr/share/doc', EXPLICIT), EXPLICIT,
   'correct state could be set for /usr/share/doc');
is($obj->mount_point('/usr/share/doc'), EXPLICIT,
   'got correct state for /usr/share/doc');
is($obj->mount_point('/usr/share'), NO_MERGE,
   'got correct new state for /usr/share');

is($obj->mount_point('/usr/share/info/libc.info-1.gz', IMPLICIT), IMPLICIT,
   'correct state could be set for /usr/share/info/libc.info-1.gz');
is($obj->mount_point('/usr/share/info/libc.info-2.gz', IMPLICIT), IMPLICIT,
   'correct state could be set for /usr/share/info/libc.info-2.gz');
is($obj->mount_point('/usr/share/info/libc.info-1.gz'), IMPLICIT,
   'got correct state for entry of /usr/share/info/libc.info-1.gz');
is($obj->mount_point('/usr/share/info/libc.info-2.gz'), IMPLICIT,
   'got correct state for entry of /usr/share/info/libc.info-2.gz');

is($obj->mount_point('/usr/share/not-set'), UNDEFINED,
   'got correct state for /usr/share/not-set');

#########################################################################
# testing a standard merge:
$obj->merge_mount_points(100, 30, 4, 3);
is_deeply([$obj->sub_directories('/usr/share/icons/hicolor')], [],
	  'merge worked for /usr/share/icons/hicolor');

is($obj->mount_point('/usr/share/icons/hicolor/8x8/apps/some-icon.png'),
   IMPLICIT,
   'got correct state for entry of /usr/share/icons/hicolor/.../some-icon.png');
is($obj->mount_point('/usr/share/icons/hicolor/8x8/apps'), IMPLICIT,
   'got correct new state for entry of /usr/share/icons/hicolor/8x8/apps');
is($obj->mount_point('/usr/share/icons/hicolor/8x8'), IMPLICIT,
   'got correct new state for entry of /usr/share/icons/hicolor/8x8');
is($obj->mount_point('/usr/share/icons/hicolor'), IMPLICIT,
   'got correct new state for entry of /usr/share/icons/hicolor');
is($obj->mount_point('/usr/share/icons'), UNDEFINED,
   'got correct state for entry of /usr/share/icons');
is($obj->mount_point('/usr/share'), NO_MERGE,
   'got correct state for entry of /usr/share');
is($obj->mount_point('/usr'), NO_MERGE, 'got correct state for entry of /usr');

is($obj->mount_point('/usr/share/info/libc.info-1.gz'), IMPLICIT,
   'still got correct state for entry of /usr/share/info/libc.info-1.gz');
is($obj->mount_point('/usr/share/info/libc.info-2.gz'), IMPLICIT,
   'still got correct state for entry of /usr/share/info/libc.info-2.gz');

#########################################################################
# testing an aggressive merges:
@sub_dirs = (qw(/usr/share/doc /usr/share/icons /usr/share/info));
foreach (1..9)
{
    $_ = '/usr/share/sub' . $_;
    push @sub_dirs, $_;
    is($obj->mount_point($_, IMPLICIT), IMPLICIT,
       'correct state could be set for ' . $_);
}
$obj->merge_mount_points(2,2,2,2);
is_deeply([$obj->sub_directories('/usr/share')], \@sub_dirs,
	  'merge ignored for /usr/share');

is($obj->mount_point('/usr/share/icons/hicolor'), IMPLICIT,
   'got correct new state for entry of /usr/share/icons/hicolor');
is($obj->mount_point('/usr/share/icons'), UNDEFINED,
   'got correct state for entry of /usr/share/icons');
is($obj->mount_point('/usr/share'), NO_MERGE,
   'got correct state for entry of /usr/share');
is($obj->mount_point('/usr'), NO_MERGE, 'got correct state for entry of /usr');

is($obj->mount_point('/usr/share', COPY), COPY,
   'correct new state could be set for /usr/share');
$obj->merge_mount_points(2);
is_deeply([$obj->sub_directories('/usr/share')], \@sub_dirs,
	  'merge still ignored for /usr/share');
is($obj->mount_point('/usr/share/icons/hicolor'), IMPLICIT,
   'got correct state for entry of /usr/share/icons/hicolor');
is($obj->mount_point('/usr/share/icons'), UNDEFINED,
   'got correct state for entry of /usr/share/icons');
is($obj->mount_point('/usr/share'), COPY,
   'got correct new state for entry of /usr/share');
is($obj->mount_point('/usr'), NO_MERGE, 'got correct state for entry of /usr');

#########################################################################
# testing invalid modifications:

output_like
{   $_ = $obj->mount_point('/var/log', IMPLICIT);   }
    qr{^$}s,
     qr{^/var/log already has incompatible state .* /var/log$re_msg_tail},
    'bad call for /var/log fails';



( run in 1.340 second using v1.01-cache-2.11-cpan-364913b4093 )