function [status, mex] = isSimBasedTestExtensionSupported(mRootModel)
%   Helper API to check for scenarios under which simulation based test
%   extension can be performed for the input root Model.

% =====================================================================
% As of R2022a, following scenarios are not supported :
% #1. Model contains Function Caller blocks which call Simulink Functions
% but the corresponding function definitions are missing
%
% #2. Model is an AUTOSAR component (such a model has the same behavior as
% in scenario #1).
%
% #3. Model is an export function model.
%
% #4. Model contains function-call inports
% =====================================================================

%   Copyright 2022 The MathWorks, Inc.

    status = true;
    mex = [];

    if ~strcmp(get_param(mRootModel,'type'), 'block_diagram')
        % We check for block diagram inputs since the simulation will be
        % performed on root model only.
        return;
    end

    if (slfeature('SLDVAutosarBSWCallersSupport') && ...
            sldvshareprivate('mdl_has_missing_slfunction_defs', mRootModel)) || ...
            strcmp(get_param(mRootModel,'IsExportFunctionModel'),'on')
        % TODO: Check if the model has root-level function-call inports.
        status = false;
        modelName = get_param(mRootModel, 'Name');
        msgId = 'Sldv:Setup:ModelUnsupportedForSimulation';
        errMsg = getString(message(msgId, modelName));
        mex = MException(msgId, errMsg);
    end
end
