function testComp = addStartUpVariantConstraintsToTestComp(testComp, modelH, startupBlkHs)
%

%   Copyright 2021-2022 The MathWorks, Inc.

    if isempty(testComp.tunableParamsAndConstraints.VariantParams)
        return;
    end

    % For each startup variant block, add a constraint to ensure that the
    % analysis always assigns value to the variant control parameter such
    % that it satisfies at-least one of the variant choices. This constraint
    % is needed if variant block is configured not to allow zero variants
    % g2576396
    for idx = 1:numel(startupBlkHs)
        if (strcmp(get_param(startupBlkHs(idx), 'AllowZeroVariantControls'), 'on'))
            continue;
        end

        if (strcmp(get_param(startupBlkHs(idx), 'BlockType'), 'VariantSource') || ...
                strcmp(get_param(startupBlkHs(idx), 'BlockType'), 'VariantSink'))

            cntrlExprs = get_param(startupBlkHs(idx), 'VariantControls');
        else
            cntrlExprs = {get_param(startupBlkHs(idx), 'Variants').Name};
        end
        
        testComp.tunableParamsAndConstraints.Constraints.multiParamConstraints{end+1} = strjoin(cntrlExprs, '||');
    end

    % Get variants constraints from Variant Manager
    modelName = get_param(modelH, 'name');
    variantConstraintObj = Simulink.variant.utils.getConfigurationDataNoThrow(modelName);
    if isempty(variantConstraintObj)
        return;
    end
    
    variantConstraint = variantConstraintObj.Constraints;
    for idx = 1:numel(variantConstraint)
        paramConstraint = variantConstraint(idx).Condition;

        testComp.tunableParamsAndConstraints.Constraints.multiParamConstraints{end+1} = paramConstraint;
    end
end
