def check_number_of_interfaces(conn, num_expect, flag, logger):
    """
       test numOfInterfaces(), numOfDefinedInterfaces() api
    """
    if flag == 0:
        num = conn.numOfInterfaces() + conn.numOfDefinedInterfaces()
    elif flag == 1:
        num = conn.numOfDefinedInterfaces()
    elif flag == 2:
        num = conn.numOfInterfaces()
    if num != num_expect:
        logger.error("Number don't match, expect %d, got %d" % (num_expect,
            num))
        return False
    logger.info('Number of interfaces matches')
    return True
