xref: /PHP-8.3/ext/snmp/tests/snmp2_set-nomib.phpt (revision ba1d9d0a)
1--TEST--
2Function snmp2_set (without MIBs loading)
3--CREDITS--
4Boris Lytockin
5--EXTENSIONS--
6snmp
7--SKIPIF--
8<?php
9require_once(__DIR__.'/skipif.inc');
10if (getenv('SKIP_ASAN')) die('skip Timeouts under ASAN');
11?>
12--ENV--
13MIBS=
14--FILE--
15<?php
16require_once(__DIR__.'/snmp_include.inc');
17
18//EXPECTF format is quickprint OFF
19snmp_set_quick_print(false);
20snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
21
22echo "Check error handing\n";
23echo "Nonexisting OID\n";
24$z = snmp2_set($hostname, $communityWrite, '.1.3.6.777.888.999.444.0', 's', 'bbb', $timeout, $retries);
25var_dump($z);
26
27echo "Bogus OID\n";
28$z = snmp2_set($hostname, $communityWrite, '.1.3.6...777.888.999.444.0', 's', 'bbb', $timeout, $retries);
29var_dump($z);
30
31echo "Checking working\n";
32$oid1 = '.1.3.6.1.2.1.1.4.0';
33$oldvalue1 = snmpget($hostname, $communityWrite, $oid1, $timeout, $retries);
34$newvalue1 = $oldvalue1 . '0';
35
36echo "Single OID\n";
37$z = snmp2_set($hostname, $communityWrite, $oid1, 's', $newvalue1, $timeout, $retries);
38var_dump($z);
39var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $newvalue1));
40$z = snmp2_set($hostname, $communityWrite, $oid1, 's', $oldvalue1, $timeout, $retries);
41var_dump($z);
42var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
43
44?>
45--EXPECTF--
46Check error handing
47Nonexisting OID
48
49Warning: snmp2_set(): Error in packet at '%s': notWritable (That object does not support modification) in %s on line %d
50bool(false)
51Bogus OID
52
53Warning: snmp2_set(): Invalid object identifier: %s in %s on line %d
54bool(false)
55Checking working
56Single OID
57bool(true)
58bool(true)
59bool(true)
60bool(true)
61