File: setup_common

package info (click to toggle)
libtest-file-perl 1.41-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 244 kB
  • ctags: 54
  • sloc: perl: 986; makefile: 2
file content (59 lines) | stat: -rw-r--r-- 1,406 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use strict;

use File::Temp qw(tempdir);
use Test::More 0.95;

my $dir = tempdir( CLEANUP => 1 ) or BAILOUT( "Could not setup temp directory" );

unless( -d $dir ) {
	mkdir 'test_files', 0700 
		or BAILOUT( "Could not make directory! $!" );
	}
	
chdir $dir or BAILOUT( "Could not change directory! $!" );

my @files = qw(
max_file       non_zero_file  not_readable   readable       zero_file
executable     min_file       not_executable not_writeable  writeable
mtime_file
);

foreach my $file ( @files ) {
	open FH, "> $file";
	close FH;
	}

{
my $count = chmod 0644, @files;
is( $count, scalar @files ) or BAILOUT( "Could not make files readable" );
}

{
my $count = chmod 0400, 'readable', 'not_writeable', 'not_executable';
is( $count, 3 ) or BAILOUT( "Could not make files readable" );
}

{
my $count = chmod 0200, 'writeable', 'not_readable',
		'zero_file', 'max_file', 'non_zero_file';
is( $count, 5 ) or BAILOUT( "Could not make files writeable" );
}

{
my $count = chmod 0100, 'executable';
is( $count, 1 ) or BAILOUT( "Could not make files executable" );
}

truncate 'zero_file', 0;
truncate 'max_file', 10;
truncate 'min_file',  0;

{
open FH, '> min_file' or BAILOUT( "Could not write to min_file: $!" );
binmode FH; #, Windows, yo!
print FH 'x' x 40, $/, 'x' x 11, $/;
close FH;
}
is( -s 'min_file', 51 + 2 * length( $/ ) );

mkdir 'sub_dir', 0755 or BAILOUT( "Could not cerate subdir: $!" );