Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Unified Diff: syzygy/refinery/process_state/process_state_util_unittest.cc

Issue 1475083002: [Refinery] Introduce TypePropagatorAnalyzer - pointer types. (Closed) Base URL: https://github.com/google/syzygy.git@master
Patch Set: Final nit Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « syzygy/refinery/process_state/process_state_util.cc ('k') | syzygy/refinery/process_state/refinery.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: syzygy/refinery/process_state/process_state_util_unittest.cc
diff --git a/syzygy/refinery/process_state/process_state_util_unittest.cc b/syzygy/refinery/process_state/process_state_util_unittest.cc
index 450a184c7e01e293981297d5e40f39858317a287..6528547e263e79d51f8cb7c8e0b2266d8ecf61df 100644
--- a/syzygy/refinery/process_state/process_state_util_unittest.cc
+++ b/syzygy/refinery/process_state/process_state_util_unittest.cc
@@ -19,8 +19,10 @@
#include "base/strings/utf_string_conversions.h"
#include "gtest/gtest.h"
#include "syzygy/refinery/core/address.h"
+#include "syzygy/refinery/process_state/layer_data.h"
#include "syzygy/refinery/process_state/process_state.h"
#include "syzygy/refinery/process_state/refinery.pb.h"
+#include "syzygy/refinery/types/type.h"
namespace refinery {
@@ -32,7 +34,8 @@ const uint32 kChecksum = 11U;
const uint32 kTimestamp = 22U;
const wchar_t kPath[] = L"c:\\path\\ModuleName";
const char kDataName[] = "data_name";
-const char kTypeName[] = "Type::Name*";
+const ModuleId kModuleId = 100;
+const TypeId kTypeId = 42;
} // namespace
@@ -67,7 +70,7 @@ TEST(ModuleLayerAccessorTest, AddModuleRecord) {
ASSERT_EQ(module.module_id(), module_layer->data().Find(signature));
}
-TEST(ModuleLayerAccessorTest, GetModuleSignatureTest) {
+TEST(ModuleLayerAccessorTest, GetModuleSignatureVATest) {
ProcessState state;
ModuleLayerAccessor accessor(&state);
pe::PEFile::Signature signature;
@@ -95,11 +98,58 @@ TEST(ModuleLayerAccessorTest, GetModuleSignatureTest) {
ASSERT_EQ(kPath, signature.path);
}
+TEST(ModuleLayerAccessorTest, GetModuleSignatureIdTest) {
+ ProcessState state;
+ ModuleLayerAccessor accessor(&state);
+
+ // Add a module and get its id.
+ accessor.AddModuleRecord(AddressRange(kAddress, kSize), kChecksum, kTimestamp,
+ kPath);
+ ModuleId module_id = accessor.GetModuleId(kAddress);
+
+ // Validate.
+ pe::PEFile::Signature signature;
+ ASSERT_TRUE(accessor.GetModuleSignature(module_id, &signature));
+
+ ASSERT_EQ(0U, signature.base_address.value());
+ ASSERT_EQ(kSize, signature.module_size);
+ ASSERT_EQ(kChecksum, signature.module_checksum);
+ ASSERT_EQ(kTimestamp, signature.module_time_date_stamp);
+ ASSERT_EQ(kPath, signature.path);
+}
+
+TEST(ModuleLayerAccessorTest, GetModuleIdTest) {
+ ProcessState state;
+ ModuleLayerAccessor accessor(&state);
+
+ // Not hitting a module case.
+ ASSERT_EQ(kNoModuleId, accessor.GetModuleId(kAddress));
+
+ // Hitting a module case.
+ accessor.AddModuleRecord(AddressRange(kAddress, kSize), kChecksum, kTimestamp,
+ kPath);
+ ModuleId module_id = accessor.GetModuleId(kAddress);
+ ASSERT_NE(kNoModuleId, module_id);
+
+ // Consistency check: the signature associated to module_id must be equal to
+ // that associated with va, up to the base address being 0.
+ pe::PEFile::Signature sig_from_va;
+ ASSERT_TRUE(accessor.GetModuleSignature(kAddress, &sig_from_va));
+ sig_from_va.base_address = core::AbsoluteAddress(0U);
+
+ pe::PEFile::Signature sig_from_id;
+ ModuleLayerPtr layer;
+ state.FindOrCreateLayer(&layer);
+ ASSERT_TRUE(layer->data().Find(module_id, &sig_from_id));
+
+ ASSERT_EQ(sig_from_va, sig_from_id);
+}
+
TEST(AddTypedBlockRecord, BasicTest) {
ProcessState state;
AddTypedBlockRecord(AddressRange(kAddress, kSize),
- base::ASCIIToUTF16(kDataName),
- base::ASCIIToUTF16(kTypeName), &state);
+ base::ASCIIToUTF16(kDataName), kModuleId, kTypeId,
+ &state);
// Validate a record was added.
TypedBlockLayerPtr layer;
@@ -115,7 +165,8 @@ TEST(AddTypedBlockRecord, BasicTest) {
// Validate TypedBlock proto.
TypedBlock* proto = record->mutable_data();
ASSERT_EQ(kDataName, proto->data_name());
- ASSERT_EQ(kTypeName, proto->type_name());
+ ASSERT_EQ(kTypeId, proto->type_id());
+ ASSERT_EQ(kModuleId, proto->module_id());
}
} // namespace refinery
« no previous file with comments | « syzygy/refinery/process_state/process_state_util.cc ('k') | syzygy/refinery/process_state/refinery.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698