Skip to content

Commit

Permalink
Update C SDK submodules to 2020-12-09. (Azure#4867)
Browse files Browse the repository at this point in the history
These are the current latest versions. Among other things, they contain fixes
for building with recent cmake.

API changes:

- `TEST_INITIALIZE_MEMORY_DEBUG` and `TEST_DEINITIALIZE_MEMORY_DEBUG`
  were removed from testrunnerswitch.h

  Azure/c-testrunnerswitcher@0711280

- `TOSTRING` macro was removed from ctest_macros.h in favor of
  `MU_TOSTRING` from macro-utils

  Azure/ctest@6d7a34c

- `SECURE_DEVICE_TYPE`, `UINT` and `XDA_HANDLE` are not defined anywhere.

- `REGISTER_UMOCK_ALIAS_TYPE` now requires the aliasing type to be
  the same size as the aliased type.

  Azure/umock-c@2ab7102

- On Windows, `interface` ends up being `#define`d to `struct`
  by Windows headers, which causes compile errors when it's used as
  a variable name. Rename those variables to `iface`.

Other changes:

- Fix `edgelet-utils` to build with newer Rust since `tools/check_submodules`
  depends on it but does not have its own `rust-toolchain` file.

- Fix `edgelet-kube` tests to use single-thread tokio runtime, because
  the multi-threaded runtime cannot be used in parallel correctly.

- Make some buffers used with `sprintf` larger because newer gcc warns that
  they might not be large enough for the string written to them.
  • Loading branch information
arsing committed Apr 20, 2021
1 parent 3ac81ec commit deb2753
Show file tree
Hide file tree
Showing 34 changed files with 1,686 additions and 1,749 deletions.
2 changes: 1 addition & 1 deletion edgelet/edgelet-kube/src/module/authentication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ mod tests {
use hyper::{header, Body, Method, Request, Response, StatusCode};
use maplit::btreemap;
use serde_json::json;
use tokio::runtime::Runtime;
use tokio::runtime::current_thread::Runtime;
use typed_headers::{mime, ContentLength, ContentType, HeaderMapExt};

use edgelet_core::{AuthId, Authenticator};
Expand Down
2 changes: 1 addition & 1 deletion edgelet/edgelet-kube/src/module/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ mod tests {
use hyper::{Body, Method, Request, StatusCode};
use maplit::btreemap;
use serde_json::json;
use tokio::runtime::Runtime;
use tokio::runtime::current_thread::Runtime;

use docker::models::{AuthConfig, ContainerCreateBody, HostConfig, Mount};
use edgelet_core::{ImagePullPolicy, ModuleSpec, RuntimeOperation};
Expand Down
2 changes: 1 addition & 1 deletion edgelet/edgelet-kube/src/module/trust_bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ mod tests {
use hyper::{Body, Error as HyperError, Method, Request, Response, StatusCode};
use maplit::btreemap;
use serde_json::json;
use tokio::runtime::Runtime;
use tokio::runtime::current_thread::Runtime;

use edgelet_test_utils::cert::TestCert;
use edgelet_test_utils::crypto::TestHsm;
Expand Down
2 changes: 1 addition & 1 deletion edgelet/edgelet-kube/src/registry/pull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ mod tests {
use hyper::{Body, Method, Request, StatusCode};
use maplit::btreemap;
use serde_json::json;
use tokio::runtime::Runtime;
use tokio::runtime::current_thread::Runtime;

use docker::models::{AuthConfig, ContainerCreateBody};
use edgelet_docker::DockerConfig;
Expand Down
2 changes: 1 addition & 1 deletion edgelet/edgelet-kube/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ mod tests {
use hyper::{Body, Method, Request, StatusCode};
use maplit::btreemap;
use serde_json::json;
use tokio::runtime::Runtime;
use tokio::runtime::current_thread::Runtime;

use edgelet_core::ModuleRuntime;
use edgelet_test_utils::routes;
Expand Down
2 changes: 1 addition & 1 deletion edgelet/edgelet-utils/src/ser_de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ where
// parameters.
struct OptionalValueVisitor<K, V> {
marker: PhantomData<fn() -> (K, V)>,
};
}

impl<K, V> OptionalValueVisitor<K, V> {
fn new() -> Self {
Expand Down
2 changes: 1 addition & 1 deletion edgelet/hsm-sys/azure-iot-hsm-c/deps/c-shared
Submodule c-shared updated 311 files
20 changes: 10 additions & 10 deletions edgelet/hsm-sys/azure-iot-hsm-c/src/edge_hsm_client_x509.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ HSM_CLIENT_HANDLE edge_x598_hsm_create()
}
else
{
const HSM_CLIENT_CRYPTO_INTERFACE* interface = hsm_client_crypto_interface();
if (interface == NULL)
const HSM_CLIENT_CRYPTO_INTERFACE* iface = hsm_client_crypto_interface();
if (iface == NULL)
{
LOG_ERROR("hsm_client_crypto_interface returned NULL");
result = NULL;
}
else
{
result = interface->hsm_client_crypto_create();
result = iface->hsm_client_crypto_create();
if (result != NULL)
{
g_ref_cnt++;
Expand Down Expand Up @@ -124,14 +124,14 @@ void edge_x509_hsm_destroy(HSM_CLIENT_HANDLE hsm_handle)
}
else
{
const HSM_CLIENT_CRYPTO_INTERFACE* interface = hsm_client_crypto_interface();
if (interface == NULL)
const HSM_CLIENT_CRYPTO_INTERFACE* iface = hsm_client_crypto_interface();
if (iface == NULL)
{
LOG_ERROR("hsm_client_crypto_interface returned NULL");
}
else
{
interface->hsm_client_crypto_destroy(hsm_handle);
iface->hsm_client_crypto_destroy(hsm_handle);
}
g_ref_cnt--;
}
Expand Down Expand Up @@ -173,9 +173,9 @@ static int get_device_id_cert_env_vars(char **device_cert_file_path, char **devi

static CERT_INFO_HANDLE get_device_id_cert_if_exists(HSM_CLIENT_HANDLE hsm_handle)
{
const HSM_CLIENT_CRYPTO_INTERFACE* interface = hsm_client_crypto_interface();
const HSM_CLIENT_CRYPTO_INTERFACE* iface = hsm_client_crypto_interface();

CERT_INFO_HANDLE result = interface->hsm_client_crypto_get_certificate(hsm_handle,
CERT_INFO_HANDLE result = iface->hsm_client_crypto_get_certificate(hsm_handle,
EDGE_DEVICE_ALIAS);
if (result == NULL)
{
Expand Down Expand Up @@ -273,8 +273,8 @@ static int edge_x509_sign_with_private_key
}
else
{
const HSM_CLIENT_CRYPTO_INTERFACE* interface = hsm_client_crypto_interface();
result = interface->hsm_client_crypto_sign_with_private_key(hsm_handle,
const HSM_CLIENT_CRYPTO_INTERFACE* iface = hsm_client_crypto_interface();
result = iface->hsm_client_crypto_sign_with_private_key(hsm_handle,
EDGE_DEVICE_ALIAS,
data,
data_size,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
//#############################################################################

static TEST_MUTEX_HANDLE g_testByTest;
static TEST_MUTEX_HANDLE g_dllByDll;

MU_DEFINE_ENUM_STRINGS(UMOCK_C_ERROR_CODE, UMOCK_C_ERROR_CODE_VALUES)

Expand Down Expand Up @@ -165,7 +164,6 @@ BEGIN_TEST_SUITE(certificate_info_func_tests)

TEST_SUITE_INITIALIZE(TestClassInitialize)
{
TEST_INITIALIZE_MEMORY_DEBUG(g_dllByDll);
g_testByTest = TEST_MUTEX_CREATE();
ASSERT_IS_NOT_NULL(g_testByTest);
umock_c_init(test_hook_on_umock_c_error);
Expand All @@ -174,7 +172,6 @@ BEGIN_TEST_SUITE(certificate_info_func_tests)
TEST_SUITE_CLEANUP(TestClassCleanup)
{
TEST_MUTEX_DESTROY(g_testByTest);
TEST_DEINITIALIZE_MEMORY_DEBUG(g_dllByDll);
}

TEST_FUNCTION_INITIALIZE(TestMethodInitialize)
Expand Down Expand Up @@ -203,8 +200,8 @@ BEGIN_TEST_SUITE(certificate_info_func_tests)
//assert
ASSERT_IS_NOT_NULL(cert_handle);
ASSERT_IS_NULL(pk);
ASSERT_ARE_EQUAL(size_t, 0, pk_size, "Line:" TOSTRING(__LINE__));
ASSERT_ARE_EQUAL(int, PRIVATE_KEY_UNKNOWN, pk_type, "Line:" TOSTRING(__LINE__));
ASSERT_ARE_EQUAL(size_t, 0, pk_size, "Line:" MU_TOSTRING(__LINE__));
ASSERT_ARE_EQUAL(int, PRIVATE_KEY_UNKNOWN, pk_type, "Line:" MU_TOSTRING(__LINE__));

//cleanup
certificate_info_destroy(cert_handle);
Expand All @@ -222,10 +219,10 @@ BEGIN_TEST_SUITE(certificate_info_func_tests)

//assert
ASSERT_IS_NOT_NULL(cert_handle);
ASSERT_ARE_EQUAL(size_t, TEST_PRIVATE_KEY_LEN, pk_size, "Line:" TOSTRING(__LINE__));
ASSERT_ARE_EQUAL(size_t, TEST_PRIVATE_KEY_LEN, pk_size, "Line:" MU_TOSTRING(__LINE__));
int cmp = memcmp(pk, TEST_PRIVATE_KEY, TEST_PRIVATE_KEY_LEN);
ASSERT_ARE_EQUAL(int, 0, cmp, "Line:" TOSTRING(__LINE__));
ASSERT_ARE_EQUAL(int, PRIVATE_KEY_PAYLOAD, pk_type, "Line:" TOSTRING(__LINE__));
ASSERT_ARE_EQUAL(int, 0, cmp, "Line:" MU_TOSTRING(__LINE__));
ASSERT_ARE_EQUAL(int, PRIVATE_KEY_PAYLOAD, pk_type, "Line:" MU_TOSTRING(__LINE__));

//cleanup
certificate_info_destroy(cert_handle);
Expand All @@ -243,10 +240,10 @@ BEGIN_TEST_SUITE(certificate_info_func_tests)

//assert
ASSERT_IS_NOT_NULL(cert_handle);
ASSERT_ARE_EQUAL(size_t, TEST_PRIVATE_KEY_LEN, pk_size, "Line:" TOSTRING(__LINE__));
ASSERT_ARE_EQUAL(size_t, TEST_PRIVATE_KEY_LEN, pk_size, "Line:" MU_TOSTRING(__LINE__));
int cmp = memcmp(pk, TEST_PRIVATE_KEY, TEST_PRIVATE_KEY_LEN);
ASSERT_ARE_EQUAL(int, 0, cmp, "Line:" TOSTRING(__LINE__));
ASSERT_ARE_EQUAL(int, PRIVATE_KEY_REFERENCE, pk_type, "Line:" TOSTRING(__LINE__));
ASSERT_ARE_EQUAL(int, 0, cmp, "Line:" MU_TOSTRING(__LINE__));
ASSERT_ARE_EQUAL(int, PRIVATE_KEY_REFERENCE, pk_type, "Line:" MU_TOSTRING(__LINE__));

//cleanup
certificate_info_destroy(cert_handle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ extern time_t get_utc_time_from_asn_string(const unsigned char *time_value, size
// Test defines and data
//#############################################################################
static TEST_MUTEX_HANDLE g_testByTest;
static TEST_MUTEX_HANDLE g_dllByDll;

MU_DEFINE_ENUM_STRINGS(UMOCK_C_ERROR_CODE, UMOCK_C_ERROR_CODE_VALUES)

Expand Down Expand Up @@ -335,57 +334,57 @@ static void test_helper_parse_cert_common_callstack
umock_c_reset_all_calls();

EXPECTED_CALL(gballoc_malloc(IGNORED_NUM_ARG));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" TOSTRING(__LINE__));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" MU_TOSTRING(__LINE__));
failed_function_list[i++] = 1;

STRICT_EXPECTED_CALL(gballoc_malloc(certificate_size));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" TOSTRING(__LINE__));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" MU_TOSTRING(__LINE__));
failed_function_list[i++] = 1;

// *************** Load and parse certificate **************
EXPECTED_CALL(BIO_s_mem());
ASSERT_IS_TRUE((i < failed_function_size), "Line:" TOSTRING(__LINE__));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" MU_TOSTRING(__LINE__));
i++;

STRICT_EXPECTED_CALL(BIO_new(TEST_BIO_METHOD));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" TOSTRING(__LINE__));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" MU_TOSTRING(__LINE__));
failed_function_list[i++] = 1;

ASSERT_IS_FALSE(certificate_len > INT_MAX, "Line:" TOSTRING(__LINE__));
ASSERT_IS_FALSE(certificate_len > INT_MAX, "Line:" MU_TOSTRING(__LINE__));
STRICT_EXPECTED_CALL(BIO_write(TEST_BIO, IGNORED_PTR_ARG, (int)certificate_len));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" TOSTRING(__LINE__));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" MU_TOSTRING(__LINE__));
failed_function_list[i++] = 1;

STRICT_EXPECTED_CALL(PEM_read_bio_X509(TEST_BIO, NULL, NULL, NULL));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" TOSTRING(__LINE__));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" MU_TOSTRING(__LINE__));
failed_function_list[i++] = 1;

STRICT_EXPECTED_CALL(BIO_free_all(TEST_BIO));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" TOSTRING(__LINE__));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" MU_TOSTRING(__LINE__));
i++;
// *************************************************

// *************** Parse validity timestamps **************
STRICT_EXPECTED_CALL(mocked_X509_get_notAfter(TEST_X509));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" TOSTRING(__LINE__));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" MU_TOSTRING(__LINE__));
i++;

STRICT_EXPECTED_CALL(mocked_X509_get_notBefore(TEST_X509));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" TOSTRING(__LINE__));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" MU_TOSTRING(__LINE__));
i++;
// *************************************************

// *************** Parse common name **************
STRICT_EXPECTED_CALL(X509_get_subject_name(TEST_X509));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" TOSTRING(__LINE__));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" MU_TOSTRING(__LINE__));
failed_function_list[i++] = 1;

STRICT_EXPECTED_CALL(gballoc_malloc(MAX_COMMON_NAME_SIZE));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" TOSTRING(__LINE__));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" MU_TOSTRING(__LINE__));
failed_function_list[i++] = 1;

// conditionally fail since certificates may not have a CN field
ASSERT_IS_TRUE((i < failed_function_size), "Line:" TOSTRING(__LINE__));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" MU_TOSTRING(__LINE__));
if (overrride && overrride->fail_common_name_lookup)
{
STRICT_EXPECTED_CALL(X509_NAME_get_text_by_NID(TEST_X509_SUBJECT_NAME, NID_commonName, IGNORED_PTR_ARG, MAX_COMMON_NAME_SIZE)).SetReturn(-1);
Expand All @@ -398,21 +397,21 @@ static void test_helper_parse_cert_common_callstack
}

STRICT_EXPECTED_CALL(X509_free(TEST_X509));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" TOSTRING(__LINE__));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" MU_TOSTRING(__LINE__));
i++;
// *************************************************

// *************** Finalize certificate info object **************
// allocator for the first certificate which includes /r/n ending
STRICT_EXPECTED_CALL(gballoc_malloc(certificate_size));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" TOSTRING(__LINE__));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" MU_TOSTRING(__LINE__));
failed_function_list[i++] = 1;

// allocator for the private key
if (private_key_set)
{
STRICT_EXPECTED_CALL(gballoc_malloc(TEST_PRIVATE_KEY_LEN));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" TOSTRING(__LINE__));
ASSERT_IS_TRUE((i < failed_function_size), "Line:" MU_TOSTRING(__LINE__));
failed_function_list[i++] = 1;
}
// *************************************************
Expand All @@ -437,7 +436,6 @@ BEGIN_TEST_SUITE(certificate_info_ut)

TEST_SUITE_INITIALIZE(suite_init)
{
TEST_INITIALIZE_MEMORY_DEBUG(g_dllByDll);
g_testByTest = TEST_MUTEX_CREATE();
ASSERT_IS_NOT_NULL(g_testByTest);

Expand Down Expand Up @@ -478,7 +476,6 @@ BEGIN_TEST_SUITE(certificate_info_ut)
umock_c_deinit();

TEST_MUTEX_DESTROY(g_testByTest);
TEST_DEINITIALIZE_MEMORY_DEBUG(g_dllByDll);
}

TEST_FUNCTION_INITIALIZE(method_init)
Expand Down

0 comments on commit deb2753

Please sign in to comment.