@@ -13,16 +13,25 @@ require_once(__DIR__.'/skipif.inc');
13
13
require_once (__DIR__ .'/snmp_include.inc ' );
14
14
15
15
$ longhostname = str_repeat ($ hostname4 , 1_000_000 );
16
- new SNMP (SNMP ::VERSION_1 , "$ hostname4:-1 " , $ community , $ timeout , $ retries );
17
- new SNMP (SNMP ::VERSION_1 , "$ hostname4:65536 " , $ community , $ timeout , $ retries );
18
- new SNMP (SNMP ::VERSION_1 , "$ longhostname: $ port " , $ community , $ timeout , $ retries );
16
+ try {
17
+ new SNMP (SNMP ::VERSION_1 , "$ hostname4:-1 " , $ community , $ timeout , $ retries );
18
+ } catch (\ValueError $ e ) {
19
+ echo $ e ->getMessage (), PHP_EOL ;
20
+ }
21
+ try {
22
+ new SNMP (SNMP ::VERSION_1 , "$ hostname4:65536 " , $ community , $ timeout , $ retries );
23
+ } catch (\ValueError $ e ) {
24
+ echo $ e ->getMessage (), PHP_EOL ;
25
+ }
26
+ try {
27
+ new SNMP (SNMP ::VERSION_1 , "$ longhostname: $ port " , $ community , $ timeout , $ retries );
28
+ } catch (\ValueError $ e ) {
29
+ echo $ e ->getMessage (), PHP_EOL ;
30
+ }
19
31
echo "OK " ;
20
32
?>
21
- --EXPECTF--
22
-
23
- Warning: SNMP::__construct(): Remote port must be between 0 and 65535 in %s on line %d
24
-
25
- Warning: SNMP::__construct(): Remote port must be between 0 and 65535 in %s on line %d
26
-
27
- Warning: SNMP::__construct(): hostname length must be lower than 128 in %s on line %d
33
+ --EXPECT--
34
+ remote port must be between 0 and 65535
35
+ remote port must be between 0 and 65535
36
+ hostname length must be lower than 128
28
37
OK
0 commit comments