RFR: 8246741: NetworkInterface/UniqueMacAddressesTest: mac address uniqueness test failed [v2]
Daniel Fuchs
dfuchs at openjdk.java.net
Thu Nov 5 16:33:56 UTC 2020
On Thu, 5 Nov 2020 16:18:11 GMT, Conor Cleary <ccleary at openjdk.org> wrote:
>> The primary goal of this fix was to refactor NetworkInterface/UniqueMacAddressesTest.java to make use of the jdk.test.lib.NetworkConfiguration class instead of java.net.NetworkInterface. This was due to the original failure being related to the use of the 'awdl' interface on macOS, which should be skipped for functional tests. The NetworkConfiguration class accounts for this when returning the list of present interfaces (originally retrieved using NetworkInterface.getNetworkInterfaces()) as well as for other OS specific properties. The effects of these changes can be seen on L59 and L101-106.
>>
>> In addition to these changes, some modifications were made to the test in the interest of keeping it concise and readable but were made bearing in mind the original logging of the test was already up to a good standard (and I sought to keep it that way). To summarize the other changes:
>>
>> - When using NetworkConfiguration::interfaces to read in a stream of NetworkInterface objects, the objects are collected into a list of records (see [JEP 395](https://openjdk.java.net/jeps/395)) to avoid multiple calls to NetworkInterface::getHardwareAddress (which can throw a SocketException) throughout the test.
>> - When checking if the MAC addresses are unique, the testMacAddressesEqual() method is not called unless the interface names are different. If testMacAddressesEqual() returns true, the calling method will simply return instead of updating the value of a boolean variable.
>> - Majority of logging was moved to the testMacAddressesEqualMethod() so that only logs for comparisons are carried out. There is scope for additional logging of, for example, the list of present interfaces returned by createNetworkInterfaceList() if deemed necessary by review.
>
> Conor Cleary has updated the pull request incrementally with one additional commit since the last revision:
>
> 8246741: Corrected summary tag, moved record declaration
Marked as reviewed by dfuchs (Reviewer).
test/jdk/java/net/NetworkInterface/UniqueMacAddressesTest.java line 46:
> 44:
> 45: static PrintStream log = System.err;
> 46: record NetIfPair(String interfaceName, byte[] address) {}
Nit: maybe add a blank line, and a comment:
static PrintStream log = System.err;
// A record pair (NetworkInterface::name, NetworkInterface::hardwareAddress)
record NetIfPair(String interfaceName, byte[] address) {}
-------------
PR: https://git.openjdk.java.net/jdk/pull/1076
More information about the net-dev
mailing list