Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d823b30 authored by Tej Singh's avatar Tej Singh
Browse files

Statsd test mapping

Makes a test mapping for statsd so that unit tests run on presubmit.

Changes to make the tests pass:
1. Require root. This is needed to write to disk, since the tests don't
run as statsd's uid

2. Remove AndroidTest.xml file in favor of the autogenerated one.

3. Remove a check in StatsService.test for getUidFromArgs. The test
checked a failure case where we passed a number bigger than INT32_MAX.
However, on a 32 bit device, strtol will return INT32_MAX when an
overflow happens, since it returns a 32 bit number on a 32 bit device.

4. Refactor a lot of e2e tests to sort dimensions, ensuring that the
dimensions are always in order, instead of relying on implicit ordering
of hashing, which can change.

5. Change a long to an int64 in TestActivationsPersistAcrossSystemServerRestart

Test: statsd_test
Bug: 129613474
Change-Id: I80dfa3bfd50ebe6d2c8c0c3ba201f3ad06b68910
parent 1fdf62b7
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -301,6 +301,8 @@ cc_test {
        "-Wno-unused-parameter",
    ],

    require_root: true,

    srcs: [
        // atom_field_options.proto needs field_options.proto, but that is
        // not included in libprotobuf-cpp-lite, so compile it here.
@@ -373,10 +375,6 @@ cc_test {
        include_dirs: ["external/protobuf/src"],
    },

    shared_libs: [
        "libprotobuf-cpp-lite",
    ],

}

//#############################

cmds/statsd/AndroidTest.xml

deleted100644 → 0
+0 −26
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 The Android Open Source Project

     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

          http://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.
-->
<configuration description="Config for statsd_test">
    <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
        <option name="cleanup" value="true" />
        <option name="push" value="statsd_test->/data/nativetest/statsd_test" />
    </target_preparer>
    <option name="test-suite-tag" value="apct" />
    <test class="com.android.tradefed.testtype.GTest" >
        <option name="native-test-device-path" value="/data/nativetest" />
        <option name="module-name" value="statsd_test" />
    </test>
</configuration>
 No newline at end of file
+7 −0
Original line number Diff line number Diff line
{
  "presubmit" : [
    {
      "name" : "statsd_test"
    }
  ]
}
 No newline at end of file
+4 −1
Original line number Diff line number Diff line
@@ -181,12 +181,15 @@ message GaugeBucketInfo {
message GaugeMetricData {
  optional DimensionsValue dimensions_in_what = 1;

  optional DimensionsValue dimensions_in_condition = 2 [deprecated = true];
  // Currently unsupported
  repeated StateValue slice_by_state = 6;

  repeated GaugeBucketInfo bucket_info = 3;

  repeated DimensionsValue dimension_leaf_values_in_what = 4;

  optional DimensionsValue dimensions_in_condition = 2 [deprecated = true];

  repeated DimensionsValue dimension_leaf_values_in_condition = 5 [deprecated = true];
}

+1 −1
Original line number Diff line number Diff line
@@ -1564,7 +1564,7 @@ TEST(StatsLogProcessorTest, TestActivationsPersistAcrossSystemServerRestart) {

    // Trigger Activation 1 for Metric 1. Should activate on boot.
    // Trigger Activation 4 for Metric 2. Should activate immediately.
    long configAddedTimeNs = metricsManager1->mLastReportTimeNs;
    int64_t configAddedTimeNs = metricsManager1->mLastReportTimeNs;
    std::vector<int> attributionUids = {111};
    std::vector<string> attributionTags = {"App1"};
    std::unique_ptr<LogEvent> event1 = CreateAcquireWakelockEvent(
Loading