diff options
author | Kevin Jacobs <kjacobs@mozilla.com> | 2019-05-02 18:29:05 +0000 |
---|---|---|
committer | Kevin Jacobs <kjacobs@mozilla.com> | 2019-05-02 18:29:05 +0000 |
commit | 7555cf82c524483db1d96da41f58b3e100edfba8 (patch) | |
tree | 5f03eb6a29dce4b471d448cbf30876ee9efb7ac4 | |
parent | 91554ca5c78f69a567e4fa119bd173f7a1f1150e (diff) | |
download | nss-hg-7555cf82c524483db1d96da41f58b3e100edfba8.tar.gz |
Bug 1548398 - Add freebl_gtest to nss.gyp, fix freebl_gtest cross-compilation. r=jcj
Differential Revision: https://phabricator.services.mozilla.com/D29581
-rw-r--r-- | gtests/freebl_gtest/mpi_unittest.cc | 14 | ||||
-rw-r--r-- | gtests/freebl_gtest/rsa_unittest.cc | 1 | ||||
-rw-r--r-- | nss.gyp | 1 |
3 files changed, 10 insertions, 6 deletions
diff --git a/gtests/freebl_gtest/mpi_unittest.cc b/gtests/freebl_gtest/mpi_unittest.cc index 2ccb8c351..b0944975e 100644 --- a/gtests/freebl_gtest/mpi_unittest.cc +++ b/gtests/freebl_gtest/mpi_unittest.cc @@ -6,6 +6,7 @@ #include <stdint.h> #include <string.h> +#include <memory> #ifdef __MACH__ #include <mach/clock.h> @@ -27,7 +28,7 @@ void gettime(struct timespec* tp) { tp->tv_sec = mts.tv_sec; tp->tv_nsec = mts.tv_nsec; #else - clock_gettime(CLOCK_MONOTONIC, tp); + ASSERT_NE(0, timespec_get(tp, TIME_UTC)); #endif } @@ -84,8 +85,9 @@ class MPITest : public ::testing::Test { mp_int a; ASSERT_EQ(MP_OKAY, mp_init(&a)); ASSERT_EQ(MP_OKAY, mp_read_unsigned_octets(&a, ref.data(), ref.size())); - uint8_t buf[len]; - ASSERT_EQ(MP_OKAY, mp_to_fixlen_octets(&a, buf, len)); + std::unique_ptr<uint8_t[]> buf(new uint8_t[len]); + ASSERT_NE(buf, nullptr); + ASSERT_EQ(MP_OKAY, mp_to_fixlen_octets(&a, buf.get(), len)); size_t compare; if (len > ref.size()) { for (size_t i = 0; i < len - ref.size(); ++i) { @@ -96,9 +98,9 @@ class MPITest : public ::testing::Test { compare = len; } dump("value", ref.data(), ref.size()); - dump("output", buf, len); - ASSERT_EQ(0, memcmp(buf + len - compare, ref.data() + ref.size() - compare, - compare)) + dump("output", buf.get(), len); + ASSERT_EQ(0, memcmp(buf.get() + len - compare, + ref.data() + ref.size() - compare, compare)) << "comparing " << compare << " octets"; mp_clear(&a); } diff --git a/gtests/freebl_gtest/rsa_unittest.cc b/gtests/freebl_gtest/rsa_unittest.cc index a1453168f..9a6a9c11f 100644 --- a/gtests/freebl_gtest/rsa_unittest.cc +++ b/gtests/freebl_gtest/rsa_unittest.cc @@ -5,6 +5,7 @@ #include "gtest/gtest.h" #include <stdint.h> +#include <memory> #include "blapi.h" #include "secitem.h" @@ -198,6 +198,7 @@ 'gtests/certdb_gtest/certdb_gtest.gyp:certdb_gtest', 'gtests/freebl_gtest/freebl_gtest.gyp:prng_gtest', 'gtests/freebl_gtest/freebl_gtest.gyp:blake2b_gtest', + 'gtests/freebl_gtest/freebl_gtest.gyp:freebl_gtest', 'gtests/mozpkix_gtest/mozpkix_gtest.gyp:mozpkix_gtest', 'gtests/nss_bogo_shim/nss_bogo_shim.gyp:nss_bogo_shim', 'gtests/pk11_gtest/pk11_gtest.gyp:pk11_gtest', |