OSDN Git Service

Add IScheduleTest for VTS libhwbinder scheduler test
authorHoward Chen <howardsoc@google.com>
Fri, 7 Apr 2017 12:15:28 +0000 (20:15 +0800)
committerHoward Chen <howardsoc@google.com>
Mon, 17 Apr 2017 06:34:34 +0000 (14:34 +0800)
Add IScheduleTest.hal:
    send(cfg, callerSta)
cfg: 1 for verbose output
caller_status:  (caller_rt_priority <<16 )| caller_cpu

with the return value defined as:
((1 if no priority inheritance)<<16) | (1 if no cpu sync)
The implementation is in ScheduleTest.cpp

Bug:36705188
Test: sailfish/prebuilt kernel/oc-dev with the libhwbinder_latency
  vts test case
Change-Id: Ie2a837c8d0d4fa95c6fd0ebd50e76412cb808df8

tests/libhwbinder/1.0/Android.bp
tests/libhwbinder/1.0/Android.mk
tests/libhwbinder/1.0/IBenchmark.hal
tests/libhwbinder/1.0/IScheduleTest.hal [new file with mode: 0644]
tests/libhwbinder/1.0/default/Android.bp
tests/libhwbinder/1.0/default/ScheduleTest.cpp [new file with mode: 0644]
tests/libhwbinder/1.0/default/ScheduleTest.h [new file with mode: 0644]

index 9c0fe45..e8d28a3 100644 (file)
@@ -4,6 +4,7 @@ filegroup {
     name: "android.hardware.tests.libhwbinder@1.0_hal",
     srcs: [
         "IBenchmark.hal",
+        "IScheduleTest.hal",
     ],
 }
 
@@ -16,6 +17,7 @@ genrule {
     ],
     out: [
         "android/hardware/tests/libhwbinder/1.0/BenchmarkAll.cpp",
+        "android/hardware/tests/libhwbinder/1.0/ScheduleTestAll.cpp",
     ],
 }
 
@@ -32,6 +34,11 @@ genrule {
         "android/hardware/tests/libhwbinder/1.0/BnHwBenchmark.h",
         "android/hardware/tests/libhwbinder/1.0/BpHwBenchmark.h",
         "android/hardware/tests/libhwbinder/1.0/BsBenchmark.h",
+        "android/hardware/tests/libhwbinder/1.0/IScheduleTest.h",
+        "android/hardware/tests/libhwbinder/1.0/IHwScheduleTest.h",
+        "android/hardware/tests/libhwbinder/1.0/BnHwScheduleTest.h",
+        "android/hardware/tests/libhwbinder/1.0/BpHwScheduleTest.h",
+        "android/hardware/tests/libhwbinder/1.0/BsScheduleTest.h",
     ],
 }
 
index 4a5f779..bb430fb 100644 (file)
@@ -34,6 +34,25 @@ $(GEN): PRIVATE_CUSTOM_TOOL = \
 $(GEN): $(LOCAL_PATH)/IBenchmark.hal
        $(transform-generated-source)
 LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IScheduleTest.hal
+#
+GEN := $(intermediates)/android/hardware/tests/libhwbinder/V1_0/IScheduleTest.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IScheduleTest.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava \
+        -randroid.hardware:hardware/interfaces \
+        -randroid.hidl:system/libhidl/transport \
+        android.hardware.tests.libhwbinder@1.0::IScheduleTest
+
+$(GEN): $(LOCAL_PATH)/IScheduleTest.hal
+       $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
 include $(BUILD_JAVA_LIBRARY)
 
 
@@ -69,6 +88,25 @@ $(GEN): PRIVATE_CUSTOM_TOOL = \
 $(GEN): $(LOCAL_PATH)/IBenchmark.hal
        $(transform-generated-source)
 LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IScheduleTest.hal
+#
+GEN := $(intermediates)/android/hardware/tests/libhwbinder/V1_0/IScheduleTest.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IScheduleTest.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+        -Ljava \
+        -randroid.hardware:hardware/interfaces \
+        -randroid.hidl:system/libhidl/transport \
+        android.hardware.tests.libhwbinder@1.0::IScheduleTest
+
+$(GEN): $(LOCAL_PATH)/IScheduleTest.hal
+       $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
 
index 6b266e2..b3aa320 100644 (file)
@@ -17,5 +17,5 @@
 package android.hardware.tests.libhwbinder@1.0;
 
 interface IBenchmark {
-  sendVec(vec<uint8_t> data) generates (vec<uint8_t> return_data);
+  sendVec(vec<uint8_t> data) generates (vec<uint8_t> data);
 };
diff --git a/tests/libhwbinder/1.0/IScheduleTest.hal b/tests/libhwbinder/1.0/IScheduleTest.hal
new file mode 100644 (file)
index 0000000..b3f57c5
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+package android.hardware.tests.libhwbinder@1.0;
+
+interface IScheduleTest {
+  send(uint32_t cfg, uint32_t callerSta) generates (uint32_t data);
+};
index e690ca5..fa1b2b3 100644 (file)
@@ -1,18 +1,16 @@
 cc_library_shared {
     name: "android.hardware.tests.libhwbinder@1.0-impl",
-    defaults: ["hidl_defaults"],
     relative_install_path: "hw",
     proprietary: true,
     srcs: [
         "Benchmark.cpp",
+        "ScheduleTest.cpp",
     ],
-
     shared_libs: [
-        "libbase",
         "libhidlbase",
         "libhidltransport",
-        "liblog",
         "libutils",
         "android.hardware.tests.libhwbinder@1.0",
+        "android.hidl.base@1.0",
     ],
 }
diff --git a/tests/libhwbinder/1.0/default/ScheduleTest.cpp b/tests/libhwbinder/1.0/default/ScheduleTest.cpp
new file mode 100644 (file)
index 0000000..6356953
--- /dev/null
@@ -0,0 +1,84 @@
+#include "ScheduleTest.h"
+#include <pthread.h>
+#include <iomanip>
+#include <iostream>
+
+using namespace std;
+
+#define ASSERT(cond)                                                      \
+    do {                                                                  \
+        if (!(cond)) {                                                    \
+            cerr << __func__ << ":" << __LINE__ << " condition:" << #cond \
+                 << " failed\n"                                           \
+                 << endl;                                                 \
+            exit(EXIT_FAILURE);                                           \
+        }                                                                 \
+    } while (0)
+
+static int threadPri() {
+    struct sched_param param;
+    int policy;
+    ASSERT(!pthread_getschedparam(pthread_self(), &policy, &param));
+    return param.sched_priority;
+}
+
+static void threadDump(const char* prefix, int verbose) {
+    struct sched_param param;
+    int policy;
+    if (!verbose) return;
+    cout << "--------------------------------------------------" << endl;
+    cout << setw(12) << left << prefix << " pid: " << getpid()
+         << " tid: " << gettid() << " cpu: " << sched_getcpu() << endl;
+    ASSERT(!pthread_getschedparam(pthread_self(), &policy, &param));
+    string s = (policy == SCHED_OTHER)
+                   ? "SCHED_OTHER"
+                   : (policy == SCHED_FIFO)
+                         ? "SCHED_FIFO"
+                         : (policy == SCHED_RR) ? "SCHED_RR" : "???";
+    cout << setw(12) << left << s << param.sched_priority << endl;
+    return;
+}
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace libhwbinder {
+namespace V1_0 {
+namespace implementation {
+
+// Methods from ::android::hardware::tests::libhwbinder::V1_0::IScheduleTest
+// follow.
+Return<uint32_t> ScheduleTest::send(uint32_t cfg, uint32_t callerSta) {
+    // TODO implement
+    int priority = threadPri();
+    int priority_caller = (callerSta >> 16) & 0xffff;
+    int verbose = cfg & 1;
+    threadDump("hwbinder", verbose);
+    uint32_t h = 0, s = 0;
+    if (priority_caller != priority) {
+        h++;
+        if (verbose) {
+            cout << "err priority_caller:" << priority_caller
+                 << ", priority:" << priority << endl;
+        }
+    }
+    int cpu = sched_getcpu();
+    int cpu_caller = (callerSta)&0xffff;
+    if (cpu != cpu_caller) {
+        s++;
+    }
+    return (h << 16) | (s & 0xffff);
+}
+
+// Methods from ::android::hidl::base::V1_0::IBase follow.
+
+IScheduleTest* HIDL_FETCH_IScheduleTest(const char* /* name */) {
+    return new ScheduleTest();
+}
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace libhwbinder
+}  // namespace tests
+}  // namespace hardware
+}  // namespace android
diff --git a/tests/libhwbinder/1.0/default/ScheduleTest.h b/tests/libhwbinder/1.0/default/ScheduleTest.h
new file mode 100644 (file)
index 0000000..ad6dd9d
--- /dev/null
@@ -0,0 +1,41 @@
+#ifndef ANDROID_HARDWARE_TESTS_LIBHWBINDER_V1_0_SCHEDULETEST_H
+#define ANDROID_HARDWARE_TESTS_LIBHWBINDER_V1_0_SCHEDULETEST_H
+
+#include <android/hardware/tests/libhwbinder/1.0/IScheduleTest.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace libhwbinder {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::tests::libhwbinder::V1_0::IScheduleTest;
+using ::android::hidl::base::V1_0::DebugInfo;
+using ::android::hidl::base::V1_0::IBase;
+using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_memory;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::sp;
+
+struct ScheduleTest : public IScheduleTest {
+    // Methods from ::android::hardware::tests::libhwbinder::V1_0::IScheduleTest
+    // follow.
+    Return<uint32_t> send(uint32_t cfg, uint32_t callerSta) override;
+
+    // Methods from ::android::hidl::base::V1_0::IBase follow.
+};
+
+}  // namespace implementation
+}  // namespace V1_0
+}  // namespace libhwbinder
+}  // namespace tests
+}  // namespace hardware
+}  // namespace android
+
+#endif  // ANDROID_HARDWARE_TESTS_LIBHWBINDER_V1_0_SCHEDULETEST_H