lib/tst_uid_gid.c: fix checking return value errors about getpwuid_r/getgrgid_r

When we  call getgrgid_r()  to  verify whether the corresponding gid is
existent, if not, getgrgid_r() will return 0 or ENOENT or ESRCH or
EBADF or EPERM...

But tst_get_unused_gid() only check return value 0, this is not complete.
For example, if the gid is not existent, getgrgid_r() in RHEL7 beta will
return ENOENT, which will cause tst_get_unused_gid failed incorrectly.
This is the same for getpwuid_r().

We should make tst_get_unused_uid/tst_get_unused_gid check all the possible
return value.

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>