diff options
author | Calder Kitagawa <ckitagawa@google.com> | 2018-04-24 13:54:46 +0000 |
---|---|---|
committer | Edward Lesmes <ehmaldonado@google.com> | 2021-07-23 22:09:53 +0000 |
commit | 05b1b6a1d8cfe2960959ff0ea3ecf96c4f198c54 (patch) | |
tree | c73343189a18e17ada847085bd27d0053e49d3ab /image_utils_unittest.cc | |
parent | 451ff5de400706acdfcfdb9bf28ca6d4c0670b81 (diff) | |
download | zucchini-05b1b6a1d8cfe2960959ff0ea3ecf96c4f198c54.tar.gz |
[Zucchini] Update ExecutableType values.
This change has some pros and some cons:
Pros:
- Human readable ExecType in patch/hex dumps as the ASCII is meaningful.
- Can be done at next to no cost at compile time.
- Assigning new values regardless of order of appearance in the enum is
more flexible. No more concern over invalidating old patches as values
will be more or less permanent once this change goes in.
Cons:
- Checking if an ExecutableType is valid requires O(n) time where n
is the number of supported Exec types using a cast.
Alternatively, we could maintain a sorted list of these types in
memory to check against in O(log(n)) or could use a set
but this is more memory. Overall not a huge deal since we only support
~9 types but it is worth understanding the tradeoffs.
- Enums don't enforce value reuse so it is possible although highly
unlikely we introduce a repeated value. However, given the use of the
switch case casting requiring unique values this is very unlikely.
Bug: 834932
Change-Id: I7bc14ea7b4434e60bb0dafa47178fb2c2c12dc7f
Reviewed-on: https://chromium-review.googlesource.com/1020446
Commit-Queue: Calder Kitagawa <ckitagawa@google.com>
Reviewed-by: Samuel Huang <huangs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553083}
NOKEYCHECK=True
GitOrigin-RevId: da4335f0d27c7fa14f6897ffeb0833d424860f7e
Diffstat (limited to 'image_utils_unittest.cc')
-rw-r--r-- | image_utils_unittest.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/image_utils_unittest.cc b/image_utils_unittest.cc index cd71a2f..f483625 100644 --- a/image_utils_unittest.cc +++ b/image_utils_unittest.cc @@ -14,4 +14,11 @@ TEST(ImageUtilsTest, Bitness) { EXPECT_EQ(8U, WidthOf(kBit64)); } +TEST(ImageUtilsTest, CastExecutableTypeToString) { + EXPECT_EQ("NoOp", CastExecutableTypeToString(kExeTypeNoOp)); + EXPECT_EQ("Px86", CastExecutableTypeToString(kExeTypeWin32X86)); + EXPECT_EQ("EA64", CastExecutableTypeToString(kExeTypeElfAArch64)); + EXPECT_EQ("DEX ", CastExecutableTypeToString(kExeTypeDex)); +} + } // namespace zucchini |