Add test_runner service
This is a new service with client and provider that can be
used for running tests in a secure processing environment
and retrieving the results. The test_runner provider allows
for arbitrary test farmework backends. The goal is to
have a cpputest backend. In this commit, a mock backend
is included for testing the service itself. The service
has its own access protocol defined under the protocols
top-level directory.
Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: If4e965c110763bd805abbdcb87e7e03cd76248b2
diff --git a/components/common/tlv/test/tlv_tests.cpp b/components/common/tlv/test/tlv_tests.cpp
index 661a810..5d8a50d 100644
--- a/components/common/tlv/test/tlv_tests.cpp
+++ b/components/common/tlv/test/tlv_tests.cpp
@@ -76,6 +76,26 @@
UNSIGNED_LONGS_EQUAL(1, decoded_record.length);
}
+TEST(TlvTests, findAndDecodeMissingOptional)
+{
+ struct tlv_const_iterator iter;
+ struct tlv_record decoded_record;
+
+ /*
+ * Checks finding a missing record is correctly
+ * identified as not present but that the following
+ * record is found.
+ */
+ const uint8_t encoded_records[] = {
+ 0x00, 0x07, 0x00, 0x02, 0x77, 0x77
+ };
+
+ tlv_const_iterator_begin(&iter, encoded_records, sizeof(encoded_records));
+ CHECK(!tlv_find_decode(&iter, 0x0001, &decoded_record));
+ CHECK(tlv_find_decode(&iter, 0x0007, &decoded_record));
+ CHECK_EQUAL(2, decoded_record.length);
+}
+
TEST(TlvTests, decodeBadRecords)
{
struct tlv_const_iterator iter;
diff --git a/components/common/tlv/tlv.c b/components/common/tlv/tlv.c
index 1308832..80c1edb 100644
--- a/components/common/tlv/tlv.c
+++ b/components/common/tlv/tlv.c
@@ -82,10 +82,13 @@
bool tlv_find_decode(struct tlv_const_iterator *iter, uint16_t tag, struct tlv_record *output)
{
- while (tlv_decode(iter, output)) {
+ struct tlv_const_iterator temp_iter = *iter;
+
+ while (tlv_decode(&temp_iter, output)) {
if (output->tag == tag) {
- /* Found a record */
+ /* Found a record - update input iterator to next record */
+ *iter = temp_iter;
return true;
}
else if (output->tag > tag) {