1--TEST--
2net_get_interfaces IPv4 Loopback
3--SKIPIF--
4<?php
5function_exists('net_get_interfaces') || print 'skip';
6--FILE--
7<?php
8
9// Test that we have exactly one unicast address with the address 127.0.0.1
10// On linux this will often be named "lo", but even that isn't guaranteed.
11
12$ifaces = net_get_interfaces();
13
14$found = false;
15foreach ($ifaces as $iface) {
16  foreach ($iface['unicast'] as $unicast) {
17    if (($unicast['address'] ?? null) === '127.0.0.1') {
18      $found = true;
19      break 2;
20    }
21  }
22}
23
24var_dump($found);
25if (!$found) {
26  // Extra diagnostics!
27  var_dump($ifaces);
28}
29?>
30--EXPECT--
31bool(true)
32