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

Commit 739594d8 authored by Zach Johnson's avatar Zach Johnson
Browse files

Get gd os tests running on host

* Run os tests on host
* Fix flaky hander clear test
* Move to linux_generic
* Remove dependency on libchrome
* Allow alarms to run on linux host where we can't get CAP_WAKE_ALARM

Test: atest bluetooth_gd_test_os
Change-Id: Ia95ce39169ac8c963052e3252e7b39ef32bd5bb1
parent 47a958f4
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
{
  "postsubmit" : [
    {
      "name" : "bluetooth_gd_test_os"
    },
    {
      "name" : "bluetooth_test_common"
    },
+90 −22
Original line number Diff line number Diff line
cc_library_static {
    name: "libbt-gd-os",
cc_defaults {
    name: "gd_defaults",
    target: {
        android: {
            test_config_template: "AndroidTestTemplate.xml",
            cflags: [
                "-DOS_ANDROID",
                "-DOS_LINUX_GENERIC",
            ],
            shared_libs: [
                "liblog"
            ]
        },
        host: {
            cflags: [
                "-DOS_LINUX",
                "-DOS_LINUX_GENERIC",
            ]
        }
    },
    cpp_std: "c++17",
    cflags: [
        "-DEXPORT_SYMBOL=__attribute__((visibility(\"default\")))",
        "-fvisibility=hidden",
        "-DLOG_NDEBUG=1",
        "-DGOOGLE_PROTOBUF_NO_RTTI",
    ],
    conlyflags: [
        "-std=c99",
    ],
    sanitize: {
        misc_undefined: ["bounds"],
    },
}

// Enables code coverage for a set of source files. Must be combined with
// "clang_coverage_bin" in order to work. See //test/gen_coverage.py for more information
// on generating code coverage.
cc_defaults {
    name: "gd_clang_file_coverage",
    target: {
        host: {
            clang_cflags: [
                "-fprofile-instr-generate",
                "-fcoverage-mapping",
            ],
        },
    },
}

// Enabled code coverage on a binary. These flags allow libraries that were
// compiled with "clang_file_coverage" to be properly linked together in
// order to create a binary that will create a profraw file when ran. Note
// these flags themselves don't enable code coverage for the source files
// compiled in the binary. See //test/gen_coverage.py for more information
// on generating code coverage.
cc_defaults {
    name: "gd_clang_coverage_bin",
    target: {
        host: {
            ldflags: [
                "-fprofile-instr-generate",
                "-fcoverage-mapping",
            ],
        },
    },
}

cc_library {
    name: "libbluetooth_gd",
    defaults: [
        "fluoride_defaults",
        "clang_file_coverage",
        "gd_defaults",
        "gd_clang_file_coverage",
    ],
    host_supported: true,
    target: {
        linux: {
            srcs: [
        "os/alarm.cc",
        "os/handler.cc",
        "os/reactor.cc",
        "os/repeating_alarm.cc",
        "os/thread.cc",
    ],
                ":BluetoothOsSources_linux_generic",
            ]
        }
    },
}

cc_test {
    name: "bluetooth_gd_test_os",
    name: "bluetooth_test_gd",
    test_suites: ["device-tests"],
    defaults: [
        "fluoride_defaults",
        "clang_coverage_bin",
        "gd_defaults",
        "gd_clang_coverage_bin",
    ],
    host_supported: true,
    target: {
        linux: {
            srcs: [
        "os/alarm_unittest.cc",
        "os/handler_unittest.cc",
        "os/reactor_unittest.cc",
        "os/repeating_alarm_unittest.cc",
        "os/thread_unittest.cc",
    ],
                ":BluetoothOsTestSources_linux_generic",
            ]
        }
    },
    static_libs : [
        "libbt-gd-os",
        "libbluetooth_gd",
    ],
    sanitize: {
        cfi: false,
+36 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 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="Runs {MODULE}.">
  <option name="test-suite-tag" value="apct" />
  <option name="test-suite-tag" value="apct-native" />
  <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer" />
  <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
    <option name="cleanup" value="true" />
    <option name="push" value="{MODULE}->/data/local/tmp/{MODULE}" />
  </target_preparer>
  <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
    <option name="run-command" value="settings put global ble_scan_always_enabled 0" />
    <option name="run-command" value="svc bluetooth disable" />
  </target_preparer>
  <target_preparer class="com.android.tradefed.targetprep.FolderSaver">
    <option name="device-path" value="/data/vendor/ssrdump" />
  </target_preparer>
  <test class="com.android.tradefed.testtype.GTest" >
    <option name="native-test-device-path" value="/data/local/tmp" />
    <option name="module-name" value="{MODULE}" />
    <option name="run-test-as" value="0" />
  </test>
</configuration>

system/gd/TEST_MAPPING

0 → 100644
+8 −0
Original line number Diff line number Diff line
{
  "presubmit" : [
    {
      "name" : "bluetooth_test_gd",
      "host" : true
    }
  ]
}
+21 −0
Original line number Diff line number Diff line
filegroup {
    name: "BluetoothOsSources_linux_generic",
    srcs: [
        "linux_generic/alarm.cc",
        "linux_generic/handler.cc",
        "linux_generic/reactor.cc",
        "linux_generic/repeating_alarm.cc",
        "linux_generic/thread.cc",
    ]
}

filegroup {
    name: "BluetoothOsTestSources_linux_generic",
    srcs: [
        "linux_generic/alarm_unittest.cc",
        "linux_generic/handler_unittest.cc",
        "linux_generic/reactor_unittest.cc",
        "linux_generic/repeating_alarm_unittest.cc",
        "linux_generic/thread_unittest.cc",
    ]
}
Loading