summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-03-05 20:44:58 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-03-05 20:44:58 +0000
commit40255f0884522d4dfa478d78024d8b62016d0edd (patch)
tree94dd5429db1b6df1a09525c375bb7eaf08342afe /tools
parent14711a6768760dfef224e671d9dbab0286de6d1b (diff)
parent19282c39306568477c18c306b0bac1d72d170883 (diff)
Merge "Fail if there are repeated fields in atoms.proto" into rvc-dev am: 19282c3930
Change-Id: I16e2912c6c193f14f660beadd4f6276a12553ade
Diffstat (limited to 'tools')
-rw-r--r--tools/stats_log_api_gen/Collation.cpp10
-rw-r--r--tools/stats_log_api_gen/test.proto31
-rw-r--r--tools/stats_log_api_gen/test_collation.cpp5
3 files changed, 28 insertions, 18 deletions
diff --git a/tools/stats_log_api_gen/Collation.cpp b/tools/stats_log_api_gen/Collation.cpp
index 8bccd7150050..aa356f1c35d2 100644
--- a/tools/stats_log_api_gen/Collation.cpp
+++ b/tools/stats_log_api_gen/Collation.cpp
@@ -237,6 +237,16 @@ int collate_atom(const Descriptor *atom, AtomDecl *atomDecl,
errorCount++;
continue;
}
+
+ if (field->is_repeated() &&
+ !(javaType == JAVA_TYPE_ATTRIBUTION_CHAIN || javaType == JAVA_TYPE_KEY_VALUE_PAIR)) {
+ print_error(field,
+ "Repeated fields are not supported in atoms. Please make field %s not "
+ "repeated.\n",
+ field->name().c_str());
+ errorCount++;
+ continue;
+ }
}
// Check that if there's an attribution chain, it's at position 1.
diff --git a/tools/stats_log_api_gen/test.proto b/tools/stats_log_api_gen/test.proto
index b892194410ae..eab622d77ef7 100644
--- a/tools/stats_log_api_gen/test.proto
+++ b/tools/stats_log_api_gen/test.proto
@@ -41,21 +41,20 @@ enum AnEnum {
message AllTypesAtom {
repeated android.os.statsd.AttributionNode attribution_chain = 1;
- optional double double_field = 2;
- optional float float_field = 3;
- optional int64 int64_field = 4;
- optional uint64 uint64_field = 5;
- optional int32 int32_field = 6;
- optional fixed64 fixed64_field = 7;
- optional fixed32 fixed32_field = 8;
- optional bool bool_field = 9;
- optional string string_field = 10;
- optional uint32 uint32_field = 11;
- optional AnEnum enum_field = 12;
- optional sfixed32 sfixed32_field = 13;
- optional sfixed64 sfixed64_field = 14;
- optional sint32 sint32_field = 15;
- optional sint64 sint64_field = 16;
+ optional float float_field = 2;
+ optional int64 int64_field = 3;
+ optional uint64 uint64_field = 4;
+ optional int32 int32_field = 5;
+ optional fixed64 fixed64_field = 6;
+ optional fixed32 fixed32_field = 7;
+ optional bool bool_field = 8;
+ optional string string_field = 9;
+ optional uint32 uint32_field = 10;
+ optional AnEnum enum_field = 11;
+ optional sfixed32 sfixed32_field = 12;
+ optional sfixed64 sfixed64_field = 13;
+ optional sint32 sint32_field = 14;
+ optional sint64 sint64_field = 15;
}
message Event {
@@ -70,6 +69,8 @@ message Event {
message BadTypesAtom {
optional IntAtom bad_int_atom = 1;
optional bytes bad_bytes = 2;
+ repeated int32 repeated_field = 3;
+ optional double double_field = 4;
}
message BadTypesEvent {
diff --git a/tools/stats_log_api_gen/test_collation.cpp b/tools/stats_log_api_gen/test_collation.cpp
index bcf18ae8bf19..a972e2342cad 100644
--- a/tools/stats_log_api_gen/test_collation.cpp
+++ b/tools/stats_log_api_gen/test_collation.cpp
@@ -98,7 +98,6 @@ TEST(CollationTest, CollateStats) {
EXPECT_SET_CONTAINS_SIGNATURE(
atoms.signatures_to_modules,
JAVA_TYPE_ATTRIBUTION_CHAIN, // AttributionChain
- JAVA_TYPE_DOUBLE, // double
JAVA_TYPE_FLOAT, // float
JAVA_TYPE_LONG, // int64
JAVA_TYPE_LONG, // uint64
@@ -157,13 +156,13 @@ TEST(CollationTest, NonMessageTypeFails) {
}
/**
- * Test that atoms that have non-primitive types are rejected.
+ * Test that atoms that have non-primitive types or repeated fields are rejected.
*/
TEST(CollationTest, FailOnBadTypes) {
Atoms atoms;
int errorCount = collate_atoms(BadTypesEvent::descriptor(), &atoms);
- EXPECT_EQ(2, errorCount);
+ EXPECT_EQ(4, errorCount);
}
/**