summaryrefslogtreecommitdiff
path: root/ext/standard/tests/general_functions/getrusage_error.phpt
blob: a40a43449a6cfbc1a55a4d1208f460271e09ecc3 (plain)
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
60
61
62
63
64
65
66
67
68
69
70
--TEST--
Test getrusage() function : error conditions - incorrect number of args
--SKIPIF--
<?php if (!function_exists("getrusage")) print "skip"; ?>
--FILE--
<?php
/* Prototype  :  array getrusage  ([ int $who  ] )
 * Description: Gets the current resource usages
 * Source code: ext/standard/microtime.c
 * Alias to functions: 
 */

/*
 * Pass an incorrect number of arguments to getrusage() to test behaviour
 */

echo "*** Testing getrusage() : error conditions ***\n";

echo "\n-- Testing getrusage() function with more than expected no. of arguments --\n";
$extra_arg = 10;
$dat = getrusage(1, $extra_arg);

echo "\n-- Testing getrusage() function with invalid argument - non-numeric STRING--\n";
$string_arg = "foo";
$dat = getrusage($string_arg);

echo "\n-- Testing getrusage() function with invalid argument - ARRAY--\n";
$array_arg = array(1,2,3);
$dat = getrusage($array_arg);

echo "\n-- Testing getrusage() function with invalid argument - OBJECT --\n";
class classA 
{
  function __toString() {
    return "ClassAObject";
  }
}
$obj_arg = new classA();
$dat = getrusage($obj_arg);

echo "\n-- Testing getrusage() function with invalid argument - RESOURCE --\n";
$file_handle=fopen(__FILE__, "r");
$dat = getrusage($file_handle);
fclose($file_handle);

?>
===DONE===
--EXPECTF--
*** Testing getrusage() : error conditions ***

-- Testing getrusage() function with more than expected no. of arguments --

Warning: getrusage() expects at most 1 parameter, 2 given in %s on line %d

-- Testing getrusage() function with invalid argument - non-numeric STRING--

Warning: getrusage() expects parameter 1 to be int, string given in %s on line %d

-- Testing getrusage() function with invalid argument - ARRAY--

Warning: getrusage() expects parameter 1 to be int, array given in %s on line %d

-- Testing getrusage() function with invalid argument - OBJECT --

Warning: getrusage() expects parameter 1 to be int, object given in %s on line %d

-- Testing getrusage() function with invalid argument - RESOURCE --

Warning: getrusage() expects parameter 1 to be int, resource given in %s on line %d
===DONE===