A model-based approach to automated test generation and error localization for Simulink/Stateflow