IOT-1868 [C++ layer] Make OCPlatform start and stop reliably
This change adds reference count to OCPlatform's static start and
stop functions and synchronizes them. It does the following:
1. Ensures that calls to the "C" APIs OCInit and OCStop are balanced.
2. Maintains backward compatibility by introducing new PlatformConfig
constructor and deprecate the old ones.
3. Updates the existing unit tests and samples.
Because this change allows the framework to stop properly, it exposes
some existing IoTivity leaks in Jenkins (Valgrind validation). Thus
the following leaks are fixed in this change to allow successful
Jenkins runs:
1. caipadapter.c: endpoint cache leak in UDP (no issue for TCP).
- https://build.iotivity.org/ci/job/iotivity-verify-unit_tests/
10907/valgrindResult/pid=24498,0x3fe
2. psinterface.c: CBOR buffer leaks in CreateResetProfile.
- https://build.iotivity.org/ci/job/iotivity-verify-unit_tests/
10922/valgrindResult/pid=2316,0x3ad
3. ocstack.c & securityResourceManager.cpp: persistent storage buffer
leaks as a result of restarting and switching OCPlatform
configuration after shutdown (e.g., between tests).
https://build.iotivity.org/ci/job/iotivity-verify-unit_tests/
10922/valgrindResult/pid=2316,0x3ad
4. OCRepresentationEncodingTest.cpp: representation value leaks.
- https://build.iotivity.org/ci/job/iotivity-verify-unit_tests/
10922/valgrindResult/pid=2316,0x3a9
5. runtest.py: change Valgrind callstack size from the default value
of 12 to 24 so that the test name is visible in the report. Helpful
for reproducibility.
Change-Id: I79406f2cf4282efbb29a69c14e42aae928f54bae
Signed-off-by: Way Vadhanasin <wayvad@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17685
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
38 files changed: