From 3b8985fb6e5e31ada5778e467445caf4f9bccf4b Mon Sep 17 00:00:00 2001 From: Mike Sheffler Date: Tue, 11 Sep 2018 00:22:20 -0700 Subject: [PATCH] Test of AutoDiff wrapper in an expression modified so that the upAligned size of the relevant binary expression is tested against the size of the expression in the AutoDiff wrapper. When the traceSize() of the expression containing the AutoDiff wrapper is computed, that value (the traceSize) will be computed such that an alignment (currently 16-bit) will be forced. It is thus necessary for the test to also upAlign the relevant binary expression. On x86_64 architectures, this test was accidentally passing because the relevant struct was already aligned on a 16-bit boundary. On AArch64 ('ARM64'), the alignment was *not* on a 16-bit boundary, and this test failed. Modifying the first argument to EXPECT_LONGS_EQUAL in this test to include upAlignment of the relevant binary expression makes the test pass in 'debug' and 'release' builds on both x86_64 and AArch64 architectures --- gtsam/nonlinear/tests/testAdaptAutoDiff.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gtsam/nonlinear/tests/testAdaptAutoDiff.cpp b/gtsam/nonlinear/tests/testAdaptAutoDiff.cpp index aa50ce73f..a85118c00 100644 --- a/gtsam/nonlinear/tests/testAdaptAutoDiff.cpp +++ b/gtsam/nonlinear/tests/testAdaptAutoDiff.cpp @@ -231,14 +231,22 @@ TEST(AdaptAutoDiff, AdaptAutoDiff) { /* ************************************************************************* */ // Test AutoDiff wrapper in an expression TEST(AdaptAutoDiff, SnavelyExpression) { + typedef AdaptAutoDiff Adaptor; + Expression P(1); Expression X(2); - typedef AdaptAutoDiff Adaptor; + Expression expression(Adaptor(), P, X); + + std::size_t RecordSize = + sizeof(internal::BinaryExpression::Record); + EXPECT_LONGS_EQUAL( - sizeof(internal::BinaryExpression::Record), - expression.traceSize()); + internal::upAligned(RecordSize) + P.traceSize() + X.traceSize(), + expression.traceSize()); + set expected = list_of(1)(2); + EXPECT(expected == expression.keys()); }