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