PengZheng opened a new pull request, #543:
URL: https://github.com/apache/celix/pull/543

   With #524 merged, the lack of exported symbols makes error injector hard to 
use.
   For example, to inject error into `celix_utils_writeOrCreateString` called 
by `celix_module_loadLibraryForManifestEntry`, we need to specify its 9th 
caller `celix_framework_installBundle`:
   
   ```C++
   TEST_F(CelixBundleContextBundlesWithErrorTestSuite, failedToGetLibraryPath) {
       celix_ei_expect_celix_utils_writeOrCreateString((void 
*)celix_framework_installBundle, 8, nullptr, 2);
       long bndId = celix_bundleContext_installBundle(ctx, 
SIMPLE_CXX_BUNDLE_LOC, true);
       ASSERT_TRUE(bndId > 0); //bundle is installed, but not started
   
       bool called = celix_bundleContext_useBundle(ctx, bndId, nullptr, [](void 
*/*handle*/, const celix_bundle_t *bnd) {
           auto state = celix_bundle_getState(bnd);
           ASSERT_EQ(state, CELIX_BUNDLE_STATE_INSTALLED);
       });
       ASSERT_TRUE(called);
   }
   ```
   
   And the first call made by `celix_framework_installBundle` came from another 
irrelevant module, which means modification to that module may fail this test 
case.
   
   Also to make the original test work, we have to export some private API, 
which break the purpose of symbol visibility control (and thus is very 
undesirable).
   
   This PR addresses both problem, it builds the code under test as a separate 
static library and link it into the test executable. The only downside is that 
we have to compile the same set of source codes twice instead of once.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to