test: check ipv6 support before testing it

fix #7983
fix #8049
Shouldn't it be
```
assert.equal(4, tests_run);
```
here? When the host supports IPv6, not test is added, but when it doesn't, one test is not run.
So in the else statement, it should also be ``assert.equal(3, tests_run);``