diff options
author | Joe Onorato <joeo@google.com> | 2017-11-18 20:32:56 -0800 |
---|---|---|
committer | Joe Onorato <joeo@google.com> | 2017-12-13 18:26:45 -0800 |
commit | 62c220b20b3fc431c27feac29a71d040fc8e2626 (patch) | |
tree | 4915764f6640ca69fcd2ecbc1dde9f1d40768dc0 /cmds/incident_helper | |
parent | 37e9278c7799719180549384d7390079a10e46ea (diff) |
Fix how we build the statsd protos.
This lets us include frameworks protos, and use the constants
and messages from them.
Change-Id: I609d6e524f780e6a5beea543a68561bede47813e
Test: make
Diffstat (limited to 'cmds/incident_helper')
-rw-r--r-- | cmds/incident_helper/Android.bp | 11 | ||||
-rw-r--r-- | cmds/incident_helper/tests/CpuFreqParser_test.cpp | 11 | ||||
-rw-r--r-- | cmds/incident_helper/tests/CpuInfoParser_test.cpp | 11 | ||||
-rw-r--r-- | cmds/incident_helper/tests/KernelWakesParser_test.cpp | 13 | ||||
-rw-r--r-- | cmds/incident_helper/tests/PageTypeInfoParser_test.cpp | 13 | ||||
-rw-r--r-- | cmds/incident_helper/tests/ProcrankParser_test.cpp | 13 | ||||
-rw-r--r-- | cmds/incident_helper/tests/SystemPropertiesParser_test.cpp | 11 |
7 files changed, 22 insertions, 61 deletions
diff --git a/cmds/incident_helper/Android.bp b/cmds/incident_helper/Android.bp index fc0bdccb268b..d7b6d69ade74 100644 --- a/cmds/incident_helper/Android.bp +++ b/cmds/incident_helper/Android.bp @@ -50,12 +50,15 @@ cc_test { "testdata/*", ], - shared_libs: [ - "libprotobuf-cpp-full", - ], - static_libs: [ "libgmock", "libplatformprotos" ], + + shared_libs: [ + "libprotobuf-cpp-full" + ], + proto: { + type: "full", + }, } diff --git a/cmds/incident_helper/tests/CpuFreqParser_test.cpp b/cmds/incident_helper/tests/CpuFreqParser_test.cpp index 1c2f9e59308d..82deee42687f 100644 --- a/cmds/incident_helper/tests/CpuFreqParser_test.cpp +++ b/cmds/incident_helper/tests/CpuFreqParser_test.cpp @@ -21,7 +21,7 @@ #include <android-base/file.h> #include <android-base/test_utils.h> #include <gmock/gmock.h> -#include <google/protobuf/message.h> +#include <google/protobuf/message_lite.h> #include <gtest/gtest.h> #include <string.h> #include <fcntl.h> @@ -42,13 +42,6 @@ public: ASSERT_TRUE(tf.fd != -1); } - string getSerializedString(::google::protobuf::Message& message) { - string expectedStr; - message.SerializeToFileDescriptor(tf.fd); - ReadFileToString(tf.path, &expectedStr); - return expectedStr; - } - protected: TemporaryFile tf; @@ -125,6 +118,6 @@ TEST_F(CpuFreqParserTest, Success) { CaptureStdout(); ASSERT_EQ(NO_ERROR, parser.Parse(fd, STDOUT_FILENO)); - EXPECT_EQ(GetCapturedStdout(), getSerializedString(expected)); + EXPECT_EQ(GetCapturedStdout(), expected.SerializeAsString()); close(fd); } diff --git a/cmds/incident_helper/tests/CpuInfoParser_test.cpp b/cmds/incident_helper/tests/CpuInfoParser_test.cpp index bbc14bca3efc..8dce53e46492 100644 --- a/cmds/incident_helper/tests/CpuInfoParser_test.cpp +++ b/cmds/incident_helper/tests/CpuInfoParser_test.cpp @@ -21,7 +21,7 @@ #include <android-base/file.h> #include <android-base/test_utils.h> #include <gmock/gmock.h> -#include <google/protobuf/message.h> +#include <google/protobuf/message_lite.h> #include <gtest/gtest.h> #include <string.h> #include <fcntl.h> @@ -42,13 +42,6 @@ public: ASSERT_TRUE(tf.fd != -1); } - string getSerializedString(::google::protobuf::Message& message) { - string expectedStr; - message.SerializeToFileDescriptor(tf.fd); - ReadFileToString(tf.path, &expectedStr); - return expectedStr; - } - protected: TemporaryFile tf; @@ -153,6 +146,6 @@ TEST_F(CpuInfoParserTest, Success) { CaptureStdout(); ASSERT_EQ(NO_ERROR, parser.Parse(fd, STDOUT_FILENO)); - EXPECT_EQ(GetCapturedStdout(), getSerializedString(expected)); + EXPECT_EQ(GetCapturedStdout(), expected.SerializeAsString()); close(fd); } diff --git a/cmds/incident_helper/tests/KernelWakesParser_test.cpp b/cmds/incident_helper/tests/KernelWakesParser_test.cpp index a8fa62088450..a98c62bd6024 100644 --- a/cmds/incident_helper/tests/KernelWakesParser_test.cpp +++ b/cmds/incident_helper/tests/KernelWakesParser_test.cpp @@ -21,7 +21,7 @@ #include <android-base/file.h> #include <android-base/test_utils.h> #include <gmock/gmock.h> -#include <google/protobuf/message.h> +#include <google/protobuf/message_lite.h> #include <gtest/gtest.h> #include <string.h> #include <fcntl.h> @@ -42,13 +42,6 @@ public: ASSERT_TRUE(tf.fd != -1); } - string getSerializedString(::google::protobuf::Message& message) { - string expectedStr; - message.SerializeToFileDescriptor(tf.fd); - ReadFileToString(tf.path, &expectedStr); - return expectedStr; - } - protected: TemporaryFile tf; @@ -76,7 +69,7 @@ TEST_F(KernelWakesParserTest, Short) { CaptureStdout(); ASSERT_EQ(NO_ERROR, parser.Parse(fd, STDOUT_FILENO)); - EXPECT_EQ(GetCapturedStdout(), getSerializedString(expected)); + EXPECT_EQ(GetCapturedStdout(), expected.SerializeAsString()); close(fd); } @@ -114,6 +107,6 @@ TEST_F(KernelWakesParserTest, Normal) { CaptureStdout(); ASSERT_EQ(NO_ERROR, parser.Parse(fd, STDOUT_FILENO)); - EXPECT_EQ(GetCapturedStdout(), getSerializedString(expected)); + EXPECT_EQ(GetCapturedStdout(), expected.SerializeAsString()); close(fd); } diff --git a/cmds/incident_helper/tests/PageTypeInfoParser_test.cpp b/cmds/incident_helper/tests/PageTypeInfoParser_test.cpp index de64e70c80c7..a9e6e816c6c5 100644 --- a/cmds/incident_helper/tests/PageTypeInfoParser_test.cpp +++ b/cmds/incident_helper/tests/PageTypeInfoParser_test.cpp @@ -21,7 +21,7 @@ #include <android-base/file.h> #include <android-base/test_utils.h> #include <gmock/gmock.h> -#include <google/protobuf/message.h> +#include <google/protobuf/message_lite.h> #include <gtest/gtest.h> #include <string.h> #include <fcntl.h> @@ -42,13 +42,6 @@ public: ASSERT_TRUE(tf.fd != -1); } - string getSerializedString(::google::protobuf::Message& message) { - string expectedStr; - message.SerializeToFileDescriptor(tf.fd); - ReadFileToString(tf.path, &expectedStr); - return expectedStr; - } - protected: TemporaryFile tf; @@ -108,6 +101,6 @@ TEST_F(PageTypeInfoParserTest, Success) { CaptureStdout(); ASSERT_EQ(NO_ERROR, parser.Parse(fd, STDOUT_FILENO)); - EXPECT_EQ(GetCapturedStdout(), getSerializedString(expected)); + EXPECT_EQ(GetCapturedStdout(), expected.SerializeAsString()); close(fd); -}
\ No newline at end of file +} diff --git a/cmds/incident_helper/tests/ProcrankParser_test.cpp b/cmds/incident_helper/tests/ProcrankParser_test.cpp index e86647ad479b..76b25d7f8f47 100644 --- a/cmds/incident_helper/tests/ProcrankParser_test.cpp +++ b/cmds/incident_helper/tests/ProcrankParser_test.cpp @@ -21,7 +21,7 @@ #include <android-base/file.h> #include <android-base/test_utils.h> #include <gmock/gmock.h> -#include <google/protobuf/message.h> +#include <google/protobuf/message_lite.h> #include <gtest/gtest.h> #include <string.h> #include <fcntl.h> @@ -42,13 +42,6 @@ public: ASSERT_TRUE(tf.fd != -1); } - string getSerializedString(::google::protobuf::Message& message) { - string expectedStr; - message.SerializeToFileDescriptor(tf.fd); - ReadFileToString(tf.path, &expectedStr); - return expectedStr; - } - protected: TemporaryFile tf; @@ -104,7 +97,7 @@ TEST_F(ProcrankParserTest, HasSwapInfo) { CaptureStdout(); ASSERT_EQ(NO_ERROR, parser.Parse(fd, STDOUT_FILENO)); - EXPECT_EQ(GetCapturedStdout(), getSerializedString(expected)); + EXPECT_EQ(GetCapturedStdout(), expected.SerializeAsString()); close(fd); } @@ -142,6 +135,6 @@ TEST_F(ProcrankParserTest, NoSwapInfo) { CaptureStdout(); ASSERT_EQ(NO_ERROR, parser.Parse(fd, STDOUT_FILENO)); - EXPECT_EQ(GetCapturedStdout(), getSerializedString(expected)); + EXPECT_EQ(GetCapturedStdout(), expected.SerializeAsString()); close(fd); } diff --git a/cmds/incident_helper/tests/SystemPropertiesParser_test.cpp b/cmds/incident_helper/tests/SystemPropertiesParser_test.cpp index 98838e98d796..2fe2411e2017 100644 --- a/cmds/incident_helper/tests/SystemPropertiesParser_test.cpp +++ b/cmds/incident_helper/tests/SystemPropertiesParser_test.cpp @@ -21,7 +21,7 @@ #include <android-base/file.h> #include <android-base/test_utils.h> #include <gmock/gmock.h> -#include <google/protobuf/message.h> +#include <google/protobuf/message_lite.h> #include <gtest/gtest.h> #include <string.h> #include <fcntl.h> @@ -42,13 +42,6 @@ public: ASSERT_TRUE(tf.fd != -1); } - string getSerializedString(::google::protobuf::Message& message) { - string expectedStr; - message.SerializeToFileDescriptor(tf.fd); - ReadFileToString(tf.path, &expectedStr); - return expectedStr; - } - protected: TemporaryFile tf; @@ -99,6 +92,6 @@ TEST_F(SystemPropertiesParserTest, HasSwapInfo) { CaptureStdout(); ASSERT_EQ(NO_ERROR, parser.Parse(fd, STDOUT_FILENO)); - EXPECT_EQ(GetCapturedStdout(), getSerializedString(expected)); + EXPECT_EQ(GetCapturedStdout(), expected.SerializeAsString()); close(fd); } |