xref: /PHP-7.2/ext/snmp/tests/snmpwalk.phpt (revision 17ccbeec)
1--TEST--
2Function snmpwalk
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(snmpwalk($hostname, $community, '.1.3.6.1.2.1.1', ''));
19var_dump(snmpwalk($hostname, $community, '.1.3.6.1.2.1.1', $timeout, ''));
20
21echo "Checking working\n";
22echo "Single OID\n";
23$return = snmpwalk($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 = snmpwalk($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 = snmpwalk($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 = snmpwalk($hostname, $community, array('.1.3.6.1.2.1.1', '.1.3.6...1'), $timeout, $retries);
51var_dump($return);
52$return = snmpwalk($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 = snmpwalk($hostname, $community, array('.1.3.6.99999.0.99999.111'), $timeout, $retries);
57var_dump($return);
58
59?>
60--EXPECTF--
61Checking error handling
62
63Warning: snmpwalk() expects parameter 4 to be integer, %s given in %s on line %d
64bool(false)
65
66Warning: snmpwalk() expects parameter 5 to be integer, %s given in %s on line %d
67bool(false)
68Checking working
69Single OID
70string(5) "array"
71int(%d)
72string(6) "string"
73string(6) "string"
74Single OID in array
75string(5) "array"
76string(6) "string"
77Default OID
78string(5) "array"
79string(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: snmpwalk(): Multi OID walks are not supported! in %s on line %d
88bool(false)
89Multiple OID with wrong OID
90
91Warning: snmpwalk(): Multi OID walks are not supported! in %s on line %d
92bool(false)
93
94Warning: snmpwalk(): Multi OID walks are not supported! in %s on line %d
95bool(false)
96Single nonexisting OID
97
98Warning: snmpwalk(): Error in packet at '%s': (noSuchName) There is no such variable name in this MIB. in %s on line %d
99bool(false)
100