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