def METHOD_NAME(group, perms, path, readonly=False):
    """
    Check the validity of one libvirt socket file, including existence,
    group name, access permission and usability of virsh command.
    :param group: Expected group of the file.
    :param perms: Expected permission string of the file.
    :param path: Absolute path of the target file.
    :return : True if success or False if any test fails.
    """
    mode = os.stat(path).st_mode
    gid = os.stat(path).st_gid
    # Check file exists as a socket file.
    if not stat.S_ISSOCK(mode):
        logging.error("File %s is not a socket file." % path)
        return False
    # Check file group ID.
    try:
        expected_gid = grp.getgrnam(group).gr_gid
        logging.debug('Group ID of %s is %s' % (group, expected_gid))
        if gid != expected_gid:
            logging.error('File group gid expected to be '
                          ' %s, but %s found' % (expected_gid, gid))
            return False
    except KeyError:
        logging.error('Can not find group "%s"' % group)
        return False
    # Check file permissions.
    mode_str = mode_bits_to_str(stat.S_IMODE(mode))
    logging.debug('Permission of file %s is %s' % (path, mode_str))
    # Zero padding perms to 4 digits.
    expected_perms = perms.zfill(4)
    if mode_str != expected_perms:
        logging.error('Expected file permission is %s, but %s '
                      'found' % (expected_perms, mode_str))
        return False
    # Check virsh connection.
    uri = 'qemu+unix:///system?socket=%s' % path
    # Prepare test XML file.
    net_name = "unix_sock_test"
    xml_cont = "<network><name>%s</name></network>" % net_name
    xml_path = os.path.join(data_dir.get_tmp_dir(), net_name + '.xml')
    with open(xml_path, 'w') as xml_file:
        xml_file.write(xml_cont)
    result = virsh.net_define(xml_path, uri=uri, ignore_status=True)
    logging.debug('Result of virsh test run is:\n %s' % result)
    try:
        if result.exit_status and not readonly:
            logging.error('Error encountered when running virsh net-define '
                          'on socket file %s' % path)
            return False
        elif readonly and not result.exit_status:
            logging.error('Expect fail when running virsh net-define on '
                          'read-only socket file %s, but succeeded.' % path)
            return False
    finally:
        # Cleanup network and temp file
        virsh.net_undefine(net_name, uri=uri, ignore_status=True)
        if os.path.exists(xml_path):
            os.remove(xml_path)
    # All success
    return True