xref: /PHP-7.1/ext/snmp/tests/snmp2_walk.phpt (revision 7af945e2)
1--TEST--
2Function snmp2_walk
3--CREDITS--
4Olivier Doucet Olivier Doucet Boris Lytochkin
5--SKIPIF--
6<?php
7require_once(dirname(__FILE__).'/skipif.inc');
8?>
9--FILE--
10<?php
11require_once(dirname(__FILE__).'/snmp_include.inc');
12
13//EXPECTF format is quickprint OFF
14snmp_set_quick_print(false);
15snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
16
17echo "Checking error handling\n";
18var_dump(snmp2_walk($hostname, $community, '.1.3.6.1.2.1.1', ''));
19var_dump(snmp2_walk($hostname, $community, '.1.3.6.1.2.1.1', $timeout, ''));
20
21echo "Checking working\n";
22echo "Single OID\n";
23$return = snmp2_walk($hostname, $community, '.1.3.6.1.2.1.1', $timeout, $retries);
24
25var_dump(gettype($return));
26var_dump(sizeof($return));
27var_dump(gettype($return[0]));
28var_dump(gettype($return[1]));
29
30echo "Single OID in array\n";
31$return = snmp2_walk($hostname, $community, array('.1.3.6.1.2.1.1'), $timeout, $retries);
32var_dump(gettype($return));
33var_dump(gettype($return[0]));
34
35echo "Default OID\n";
36$return = snmpwalk($hostname, $community, '', $timeout, $retries);
37var_dump(gettype($return));
38var_dump(gettype($return[0]));
39
40echo "More error handling\n";
41echo "Single incorrect OID\n";
42$return = snmpwalk($hostname, $community, '.1.3.6...1', $timeout, $retries);
43var_dump($return);
44
45echo "Multiple correct OID\n";
46$return = snmp2_walk($hostname, $community, array('.1.3.6.1.2.1.1', '.1.3.6'), $timeout, $retries);
47var_dump($return);
48
49echo "Multiple OID with wrong OID\n";
50$return = snmp2_walk($hostname, $community, array('.1.3.6.1.2.1.1', '.1.3.6...1'), $timeout, $retries);
51var_dump($return);
52$return = snmp2_walk($hostname, $community, array('.1.3.6...1', '.1.3.6.1.2.1.1'), $timeout, $retries);
53var_dump($return);
54
55echo "Single nonexisting OID\n";
56$return = snmp2_walk($hostname, $community, array('.1.3.6.99999.0.99999.111'), $timeout, $retries);
57var_dump($return);
58
59?>
60--EXPECTF--
61Checking error handling
62
63Warning: snmp2_walk() expects parameter 4 to be integer, %s given in %s on line %d
64bool(false)
65
66Warning: snmp2_walk() expects parameter 5 to be integer, %s given in %s on line %d
67bool(false)
68Checking working
69Single OID
70%unicode|string%(5) "array"
71int(%d)
72%unicode|string%(6) "string"
73%unicode|string%(6) "string"
74Single OID in array
75%unicode|string%(5) "array"
76%unicode|string%(6) "string"
77Default OID
78%unicode|string%(5) "array"
79%unicode|string%(6) "string"
80More error handling
81Single incorrect OID
82
83Warning: snmpwalk(): Invalid object identifier: %s in %s on line %d
84bool(false)
85Multiple correct OID
86
87Warning: snmp2_walk(): Multi OID walks are not supported! in %s on line %d
88bool(false)
89Multiple OID with wrong OID
90
91Warning: snmp2_walk(): Multi OID walks are not supported! in %s on line %d
92bool(false)
93
94Warning: snmp2_walk(): Multi OID walks are not supported! in %s on line %d
95bool(false)
96Single nonexisting OID
97
98Warning: snmp2_walk(): Error in packet at '%s': No more variables left in this MIB View (It is past the end of the MIB tree) in %s on line %d
99bool(false)
100