File: obviously_non_multi_user.t

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 (56 lines) | stat: -rw-r--r-- 1,566 bytes parent folder | download | duplicates (4)
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
use Test::More 0.95;

BEGIN {
	our $getpwuid_should_die = 0;
	our $getgrgid_should_die = 0;
	};

BEGIN{
	no warnings;

	*CORE::GLOBAL::getpwuid = sub ($) { die "Fred"   if $getpwuid_should_die };
	*CORE::GLOBAL::getgrgid = sub ($) { die "Barney" if $getgrgid_should_die };
	}

use_ok( 'Test::File' );

ok( defined &{ "Test::File::_obviously_non_multi_user" }, "_win32 defined" );

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# The ones that we know aren't multi-user
subtest macos_single_user => sub {
	local $^O = 'MacOS';
	ok( Test::File::_obviously_non_multi_user(), "Returns false for MacOS" );
	};

subtest dos_single_user => sub {
	local $^O = 'dos';
	ok( Test::File::_obviously_non_multi_user(), "Returns true for Win32" );
	};

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# The ones that use get*, but die
subtest getpwuid_should_die => sub {
	local $^O = 'Fooey';
	$getpwuid_should_die = 1;
	$getgrgid_should_die = 0;
	ok( Test::File::_obviously_non_multi_user(), 'getpwuid dying returns true' );
	};

subtest getgrgid_should_die => sub {
	local $^O = 'Fooey';
	$getpwuid_should_die = 0;
	$getgrgid_should_die = 1;
	ok( Test::File::_obviously_non_multi_user(), 'getgrgid dying returns true' );
	};

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# The ones that use get*, but don't die
subtest nothing_dies => sub {
	local $^O = 'Fooey';
	$getpwuid_should_die = 0;
	$getgrgid_should_die = 0;
	ok( ! Test::File::_obviously_non_multi_user(), 'getpwuid dying returns true' );
	};

done_testing();