-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pw_build: Updates to pw_cc_blob_library
- Support specifying the alignment of the blob with the alignas argument. - Require the namespace argument. - Isolate blob include paths under "$target_gen_dir/$target_name" so they aren't shared by all blobs declared in the same directory. - No longer use different one-line formatting for short blobs to simplify code generation. - Add a unit test that checks the contents of a blob. Change-Id: I61d58b6cb95576a89fd8123b9f41ffeb0db38860 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/100801 Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com> Reviewed-by: Ewout van Bekkum <ewout@google.com> Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
- Loading branch information
Showing
10 changed files
with
294 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2022 The Pigweed Authors | ||
// | ||
// 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. | ||
|
||
#include <cstddef> | ||
|
||
#include "gtest/gtest.h" | ||
#include "pw_build/test_blob.h" | ||
|
||
namespace pw::build { | ||
namespace { | ||
|
||
static_assert(test::ns::kFirstBlob0123.size() == 4); | ||
static_assert(test::ns::kFirstBlob0123.data() != nullptr); | ||
|
||
static_assert(test::ns::kSecondBlob0123.size() == 4); | ||
static_assert(test::ns::kSecondBlob0123.data() != nullptr); | ||
|
||
TEST(CcBlobLibraryTest, FirstBlobContentsMatch) { | ||
EXPECT_EQ(test::ns::kFirstBlob0123[0], std::byte{0}); | ||
EXPECT_EQ(test::ns::kFirstBlob0123[1], std::byte{1}); | ||
EXPECT_EQ(test::ns::kFirstBlob0123[2], std::byte{2}); | ||
EXPECT_EQ(test::ns::kFirstBlob0123[3], std::byte{3}); | ||
} | ||
|
||
TEST(CcBlobLibraryTest, SecondBlobContentsMatch) { | ||
EXPECT_EQ(test::ns::kSecondBlob0123[0], std::byte{0}); | ||
EXPECT_EQ(test::ns::kSecondBlob0123[1], std::byte{1}); | ||
EXPECT_EQ(test::ns::kSecondBlob0123[2], std::byte{2}); | ||
EXPECT_EQ(test::ns::kSecondBlob0123[3], std::byte{3}); | ||
} | ||
|
||
TEST(CcBlobLibraryTest, FirstBlobAlignedTo512) { | ||
// This checks that the variable is aligned to 512, but cannot guarantee that | ||
// alignas was specified correctly, since it could be aligned to 512 by | ||
// coincidence. | ||
const uintptr_t addr = reinterpret_cast<uintptr_t>(&test::ns::kFirstBlob0123); | ||
constexpr uintptr_t kAlignmentMask = static_cast<uintptr_t>(512 - 1); | ||
EXPECT_EQ(addr & kAlignmentMask, 0u); | ||
} | ||
|
||
} // namespace | ||
} // namespace pw::build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.