Skip to content

Commit

Permalink
Add mbedTLS e2e tests (#2168)
Browse files Browse the repository at this point in the history
  • Loading branch information
danewalton authored Nov 24, 2021
1 parent 6c4899d commit 32942ab
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 35 deletions.
35 changes: 35 additions & 0 deletions build/.vsts-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,41 @@ jobs:
- script: sudo rm -rf $(Agent.BuildDirectory)/*
displayName: 'Cleanup'
condition: always()
- job: mbedtls
variables:
_PREVIEW_VSTS_DOCKER_IMAGE: "aziotbld/linux-c-ubuntu-mbed"
pool:
name: 'sdk-c--ubuntu-18'
displayName: 'mbedTLS'
steps:
- script: |
LD_LIBRARY_PATH=/usr/local/lib
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/my_library/
sudo -E bash jenkins/linux_mbedtls.sh
displayName: 'Build'
- script: |
cd cmake && sudo -E ../build_all/linux/run_tests.sh
env:
IOTHUB_CONNECTION_STRING: $(IOTHUB-CONNECTION-STRING)
IOTHUB_EVENTHUB_CONNECTION_STRING: $(IOTHUB-EVENTHUB-CONNECTION-STRING)
IOTHUB_E2E_X509_CERT_BASE64: $(IOTHUB-E2E-X509-CERT-BASE64)
IOTHUB_E2E_X509_PRIVATE_KEY_BASE64: $(IOTHUB-E2E-X509-PRIVATE-KEY-BASE64)
IOTHUB_E2E_X509_THUMBPRINT: $(IOTHUB-E2E-X509-THUMBPRINT)
IOTHUB_POLICY_KEY: $(IOTHUB-POLICY-KEY)
STORAGE_ACCOUNT_CONNECTION_STRING: $(STORAGE-ACCOUNT-CONNECTION-STRING)
IOT_DPS_CONNECTION_STRING: $(IOT-DPS-CONNECTION-STRING)
IOT_DPS_ID_SCOPE: $(IOT-DPS-ID-SCOPE)
IOTHUB_CA_ROOT_CERT: $(IOTHUB-CA-ROOT-CERT)
IOTHUB_CA_ROOT_CERT_KEY: $(IOTHUB-CA-ROOT-CERT-KEY)
IOT_DPS_GLOBAL_ENDPOINT: $(IOT-DPS-GLOBAL-ENDPOINT)
IOTHUB_DEVICE_CONN_STRING_INVALIDCERT: $(IOTHUB-DEVICE-CONN-STRING-INVALIDCERT)
IOTHUB_CONN_STRING_INVALIDCERT: $(IOTHUB-CONN-STRING-INVALIDCERT)
DPS_GLOBALDEVICEENDPOINT_INVALIDCERT: $(DPS-GLOBALDEVICEENDPOINT-INVALIDCERT)
PROVISIONING_CONNECTION_STRING_INVALIDCERT: $(PROVISIONING-CONNECTION-STRING-INVALIDCERT)
displayName: "Run Tests"
- script: sudo rm -rf $(Agent.BuildDirectory)/*
displayName: 'Cleanup'
condition: always()
- job: cares
variables:
_PREVIEW_VSTS_DOCKER_IMAGE: "aziotbld/linux-c-ubuntu-c-ares"
Expand Down
2 changes: 1 addition & 1 deletion iothub_client/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ add_unittest_directory(message_queue_ut)
add_unittest_directory(iothubmoduleclient_ll_ut)
add_unittest_directory(iothubmoduleclient_ut)

if(${use_http} AND NOT (${use_wolfssl} OR ${use_bearssl}))
if(${use_http} AND NOT (${use_wolfssl} OR ${use_bearssl} OR ${use_mbedtls}))
add_unittest_directory(iothubtransporthttp_ut)
add_e2etest_directory(iothubclient_http_e2e)
endif()
Expand Down
64 changes: 32 additions & 32 deletions iothub_service_client/src/iothub_messaging_ll.c
Original file line number Diff line number Diff line change
Expand Up @@ -1368,54 +1368,54 @@ IOTHUB_MESSAGING_RESULT IoTHubMessaging_LL_Send(IOTHUB_MESSAGING_HANDLE messagin
LogError("Could not create a message.");
result = IOTHUB_MESSAGING_ERROR;
}
else if ((to_amqp_value = amqpvalue_create_string(deviceDestinationString)) == NULL)
{
LogError("Could not create properties for message - amqpvalue_create_string");
message_destroy(amqpMessage);
result = IOTHUB_MESSAGING_ERROR;
}
else
{
BINARY_DATA binary_data;

binary_data.bytes = messageContent;
binary_data.length = messageContentSize;

if (message_add_body_amqp_data(amqpMessage, binary_data) != 0)
{
LogError("Failed setting the body of the uAMQP message.");
result = IOTHUB_MESSAGING_ERROR;
}
else if (addPropertiesToAMQPMessage(message, amqpMessage, to_amqp_value) != 0)
if ((to_amqp_value = amqpvalue_create_string(deviceDestinationString)) == NULL)
{
message_destroy(amqpMessage);
LogError("Failed setting properties of the uAMQP message.");
result = IOTHUB_MESSAGING_ERROR;
}
else if (addApplicationPropertiesToAMQPMessage(message, amqpMessage) != 0)
{
message_destroy(amqpMessage);
LogError("Failed setting application properties of the uAMQP message.");
LogError("Could not create properties for message - amqpvalue_create_string");
result = IOTHUB_MESSAGING_ERROR;
}
else
{
messagingHandle->callback_data->sendCompleteCallback = sendCompleteCallback;
messagingHandle->callback_data->sendUserContext = userContextCallback;
BINARY_DATA binary_data;

binary_data.bytes = messageContent;
binary_data.length = messageContentSize;

if (messagesender_send_async(messagingHandle->message_sender, amqpMessage, IoTHubMessaging_LL_SendMessageComplete, messagingHandle, 0) == NULL)
if (message_add_body_amqp_data(amqpMessage, binary_data) != 0)
{
LogError("Could not set outgoing window.");
message_destroy(amqpMessage);

LogError("Failed setting the body of the uAMQP message.");
result = IOTHUB_MESSAGING_ERROR;
}
else if (addPropertiesToAMQPMessage(message, amqpMessage, to_amqp_value) != 0)
{
LogError("Failed setting properties of the uAMQP message.");
result = IOTHUB_MESSAGING_ERROR;
}
else if (addApplicationPropertiesToAMQPMessage(message, amqpMessage) != 0)
{
LogError("Failed setting application properties of the uAMQP message.");
result = IOTHUB_MESSAGING_ERROR;
}
else
{
result = IOTHUB_MESSAGING_OK;
messagingHandle->callback_data->sendCompleteCallback = sendCompleteCallback;
messagingHandle->callback_data->sendUserContext = userContextCallback;

if (messagesender_send_async(messagingHandle->message_sender, amqpMessage, IoTHubMessaging_LL_SendMessageComplete, messagingHandle, 0) == NULL)
{
LogError("Could not set outgoing window.");
result = IOTHUB_MESSAGING_ERROR;
}
else
{
result = IOTHUB_MESSAGING_OK;
}
}
amqpvalue_destroy(to_amqp_value);
}
message_destroy(amqpMessage);
amqpvalue_destroy(to_amqp_value);
}
}
free(deviceDestinationString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1279,10 +1279,10 @@ BEGIN_TEST_SUITE(iothub_messaging_ll_ut)
STRICT_EXPECTED_CALL(messagesender_send_async(IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_PTR_ARG, IGNORED_NUM_ARG))
.IgnoreAllArguments();

STRICT_EXPECTED_CALL(message_destroy(IGNORED_PTR_ARG))
.IgnoreAllArguments();
STRICT_EXPECTED_CALL(amqpvalue_destroy(IGNORED_PTR_ARG))
.IgnoreAllArguments();
STRICT_EXPECTED_CALL(message_destroy(IGNORED_PTR_ARG))
.IgnoreAllArguments();

STRICT_EXPECTED_CALL(gballoc_free(IGNORED_PTR_ARG))
.IgnoreArgument(1);
Expand Down
29 changes: 29 additions & 0 deletions jenkins/linux_mbedtls.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.

set -x # Set trace on
set -o errexit # Exit if command failed
set -o nounset # Exit if variable not set
set -o pipefail # Exit if pipe failed

# Print version
cat /etc/*release | grep VERSION*
gcc --version
curl --version

build_root=$(cd "$(dirname "$0")/.." && pwd)
cd $build_root

build_folder=$build_root"/cmake"

# Set the default cores
CORES=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu)

rm -r -f $build_folder
mkdir -p $build_folder
pushd $build_folder
cmake $build_root -Duse_mbedtls=ON -Duse_openssl=OFF -Ddont_use_uploadtoblob=ON -Drun_e2e_tests=ON
make --jobs=$CORES

popd

0 comments on commit 32942ab

Please sign in to comment.