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