Commit ac72e0ed authored by Franziskus Kiefer's avatar Franziskus Kiefer

Bug 1363213 - more, non-leaking mpi tests; run them on TC, r=ttaubert

Differential Revision: https://nss-review.dev.mozaws.net/D284

--HG--
extra : rebase_source : 1b7a656ed77e1a8dd6c695beeba7b5d6bc128921
extra : amend_source : fcbc61ff59341d89bd0c13eb8488df2376a225af
parent ffe4ee4c
......@@ -455,6 +455,19 @@ async function scheduleTestBuilds(base, args = "") {
symbol: "mpi",
kind: "test"
}));
queue.scheduleTask(merge(base, {
parent: task_build,
command: [
"/bin/bash",
"-c",
"bin/checkout.sh && nss/automation/taskcluster/scripts/run_tests.sh"
],
name: "Gtests",
symbol: "Gtest",
tests: "gtests",
cycle: "standard",
kind: "test"
}));
return queue.submit();
}
......
......@@ -40,16 +40,18 @@ class MPITest : public ::testing::Test {
protected:
void TestCmp(const std::string a_string, const std::string b_string,
int result) {
mp_int a, b, c;
mp_int a, b;
MP_DIGITS(&a) = 0;
MP_DIGITS(&b) = 0;
MP_DIGITS(&c) = 0;
ASSERT_EQ(MP_OKAY, mp_init(&a));
ASSERT_EQ(MP_OKAY, mp_init(&b));
mp_read_radix(&a, a_string.c_str(), 16);
mp_read_radix(&b, b_string.c_str(), 16);
EXPECT_EQ(result, mp_cmp(&a, &b));
mp_clear(&a);
mp_clear(&b);
}
};
......@@ -58,7 +60,41 @@ TEST_F(MPITest, MpiCmp10Test) { TestCmp("1", "0", 1); }
TEST_F(MPITest, MpiCmp00Test) { TestCmp("0", "0", 0); }
TEST_F(MPITest, MpiCmp11Test) { TestCmp("1", "1", 0); }
TEST_F(MPITest, MpiCmpConstTest) {
TEST_F(MPITest, MpiCmpUnalignedTest) {
mp_int a, b, c;
MP_DIGITS(&a) = 0;
MP_DIGITS(&b) = 0;
MP_DIGITS(&c) = 0;
ASSERT_EQ(MP_OKAY, mp_init(&a));
ASSERT_EQ(MP_OKAY, mp_init(&b));
ASSERT_EQ(MP_OKAY, mp_init(&c));
mp_read_radix(&a, "ffffffffffffffff3b4e802b4e1478", 16);
mp_read_radix(&b, "ffffffffffffffff3b4e802b4e1478", 16);
EXPECT_EQ(0, mp_cmp(&a, &b));
// Now change a and b such that they contain the same numbers but are not
// aligned.
// a = ffffffffffffff|ff3b4e802b4e1478
// b = ffffffffffffffff|3b4e802b4e1478
MP_DIGITS(&b)[0] &= 0x00ffffffffffffff;
MP_DIGITS(&b)[1] = 0xffffffffffffffff;
EXPECT_EQ(-1, mp_cmp(&a, &b));
ASSERT_EQ(MP_OKAY, mp_sub(&a, &b, &c));
char c_tmp[40];
ASSERT_EQ(MP_OKAY, mp_toradix(&c, c_tmp, 16));
ASSERT_TRUE(strncmp(c_tmp, "feffffffffffffff100000000000000", 31));
mp_clear(&a);
mp_clear(&b);
mp_clear(&c);
}
// This test is slow. Disable it by default so we can run these tests on CI.
class DISABLED_MPITest : public ::testing::Test {};
TEST_F(DISABLED_MPITest, MpiCmpConstTest) {
mp_int a, b, c;
MP_DIGITS(&a) = 0;
MP_DIGITS(&b) = 0;
......@@ -115,6 +151,10 @@ TEST_F(MPITest, MpiCmpConstTest) {
ASSERT_EQ(1, r);
}
printf("time c: %u\n", time_c / runs);
mp_clear(&a);
mp_clear(&b);
mp_clear(&c);
}
} // nss_test
......@@ -83,7 +83,7 @@ gtest_cleanup()
}
################## main #################################################
GTESTS="prng_gtest der_gtest pk11_gtest util_gtest"
GTESTS="prng_gtest der_gtest pk11_gtest util_gtest freebl_gtest"
SOURCE_DIR="$PWD"/../..
gtest_init $0
gtest_start
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment