Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Add CBMC OTA proof for prvRequestJob_MQTT #1965

Merged
merged 2 commits into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions tools/cbmc/proofs/OTA/prvRequestJob_MQTT/Makefile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"ENTRY": "prvRequestJob_MQTT",

"CBMCFLAGS":
[
"--unwind 1"
],

"OBJS":
[
"$(ENTRY)_harness.goto",
"$(FREERTOS)/libraries/freertos_plus/aws/ota/src/mqtt/aws_iot_ota_mqtt.goto",
"$(FREERTOS)/libraries/freertos_plus/aws/ota/src/aws_iot_ota_agent.goto",
"$(FREERTOS)/libraries/freertos_plus/aws/ota/src/aws_iot_ota_interface.goto",
"$(FREERTOS)/libraries/3rdparty/mbedtls/library/base64.goto"
],
"DEF":
[
"_CONSOLE",
"_CRT_SECURE_NO_WARNINGS",
"__free_rtos__"
],

"INC":
[
"$(FREERTOS)/libraries/freertos_plus/aws/ota/src",
"$(FREERTOS)/libraries/3rdparty/mbedtls/include",
"$(FREERTOS)/libraries/freertos_plus/aws/ota/include",
"$(FREERTOS)/libraries/freertos_plus/standard/crypto/include",
"$(FREERTOS)/freertos_kernel/include",
"$(FREERTOS)/freertos_kernel/portable/MSVC-MingW",
"$(FREERTOS)/vendors/pc/boards/windows/aws_demos/config_files",
"$(FREERTOS)/vendors/pc/boards/windows/aws_demos/application_code",
"$(FREERTOS)/demos/include",
"$(FREERTOS)/libraries/3rdparty/tracealyzer_recorder/Include",
"$(FREERTOS)/libraries/c_sdk/standard/mqtt/include",
"$(FREERTOS)/libraries/c_sdk/standard/common/include",
"$(FREERTOS)/libraries/abstractions/platform/include",
"$(FREERTOS)/libraries/abstractions/platform/freertos/include",
"$(FREERTOS)/libraries/abstractions/secure_sockets/include",
"$(FREERTOS)/libraries/c_sdk/standard/common/include/private",
"$(FREERTOS)/libraries/3rdparty/tinycbor",
"$(FREERTOS)/libraries/c_sdk/standard/https/include",
"$(FREERTOS)/libraries/3rdparty/jsmn",
"$(FREERTOS)/libraries/c_sdk/standard/mqtt/include/types"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* Standard includes. */
#include <stdio.h>

/* prvRequestJob_Mqtt includes. */
#include "aws_iot_ota_agent.h" /* OTA_Err_t */
#include "aws_iot_ota_agent_internal.h" /* OTA_AgentContext_t */
#include "iot_mqtt_types.h" /* IotMqttError_t */

IotMqttError_t IotMqtt_TimedPublish(IotMqttConnection_t mqttConnection, const IotMqttPublishInfo_t *pPublishInfo, uint32_t flags, uint32_t timeoutMs)
{
/* We may want to havoc parts of mqttConnection */
IotMqttError_t unconstrainedIotMqttError;
return unconstrainedIotMqttError;
}

IotMqttError_t IotMqtt_TimedSubscribe( IotMqttConnection_t mqttConnection,
const IotMqttSubscription_t * pSubscriptionList,
size_t subscriptionCount,
uint32_t flags,
uint32_t timeoutMs )
{
/* We may want to havoc parts of mqttConnection */
IotMqttError_t unconstrainedIotMqttError;
return unconstrainedIotMqttError;
}

/* This is the function signature for the function under test */
OTA_Err_t prvRequestJob_Mqtt( OTA_AgentContext_t * pxAgentCtx );

void harness() {
OTA_AgentContext_t pxAgentCtx;
OTA_ConnectionContext_t connContext;
pxAgentCtx.pvConnectionContext = nondet_bool() ? &connContext:NULL;
__CPROVER_assume(pxAgentCtx.pvConnectionContext != NULL);

prvRequestJob_Mqtt(&pxAgentCtx);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything that can be asserted about pxAgentCtx after this operation finishes?

Copy link
Contributor Author

@yanjos-dev yanjos-dev May 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pxAgentCtx is being operated on so it's possible that we could do some validation on what a "correct" pxAgentCtx would look like after the function has been called. Although this would be more along the lines of functional testing and is out of scope for this change.

}