xref: /PHP-8.0/ext/snmp/tests/snmprealwalk.phpt (revision 752012a4)
1--TEST--
2Function snmprealwalk
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 = snmprealwalk($hostname, $community, '.1.3.6.1.2.1.1', $timeout, $retries);
20var_dump(gettype($return));
21var_dump(sizeof($return));
22var_dump(key($return));
23var_dump(array_shift($return));
24
25echo "Single OID in array\n";
26$return = snmprealwalk($hostname, $community, array('.1.3.6.1.2.1.1'), $timeout, $retries);
27var_dump(gettype($return));
28var_dump(sizeof($return));
29var_dump(key($return));
30var_dump(array_shift($return));
31
32echo "More error handling\n";
33echo "Multiple correct OID\n";
34$return = snmprealwalk($hostname, $community, array('.1.3.6.1.2.1.1', '.1.3.6'), $timeout, $retries);
35var_dump($return);
36
37echo "Multiple OID with wrong OID\n";
38$return = snmprealwalk($hostname, $community, array('.1.3.6.1.2.1.1', '.1.3.6...1'), $timeout, $retries);
39var_dump($return);
40$return = snmprealwalk($hostname, $community, array('.1.3.6...1', '.1.3.6.1.2.1.1'), $timeout, $retries);
41var_dump($return);
42
43echo "Single nonexisting OID\n";
44$return = snmprealwalk($hostname, $community, array('.1.3.6.99999.0.99999.111'), $timeout, $retries);
45var_dump($return);
46
47?>
48--EXPECTF--
49Checking working
50Single OID
51string(5) "array"
52int(%d)
53string(%d) "%s"
54string(%d) "%s"
55Single OID in array
56string(5) "array"
57int(%d)
58string(%d) "%s"
59string(%d) "%s"
60More error handling
61Multiple correct OID
62
63Warning: snmprealwalk(): Multi OID walks are not supported! in %s on line %d
64bool(false)
65Multiple OID with wrong OID
66
67Warning: snmprealwalk(): Multi OID walks are not supported! in %s on line %d
68bool(false)
69
70Warning: snmprealwalk(): Multi OID walks are not supported! in %s on line %d
71bool(false)
72Single nonexisting OID
73
74Warning: snmprealwalk(): Error in packet at '%s': (noSuchName) There is no such variable name in this MIB. in %s on line %d
75bool(false)
76