def METHOD_NAME(link, code):
    """Check if the source code matches the library component.
    Compile source code relative to one component and link to another component.
    Then run the generated executor.
    Args:
        link: The name of component that the source code will link with.
        code: The source code related component name.
    Returns:
        Returns 0 if links and runs successfully, otherwise 1.
    """
    exec_cmd("cmake --build . -v --target clean", True)
    arch = ''
    vcpkg = ''
    openssldir = ''
    mbedtlsdir = ''
    if platform.system() == "Windows":
        arch = '-A x64'
        vcpkg_root = os.environ.get('VCPKG_ROOT')
        if vcpkg_root is not None:
            vcpkg = f"-DCMAKE_TOOLCHAIN_FILE={vcpkg_root}/scripts/buildsystems/vcpkg.cmake"
    elif platform.system() == "Darwin":
        openssldir = '-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl'
        mbedtlsdir = '-DMBEDTLS_ROOT_DIR=/usr/local/opt/mbedtls@2'
    cmd = f"cmake .." \
          f" {arch}" \
          f" {vcpkg}" \
          f" -DEVENT__LINK_COMPONENT={link}" \
          f" -DEVENT__CODE_COMPONENT={code}" \
          f" {openssldir}" \
          f" {mbedtlsdir}"
    if link_type == "static":
        cmd = "".join([cmd, " -DLIBEVENT_STATIC_LINK=1"])
    r = exec_cmd(cmd, True)
    if r == 0:
        r = exec_cmd('cmake --build . -v', True)
        if r == 0:
            r = exec_cmd('ctest', True)
    if r != 0:
        r = 1
    return r