aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Scull <ascull@google.com>2021-07-16 12:43:31 +0000
committerCQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>2021-07-17 01:23:56 +0000
commitfa89d260274877fe2d8158b68571efe1ea203ceb (patch)
treeafb55fb7b9042d4634c54725c9d12de4b5ca4e4b
parent2cbce15de4a291058cfd9d2ffe038bbbbe1f2aff (diff)
downloadopen-dice-fa89d260274877fe2d8158b68571efe1ea203ceb.tar.gz
Support testing with Googletest and on 32-bit
Building the tests with DICE_USE_GTEST will use Googletest rather than the Pigweed Test framework in cases where the latter is not available. The test code is compatible with either. Also choose a different test value that will work on both 64-bit and 32-bit targets. Change-Id: If12515d020446838780b4b7c18eece04616daab5 Reviewed-on: https://pigweed-review.googlesource.com/c/open-dice/+/53500 Reviewed-by: Darren Krahn <dkrahn@google.com> Commit-Queue: Andrew Scull <ascull@google.com>
-rw-r--r--include/dice/test_framework.h24
-rw-r--r--src/boringssl_ops_test.cc2
-rw-r--r--src/cbor_cert_op_test.cc2
-rw-r--r--src/cbor_writer_test.cc4
-rw-r--r--src/dice_test.cc2
-rw-r--r--src/mbedtls_ops_test.cc2
-rw-r--r--src/template_cbor_cert_op_test.cc2
-rw-r--r--src/template_cert_op_test.cc2
8 files changed, 32 insertions, 8 deletions
diff --git a/include/dice/test_framework.h b/include/dice/test_framework.h
new file mode 100644
index 0000000..16e1c90
--- /dev/null
+++ b/include/dice/test_framework.h
@@ -0,0 +1,24 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+#ifndef DICE_TEST_FRAMEWORK_H_
+#define DICE_TEST_FRAMEWORK_H_
+
+#ifdef DICE_USE_GTEST
+#include "gtest/gtest.h"
+#else
+#include "pw_unit_test/framework.h"
+#endif
+
+#endif // DICE_TEST_FRAMEWORK_H_
diff --git a/src/boringssl_ops_test.cc b/src/boringssl_ops_test.cc
index 9f3fe95..9dc94ba 100644
--- a/src/boringssl_ops_test.cc
+++ b/src/boringssl_ops_test.cc
@@ -22,10 +22,10 @@
#include "dice/dice.h"
#include "dice/known_test_values.h"
+#include "dice/test_framework.h"
#include "dice/test_utils.h"
#include "dice/utils.h"
#include "pw_string/format.h"
-#include "pw_unit_test/framework.h"
namespace {
diff --git a/src/cbor_cert_op_test.cc b/src/cbor_cert_op_test.cc
index 84cee6a..e424509 100644
--- a/src/cbor_cert_op_test.cc
+++ b/src/cbor_cert_op_test.cc
@@ -23,10 +23,10 @@
#include "dice/boringssl_ops.h"
#include "dice/dice.h"
#include "dice/known_test_values.h"
+#include "dice/test_framework.h"
#include "dice/test_utils.h"
#include "dice/utils.h"
#include "pw_string/format.h"
-#include "pw_unit_test/framework.h"
namespace {
diff --git a/src/cbor_writer_test.cc b/src/cbor_writer_test.cc
index a92b1fc..f664052 100644
--- a/src/cbor_writer_test.cc
+++ b/src/cbor_writer_test.cc
@@ -14,7 +14,7 @@
#include "dice/cbor_writer.h"
-#include "pw_unit_test/framework.h"
+#include "dice/test_framework.h"
namespace {
@@ -401,7 +401,7 @@ TEST(CborWriterTest, MeasurementOffsetOverflow) {
EXPECT_TRUE(CborOutOverflowed(&out));
CborOutInit(nullptr, 0, &out);
CborWriteBstr(SIZE_MAX - 10, nullptr, &out);
- CborWriteArray(/*num_elements=*/8368257314, &out);
+ CborWriteArray(/*num_elements=*/4073290018, &out);
EXPECT_TRUE(CborOutOverflowed(&out));
CborOutInit(nullptr, 0, &out);
CborWriteBstr(SIZE_MAX - 10, nullptr, &out);
diff --git a/src/dice_test.cc b/src/dice_test.cc
index ff4edf0..802896d 100644
--- a/src/dice_test.cc
+++ b/src/dice_test.cc
@@ -15,12 +15,12 @@
#include "dice/dice.h"
#include "dice/known_test_values.h"
+#include "dice/test_framework.h"
#include "dice/utils.h"
#include "openssl/crypto.h"
#include "openssl/digest.h"
#include "openssl/hkdf.h"
#include "openssl/sha.h"
-#include "pw_unit_test/framework.h"
namespace {
diff --git a/src/mbedtls_ops_test.cc b/src/mbedtls_ops_test.cc
index 1b64922..9b8c618 100644
--- a/src/mbedtls_ops_test.cc
+++ b/src/mbedtls_ops_test.cc
@@ -22,10 +22,10 @@
#include "dice/dice.h"
#include "dice/known_test_values.h"
+#include "dice/test_framework.h"
#include "dice/test_utils.h"
#include "dice/utils.h"
#include "pw_string/format.h"
-#include "pw_unit_test/framework.h"
namespace {
diff --git a/src/template_cbor_cert_op_test.cc b/src/template_cbor_cert_op_test.cc
index d41535c..d783950 100644
--- a/src/template_cbor_cert_op_test.cc
+++ b/src/template_cbor_cert_op_test.cc
@@ -23,10 +23,10 @@
#include "dice/boringssl_ops.h"
#include "dice/dice.h"
#include "dice/known_test_values.h"
+#include "dice/test_framework.h"
#include "dice/test_utils.h"
#include "dice/utils.h"
#include "pw_string/format.h"
-#include "pw_unit_test/framework.h"
namespace {
diff --git a/src/template_cert_op_test.cc b/src/template_cert_op_test.cc
index 8410438..ed3c03e 100644
--- a/src/template_cert_op_test.cc
+++ b/src/template_cert_op_test.cc
@@ -23,10 +23,10 @@
#include "dice/boringssl_ops.h"
#include "dice/dice.h"
#include "dice/known_test_values.h"
+#include "dice/test_framework.h"
#include "dice/test_utils.h"
#include "dice/utils.h"
#include "pw_string/format.h"
-#include "pw_unit_test/framework.h"
namespace {