diff --git a/smart_card_connector_app/build/js_to_cxx_tests/Makefile b/smart_card_connector_app/build/js_to_cxx_tests/Makefile index c4d77d034..d9aef4547 100644 --- a/smart_card_connector_app/build/js_to_cxx_tests/Makefile +++ b/smart_card_connector_app/build/js_to_cxx_tests/Makefile @@ -36,6 +36,7 @@ SOURCE_DIR := $(ROOT_PATH)/smart_card_connector_app/src/ # targets (for ../executable_module/cpp_unittests/). Get rid of duplicate # compilation by putting them into static libraries. CXX_SOURCES := \ + $(ROOT_PATH)/common/cpp/src/logging_integration_test_helper.cc \ $(SOURCE_DIR)/application_integration_test_helper.cc \ $(SOURCE_DIR)/testing_smart_card_simulation.cc \ diff --git a/smart_card_connector_app/src/pcsc-api-jstocxxtest.js b/smart_card_connector_app/src/pcsc-api-jstocxxtest.js index 3effbd4cb..99d1c9e66 100644 --- a/smart_card_connector_app/src/pcsc-api-jstocxxtest.js +++ b/smart_card_connector_app/src/pcsc-api-jstocxxtest.js @@ -1206,6 +1206,28 @@ goog.exportSymbol('testPcscApi', { assert(called); assertEquals(result.getErrorCode(), API.SCARD_E_INVALID_HANDLE); }, + + // Test that no unexpected exceptions occur when the C++ module is crashing + // while there's a connected PC/SC client. + 'testCrashWithActiveClient': async function() { + const BAD_CONTEXT = 123; + await testController.setUpCppHelper( + 'LoggingTestHelper', /*helperArgument=*/ {}); + await launchPcscServer(/*initialDevices=*/[]); + // Make a random call, to make sure all lazily created per-client state + // gets initialized. + await client.api.SCardIsValidContext(BAD_CONTEXT); + + // Trigger the C++ module crash. + try { + await testController.sendMessageToCppHelper( + 'LoggingTestHelper', 'crash-via-check'); + } catch (e) { + // This is expected branch - discard the exception. + } + + assert(client.clientHandler.isDisposed()); + }, }, // Test that the PC/SC server can shut down successfully when there's an