[automerger skipped] DO NOT MERGE Update VTS tag version to 11_R16 am: dd7f4d6391 -s ours am: 9fe2885383 -s ours am: b1ceec03f5 -s ours am: abc16b7c29 -s ours
am skip reason: contains skip directive
Original change: https://android-review.googlesource.com/c/platform/test/vts/+/2917628
Change-Id: Ie6ff59450d5bfaab3ad4b5246bfbb30f799df140
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/.gitignore b/.gitignore
index a03d342..e1340e7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,9 +5,6 @@
*.py[cod]
*$py.class
-# C extensions
-*.so
-
# Distribution / packaging
.Python
env/
diff --git a/__init__.py b/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/__init__.py
+++ /dev/null
diff --git a/compilation_tools/vtsc/Android.bp b/compilation_tools/vtsc/Android.bp
deleted file mode 100644
index 1ef3d56..0000000
--- a/compilation_tools/vtsc/Android.bp
+++ /dev/null
@@ -1,82 +0,0 @@
-//
-// 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 {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-cc_library_host_shared {
-
- name: "libvtsc",
-
- srcs: [
- "VtsCompilerUtils.cpp",
- "code_gen/CodeGenBase.cpp",
- "code_gen/common/HalHidlCodeGenUtils.cpp",
- "code_gen/driver/DriverCodeGenBase.cpp",
- "code_gen/driver/HalCodeGen.cpp",
- "code_gen/driver/HalHidlCodeGen.cpp",
- "code_gen/driver/LibSharedCodeGen.cpp",
- "code_gen/fuzzer/FuzzerCodeGenBase.cpp",
- "code_gen/fuzzer/HalHidlFuzzerCodeGen.cpp",
- "code_gen/profiler/ProfilerCodeGenBase.cpp",
- "code_gen/profiler/HalHidlProfilerCodeGen.cpp",
- ],
-
- include_dirs: ["test/vts/drivers/hal/common"],
-
- static_libs: ["libz"],
-
- shared_libs: [
- "libbase",
- "libhidl-gen-host-utils",
- "libhidl-gen-utils",
- "libprotobuf-cpp-full",
- "libvts_common",
- "libvts_multidevice_proto",
- ],
-
- cflags: [
- "-Wall",
- "-Werror",
- ],
-
-}
-
-cc_binary_host {
-
- name: "vtsc",
-
- srcs: ["VtsCompilerMain.cpp"],
-
- include_dirs: ["test/vts/drivers/hal/common"],
-
- static_libs: ["libz"],
-
- shared_libs: [
- "libbase",
- "libhidl-gen-host-utils",
- "libhidl-gen-utils",
- "libvts_multidevice_proto",
- "libvtsc",
- ],
-
- cflags: [
- "-Wall",
- "-Werror",
- ],
-
-}
diff --git a/compilation_tools/vtsc/VtsCompilerMain.cpp b/compilation_tools/vtsc/VtsCompilerMain.cpp
deleted file mode 100644
index 1a434ae..0000000
--- a/compilation_tools/vtsc/VtsCompilerMain.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include <dirent.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include <iostream>
-
-#include <android-base/logging.h>
-#include "VtsCompilerUtils.h"
-#include "code_gen/CodeGenBase.h"
-
-using namespace std;
-
-// To generate both header and source files,
-// Usage: vtsc -mDRIVER | -mPROFILER <.vts input file path> \
-// <header output dir> <C/C++ source output file path>
-// To generate only a header file,
-// Usage: vtsc -mDRIVER | -mPROFILER -tHEADER -b<base path> \
-// <.vts input file or dir path> <header output file or dir path>
-// To generate only a source file,
-// Usage: vtsc -mDRIVER | -mPROFILER -tSOURCE -b<base path> \
-// <.vts input file or dir path> \
-// <C/C++ source output file or dir path>
-// where <base path> is a base path of where .vts input file or dir is
-// stored but should be excluded when computing the package path of generated
-// source or header output file(s).
-
-int main(int argc, char* argv[]) {
-#ifdef VTS_DEBUG
- cout << "Android VTS Compiler (AVTSC)" << endl;
-#endif
- int opt_count = 0;
- android::vts::VtsCompileMode mode = android::vts::kDriver;
- android::vts::VtsCompileFileType type = android::vts::VtsCompileFileType::kBoth;
- string vts_base_dir;
- for (int i = 0; i < argc; i++) {
-#ifdef VTS_DEBUG
- cout << "- args[" << i << "] " << argv[i] << endl;
-#endif
- if (argv[i] && strlen(argv[i]) > 1 && argv[i][0] == '-') {
- opt_count++;
- if (argv[i][1] == 'm') {
- if (!strcmp(&argv[i][2], "PROFILER")) {
- mode = android::vts::kProfiler;
-#ifdef VTS_DEBUG
- cout << "- mode: PROFILER" << endl;
-#endif
- } else if (!strcmp(&argv[i][2], "FUZZER")) {
- mode = android::vts::kFuzzer;
-#ifdef VTS_DEBUG
- cout << "- mode: FUZZER" << endl;
-#endif
- }
- }
- if (argv[i][1] == 't') {
- if (!strcmp(&argv[i][2], "HEADER")) {
- type = android::vts::kHeader;
-#ifdef VTS_DEBUG
- cout << "- type: HEADER" << endl;
-#endif
- } else if (!strcmp(&argv[i][2], "SOURCE")) {
- type = android::vts::kSource;
-#ifdef VTS_DEBUG
- cout << "- type: SOURCE" << endl;
-#endif
- }
- }
- if (argv[i][1] == 'b') {
- vts_base_dir = &argv[i][2];
-#ifdef VTS_DEBUG
- cout << "- VTS base dir: " << vts_base_dir << endl;
-#endif
- }
- }
- }
- if (argc < 5) {
- cerr << "argc " << argc << " < 5" << endl;
- return -1;
- }
- switch (type) {
- case android::vts::kBoth:
- android::vts::Translate(
- mode, argv[opt_count + 1], argv[opt_count + 2], argv[opt_count + 3]);
- break;
- case android::vts::kHeader:
- case android::vts::kSource: {
- struct stat s;
- bool is_dir = false;
- if (vts_base_dir.length() > 0) {
- if (chdir(vts_base_dir.c_str())) {
- cerr << __func__ << " can't chdir to " << vts_base_dir << endl;
- exit(-1);
- }
- }
- if (stat(argv[opt_count + 1], &s) == 0) {
- if (s.st_mode & S_IFDIR) {
- is_dir = true;
- }
- }
- if (!is_dir) {
- android::vts::TranslateToFile(
- mode, argv[opt_count + 1], argv[opt_count + 2], type);
- } else {
- DIR* input_dir;
- struct dirent* ent;
- if ((input_dir = opendir(argv[opt_count + 1])) != NULL) {
- // argv[opt_count + 2] should be a directory. if that dir does not exist,
- // that dir is created as part of the translation operation.
- while ((ent = readdir(input_dir)) != NULL) {
- if (!strncmp(&ent->d_name[strlen(ent->d_name)-4], ".vts", 4)) {
- string src_file = android::vts::RemoveBaseDir(
- android::vts::PathJoin(
- argv[opt_count + 1], ent->d_name), vts_base_dir);
- string dst_file = android::vts::RemoveBaseDir(
- android::vts::PathJoin(
- argv[opt_count + 2], ent->d_name), vts_base_dir);
- if (type == android::vts::kHeader) {
- dst_file = android::vts::PathJoin(dst_file.c_str(), ".h");
- } else {
- dst_file = android::vts::PathJoin(dst_file.c_str(), ".cpp");
- }
-#ifdef VTS_DEBUG
- cout << ent->d_name << endl;
- cout << "<- " << src_file.c_str() << endl;
- cout << "-> " << dst_file.c_str() << endl;
-#endif
- android::vts::TranslateToFile(
- mode, src_file.c_str(), dst_file.c_str(), type);
- }
- }
- closedir(input_dir);
- } else {
- cerr << __func__ << " can't open the given input dir, "
- << argv[opt_count + 1] << "." << endl;
- exit(-1);
- }
- }
- break;
- }
- }
- return 0;
-}
diff --git a/compilation_tools/vtsc/VtsCompilerUtils.cpp b/compilation_tools/vtsc/VtsCompilerUtils.cpp
deleted file mode 100644
index 28728f2..0000000
--- a/compilation_tools/vtsc/VtsCompilerUtils.cpp
+++ /dev/null
@@ -1,645 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "VtsCompilerUtils.h"
-
-#include <limits.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <cstdint>
-#include <fstream>
-#include <iostream>
-#include <sstream>
-
-#include <google/protobuf/text_format.h>
-
-#include "utils/InterfaceSpecUtil.h"
-#include "utils/StringUtil.h"
-
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-string ComponentClassToString(int component_class) {
- switch (component_class) {
- case UNKNOWN_CLASS:
- return "unknown_class";
- case HAL_CONVENTIONAL:
- return "hal_conventional";
- case HAL_CONVENTIONAL_SUBMODULE:
- return "hal_conventional_submodule";
- case HAL_HIDL:
- return "hal_hidl";
- case HAL_HIDL_WRAPPED_CONVENTIONAL:
- return "hal_hidl_wrapped_conventional";
- case HAL_LEGACY:
- return "hal_legacy";
- case LIB_SHARED:
- return "lib_shared";
- }
- cerr << "error: invalid component_class " << component_class << endl;
- exit(-1);
-}
-
-string ComponentTypeToString(int component_type) {
- switch (component_type) {
- case UNKNOWN_TYPE:
- return "unknown_type";
- case AUDIO:
- return "audio";
- case CAMERA:
- return "camera";
- case GPS:
- return "gps";
- case LIGHT:
- return "light";
- case WIFI:
- return "wifi";
- case MOBILE:
- return "mobile";
- case BLUETOOTH:
- return "bluetooth";
- case TV_INPUT:
- return "tv_input";
- case NFC:
- return "nfc";
- case VEHICLE:
- return "vehicle";
- case VIBRATOR:
- return "vibrator";
- case THERMAL:
- return "thermal";
- case CONTEXTHUB:
- return "contexthub";
- case SENSORS:
- return "sensors";
- case VR:
- return "vr";
- case GRAPHICS_ALLOCATOR:
- return "graphics_allocator";
- case GRAPHICS_MAPPER:
- return "graphics_mapper";
- case GRAPHICS_COMPOSER:
- return "graphics_composer";
- case BIONIC_LIBM:
- return "bionic_libm";
- case TV_CEC:
- return "tv_cec";
- case RADIO:
- return "radio";
- case MEDIA_OMX:
- return "media_omx";
- case BIONIC_LIBC:
- return "bionic_libc";
- case VNDK_LIBCUTILS:
- return "vndk_libcutils";
- }
- cerr << "error: invalid component_type " << component_type << endl;
- exit(-1);
-}
-
-string GetCppVariableType(const std::string scalar_type_string) {
- if (scalar_type_string == "void" ||
- scalar_type_string == "int32_t" || scalar_type_string == "uint32_t" ||
- scalar_type_string == "int8_t" || scalar_type_string == "uint8_t" ||
- scalar_type_string == "int64_t" || scalar_type_string == "uint64_t" ||
- scalar_type_string == "int16_t" || scalar_type_string == "uint16_t") {
- return scalar_type_string;
- } else if (scalar_type_string == "bool_t") {
- return "bool";
- } else if (scalar_type_string == "float_t") {
- return "float";
- } else if (scalar_type_string == "double_t") {
- return "double";
- } else if (scalar_type_string == "ufloat") {
- return "unsigned float";
- } else if (scalar_type_string == "udouble") {
- return "unsigned double";
- } else if (scalar_type_string == "string") {
- return "std::string";
- } else if (scalar_type_string == "pointer") {
- return "void*";
- } else if (scalar_type_string == "char_pointer") {
- return "char*";
- } else if (scalar_type_string == "uchar_pointer") {
- return "unsigned char*";
- } else if (scalar_type_string == "void_pointer") {
- return "void*";
- } else if (scalar_type_string == "function_pointer") {
- return "void*";
- }
-
- cerr << __func__ << ":" << __LINE__ << " "
- << "error: unknown scalar_type " << scalar_type_string << endl;
- exit(-1);
-}
-
-string GetCppVariableType(const VariableSpecificationMessage& arg,
- bool generate_const) {
- string result;
- switch (arg.type()) {
- case TYPE_VOID:
- {
- return "void";
- }
- case TYPE_PREDEFINED:
- {
- result = arg.predefined_type();
- break;
- }
- case TYPE_SCALAR:
- {
- result = GetCppVariableType(arg.scalar_type());
- break;
- }
- case TYPE_STRING:
- {
- result = "::android::hardware::hidl_string";
- break;
- }
- case TYPE_ENUM:
- {
- if (!arg.has_enum_value() && arg.has_predefined_type()) {
- result = arg.predefined_type();
- } else if (arg.has_enum_value() && arg.has_name()) {
- result = arg.name(); // nested enum type.
- } else {
- cerr << __func__ << ":" << __LINE__
- << " ERROR no predefined_type set for enum variable" << endl;
- exit(-1);
- }
- break;
- }
- case TYPE_VECTOR:
- {
- string element_type = GetCppVariableType(arg.vector_value(0));
- result = "::android::hardware::hidl_vec<" + element_type + ">";
- break;
- }
- case TYPE_ARRAY:
- {
- VariableSpecificationMessage cur_val = arg;
- vector<int32_t> array_sizes;
- while (cur_val.type() == TYPE_ARRAY) {
- array_sizes.push_back(cur_val.vector_size());
- VariableSpecificationMessage temp = cur_val.vector_value(0);
- cur_val = temp;
- }
- string element_type = GetCppVariableType(cur_val);
- result = "::android::hardware::hidl_array<" + element_type + ", ";
- for (size_t i = 0; i < array_sizes.size(); i++) {
- result += to_string(array_sizes[i]);
- if (i != array_sizes.size() - 1) result += ", ";
- }
- result += ">";
- break;
- }
- case TYPE_STRUCT:
- {
- if (arg.struct_value_size() == 0 && arg.has_predefined_type()) {
- result = arg.predefined_type();
- } else if (arg.has_struct_type()) {
- result = arg.struct_type();
- } else if (arg.sub_struct_size() > 0 || arg.struct_value_size() > 0) {
- result = arg.name();
- } else {
- cerr << __func__ << ":" << __LINE__ << " ERROR"
- << " no predefined_type, struct_type, nor sub_struct set"
- << " for struct variable"
- << " (arg name " << arg.name() << ")" << endl;
- exit(-1);
- }
- break;
- }
- case TYPE_UNION:
- {
- if (arg.union_value_size() == 0 && arg.has_predefined_type()) {
- result = arg.predefined_type();
- } else if (arg.has_union_type()) {
- result = arg.union_type();
- } else {
- cerr << __func__ << ":" << __LINE__
- << " ERROR no predefined_type or union_type set for union"
- << " variable" << endl;
- exit(-1);
- }
- break;
- }
- case TYPE_SAFE_UNION: {
- if (arg.safe_union_value_size() == 0 && arg.has_predefined_type()) {
- result = arg.predefined_type();
- } else {
- cerr << __func__ << ":" << __LINE__
- << " ERROR no predefined_type set for safe union"
- << " variable" << endl;
- exit(-1);
- }
- break;
- }
- case TYPE_HIDL_CALLBACK:
- {
- if (arg.has_predefined_type()) {
- result = "sp<" + arg.predefined_type() + ">";
- } else {
- cerr << __func__ << ":" << __LINE__
- << " ERROR no predefined_type set for hidl callback variable"
- << endl;
- exit(-1);
- }
- break;
- }
- case TYPE_HANDLE:
- {
- result = "::android::hardware::hidl_handle";
- break;
- }
- case TYPE_HIDL_INTERFACE:
- {
- if (arg.has_predefined_type()) {
- result = "sp<" + arg.predefined_type() + ">";
- } else {
- cerr << __func__ << ":" << __LINE__
- << " ERROR no predefined_type set for hidl interface variable"
- << endl;
- exit(-1);
- }
- break;
- }
- case TYPE_MASK:
- {
- result = GetCppVariableType(arg.scalar_type());
- break;
- }
- case TYPE_HIDL_MEMORY:
- {
- result = "::android::hardware::hidl_memory";
- break;
- }
- case TYPE_POINTER:
- {
- result = "void*";
- if (generate_const) {
- result = "const " + result;
- }
- return result;
- }
- case TYPE_FMQ_SYNC:
- {
- string element_type = GetCppVariableType(arg.fmq_value(0));
- result = "::android::hardware::MQDescriptorSync<" + element_type + ">";
- break;
- }
- case TYPE_FMQ_UNSYNC:
- {
- string element_type = GetCppVariableType(arg.fmq_value(0));
- result = "::android::hardware::MQDescriptorUnsync<" + element_type + ">";
- break;
- }
- case TYPE_REF:
- {
- VariableSpecificationMessage cur_val = arg;
- int ref_depth = 0;
- while (cur_val.type() == TYPE_REF) {
- ref_depth++;
- VariableSpecificationMessage temp = cur_val.ref_value();
- cur_val = temp;
- }
- string element_type = GetCppVariableType(cur_val);
- result = element_type;
- for (int i = 0; i < ref_depth; i++) {
- result += " const*";
- }
- return result;
- break;
- }
- default:
- {
- cerr << __func__ << ":" << __LINE__ << " " << ": type " << arg.type()
- << " not supported" << endl;
- exit(-1);
- }
- }
- if (generate_const) {
- return "const " + result + "&";
- }
- return result;
-}
-
-string GetConversionToProtobufFunctionName(VariableSpecificationMessage arg) {
- if (arg.type() == TYPE_PREDEFINED) {
- if (arg.predefined_type() == "camera_info_t*") {
- return "ConvertCameraInfoToProtobuf";
- } else if (arg.predefined_type() == "hw_device_t**") {
- return "";
- } else {
- cerr << __FILE__ << ":" << __LINE__ << " "
- << "error: unknown instance type " << arg.predefined_type() << endl;
- }
- }
- cerr << __FUNCTION__ << ": non-supported type " << arg.type() << endl;
- exit(-1);
-}
-
-string GetCppInstanceType(
- const VariableSpecificationMessage& arg,
- const string& msg,
- const ComponentSpecificationMessage* message) {
- switch(arg.type()) {
- case TYPE_PREDEFINED: {
- if (arg.predefined_type() == "struct light_state_t*") {
- if (msg.length() == 0) {
- return "GenerateLightState()";
- } else {
- return "GenerateLightStateUsingMessage(" + msg + ")";
- }
- } else if (arg.predefined_type() == "GpsCallbacks*") {
- return "GenerateGpsCallbacks()";
- } else if (arg.predefined_type() == "GpsUtcTime") {
- return "GenerateGpsUtcTime()";
- } else if (arg.predefined_type() == "vts_gps_latitude") {
- return "GenerateLatitude()";
- } else if (arg.predefined_type() == "vts_gps_longitude") {
- return "GenerateLongitude()";
- } else if (arg.predefined_type() == "vts_gps_accuracy") {
- return "GenerateGpsAccuracy()";
- } else if (arg.predefined_type() == "vts_gps_flags_uint16") {
- return "GenerateGpsFlagsUint16()";
- } else if (arg.predefined_type() == "GpsPositionMode") {
- return "GenerateGpsPositionMode()";
- } else if (arg.predefined_type() == "GpsPositionRecurrence") {
- return "GenerateGpsPositionRecurrence()";
- } else if (arg.predefined_type() == "hw_module_t*") {
- return "(hw_module_t*) malloc(sizeof(hw_module_t))";
- } else if (arg.predefined_type() == "hw_module_t**") {
- return "(hw_module_t**) malloc(sizeof(hw_module_t*))";
- } else if (arg.predefined_type() == "hw_device_t**") {
- return "(hw_device_t**) malloc(sizeof(hw_device_t*))";
- } else if (arg.predefined_type() == "camera_info_t*") {
- if (msg.length() == 0) {
- return "GenerateCameraInfo()";
- } else {
- return "GenerateCameraInfoUsingMessage(" + msg + ")";
- }
- } else if (arg.predefined_type() == "camera_module_callbacks_t*") {
- return "GenerateCameraModuleCallbacks()";
- } else if (arg.predefined_type() == "camera_notify_callback") {
- return "GenerateCameraNotifyCallback()";
- } else if (arg.predefined_type() == "camera_data_callback") {
- return "GenerateCameraDataCallback()";
- } else if (arg.predefined_type() == "camera_data_timestamp_callback") {
- return "GenerateCameraDataTimestampCallback()";
- } else if (arg.predefined_type() == "camera_request_memory") {
- return "GenerateCameraRequestMemory()";
- } else if (arg.predefined_type() == "wifi_handle*") {
- return "(wifi_handle*) malloc(sizeof(wifi_handle))";
- } else if (arg.predefined_type() == "struct camera_device*") {
- return "(struct camera_device*) malloc(sizeof(struct camera_device))";
- } else if (arg.predefined_type() == "struct preview_stream_ops*") {
- return "(preview_stream_ops*) malloc(sizeof(preview_stream_ops))";
- } else if (endsWith(arg.predefined_type(), "*")) {
- // known use cases: bt_callbacks_t
- return "(" + arg.predefined_type() + ") malloc(sizeof("
- + arg.predefined_type().substr(0, arg.predefined_type().size() - 1)
- + "))";
- } else {
- cerr << __func__ << ":" << __LINE__ << " "
- << "error: unknown instance type " << arg.predefined_type() << endl;
- }
- break;
- }
- case TYPE_SCALAR: {
- if (arg.scalar_type() == "bool_t") {
- return "RandomBool()";
- } else if (arg.scalar_type() == "uint32_t") {
- return "RandomUint32()";
- } else if (arg.scalar_type() == "int32_t") {
- return "RandomInt32()";
- } else if (arg.scalar_type() == "uint64_t") {
- return "RandomUint64()";
- } else if (arg.scalar_type() == "int64_t") {
- return "RandomInt64()";
- } else if (arg.scalar_type() == "uint16_t") {
- return "RandomUint16()";
- } else if (arg.scalar_type() == "int16_t") {
- return "RandomInt16()";
- } else if (arg.scalar_type() == "uint8_t") {
- return "RandomUint8()";
- } else if (arg.scalar_type() == "int8_t") {
- return "RandomInt8()";
- } else if (arg.scalar_type() == "float_t") {
- return "RandomFloat()";
- } else if (arg.scalar_type() == "double_t") {
- return "RandomDouble()";
- } else if (arg.scalar_type() == "char_pointer") {
- return "RandomCharPointer()";
- } else if (arg.scalar_type() == "uchar_pointer") {
- return "(unsigned char*) RandomCharPointer()";
- } else if (arg.scalar_type() == "pointer" ||
- arg.scalar_type() == "void_pointer") {
- return "RandomVoidPointer()";
- }
- cerr << __FILE__ << ":" << __LINE__ << " "
- << "error: unsupported scalar data type " << arg.scalar_type() << endl;
- exit(-1);
- }
- case TYPE_ENUM:
- case TYPE_MASK: {
- if (!arg.has_enum_value() && arg.has_predefined_type()) {
- if (!message || message->component_class() != HAL_HIDL) {
- return "(" + arg.predefined_type() + ") RandomUint32()";
- } else {
- std::string predefined_type_name = arg.predefined_type();
- ReplaceSubString(predefined_type_name, "::", "__");
- return "Random" + predefined_type_name + "()";
- // TODO: generate a function which can dynamically choose the value.
- /* for (const auto& attribute : message->attribute()) {
- if (attribute.type() == TYPE_ENUM &&
- attribute.name() == arg.predefined_type()) {
- // TODO: pick at runtime
- return message->component_name() + "::"
- + arg.predefined_type() + "::"
- + attribute.enum_value().enumerator(0);
- }
- } */
- }
- } else {
- cerr << __func__
- << " ENUM either has enum value or doesn't have predefined type"
- << endl;
- exit(-1);
- }
- break;
- }
- case TYPE_STRING: {
- return "android::hardware::hidl_string(RandomCharPointer())";
- }
- case TYPE_STRUCT: {
- if (arg.struct_value_size() == 0 && arg.has_predefined_type()) {
- return message->component_name() + "::" + arg.predefined_type() + "()";
- }
- break;
- }
- case TYPE_VECTOR: { // only for HAL_HIDL
- // TODO: generate code that initializes a local hidl_vec.
- return "";
- }
- case TYPE_HIDL_CALLBACK: {
- return arg.predefined_type() + "()";
- }
- default:
- break;
- }
- cerr << __func__ << ": error: unsupported type " << arg.type() << endl;
- exit(-1);
-}
-
-int vts_fs_mkdirs(char* file_path, mode_t mode) {
- char* p;
-
- for (p = strchr(file_path + 1, '/'); p; p = strchr(p + 1, '/')) {
- *p = '\0';
- if (mkdir(file_path, mode) == -1) {
- if (errno != EEXIST) {
- *p = '/';
- return -1;
- }
- }
- *p = '/';
- }
- return 0;
-}
-
-string ClearStringWithNameSpaceAccess(const string& str) {
- string result = str;
- ReplaceSubString(result, "::", "__");
- return result;
-}
-
-// Returns a string which joins the given dir_path and file_name.
-string PathJoin(const char* dir_path, const char* file_name) {
- string result;
- if (dir_path) {
- result = dir_path;
- if (!file_name) return result;
- } else if (!file_name) return result;
-
- if (file_name[0] != '.') {
- if (result.c_str()[result.length()-1] != '/') {
- result += "/";
- }
- }
- result += file_name;
- return result;
-}
-
-// Returns a string which remove given base_path from file_path if included.
-string RemoveBaseDir(const string& file_path, const string& base_path) {
- if (base_path.empty() ||
- strncmp(file_path.c_str(), base_path.c_str(), base_path.length())) {
- return file_path;
- }
- string result;
- result = &file_path.c_str()[base_path.length()];
- if (result.c_str()[0] == '/') {
- result = &result.c_str()[1];
- }
- return result;
-}
-
-string GetPackageName(const ComponentSpecificationMessage& message) {
- if (!message.package().empty()) {
- return message.package();
- }
- return "";
-}
-
-string GetPackagePath(const ComponentSpecificationMessage& message) {
- string package_path = GetPackageName(message);
- ReplaceSubString(package_path, ".", "/");
- return package_path;
-}
-
-string GetPackageNamespaceToken(const ComponentSpecificationMessage& message) {
- string package_token = GetPackageName(message);
- ReplaceSubString(package_token, ".", "::");
- return package_token;
-}
-
-string GetVersion(const ComponentSpecificationMessage& message,
- bool for_macro) {
- return GetVersionString(message.component_type_version_major(),
- message.component_type_version_minor(), for_macro);
-}
-
-int GetMajorVersion(const ComponentSpecificationMessage& message) {
- return message.component_type_version_major();
-}
-
-int GetMinorVersion(const ComponentSpecificationMessage& message) {
- return message.component_type_version_minor();
-}
-
-string GetComponentBaseName(const ComponentSpecificationMessage& message) {
- if (!message.component_name().empty()) {
- return (message.component_name() == "types"
- ? "types"
- : message.component_name().substr(1));
- } else
- return GetComponentName(message);
-}
-
-string GetComponentName(const ComponentSpecificationMessage& message) {
- if (!message.component_name().empty()) {
- return message.component_name();
- }
-
- string component_name = message.original_data_structure_name();
- while (!component_name.empty()
- && (std::isspace(component_name.back()) || component_name.back() == '*')) {
- component_name.pop_back();
- }
- const auto pos = component_name.find_last_of(" ");
- if (pos != std::string::npos) {
- component_name = component_name.substr(pos + 1);
- }
- return component_name;
-}
-
-FQName GetFQName(const ComponentSpecificationMessage& message) {
- return FQName(message.package(),
- GetVersionString(message.component_type_version_major(),
- message.component_type_version_minor()),
- GetComponentName(message));
-}
-
-string GetVarString(const string& var_name) {
- string var_str = var_name;
- for (size_t i = 0; i < var_name.length(); i++) {
- if (!isdigit(var_str[i]) && !isalpha(var_str[i])) {
- var_str[i] = '_';
- }
- }
- return var_str;
-}
-
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/VtsCompilerUtils.h b/compilation_tools/vtsc/VtsCompilerUtils.h
deleted file mode 100644
index 7e265a0..0000000
--- a/compilation_tools/vtsc/VtsCompilerUtils.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef VTS_COMPILATION_TOOLS_VTSC_CODE_UTILS_H_
-#define VTS_COMPILATION_TOOLS_VTSC_CODE_UTILS_H_
-
-#include <hidl-util/FQName.h>
-#include <sys/types.h>
-
-#include <string>
-
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-// Returns the component class name as a string
-extern string ComponentClassToString(int component_class);
-
-// Returns the component type name as a string
-extern string ComponentTypeToString(int component_type);
-
-// Returns the C/C++ variable type name of a given data type.
-extern string GetCppVariableType(const string primitive_type_string);
-
-// Returns the C/C++ basic variable type name of a given argument.
-string GetCppVariableType(const VariableSpecificationMessage& arg,
- bool generate_const = false);
-
-// Get the C/C++ instance type name of an argument.
-extern string GetCppInstanceType(
- const VariableSpecificationMessage& arg,
- const string& msg = string(),
- const ComponentSpecificationMessage* message = NULL);
-
-// Returns the name of a function which can convert the given arg to a protobuf.
-extern string GetConversionToProtobufFunctionName(
- VariableSpecificationMessage arg);
-
-// fs_mkdirs for VTS.
-extern int vts_fs_mkdirs(char* file_path, mode_t mode);
-
-// Replace the name space access symbol "::" in the string to "__" to prevent
-// mis-interpretation in generated cpp code.
-string ClearStringWithNameSpaceAccess(const string& str);
-
-// Returns a string which joins the given dir_path and file_name.
-string PathJoin(const char* dir_path, const char* file_name);
-
-// Returns a string which remove given base_path from file_path if included.
-string RemoveBaseDir(const string& file_path, const string& base_path);
-
-// Get the package name from the message if set. e.g. android.hardware.foo
-string GetPackageName(const ComponentSpecificationMessage& message);
-
-// Get the path of package from the message. e.g. android/hardware/for
-string GetPackagePath(const ComponentSpecificationMessage& message);
-
-// Get the namespace token of package from the message.
-// e.g. android::hardware::foo
-string GetPackageNamespaceToken(const ComponentSpecificationMessage& message);
-
-// Get component version string from the message. e.g. 1.0
-// If for_macro = true, return the version string with format like V1_0.
-std::string GetVersion(const ComponentSpecificationMessage& message,
- bool for_macro = false);
-
-// Get component major version from the message. e.g. 1.0 -> 1
-int GetMajorVersion(const ComponentSpecificationMessage& message);
-
-// Get component minor version from the message. e.g. 1.0 -> 0
-int GetMinorVersion(const ComponentSpecificationMessage& message);
-
-// Get the base name of component from the message. e.g. typs, Foo.
-std::string GetComponentBaseName(const ComponentSpecificationMessage& message);
-
-// Get the component name from message,e.g. IFoo, IFooCallback, types etc.
-string GetComponentName(const ComponentSpecificationMessage& message);
-
-// Generate the FQName of the given message..
-FQName GetFQName(const ComponentSpecificationMessage& message);
-
-// Generate a plain string from the name of given variable, replace any special
-// character (non alphabat or digital) with '_'
-// e.g. msg.test --> msg_test, msg[test] --> msg_test_
-string GetVarString(const string& var_name);
-
-} // namespace vts
-} // namespace android
-
-#endif // VTS_COMPILATION_TOOLS_VTSC_CODE_UTILS_H_
diff --git a/compilation_tools/vtsc/code_gen/CodeGenBase.cpp b/compilation_tools/vtsc/code_gen/CodeGenBase.cpp
deleted file mode 100644
index 9019698..0000000
--- a/compilation_tools/vtsc/code_gen/CodeGenBase.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "code_gen/CodeGenBase.h"
-
-#include <limits.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <cstdint>
-#include <fstream>
-#include <iostream>
-#include <sstream>
-#include <string>
-
-#include <hidl-util/Formatter.h>
-
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-#include "utils/InterfaceSpecUtil.h"
-
-#include "VtsCompilerUtils.h"
-#include "code_gen/driver/HalCodeGen.h"
-#include "code_gen/driver/HalHidlCodeGen.h"
-#include "code_gen/driver/LibSharedCodeGen.h"
-#include "code_gen/fuzzer/FuzzerCodeGenBase.h"
-#include "code_gen/fuzzer/HalHidlFuzzerCodeGen.h"
-#include "code_gen/profiler/ProfilerCodeGenBase.h"
-#include "code_gen/profiler/HalHidlProfilerCodeGen.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-CodeGenBase::CodeGenBase(const char* input_vts_file_path)
- : input_vts_file_path_(input_vts_file_path) {}
-
-CodeGenBase::~CodeGenBase() {}
-
-void Translate(VtsCompileMode mode,
- const char* input_vts_file_path,
- const char* output_header_dir_path,
- const char* output_cpp_file_path) {
- string output_header_file_path = string(output_header_dir_path) + "/"
- + string(input_vts_file_path);
- output_header_file_path = output_header_file_path + ".h";
-
- TranslateToFile(mode, input_vts_file_path, output_header_file_path.c_str(),
- android::vts::kHeader);
-
- TranslateToFile(mode, input_vts_file_path, output_cpp_file_path,
- android::vts::kSource);
-}
-
-void TranslateToFile(VtsCompileMode mode,
- const char* input_vts_file_path,
- const char* output_file_path,
- VtsCompileFileType file_type) {
- string output_cpp_file_path_str = string(output_file_path);
-
- size_t found;
- found = output_cpp_file_path_str.find_last_of("/");
- string output_dir = output_cpp_file_path_str.substr(0, found + 1);
-
- ComponentSpecificationMessage message;
- if (!ParseInterfaceSpec(input_vts_file_path, &message)) {
- cerr << __func__ << " can't parse " << input_vts_file_path << endl;
- exit(-1);
- }
-
- vts_fs_mkdirs(&output_dir[0], 0777);
-
- FILE* output_file = fopen(output_file_path, "w+");
- if (output_file == NULL) {
- cerr << __func__ << " could not open file " << output_file_path << endl;
- exit(-1);
- }
- Formatter out(output_file);
-
- if (mode == kDriver) {
- unique_ptr<CodeGenBase> code_generator;
- switch (message.component_class()) {
- case LIB_SHARED:
- code_generator.reset(new LibSharedCodeGen(input_vts_file_path));
- break;
- case HAL_HIDL:
- code_generator.reset(new HalHidlCodeGen(input_vts_file_path));
- break;
- default:
- cerr << "not yet supported component_class "
- << message.component_class();
- exit(-1);
- }
- if (file_type == kHeader) {
- code_generator->GenerateHeaderFile(out, message);
- } else if (file_type == kSource){
- code_generator->GenerateSourceFile(out, message);
- } else {
- cerr << __func__ << " doesn't support file_type = kBoth." << endl;
- exit(-1);
- }
- } else if (mode == kFuzzer) {
- unique_ptr<FuzzerCodeGenBase> fuzzer_generator;
- switch (message.component_class()) {
- case HAL_HIDL:
- {
- fuzzer_generator = make_unique<HalHidlFuzzerCodeGen>(message);
- break;
- }
- default:
- cerr << "not yet supported component_class "
- << message.component_class();
- exit(-1);
- }
- if (file_type == kHeader) {
- fuzzer_generator->GenerateHeaderFile(out);
- } else if (file_type == kSource){
- fuzzer_generator->GenerateSourceFile(out);
- } else {
- cerr << __func__ << " doesn't support file_type = kBoth." << endl;
- exit(-1);
- }
- } else if (mode == kProfiler) {
- unique_ptr<ProfilerCodeGenBase> profiler_generator;
- switch (message.component_class()) {
- case HAL_HIDL:
- profiler_generator.reset(new HalHidlProfilerCodeGen());
- break;
- default:
- cerr << "not yet supported component_class "
- << message.component_class();
- exit(-1);
- }
- if (file_type == kHeader) {
- profiler_generator->GenerateHeaderFile(out, message);
- } else if (file_type == kSource){
- profiler_generator->GenerateSourceFile(out, message);
- } else {
- cerr << __func__ << " doesn't support file_type = kBoth." << endl;
- exit(-1);
- }
- }
-}
-
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/code_gen/CodeGenBase.h b/compilation_tools/vtsc/code_gen/CodeGenBase.h
deleted file mode 100644
index 24d3695..0000000
--- a/compilation_tools/vtsc/code_gen/CodeGenBase.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_CODEGENBASE_H_
-#define VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_CODEGENBASE_H_
-
-#include <hidl-util/Formatter.h>
-#include <iostream>
-#include <sstream>
-#include <string>
-
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-enum VtsCompileMode {
- kDriver = 0,
- kProfiler,
- kFuzzer
-};
-
-// Specifies what kinds of files to generate.
-enum VtsCompileFileType {
- kBoth = 0,
- kHeader,
- kSource,
-};
-
-class CodeGenBase {
- public:
- explicit CodeGenBase(const char* input_vts_file_path);
- virtual ~CodeGenBase();
-
- // Generate both a C/C++ file and its header file.
- virtual void GenerateAll(Formatter& header_out, Formatter& source_out,
- const ComponentSpecificationMessage& message) = 0;
-
- // Generates source file.
- virtual void GenerateSourceFile(
- Formatter& out, const ComponentSpecificationMessage& message) = 0;
-
- // Generates header file.
- virtual void GenerateHeaderFile(
- Formatter& out, const ComponentSpecificationMessage& message) = 0;
-
- const char* input_vts_file_path() const {
- return input_vts_file_path_;
- }
-
- protected:
- const char* input_vts_file_path_;
-};
-
-// TODO(zhuoyao): move these methods to util files.
-// Translates the VTS proto file to C/C++ code and header files.
-void Translate(VtsCompileMode mode,
- const char* input_vts_file_path,
- const char* output_header_dir_path,
- const char* output_cpp_file_path);
-
-
-// Translates the VTS proto file to a C/C++ source or header file.
-void TranslateToFile(VtsCompileMode mode,
- const char* input_vts_file_path,
- const char* output_file_path,
- VtsCompileFileType file_type);
-
-} // namespace vts
-} // namespace android
-
-#endif // VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_CODEGENBASE_H_
diff --git a/compilation_tools/vtsc/code_gen/common/HalHidlCodeGenUtils.cpp b/compilation_tools/vtsc/code_gen/common/HalHidlCodeGenUtils.cpp
deleted file mode 100644
index 0590f2f..0000000
--- a/compilation_tools/vtsc/code_gen/common/HalHidlCodeGenUtils.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "HalHidlCodeGenUtils.h"
-
-namespace android {
-namespace vts {
-
-bool IsElidableType(const VariableType& type) {
- if (type == TYPE_SCALAR || type == TYPE_ENUM || type == TYPE_MASK ||
- type == TYPE_POINTER || type == TYPE_HIDL_INTERFACE ||
- type == TYPE_VOID) {
- return true;
- }
- return false;
-}
-
-bool IsConstType(const VariableType& type) {
- if (type == TYPE_ARRAY || type == TYPE_VECTOR || type == TYPE_REF ||
- type == TYPE_HIDL_INTERFACE) {
- return true;
- }
- if (IsElidableType(type)) {
- return false;
- }
- return true;
-}
-
-bool IsUserDefinedType(const VariableType& type) {
- if (type == TYPE_ENUM || type == TYPE_STRUCT || type == TYPE_UNION ||
- type == TYPE_SAFE_UNION) {
- return true;
- }
- return false;
-}
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/code_gen/common/HalHidlCodeGenUtils.h b/compilation_tools/vtsc/code_gen/common/HalHidlCodeGenUtils.h
deleted file mode 100644
index 2df2987..0000000
--- a/compilation_tools/vtsc/code_gen/common/HalHidlCodeGenUtils.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_COMMON_HALHIDLCODEGENUTILS_H_
-#define VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_COMMON_HALHIDLCODEGENUTILS_H_
-
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-namespace android {
-namespace vts {
-
-// Returns true iff type is elidable.
-bool IsElidableType(const VariableType& type);
-// Returns true if a HIDL type uses 'const' in its native C/C++ form.
-bool IsConstType(const VariableType& type);
-// Returns true iff type is a user defined type
-bool IsUserDefinedType(const VariableType& type);
-} // namespace vts
-} // namespace android
-
-#endif // VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_COMMON_HALHIDLCODEGENUTILS_H_
diff --git a/compilation_tools/vtsc/code_gen/driver/DriverCodeGenBase.cpp b/compilation_tools/vtsc/code_gen/driver/DriverCodeGenBase.cpp
deleted file mode 100644
index fc9e517..0000000
--- a/compilation_tools/vtsc/code_gen/driver/DriverCodeGenBase.cpp
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "code_gen/driver/DriverCodeGenBase.h"
-
-#include <iostream>
-#include <string>
-
-#include <hidl-util/Formatter.h>
-#include <hidl-util/FQName.h>
-
-#include "VtsCompilerUtils.h"
-#include "utils/InterfaceSpecUtil.h"
-#include "utils/StringUtil.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-void DriverCodeGenBase::GenerateAll(
- Formatter& header_out, Formatter& source_out,
- const ComponentSpecificationMessage& message) {
- GenerateHeaderFile(header_out, message);
- GenerateSourceFile(source_out, message);
-}
-
-void DriverCodeGenBase::GenerateHeaderFile(
- Formatter& out, const ComponentSpecificationMessage& message) {
- string component_name = GetComponentName(message);
- if (component_name.empty()) {
- cerr << __func__ << ":" << __LINE__ << " error component_name is empty"
- << "\n";
- exit(-1);
- }
-
- string component_name_token;
- if (message.component_class() == HAL_HIDL) {
- FQName component_fq_name = GetFQName(message);
- component_name_token = component_fq_name.tokenName();
- } else {
- string version = GetVersion(message, true);
- component_name_token =
- ComponentClassToString(message.component_class()) + "_" +
- ComponentTypeToString(message.component_type()) + "_" + version;
- }
- string fuzzer_extended_class_name;
- if (message.component_class() == HAL_HIDL) {
- fuzzer_extended_class_name = "FuzzerExtended_" + component_name_token;
- } else {
- fuzzer_extended_class_name = "FuzzerExtended_" + GetComponentName(message);
- }
-
- out << "#ifndef __VTS_DRIVER__" << component_name_token << "__\n";
- out << "#define __VTS_DRIVER__" << component_name_token << "__\n";
- out << "\n";
-
- out << "#undef LOG_TAG\n";
- out << "#define LOG_TAG \"" << fuzzer_extended_class_name << "\"\n";
-
- GenerateHeaderIncludeFiles(out, message, fuzzer_extended_class_name);
-
- GenerateOpenNameSpaces(out, message);
- GenerateClassHeader(out, message, fuzzer_extended_class_name);
- out << "\n\n";
- GenerateHeaderGlobalFunctionDeclarations(out, message);
- GenerateCloseNameSpaces(out, message);
- out << "#endif" << "\n";
-}
-
-void DriverCodeGenBase::GenerateSourceFile(
- Formatter& out, const ComponentSpecificationMessage& message) {
- string component_name = GetComponentName(message);
- if (component_name.empty()) {
- cerr << __func__ << ":" << __LINE__ << " error component_name is empty"
- << "\n";
- exit(-1);
- }
- FQName component_fq_name = GetFQName(message);
- string component_name_token = component_fq_name.tokenName();
- string fuzzer_extended_class_name;
- if (message.component_class() == HAL_HIDL) {
- fuzzer_extended_class_name = "FuzzerExtended_" + component_name_token;
- } else {
- fuzzer_extended_class_name = "FuzzerExtended_" + GetComponentName(message);
- }
- GenerateSourceIncludeFiles(out, message, fuzzer_extended_class_name);
- out << "\n\n";
- GenerateOpenNameSpaces(out, message);
- GenerateClassImpl(out, message, fuzzer_extended_class_name);
- GenerateCppBodyGlobalFunctions(out, message, fuzzer_extended_class_name);
- GenerateCloseNameSpaces(out, message);
-}
-
-void DriverCodeGenBase::GenerateClassHeader(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) {
- GenerateHeaderInterfaceImpl(out, message);
- out << "class " << fuzzer_extended_class_name << " : public DriverBase {"
- << "\n";
- out << " public:" << "\n";
-
- out.indent();
- GenerateClassConstructionFunction(out, message, fuzzer_extended_class_name);
- GeneratePublicFunctionDeclarations(out, message);
- out.unindent();
-
- out << " protected:" << "\n";
-
- out.indent();
- out << "bool Fuzz(FunctionSpecificationMessage* func_msg, void** result, "
- << "const string& callback_socket_name);\n";
- out << "bool CallFunction(const FunctionSpecificationMessage& func_msg, "
- << "const string& callback_socket_name, "
- << "FunctionSpecificationMessage* result_msg);\n";
- out << "bool VerifyResults(const FunctionSpecificationMessage& expected_result, "
- << "const FunctionSpecificationMessage& actual_result);\n";
- out << "bool GetAttribute(FunctionSpecificationMessage* func_msg, "
- << "void** result);\n";
-
- // Produce Fuzz method(s) for sub_struct(s).
- for (auto const& sub_struct : message.interface().sub_struct()) {
- GenerateFuzzFunctionForSubStruct(out, sub_struct, "_");
- }
- // Generate additional function declarations if any.
- GenerateAdditionalFuctionDeclarations(out, message,
- fuzzer_extended_class_name);
- out.unindent();
-
- out << " private:" << "\n";
-
- out.indent();
- // Generate declarations of private members if any.
- GeneratePrivateMemberDeclarations(out, message);
- out.unindent();
-
- out << "};\n";
-}
-
-void DriverCodeGenBase::GenerateClassImpl(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) {
- GenerateCppBodyInterfaceImpl(out, message, fuzzer_extended_class_name);
- GenerateCppBodyFuzzFunction(out, message, fuzzer_extended_class_name);
- GenerateCppBodyGetAttributeFunction(out, message, fuzzer_extended_class_name);
- GenerateDriverFunctionImpl(out, message, fuzzer_extended_class_name);
- GenerateVerificationFunctionImpl(out, message, fuzzer_extended_class_name);
-}
-
-void DriverCodeGenBase::GenerateHeaderIncludeFiles(Formatter& out,
- const ComponentSpecificationMessage& message, const string&) {
- for (auto const& header : message.header()) {
- out << "#include " << header << "\n";
- }
- out << "\n";
- out << "#include <log/log.h>"
- << "\n";
- out << "#include <stdarg.h>"
- << "\n";
- out << "#include <stdio.h>"
- << "\n";
- out << "#include <stdlib.h>"
- << "\n";
- out << "#include <string.h>"
- << "\n";
- out << "\n";
- out << "#include <driver_base/DriverBase.h>"
- << "\n";
- out << "#include <driver_base/DriverCallbackBase.h>"
- << "\n";
- out << "\n";
- if (message.component_class() == HAL_HIDL) {
- out << "#include <VtsDriverCommUtil.h>" << "\n";
- out << "\n";
- }
-}
-
-void DriverCodeGenBase::GenerateSourceIncludeFiles(Formatter& out,
- const ComponentSpecificationMessage& message, const string&) {
- if (message.component_class() != HAL_HIDL) {
- out << "#include \"" << input_vts_file_path_ << ".h\"\n";
- for (auto const& header : message.header()) {
- out << "#include " << header << "\n";
- }
- out << "#include \"vts_datatype.h\"" << "\n";
- } else {
- out << "#include \"" << GetPackagePath(message) << "/"
- << GetVersion(message) << "/" << GetComponentBaseName(message)
- << ".vts.h\"\n";
- }
- out << "#include \"vts_measurement.h\"" << "\n";
- out << "#include <android-base/logging.h>"
- << "\n";
-}
-
-void DriverCodeGenBase::GenerateHeaderGlobalFunctionDeclarations(
- Formatter& out, const ComponentSpecificationMessage& message,
- const bool print_extern_block) {
- string function_name_prefix = GetFunctionNamePrefix(message);
-
- if (print_extern_block) {
- out << "extern \"C\" {" << "\n";
- }
- out << "extern "
- << "android::vts::DriverBase* " << function_name_prefix << "();\n";
- if (print_extern_block) {
- out << "}" << "\n";
- }
-}
-
-void DriverCodeGenBase::GenerateCppBodyGlobalFunctions(
- Formatter& out, const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name, const bool print_extern_block) {
- string function_name_prefix = GetFunctionNamePrefix(message);
-
- if (print_extern_block) {
- out << "extern \"C\" {" << "\n";
- }
- out << "android::vts::DriverBase* " << function_name_prefix << "() {\n";
- out.indent();
- out << "return (android::vts::DriverBase*) "
- << "new android::vts::";
- out << fuzzer_extended_class_name << "();\n";
- out.unindent();
- out << "}\n\n";
- if (print_extern_block) {
- out << "}\n";
- }
-}
-
-void DriverCodeGenBase::GenerateFuzzFunctionForSubStruct(
- Formatter& out, const StructSpecificationMessage& message,
- const string& parent_path) {
- out << "bool Fuzz_" << parent_path << message.name()
- << "(FunctionSpecificationMessage* func_msg," << "\n";
- out << " void** result, const string& callback_socket_name);"
- << "\n";
-
- out << "bool GetAttribute_" << parent_path << message.name()
- << "(FunctionSpecificationMessage* /*func_msg*/,"
- << "\n";
- out << " void** /*result*/);"
- << "\n";
-
- for (auto const& sub_struct : message.sub_struct()) {
- GenerateFuzzFunctionForSubStruct(out, sub_struct,
- parent_path + message.name() + "_");
- }
-}
-
-void DriverCodeGenBase::GenerateDriverFunctionImpl(Formatter& out,
- const ComponentSpecificationMessage& /*message*/,
- const string& fuzzer_extended_class_name) {
- out << "bool " << fuzzer_extended_class_name
- << "::CallFunction(const FunctionSpecificationMessage&, const string&, "
- << "FunctionSpecificationMessage* ) {\n";
- out.indent();
- out << "/* No implementation yet. */\n";
- out << "return true;\n";
- out.unindent();
- out << "}\n";
-}
-
-void DriverCodeGenBase::GenerateVerificationFunctionImpl(Formatter& out,
- const ComponentSpecificationMessage& /*message*/,
- const string& fuzzer_extended_class_name) {
- out << "bool " << fuzzer_extended_class_name
- << "::VerifyResults(const FunctionSpecificationMessage&, "
- << "const FunctionSpecificationMessage&) {\n";
- out.indent();
- out << "/* No implementation yet. */\n";
- out << "return true;\n";
- out.unindent();
- out << "}\n";
-}
-
-void DriverCodeGenBase::GenerateNamespaceName(
- Formatter& out, const ComponentSpecificationMessage& message) {
- if (message.component_class() == HAL_HIDL && message.has_package()) {
- out << GetPackageNamespaceToken(message)
- << "::" << GetVersion(message, true);
- } else {
- cerr << __func__ << ":" << __LINE__ << " no namespace" << "\n";
- exit(-1);
- }
-}
-
-void DriverCodeGenBase::GenerateOpenNameSpaces(Formatter& out,
- const ComponentSpecificationMessage& message) {
- if (message.component_class() == HAL_HIDL && message.has_package()) {
- out << "using namespace ";
- GenerateNamespaceName(out, message);
- out << ";" << "\n";
- }
-
- out << "namespace android {" << "\n";
- out << "namespace vts {" << "\n";
-}
-
-void DriverCodeGenBase::GenerateCloseNameSpaces(Formatter& out,
- const ComponentSpecificationMessage& /*message*/) {
- out << "} // namespace vts" << "\n";
- out << "} // namespace android" << "\n";
-}
-
-void DriverCodeGenBase::GenerateCodeToStartMeasurement(Formatter& out) {
- out << "VtsMeasurement vts_measurement;" << "\n";
- out << "vts_measurement.Start();" << "\n";
-}
-
-void DriverCodeGenBase::GenerateCodeToStopMeasurement(Formatter& out) {
- out << "vector<float>* measured = vts_measurement.Stop();" << "\n";
- out << "LOG(INFO) << \"time \" << (*measured)[0];"
- << "\n";
-}
-
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/code_gen/driver/DriverCodeGenBase.h b/compilation_tools/vtsc/code_gen/driver/DriverCodeGenBase.h
deleted file mode 100644
index 374770c..0000000
--- a/compilation_tools/vtsc/code_gen/driver/DriverCodeGenBase.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_DRIVER_CODEGENBASE_H_
-#define VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_DRIVER_CODEGENBASE_H_
-
-#include <string>
-
-#include <hidl-util/Formatter.h>
-#include <hidl-util/FQName.h>
-
-#include "code_gen/CodeGenBase.h"
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-class DriverCodeGenBase : public CodeGenBase {
- public:
- explicit DriverCodeGenBase(const char* input_vts_file_path)
- : CodeGenBase(input_vts_file_path) {}
-
- // Generate both a C/C++ file and its header file.
- virtual void GenerateAll(Formatter& header_out, Formatter& source_out,
- const ComponentSpecificationMessage& message);
-
- // Generates source file.
- virtual void GenerateSourceFile(
- Formatter& out, const ComponentSpecificationMessage& message);
-
- // Generates header file.
- virtual void GenerateHeaderFile(
- Formatter& out, const ComponentSpecificationMessage& message);
-
- protected:
-
- // Generates header code for a specific class.
- virtual void GenerateClassHeader(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name);
-
- // Generates source code for a specific class.
- virtual void GenerateClassImpl(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name);
-
- // Generates code for Fuzz(...) function body.
- virtual void GenerateCppBodyFuzzFunction(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) = 0;
-
- // Generates code for GetAttribute(...) function body.
- virtual void GenerateCppBodyGetAttributeFunction(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) = 0;
-
- // Generates code for CallFuction(...) function body.
- virtual void GenerateDriverFunctionImpl(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name);
-
- // Generates code for VerifyResults(...) function body.
- virtual void GenerateVerificationFunctionImpl(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name);
-
- // Generates C/C++ code for interface implemetation class.
- virtual void GenerateCppBodyInterfaceImpl(
- Formatter& /*out*/, const ComponentSpecificationMessage& /*message*/,
- const string& /*fuzzer_extended_class_name*/) {};
-
- // Generates header code for interface impl class.
- virtual void GenerateHeaderInterfaceImpl(
- Formatter& /*out*/, const ComponentSpecificationMessage& /*message*/) {};
-
- // Generates header code for construction function.
- virtual void GenerateClassConstructionFunction(Formatter& /*out*/,
- const ComponentSpecificationMessage& /*message*/,
- const string& /*fuzzer_extended_class_name*/) {};
-
- // Generates header code for additional function declarations if any.
- virtual void GenerateAdditionalFuctionDeclarations(Formatter& /*out*/,
- const ComponentSpecificationMessage& /*message*/,
- const string& /*fuzzer_extended_class_name*/) {};
-
- // Generates header code to declare the C/C++ global functions.
- virtual void GenerateHeaderGlobalFunctionDeclarations(Formatter& out,
- const ComponentSpecificationMessage& message,
- const bool print_extern_block = true);
-
- // Generates code for the bodies of the C/C++ global functions.
- virtual void GenerateCppBodyGlobalFunctions(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name,
- const bool print_extern_block = true);
-
- // Generates header code for include declarations.
- virtual void GenerateHeaderIncludeFiles(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name);
-
- // Generates source code for include declarations.
- virtual void GenerateSourceIncludeFiles(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name);
-
- // Generates header code for public function declarations if any.
- virtual void GeneratePublicFunctionDeclarations(
- Formatter& /*out*/, const ComponentSpecificationMessage& /*message*/) {};
-
- // Generates header code for private member declarations if any.
- virtual void GeneratePrivateMemberDeclarations(Formatter& /*out*/,
- const ComponentSpecificationMessage& /*message*/) {};
-
- //********** Utility functions *****************
- // Generates the namespace name of a HIDL component, crashes otherwise.
- void GenerateNamespaceName(
- Formatter& out, const ComponentSpecificationMessage& message);
-
- // Generates code that opens the default namespaces.
- void GenerateOpenNameSpaces(
- Formatter& out, const ComponentSpecificationMessage& message);
-
- // Generates code that closes the default namespaces.
- void GenerateCloseNameSpaces(Formatter& out,
- const ComponentSpecificationMessage& message);
-
- // Generates code that starts the measurement.
- void GenerateCodeToStartMeasurement(Formatter& out);
-
- // Generates code that stops the measurement.
- void GenerateCodeToStopMeasurement(Formatter& out);
-
- void GenerateFuzzFunctionForSubStruct(
- Formatter& out, const StructSpecificationMessage& message,
- const string& parent_path);
-};
-
-} // namespace vts
-} // namespace android
-
-#endif // VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_DRIVER_CODEGENBASE_H_
diff --git a/compilation_tools/vtsc/code_gen/driver/HalCodeGen.cpp b/compilation_tools/vtsc/code_gen/driver/HalCodeGen.cpp
deleted file mode 100644
index 2b556bd..0000000
--- a/compilation_tools/vtsc/code_gen/driver/HalCodeGen.cpp
+++ /dev/null
@@ -1,903 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "code_gen/driver/HalCodeGen.h"
-
-#include <iostream>
-#include <string>
-
-#include "VtsCompilerUtils.h"
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-#include "utils/InterfaceSpecUtil.h"
-#include "utils/StringUtil.h"
-
-using namespace std;
-using namespace android;
-
-namespace android {
-namespace vts {
-
-const char* const HalCodeGen::kInstanceVariableName = "device_";
-
-void HalCodeGen::GenerateCppBodyInterfaceImpl(
- Formatter& out, const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) {
- bool first_callback = true;
-
- for (int i = 0; i < message.interface().attribute_size(); i++) {
- const VariableSpecificationMessage& attribute = message.interface().attribute(i);
- if (attribute.type() != TYPE_FUNCTION_POINTER || !attribute.is_callback()) {
- continue;
- }
- string name =
- "vts_callback_" + fuzzer_extended_class_name + "_" + attribute.name();
- if (first_callback) {
- out << "static string callback_socket_name_;" << "\n";
- first_callback = false;
- }
- out << "\n";
- out << "class " << name << " : public DriverCallbackBase {"
- << "\n";
- out << " public:" << "\n";
- out.indent();
- out << name << "(const string& callback_socket_name) {" << "\n";
- out.indent();
- out << "callback_socket_name_ = callback_socket_name;" << "\n";
- out.unindent();
- out << "}" << "\n";
-
- int primitive_format_index = 0;
- for (const FunctionPointerSpecificationMessage& func_pt_spec :
- attribute.function_pointer()) {
- const string& callback_name = func_pt_spec.function_name();
- // TODO: callback's return value is assumed to be 'void'.
- out << "\n";
- out << "static ";
- bool has_return_value = false;
- if (!func_pt_spec.has_return_type() ||
- !func_pt_spec.return_type().has_type() ||
- func_pt_spec.return_type().type() == TYPE_VOID) {
- out << "void" << "\n";
- } else if (func_pt_spec.return_type().type() == TYPE_PREDEFINED) {
- out << func_pt_spec.return_type().predefined_type();
- has_return_value = true;
- } else {
- cerr << __func__ << ":" << __LINE__ << " ERROR unknown type "
- << func_pt_spec.return_type().type() << "\n";
- exit(-1);
- }
- out << " " << callback_name << "(";
- int primitive_type_index;
- primitive_type_index = 0;
- for (const auto& arg : func_pt_spec.arg()) {
- if (primitive_type_index != 0) {
- out << ", ";
- }
- if (arg.is_const()) {
- out << "const ";
- }
- if (arg.type() == TYPE_SCALAR) {
- /*
- if (arg.scalar_type() == "pointer") {
- out << definition.aggregate_value(
- primitive_format_index).primitive_name(primitive_type_index)
- << " ";
- } */
- if (arg.scalar_type() == "char_pointer") {
- out << "char* ";
- } else if (arg.scalar_type() == "uchar_pointer") {
- out << "unsigned char* ";
- } else if (arg.scalar_type() == "bool_t") {
- out << "bool ";
- } else if (arg.scalar_type() == "int8_t" ||
- arg.scalar_type() == "uint8_t" ||
- arg.scalar_type() == "int16_t" ||
- arg.scalar_type() == "uint16_t" ||
- arg.scalar_type() == "int32_t" ||
- arg.scalar_type() == "uint32_t" ||
- arg.scalar_type() == "size_t" ||
- arg.scalar_type() == "int64_t" ||
- arg.scalar_type() == "uint64_t") {
- out << arg.scalar_type() << " ";
- } else if (arg.scalar_type() == "void_pointer") {
- out << "void*";
- } else {
- cerr << __func__ << " unsupported scalar type " << arg.scalar_type()
- << "\n";
- exit(-1);
- }
- } else if (arg.type() == TYPE_PREDEFINED) {
- out << arg.predefined_type() << " ";
- } else {
- cerr << __func__ << " unsupported type" << "\n";
- exit(-1);
- }
- out << "arg" << primitive_type_index;
- primitive_type_index++;
- }
- out << ") {" << "\n";
- out.indent();
-#if USE_VAARGS
- out << " const char fmt[] = \""
- << definition.primitive_format(primitive_format_index) << "\";"
- << "\n";
- out << " va_list argp;" << "\n";
- out << " const char* p;" << "\n";
- out << " int i;" << "\n";
- out << " char* s;" << "\n";
- out << " char fmtbuf[256];" << "\n";
- out << "\n";
- out << " va_start(argp, fmt);" << "\n";
- out << "\n";
- out << " for (p = fmt; *p != '\\0'; p++) {" << "\n";
- out << " if (*p != '%') {" << "\n";
- out << " putchar(*p);" << "\n";
- out << " continue;" << "\n";
- out << " }" << "\n";
- out << " switch (*++p) {" << "\n";
- out << " case 'c':" << "\n";
- out << " i = va_arg(argp, int);" << "\n";
- out << " putchar(i);" << "\n";
- out << " break;" << "\n";
- out << " case 'd':" << "\n";
- out << " i = va_arg(argp, int);" << "\n";
- out << " s = itoa(i, fmtbuf, 10);" << "\n";
- out << " fputs(s, stdout);" << "\n";
- out << " break;" << "\n";
- out << " case 's':" << "\n";
- out << " s = va_arg(argp, char *);" << "\n";
- out << " fputs(s, stdout);" << "\n";
- out << " break;" << "\n";
- // out << " case 'p':
- out << " case '%':" << "\n";
- out << " putchar('%');" << "\n";
- out << " break;" << "\n";
- out << " }" << "\n";
- out << " }" << "\n";
- out << " va_end(argp);" << "\n";
-#endif
- // TODO: check whether bytes is set and handle properly if not.
- out << "AndroidSystemCallbackRequestMessage callback_message;"
- << "\n";
- out << "callback_message.set_id(GetCallbackID(\"" << callback_name
- << "\"));" << "\n";
-
- primitive_type_index = 0;
- for (const auto& arg : func_pt_spec.arg()) {
- out << "VariableSpecificationMessage* var_msg" << primitive_type_index
- << " = callback_message.add_arg();" << "\n";
- if (arg.type() == TYPE_SCALAR) {
- out << "var_msg" << primitive_type_index << "->set_type("
- << "TYPE_SCALAR);" << "\n";
- out << "var_msg" << primitive_type_index << "->set_scalar_type(\""
- << arg.scalar_type() << "\");" << "\n";
- out << "var_msg" << primitive_type_index << "->mutable_scalar_value()";
- if (arg.scalar_type() == "bool_t") {
- out << "->set_" << arg.scalar_type() << "("
- << arg.scalar_value().bool_t() << ");" << "\n";
- } else if (arg.scalar_type() == "int8_t") {
- out << "->set_" << arg.scalar_type() << "("
- << arg.scalar_value().int8_t() << ");" << "\n";
- } else if (arg.scalar_type() == "uint8_t") {
- out << "->set_" << arg.scalar_type() << "("
- << arg.scalar_value().uint8_t() << ");" << "\n";
- } else if (arg.scalar_type() == "int16_t") {
- out << "->set_" << arg.scalar_type() << "("
- << arg.scalar_value().int16_t() << ");" << "\n";
- } else if (arg.scalar_type() == "uint16_t") {
- out << "->set_" << arg.scalar_type() << "("
- << arg.scalar_value().uint16_t() << ");" << "\n";
- } else if (arg.scalar_type() == "int32_t") {
- out << "->set_" << arg.scalar_type() << "("
- << arg.scalar_value().int32_t() << ");" << "\n";
- } else if (arg.scalar_type() == "uint32_t") {
- out << "->set_" << arg.scalar_type() << "("
- << arg.scalar_value().uint32_t() << ");" << "\n";
- } else if (arg.scalar_type() == "size_t") {
- out << "->set_uint32_t("
- << arg.scalar_value().uint32_t() << ");" << "\n";
- } else if (arg.scalar_type() == "int64_t") {
- out << "->set_" << arg.scalar_type() << "("
- << arg.scalar_value().int64_t() << ");" << "\n";
- } else if (arg.scalar_type() == "uint64_t") {
- out << "->set_" << arg.scalar_type() << "("
- << arg.scalar_value().uint64_t() << ");" << "\n";
- } else if (arg.scalar_type() == "char_pointer") {
- // pointer value is not meaning when it is passed to another machine.
- out << "->set_" << arg.scalar_type() << "("
- << arg.scalar_value().char_pointer() << ");" << "\n";
- } else if (arg.scalar_type() == "uchar_pointer") {
- // pointer value is not meaning when it is passed to another machine.
- out << "->set_" << arg.scalar_type() << "("
- << arg.scalar_value().uchar_pointer() << ");" << "\n";
- } else if (arg.scalar_type() == "void_pointer") {
- // pointer value is not meaning when it is passed to another machine.
- out << "->set_" << arg.scalar_type() << "("
- << arg.scalar_value().void_pointer() << ");" << "\n";
- } else {
- cerr << __func__ << " unsupported scalar type " << arg.scalar_type()
- << "\n";
- exit(-1);
- }
- } else if (arg.type() == TYPE_PREDEFINED) {
- out << "var_msg" << primitive_type_index << "->set_type("
- << "TYPE_PREDEFINED);" << "\n";
- // TODO: actually handle such case.
- } else {
- cerr << __func__ << " unsupported type" << "\n";
- exit(-1);
- }
- primitive_type_index++;
- }
- out << "RpcCallToAgent(callback_message, callback_socket_name_);"
- << "\n";
- if (has_return_value) {
- // TODO: consider actual return type.
- out << "return NULL;";
- }
- out.unindent();
- out << "}" << "\n";
- out << "\n";
-
- primitive_format_index++;
- }
- out << "\n";
- out.unindent();
- out << " private:" << "\n";
- out << "};" << "\n";
- out << "\n";
- }
-}
-
-void HalCodeGen::GenerateCppBodyFuzzFunction(
- Formatter& out, const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) {
- for (auto const& sub_struct : message.interface().sub_struct()) {
- GenerateCppBodyFuzzFunction(out, sub_struct, fuzzer_extended_class_name,
- message.original_data_structure_name(),
- sub_struct.is_pointer() ? "->" : ".");
- }
-
- out << "bool " << fuzzer_extended_class_name << "::Fuzz(" << "\n";
- out << " FunctionSpecificationMessage* func_msg," << "\n";
- out << " void** result, const string& callback_socket_name) {" << "\n";
- out.indent();
- out << "const char* func_name = func_msg->name().c_str();" << "\n";
- out << "LOG(INFO) << \" '\" << func_name << \"'\";"
- << "\n";
-
- // to call another function if it's for a sub_struct
- if (message.interface().sub_struct().size() > 0) {
- out << "if (func_msg->parent_path().length() > 0) {" << "\n";
- out.indent();
- for (auto const& sub_struct : message.interface().sub_struct()) {
- GenerateSubStructFuzzFunctionCall(out, sub_struct, "");
- }
- out.unindent();
- out << "}" << "\n";
- }
-
- out << message.original_data_structure_name()
- << "* local_device = ";
- out << "reinterpret_cast<" << message.original_data_structure_name()
- << "*>(" << kInstanceVariableName << ");" << "\n";
-
- out << "if (local_device == NULL) {" << "\n";
- out.indent();
- out << "LOG(INFO) << \"use hmi \" << (uint64_t)hmi_;"
- << "\n";
- out << "local_device = reinterpret_cast<"
- << message.original_data_structure_name() << "*>(hmi_);\n";
- out.unindent();
- out << "}" << "\n";
- out << "if (local_device == NULL) {" << "\n";
- out.indent();
- out << "LOG(ERROR) << \"both device_ and hmi_ are NULL.\";\n";
- out << "return false;" << "\n";
- out.unindent();
- out << "}" << "\n";
-
- for (auto const& api : message.interface().api()) {
- out << "if (!strcmp(func_name, \"" << api.name() << "\")) {" << "\n";
- out.indent();
- out << "LOG(INFO) << \"match\" <<;\n";
- // args - definition;
- int arg_count = 0;
- for (auto const& arg : api.arg()) {
- if (arg.is_callback()) { // arg.type() isn't always TYPE_FUNCTION_POINTER
- string name = "vts_callback_" + fuzzer_extended_class_name + "_" +
- arg.predefined_type(); // TODO - check to make sure name
- // is always correct
- if (name.back() == '*') name.pop_back();
- out << name << "* arg" << arg_count << "callback = new ";
- out << name << "(callback_socket_name);" << "\n";
- out << "arg" << arg_count << "callback->Register(func_msg->arg("
- << arg_count << "));" << "\n";
-
- out << GetCppVariableType(arg) << " ";
- out << "arg" << arg_count << " = (" << GetCppVariableType(arg)
- << ") malloc(sizeof(" << GetCppVariableType(arg) << "));"
- << "\n";
- // TODO: think about how to free the malloced callback data structure.
- // find the spec.
- bool found = false;
- cout << name << "\n";
- for (auto const& attribute : message.interface().attribute()) {
- if (attribute.type() == TYPE_FUNCTION_POINTER &&
- attribute.is_callback()) {
- string target_name = "vts_callback_" + fuzzer_extended_class_name +
- "_" + attribute.name();
- cout << "compare" << "\n";
- cout << target_name << "\n";
- if (name == target_name) {
- if (attribute.function_pointer_size() > 1) {
- for (auto const& func_pt : attribute.function_pointer()) {
- out << "arg" << arg_count << "->"
- << func_pt.function_name() << " = arg" << arg_count
- << "callback->" << func_pt.function_name() << ";"
- << "\n";
- }
- } else {
- out << "arg" << arg_count << " = arg" << arg_count
- << "callback->" << attribute.name() << ";" << "\n";
- }
- found = true;
- break;
- }
- }
- }
- if (!found) {
- cerr << __func__ << " ERROR callback definition missing for " << name
- << " of " << api.name() << "\n";
- exit(-1);
- }
- } else {
- out << GetCppVariableType(arg) << " ";
- out << "arg" << arg_count << " = ";
- if (arg_count == 0 && arg.type() == TYPE_PREDEFINED &&
- !strncmp(arg.predefined_type().c_str(),
- message.original_data_structure_name().c_str(),
- message.original_data_structure_name().length())) {
- out << "reinterpret_cast<" << GetCppVariableType(arg) << ">("
- << kInstanceVariableName << ")";
- } else {
- std::stringstream msg_ss;
- msg_ss << "func_msg->arg(" << arg_count << ")";
- string msg = msg_ss.str();
-
- if (arg.type() == TYPE_SCALAR) {
- out << "(" << msg << ".type() == TYPE_SCALAR)? ";
- if (arg.scalar_type() == "pointer" ||
- arg.scalar_type() == "pointer_pointer" ||
- arg.scalar_type() == "char_pointer" ||
- arg.scalar_type() == "uchar_pointer" ||
- arg.scalar_type() == "void_pointer" ||
- arg.scalar_type() == "function_pointer") {
- out << "reinterpret_cast<" << GetCppVariableType(arg) << ">";
- }
- out << "(" << msg << ".scalar_value()";
-
- if (arg.scalar_type() == "bool_t" ||
- arg.scalar_type() == "int32_t" ||
- arg.scalar_type() == "uint32_t" ||
- arg.scalar_type() == "int64_t" ||
- arg.scalar_type() == "uint64_t" ||
- arg.scalar_type() == "int16_t" ||
- arg.scalar_type() == "uint16_t" ||
- arg.scalar_type() == "int8_t" ||
- arg.scalar_type() == "uint8_t" ||
- arg.scalar_type() == "float_t" ||
- arg.scalar_type() == "double_t") {
- out << "." << arg.scalar_type() << "() ";
- } else if (arg.scalar_type() == "pointer" ||
- arg.scalar_type() == "char_pointer" ||
- arg.scalar_type() == "uchar_pointer" ||
- arg.scalar_type() == "void_pointer") {
- out << ".pointer() ";
- } else {
- cerr << __func__ << " ERROR unsupported scalar type "
- << arg.scalar_type() << "\n";
- exit(-1);
- }
- out << ") : ";
- } else {
- cerr << __func__ << " unknown type " << msg << "\n";
- }
-
- out << "( (" << msg << ".type() == TYPE_PREDEFINED || " << msg
- << ".type() == TYPE_STRUCT || " << msg
- << ".type() == TYPE_SCALAR)? ";
- out << GetCppInstanceType(arg, msg);
- out << " : " << GetCppInstanceType(arg) << " )";
- // TODO: use the given message and call a lib function which converts
- // a message to a C/C++ struct.
- }
- out << ";" << "\n";
- }
- out << "LOG(INFO) << \"arg" << arg_count << " = \" << arg" << arg_count
- << ";\n";
- arg_count++;
- }
-
- // actual function call
- GenerateCodeToStartMeasurement(out);
- out << "LOG(INFO) << \"hit2.\" << device_;\n";
-
- // checks whether the function is actually defined.
- out << "if (reinterpret_cast<"
- << message.original_data_structure_name() << "*>(local_device)->"
- << api.name() << " == NULL" << ") {" << "\n";
- out.indent();
- out << "LOG(ERROR) << \"api not set.\";\n";
- // todo: consider throwing an exception at least a way to tell more
- // specifically to the caller.
- out << "return false;" << "\n";
- out.unindent();
- out << "}" << "\n";
-
- out << "LOG(INFO) << \"Call an API.\";\n";
- out << "LOG(INFO) << \"local_device = \" << local_device;\n";
-
- if (!api.has_return_type() || api.return_type().type() == TYPE_VOID) {
- out << "*result = NULL;" << "\n";
- } else {
- out << "*result = const_cast<void*>(reinterpret_cast<const void*>(";
- }
- out << "local_device->" << api.name() << "(";
- if (arg_count > 0) out << "\n";
-
- for (int index = 0; index < arg_count; index++) {
- out << "arg" << index;
- if (index != (arg_count - 1)) {
- out << "," << "\n";
- }
- }
-
- if (api.has_return_type() && api.return_type().type() != TYPE_VOID) {
- out << "))";
- }
- out << ");" << "\n";
- GenerateCodeToStopMeasurement(out);
- out << "LOG(INFO) << \"called\";\n";
-
- // Copy the output (call by pointer or reference cases).
- arg_count = 0;
- for (auto const& arg : api.arg()) {
- if (arg.is_output()) {
- // TODO check the return value
- out << GetConversionToProtobufFunctionName(arg) << "(arg"
- << arg_count << ", "
- << "func_msg->mutable_arg(" << arg_count << "));" << "\n";
- }
- arg_count++;
- }
-
- out << "return true;" << "\n";
- out.unindent();
- out << "}" << "\n";
- }
- // TODO: if there were pointers, free them.
- out << "LOG(ERROR) << \"func not found\";\n";
- out << "return false;" << "\n";
- out.unindent();
- out << "}" << "\n";
-}
-
-void HalCodeGen::GenerateCppBodyFuzzFunction(
- Formatter& out, const StructSpecificationMessage& message,
- const string& fuzzer_extended_class_name,
- const string& original_data_structure_name, const string& parent_path) {
- for (auto const& sub_struct : message.sub_struct()) {
- GenerateCppBodyFuzzFunction(
- out, sub_struct, fuzzer_extended_class_name,
- original_data_structure_name,
- parent_path + message.name() + (sub_struct.is_pointer() ? "->" : "."));
- }
-
- string parent_path_printable(parent_path);
- ReplaceSubString(parent_path_printable, "->", "_");
- replace(parent_path_printable.begin(), parent_path_printable.end(), '.', '_');
-
- out << "bool " << fuzzer_extended_class_name << "::Fuzz_"
- << parent_path_printable + message.name() << "(" << "\n";
- out << "FunctionSpecificationMessage* func_msg," << "\n";
- out << "void** result, const string& callback_socket_name) {" << "\n";
- out.indent();
- out << "const char* func_name = func_msg->name().c_str();" << "\n";
- out << "LOG(INFO) << func_name;\n";
-
- bool is_open;
- for (auto const& api : message.api()) {
- is_open = false;
- if ((parent_path_printable + message.name()) == "_common_methods" &&
- api.name() == "open") {
- is_open = true;
- }
-
- out << "if (!strcmp(func_name, \"" << api.name() << "\")) {" << "\n";
- out.indent();
-
- out << original_data_structure_name << "* local_device = ";
- out << "reinterpret_cast<" << original_data_structure_name << "*>("
- << kInstanceVariableName << ");" << "\n";
-
- out << "if (local_device == NULL) {" << "\n";
- out.indent();
- out << "LOG(INFO) << \"use hmi\";\n";
- out << "local_device = reinterpret_cast<"
- << original_data_structure_name << "*>(hmi_);" << "\n";
- out.unindent();
- out << "}" << "\n";
- out << "if (local_device == NULL) {" << "\n";
- out.indent();
- out << "LOG(ERROR) << \"both device_ and hmi_ are NULL.\";\n";
- out << "return false;" << "\n";
- out.unindent();
- out << "}" << "\n";
-
- // args - definition;
- int arg_count = 0;
- for (auto const& arg : api.arg()) {
- out << GetCppVariableType(arg) << " ";
- out << "arg" << arg_count << " = ";
- if (arg_count == 0 && arg.type() == TYPE_PREDEFINED &&
- !strncmp(arg.predefined_type().c_str(),
- original_data_structure_name.c_str(),
- original_data_structure_name.length())) {
- out << "reinterpret_cast<" << GetCppVariableType(arg) << ">("
- << kInstanceVariableName << ")";
- } else {
- std::stringstream msg_ss;
- msg_ss << "func_msg->arg(" << arg_count << ")";
- string msg = msg_ss.str();
-
- if (arg.type() == TYPE_SCALAR) {
- out << "(" << msg << ".type() == TYPE_SCALAR && " << msg
- << ".scalar_value()";
- if (arg.scalar_type() == "pointer" ||
- arg.scalar_type() == "char_pointer" ||
- arg.scalar_type() == "uchar_pointer" ||
- arg.scalar_type() == "void_pointer" ||
- arg.scalar_type() == "function_pointer") {
- out << ".has_pointer())? ";
- out << "reinterpret_cast<" << GetCppVariableType(arg) << ">";
- } else {
- out << ".has_" << arg.scalar_type() << "())? ";
- }
- out << "(" << msg << ".scalar_value()";
-
- if (arg.scalar_type() == "int32_t" ||
- arg.scalar_type() == "uint32_t" ||
- arg.scalar_type() == "int64_t" ||
- arg.scalar_type() == "uint64_t" ||
- arg.scalar_type() == "int16_t" ||
- arg.scalar_type() == "uint16_t" ||
- arg.scalar_type() == "int8_t" || arg.scalar_type() == "uint8_t" ||
- arg.scalar_type() == "float_t" ||
- arg.scalar_type() == "double_t") {
- out << "." << arg.scalar_type() << "() ";
- } else if (arg.scalar_type() == "pointer" ||
- arg.scalar_type() == "char_pointer" ||
- arg.scalar_type() == "uchar_pointer" ||
- arg.scalar_type() == "function_pointer" ||
- arg.scalar_type() == "void_pointer") {
- out << ".pointer() ";
- } else {
- cerr << __func__ << " ERROR unsupported type " << arg.scalar_type()
- << "\n";
- exit(-1);
- }
- out << ") : ";
- }
-
- if (is_open) {
- if (arg_count == 0) {
- out << "hmi_;" << "\n";
- } else if (arg_count == 1) {
- out << "((hmi_) ? const_cast<char*>(hmi_->name) : NULL)" << "\n";
- } else if (arg_count == 2) {
- out << "(struct hw_device_t**) &device_" << "\n";
- } else {
- cerr << __func__ << " ERROR additional args for open " << arg_count
- << "\n";
- exit(-1);
- }
- } else {
- out << "( (" << msg << ".type() == TYPE_PREDEFINED || " << msg
- << ".type() == TYPE_STRUCT || " << msg
- << ".type() == TYPE_SCALAR)? ";
- out << GetCppInstanceType(arg, msg);
- out << " : " << GetCppInstanceType(arg) << " )";
- // TODO: use the given message and call a lib function which converts
- // a message to a C/C++ struct.
- }
- }
- out << ";" << "\n";
- out << "LOG(INFO) << \"arg" << arg_count << " = \" << arg" << arg_count
- << "\n\n";
- arg_count++;
- }
-
- // actual function call
- GenerateCodeToStartMeasurement(out);
- out << "LOG(INFO) << \"hit2.\" << device_;\n";
-
- out << "if (reinterpret_cast<" << original_data_structure_name
- << "*>(local_device)" << parent_path << message.name() << "->"
- << api.name() << " == NULL";
- out << ") {" << "\n";
- out.indent();
- out << "LOG(ERROR) << \"api not set.\";\n";
- // todo: consider throwing an exception at least a way to tell more
- // specifically to the caller.
- out << "return false;" << "\n";
- out.unindent();
- out << "}" << "\n";
-
- out << "LOG(INFO) << \"Call an API.\";\n";
- if (!api.has_return_type() || api.return_type().type() == TYPE_VOID) {
- out << "*result = NULL;" << "\n";
- } else {
- out << "*result = const_cast<void*>(reinterpret_cast<const void*>(";
- }
- out << "local_device" << parent_path << message.name() << "->"
- << api.name() << "(";
- if (arg_count > 0) out << "\n";
-
- for (int index = 0; index < arg_count; index++) {
- out << "arg" << index;
- if (index != (arg_count - 1)) {
- out << "," << "\n";
- }
- }
- if (api.has_return_type() && api.return_type().type() != TYPE_VOID) {
- out << "))";
- }
- out << ");" << "\n";
- GenerateCodeToStopMeasurement(out);
- out << "LOG(INFO) << \"called\";\n";
-
- // Copy the output (call by pointer or reference cases).
- arg_count = 0;
- for (auto const& arg : api.arg()) {
- if (arg.is_output()) {
- // TODO check the return value
- out << GetConversionToProtobufFunctionName(arg) << "(arg"
- << arg_count << ", "
- << "func_msg->mutable_arg(" << arg_count << "));" << "\n";
- }
- arg_count++;
- }
-
- out << "return true;" << "\n";
- out.unindent();
- out << "}" << "\n";
- }
- // TODO: if there were pointers, free them.
- out << "return false;" << "\n";
- out.unindent();
- out << "}" << "\n";
-}
-
-void HalCodeGen::GenerateCppBodyGetAttributeFunction(
- Formatter& out, const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) {
- for (auto const& sub_struct : message.interface().sub_struct()) {
- GenerateCppBodyGetAttributeFunction(
- out, sub_struct, fuzzer_extended_class_name,
- message.original_data_structure_name(),
- sub_struct.is_pointer() ? "->" : ".");
- }
-
- out << "bool " << fuzzer_extended_class_name << "::GetAttribute(" << "\n";
- out << " FunctionSpecificationMessage* func_msg," << "\n";
- out << " void** result) {" << "\n";
- out.indent();
- out << "const char* func_name = func_msg->name().c_str();" << "\n";
- out << "LOG(INFO) << \" '\" << func_name << \"'\";\n";
-
- // to call another function if it's for a sub_struct
- if (message.interface().sub_struct().size() > 0) {
- out << " if (func_msg->parent_path().length() > 0) {" << "\n";
- out.indent();
- for (auto const& sub_struct : message.interface().sub_struct()) {
- GenerateSubStructGetAttributeFunctionCall(out, sub_struct, "");
- }
- out.unindent();
- out << "}" << "\n";
- }
-
- out << message.original_data_structure_name()
- << "* local_device = ";
- out << "reinterpret_cast<" << message.original_data_structure_name()
- << "*>(" << kInstanceVariableName << ");" << "\n";
-
- out << "if (local_device == NULL) {" << "\n";
- out.indent();
- out << "LOG(INFO) << \"use hmi \" << (uint64_t)hmi_;\n";
- out << "local_device = reinterpret_cast<"
- << message.original_data_structure_name() << "*>(hmi_);" << "\n";
- out.unindent();
- out << "}" << "\n";
- out << "if (local_device == NULL) {" << "\n";
- out.indent();
- out << "LOG(ERROR) << \"both device_ and hmi_ are NULL.\";\n";
- out << "return false;" << "\n";
- out.unindent();
- out << "}" << "\n";
-
- for (auto const& attribute : message.interface().attribute()) {
- if (attribute.type() == TYPE_SUBMODULE ||
- attribute.type() == TYPE_SCALAR) {
- out << "if (!strcmp(func_name, \"" << attribute.name() << "\")) {" << "\n";
- out.indent();
- out << "LOG(INFO) << \"match\";\n";
-
- // actual function call
- out << "LOG(INFO) << \"hit2.\" << device_ ;\n";
-
- out << "LOG(INFO) << \"ok. let's read attribute.\";\n";
- out << "*result = const_cast<void*>(reinterpret_cast<const void*>(";
- out << "local_device->" << attribute.name();
- out << "));" << "\n";
-
- out << "LOG(INFO) << \"got\";\n";
-
- out << "return true;" << "\n";
- out.unindent();
- out << "}" << "\n";
- }
- }
- // TODO: if there were pointers, free them.
- out << "LOG(ERROR) << \"attribute not found\";\n";
- out << "return false;" << "\n";
- out.unindent();
- out << "}" << "\n";
-}
-
-void HalCodeGen::GenerateCppBodyGetAttributeFunction(
- Formatter& out, const StructSpecificationMessage& message,
- const string& fuzzer_extended_class_name,
- const string& original_data_structure_name, const string& parent_path) {
- for (auto const& sub_struct : message.sub_struct()) {
- GenerateCppBodyGetAttributeFunction(
- out, sub_struct, fuzzer_extended_class_name,
- original_data_structure_name,
- parent_path + message.name() + (sub_struct.is_pointer() ? "->" : "."));
- }
-
- string parent_path_printable(parent_path);
- ReplaceSubString(parent_path_printable, "->", "_");
- replace(parent_path_printable.begin(), parent_path_printable.end(), '.', '_');
-
- out << "bool " << fuzzer_extended_class_name << "::GetAttribute_"
- << parent_path_printable + message.name() << "(" << "\n";
- out << " FunctionSpecificationMessage* func_msg," << "\n";
- out << " void** result) {" << "\n";
- out.indent();
- out << "const char* func_name = func_msg->name().c_str();" << "\n";
- out << "LOG(INFO) << func_name;\n";
-
- out << original_data_structure_name
- << "* local_device = ";
- out << "reinterpret_cast<" << original_data_structure_name
- << "*>(" << kInstanceVariableName << ");" << "\n";
-
- out << "if (local_device == NULL) {" << "\n";
- out.indent();
- out << " LOG(INFO) << \"use hmi \" << (uint64_t)hmi_;\n";
- out << " local_device = reinterpret_cast<"
- << original_data_structure_name << "*>(hmi_);" << "\n";
- out.unindent();
- out << "}" << "\n";
- out << "if (local_device == NULL) {" << "\n";
- out.indent();
- out << "LOG(ERROR) << \"both device_ and hmi_ are NULL.\";\n";
- out << "return false;" << "\n";
- out.unindent();
- out << "}" << "\n";
-
- for (auto const& attribute : message.attribute()) {
- if (attribute.type() == TYPE_SUBMODULE ||
- attribute.type() == TYPE_SCALAR) {
- out << "if (!strcmp(func_name, \"" << attribute.name() << "\")) {" << "\n";
- out.indent();
- out << "LOG(INFO) << \"match\";\n";
-
- // actual function call
- out << "LOG(INFO) << \"hit2.\" << device_;\n";
-
- out << "LOG(INFO) << \"ok. let's read attribute.\";\n";
- out << "*result = const_cast<void*>(reinterpret_cast<const void*>(";
- out << "local_device" << parent_path << message.name() << ".";
- // TODO: use parent's is_pointer()
- out << attribute.name();
- out << "));" << "\n";
-
- out << "LOG(INFO) << \"got\";\n";
-
- out << "return true;" << "\n";
- out.unindent();
- out << "}" << "\n";
- }
- }
- // TODO: if there were pointers, free them.
- out << "LOG(ERROR) << \"attribute not found\";\n";
- out << "return false;" << "\n";
- out.unindent();
- out << "}" << "\n";
-}
-
-void HalCodeGen::GenerateClassConstructionFunction(Formatter& out,
- const ComponentSpecificationMessage& /*message*/,
- const string& fuzzer_extended_class_name) {
- out << fuzzer_extended_class_name << "() : DriverBase(HAL_CONVENTIONAL) {}\n";
-}
-
-void HalCodeGen::GenerateSubStructFuzzFunctionCall(
- Formatter& out, const StructSpecificationMessage& message,
- const string& parent_path) {
- string current_path(parent_path);
- if (current_path.length() > 0) {
- current_path += ".";
- }
- current_path += message.name();
-
- string current_path_printable(current_path);
- replace(current_path_printable.begin(), current_path_printable.end(), '.',
- '_');
-
- out << "if (func_msg->parent_path() == \"" << current_path << "\") {"
- << "\n";
- out.indent();
- out << "return Fuzz__" << current_path_printable
- << "(func_msg, result, callback_socket_name);" << "\n";
- out.unindent();
- out << "}" << "\n";
-
- for (auto const& sub_struct : message.sub_struct()) {
- GenerateSubStructFuzzFunctionCall(out, sub_struct, current_path);
- }
-}
-
-void HalCodeGen::GenerateSubStructGetAttributeFunctionCall(
- Formatter& out, const StructSpecificationMessage& message,
- const string& parent_path) {
- string current_path(parent_path);
- if (current_path.length() > 0) {
- current_path += ".";
- }
- current_path += message.name();
-
- string current_path_printable(current_path);
- replace(current_path_printable.begin(), current_path_printable.end(), '.',
- '_');
-
- out << "if (func_msg->parent_path() == \"" << current_path << "\") {"
- << "\n";
- out.indent();
- out << " return GetAttribute__" << current_path_printable
- << "(func_msg, result);" << "\n";
- out.unindent();
- out << "}" << "\n";
-
- for (auto const& sub_struct : message.sub_struct()) {
- GenerateSubStructGetAttributeFunctionCall(out, sub_struct, current_path);
- }
-}
-
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/code_gen/driver/HalCodeGen.h b/compilation_tools/vtsc/code_gen/driver/HalCodeGen.h
deleted file mode 100644
index 194b396..0000000
--- a/compilation_tools/vtsc/code_gen/driver/HalCodeGen.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_DRIVER_HALCODEGEN_H_
-#define VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_DRIVER_HALCODEGEN_H_
-
-#include <string>
-
-#include "code_gen/driver/DriverCodeGenBase.h"
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-
-class HalCodeGen : public DriverCodeGenBase {
- public:
- explicit HalCodeGen(const char* input_vts_file_path)
- : DriverCodeGenBase(input_vts_file_path) {}
-
- protected:
- void GenerateCppBodyFuzzFunction(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) override;
-
- void GenerateCppBodyGetAttributeFunction(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) override;
-
- void GenerateCppBodyInterfaceImpl(
- Formatter& out, const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) override;
-
- void GenerateClassConstructionFunction(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) override;
-
- void GenerateSubStructFuzzFunctionCall(Formatter& out,
- const StructSpecificationMessage& message, const string& parent_path);
-
- void GenerateSubStructGetAttributeFunctionCall(Formatter& out,
- const StructSpecificationMessage& message, const string& parent_path);
-
- void GenerateCppBodyFuzzFunction(Formatter& out,
- const StructSpecificationMessage& message,
- const string& fuzzer_extended_class_name,
- const string& original_data_structure_name, const string& parent_path);
-
- void GenerateCppBodyGetAttributeFunction(Formatter& out,
- const StructSpecificationMessage& message,
- const string& fuzzer_extended_class_name,
- const string& original_data_structure_name, const string& parent_path);
-
- // instance variable name (e.g., device_);
- static const char* const kInstanceVariableName;
-};
-
-} // namespace vts
-} // namespace android
-
-#endif // VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_DRIVER_HALCODEGEN_H_
diff --git a/compilation_tools/vtsc/code_gen/driver/HalHidlCodeGen.cpp b/compilation_tools/vtsc/code_gen/driver/HalHidlCodeGen.cpp
deleted file mode 100644
index 14c1244..0000000
--- a/compilation_tools/vtsc/code_gen/driver/HalHidlCodeGen.cpp
+++ /dev/null
@@ -1,1792 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "code_gen/driver/HalHidlCodeGen.h"
-
-#include <iostream>
-#include <string>
-
-#include "VtsCompilerUtils.h"
-#include "code_gen/common/HalHidlCodeGenUtils.h"
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-#include "utils/InterfaceSpecUtil.h"
-#include "utils/StringUtil.h"
-
-using namespace std;
-using namespace android;
-
-namespace android {
-namespace vts {
-
-const char* const HalHidlCodeGen::kInstanceVariableName = "hw_binder_proxy_";
-
-void HalHidlCodeGen::GenerateCppBodyInterfaceImpl(
- Formatter& out, const ComponentSpecificationMessage& message,
- const string& /*fuzzer_extended_class_name*/) {
- out << "\n";
- FQName component_fq_name = GetFQName(message);
- for (const auto& api : message.interface().api()) {
- // Generate return statement.
- if (CanElideCallback(api)) {
- out << "::android::hardware::Return<"
- << GetCppVariableType(api.return_type_hidl(0)) << "> ";
- } else {
- out << "::android::hardware::Return<void> ";
- }
- // Generate function call.
- string full_method_name =
- "Vts_" + component_fq_name.tokenName() + "::" + api.name();
- out << full_method_name << "(\n";
- out.indent();
- for (int index = 0; index < api.arg_size(); index++) {
- const auto& arg = api.arg(index);
- out << GetCppVariableType(arg, IsConstType(arg.type())) << " arg" << index
- << " __attribute__((__unused__))";
- if (index != (api.arg_size() - 1)) out << ",\n";
- }
- if (api.return_type_hidl_size() == 0 || CanElideCallback(api)) {
- out << ") {\n";
- } else { // handle the case of callbacks.
- out << (api.arg_size() != 0 ? ", " : "");
- out << "std::function<void(";
- for (int index = 0; index < api.return_type_hidl_size(); index++) {
- const auto& return_val = api.return_type_hidl(index);
- out << GetCppVariableType(return_val, IsConstType(return_val.type()))
- << " arg" << index;
- if (index != (api.return_type_hidl_size() - 1)) {
- out << ",";
- }
- }
- out << ")> cb) {\n";
- }
- out << "LOG(INFO) << \"" << api.name() << " called\";\n";
- out << "AndroidSystemCallbackRequestMessage callback_message;\n";
- out << "callback_message.set_id(GetCallbackID(\"" << api.name()
- << "\"));\n";
- out << "callback_message.set_name(\"" << full_method_name << "\");\n";
- for (int index = 0; index < api.arg_size(); index++) {
- out << "VariableSpecificationMessage* var_msg" << index << " = "
- << "callback_message.add_arg();\n";
- GenerateSetResultCodeForTypedVariable(out, api.arg(index),
- "var_msg" + std::to_string(index),
- "arg" + std::to_string(index));
- }
- out << "RpcCallToAgent(callback_message, callback_socket_name_);\n";
-
- // TODO(zhuoyao): return the received results from host.
- if (CanElideCallback(api)) {
- out << "return ";
- GenerateDefaultReturnValForTypedVariable(out, api.return_type_hidl(0));
- out << ";\n";
- } else {
- if (api.return_type_hidl_size() > 0) {
- out << "cb(";
- for (int index = 0; index < api.return_type_hidl_size(); index++) {
- GenerateDefaultReturnValForTypedVariable(out,
- api.return_type_hidl(index));
- if (index != (api.return_type_hidl_size() - 1)) {
- out << ", ";
- }
- }
- out << ");\n";
- }
- out << "return ::android::hardware::Void();\n";
- }
- out.unindent();
- out << "}"
- << "\n";
- out << "\n";
- }
-
- string component_name_token = "Vts_" + component_fq_name.tokenName();
- out << "sp<" << component_fq_name.cppName() << "> VtsFuzzerCreate"
- << component_name_token << "(const string& callback_socket_name) {\n";
- out.indent();
- out << "static sp<" << component_fq_name.cppName() << "> result;\n";
- out << "result = new " << component_name_token << "(callback_socket_name);\n";
- out << "return result;\n";
- out.unindent();
- out << "}\n\n";
-}
-
-void HalHidlCodeGen::GenerateScalarTypeInC(Formatter& out, const string& type) {
- if (type == "bool_t") {
- out << "bool";
- } else if (type == "int8_t" ||
- type == "uint8_t" ||
- type == "int16_t" ||
- type == "uint16_t" ||
- type == "int32_t" ||
- type == "uint32_t" ||
- type == "int64_t" ||
- type == "uint64_t" ||
- type == "size_t") {
- out << type;
- } else if (type == "float_t") {
- out << "float";
- } else if (type == "double_t") {
- out << "double";
- } else if (type == "char_pointer") {
- out << "char*";
- } else if (type == "void_pointer") {
- out << "void*";
- } else {
- cerr << __func__ << ":" << __LINE__
- << " unsupported scalar type " << type << "\n";
- exit(-1);
- }
-}
-
-void HalHidlCodeGen::GenerateCppBodyFuzzFunction(
- Formatter& out, const ComponentSpecificationMessage& /*message*/,
- const string& fuzzer_extended_class_name) {
- out << "bool " << fuzzer_extended_class_name << "::Fuzz(" << "\n";
- out.indent();
- out << "FunctionSpecificationMessage* /*func_msg*/,"
- << "\n";
- out << "void** /*result*/, const string& /*callback_socket_name*/) {\n";
- out << "return true;\n";
- out.unindent();
- out << "}\n";
-}
-
-void HalHidlCodeGen::GenerateDriverFunctionImpl(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) {
- if (message.component_name() != "types") {
- out << "bool " << fuzzer_extended_class_name << "::CallFunction("
- << "\n";
- out.indent();
- out << "const FunctionSpecificationMessage& func_msg,"
- << "\n";
- out << "const string& callback_socket_name __attribute__((__unused__)),"
- << "\n";
- out << "FunctionSpecificationMessage* result_msg) {\n";
-
- out << "const char* func_name = func_msg.name().c_str();" << "\n";
- out << "if (hw_binder_proxy_ == nullptr) {\n";
- out.indent();
- out << "LOG(ERROR) << \"" << kInstanceVariableName << " is null. \";\n";
- out << "return false;\n";
- out.unindent();
- out << "}\n";
- for (auto const& api : message.interface().api()) {
- GenerateDriverImplForMethod(out, api);
- }
-
- GenerateDriverImplForReservedMethods(out);
-
- out << "return false;\n";
- out.unindent();
- out << "}\n";
- }
-}
-
-void HalHidlCodeGen::GenerateDriverImplForReservedMethods(Formatter& out) {
- // Generate call for reserved method: notifySyspropsChanged.
- out << "if (!strcmp(func_name, \"notifySyspropsChanged\")) {\n";
- out.indent();
-
- out << "LOG(INFO) << \"Call notifySyspropsChanged\";"
- << "\n";
- out << kInstanceVariableName << "->notifySyspropsChanged();\n";
- out << "result_msg->set_name(\"notifySyspropsChanged\");\n";
- out << "return true;\n";
-
- out.unindent();
- out << "}\n";
- // TODO(zhuoyao): Add generation code for other reserved method,
- // e.g interfaceChain
-}
-
-void HalHidlCodeGen::GenerateDriverImplForMethod(Formatter& out,
- const FunctionSpecificationMessage& func_msg) {
- out << "if (!strcmp(func_name, \"" << func_msg.name() << "\")) {\n";
- out.indent();
- // Process the arguments.
- for (int i = 0; i < func_msg.arg_size(); i++) {
- const auto& arg = func_msg.arg(i);
- string cur_arg_name = "arg" + std::to_string(i);
- string var_type = GetCppVariableType(arg);
-
- if (arg.type() == TYPE_POINTER ||
- (arg.type() == TYPE_SCALAR &&
- (arg.scalar_type() == "pointer" ||
- arg.scalar_type() == "void_pointer" ||
- arg.scalar_type() == "function_pointer"))) {
- out << var_type << " " << cur_arg_name << " = nullptr;\n";
- } else if (arg.type() == TYPE_SCALAR) {
- out << var_type << " " << cur_arg_name << " = 0;\n";
- } else if (arg.type() == TYPE_FMQ_SYNC || arg.type() == TYPE_FMQ_UNSYNC) {
- // FMQ type, use pointer to store arguments because copy assignment
- // is not allowed for fmq descriptor.
- // Use const because getDesc() function in FMQ implementation
- // returns const type.
- out << "const " << var_type << "* " << cur_arg_name << ";\n";
- } else {
- out << var_type << " " << cur_arg_name << ";\n";
- }
-
- GenerateDriverImplForTypedVariable(
- out, arg, cur_arg_name, "func_msg.arg(" + std::to_string(i) + ")");
- }
-
- // may need to check whether the function is actually defined.
- out << "LOG(DEBUG) << \"local_device = \" << " << kInstanceVariableName
- << ".get();\n";
-
- // Call the HAL function.
- if (CanElideCallback(func_msg)) {
- out << GetCppVariableType(func_msg.return_type_hidl(0)) << " result0 = ";
- GenerateHalFunctionCall(out, func_msg);
- // Set the return results value to the proto message.
- for (int index = 0; index < func_msg.return_type_hidl_size(); index++) {
- out << "VariableSpecificationMessage* result_val_" << index << " = "
- << "result_msg->add_return_type_hidl();\n";
- GenerateSetResultCodeForTypedVariable(
- out, func_msg.return_type_hidl(index),
- "result_val_" + std::to_string(index),
- "result" + std::to_string(index));
- }
- } else {
- GenerateHalFunctionCall(out, func_msg);
- }
-
- out << "return true;\n";
- out.unindent();
- out << "}\n";
-}
-
-void HalHidlCodeGen::GenerateHalFunctionCall(Formatter& out,
- const FunctionSpecificationMessage& func_msg) {
- out << kInstanceVariableName << "->" << func_msg.name() << "(";
- for (int index = 0; index < func_msg.arg_size(); index++) {
- if (func_msg.arg(index).type() == TYPE_FMQ_SYNC ||
- func_msg.arg(index).type() == TYPE_FMQ_UNSYNC) {
- // only FMQ types store arguments as pointers, dereference it now.
- out << "*arg" << index;
- } else {
- out << "arg" << index;
- }
- if (index != (func_msg.arg_size() - 1)) out << ", ";
- }
- if (func_msg.return_type_hidl_size()== 0 || CanElideCallback(func_msg)) {
- out << ");\n";
- out << "result_msg->set_name(\"" << func_msg.name() << "\");\n";
- } else {
- out << (func_msg.arg_size() != 0 ? ", " : "");
- GenerateSyncCallbackFunctionImpl(out, func_msg);
- out << ");\n";
- }
-}
-
-void HalHidlCodeGen::GenerateSyncCallbackFunctionImpl(Formatter& out,
- const FunctionSpecificationMessage& func_msg) {
- out << "[&](";
- for (int index = 0; index < func_msg.return_type_hidl_size(); index++) {
- const auto& return_val = func_msg.return_type_hidl(index);
- out << GetCppVariableType(return_val, IsConstType(return_val.type()))
- << " arg" << index << " __attribute__((__unused__))";
- if (index != (func_msg.return_type_hidl_size() - 1)) out << ",";
- }
- out << "){\n";
- out.indent();
- out << "LOG(INFO) << \"callback " << func_msg.name() << " called\""
- << ";\n";
-
- // Set the return results value to the proto message.
- out << "result_msg->set_name(\"" << func_msg.name() << "\");\n";
- for (int index = 0; index < func_msg.return_type_hidl_size(); index++) {
- out << "VariableSpecificationMessage* result_val_" << index << " = "
- << "result_msg->add_return_type_hidl();\n";
- GenerateSetResultCodeForTypedVariable(out, func_msg.return_type_hidl(index),
- "result_val_" + std::to_string(index),
- "arg" + std::to_string(index));
- }
- out.unindent();
- out << "}";
-}
-
-void HalHidlCodeGen::GenerateCppBodyGetAttributeFunction(
- Formatter& out, const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) {
- if (message.component_name() != "types") {
- out << "bool " << fuzzer_extended_class_name << "::GetAttribute(" << "\n";
- out.indent();
- out << "FunctionSpecificationMessage* /*func_msg*/,"
- << "\n";
- out << "void** /*result*/) {"
- << "\n";
- // TOOD: impl
- out << "LOG(ERROR) << \"attribute not found.\";\n"
- << "return false;\n";
- out.unindent();
- out << "}" << "\n";
- }
-}
-
-void HalHidlCodeGen::GenerateClassConstructionFunction(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) {
- out << fuzzer_extended_class_name << "() : DriverBase(";
- if (message.component_name() != "types") {
- out << "HAL_HIDL), " << kInstanceVariableName << "()";
- } else {
- out << "HAL_HIDL)";
- }
- out << " {}" << "\n";
- out << "\n";
-
- FQName fqname = GetFQName(message);
- out << "explicit " << fuzzer_extended_class_name << "(" << fqname.cppName()
- << "* hw_binder_proxy) : DriverBase("
- << "HAL_HIDL)";
- if (message.component_name() != "types") {
- out << ", " << kInstanceVariableName << "(hw_binder_proxy)";
- }
- out << " {}\n";
-}
-
-void HalHidlCodeGen::GenerateHeaderGlobalFunctionDeclarations(Formatter& out,
- const ComponentSpecificationMessage& message,
- const bool print_extern_block) {
- if (message.component_name() != "types") {
- if (print_extern_block) {
- out << "extern \"C\" {" << "\n";
- }
- DriverCodeGenBase::GenerateHeaderGlobalFunctionDeclarations(
- out, message, false);
-
- string function_name_prefix = GetFunctionNamePrefix(message);
- FQName fqname = GetFQName(message);
- out << "extern "
- << "android::vts::DriverBase* " << function_name_prefix
- << "with_arg(uint64_t hw_binder_proxy);\n";
- if (print_extern_block) {
- out << "}" << "\n";
- }
- }
-}
-
-void HalHidlCodeGen::GenerateCppBodyGlobalFunctions(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name, const bool print_extern_block) {
- if (message.component_name() != "types") {
- if (print_extern_block) {
- out << "extern \"C\" {" << "\n";
- }
- DriverCodeGenBase::GenerateCppBodyGlobalFunctions(
- out, message, fuzzer_extended_class_name, false);
-
- string function_name_prefix = GetFunctionNamePrefix(message);
- FQName fqname = GetFQName(message);
- out << "android::vts::DriverBase* " << function_name_prefix << "with_arg("
- << "uint64_t hw_binder_proxy) {\n";
- out.indent();
- out << fqname.cppName() << "* arg = nullptr;\n";
- out << "if (hw_binder_proxy) {\n";
- out.indent();
- out << "arg = reinterpret_cast<" << fqname.cppName()
- << "*>(hw_binder_proxy);\n";
- out.unindent();
- out << "} else {\n";
- out.indent();
- out << "LOG(INFO) << \" Creating DriverBase with null proxy.\";\n";
- out.unindent();
- out << "}\n";
- out << "android::vts::DriverBase* result ="
- << "\n"
- << " new android::vts::" << fuzzer_extended_class_name << "(\n"
- << " arg);\n";
- out << "if (arg != nullptr) {\n";
- out.indent();
- out << "arg->decStrong(arg);" << "\n";
- out.unindent();
- out << "}\n";
- out << "return result;" << "\n";
- out.unindent();
- out << "}\n\n";
- if (print_extern_block) {
- out << "}" << "\n";
- }
- }
-}
-
-void HalHidlCodeGen::GenerateClassHeader(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) {
- if (message.component_name() != "types") {
- for (const auto& attribute : message.interface().attribute()) {
- GenerateAllFunctionDeclForAttribute(out, attribute);
- }
- DriverCodeGenBase::GenerateClassHeader(out, message,
- fuzzer_extended_class_name);
- } else {
- for (const auto& attribute : message.attribute()) {
- GenerateAllFunctionDeclForAttribute(out, attribute);
- };
- }
-}
-
-void HalHidlCodeGen::GenerateHeaderInterfaceImpl(
- Formatter& out, const ComponentSpecificationMessage& message) {
- out << "\n";
- FQName component_fq_name = GetFQName(message);
- string component_name_token = "Vts_" + component_fq_name.tokenName();
- out << "class " << component_name_token << " : public "
- << component_fq_name.cppName() << ", public DriverCallbackBase {\n";
- out << " public:\n";
- out.indent();
- out << component_name_token << "(const string& callback_socket_name)\n"
- << " : callback_socket_name_(callback_socket_name) {};\n\n";
- out << "virtual ~" << component_name_token << "()"
- << " = default;\n\n";
- for (const auto& api : message.interface().api()) {
- // Generate return statement.
- if (CanElideCallback(api)) {
- out << "::android::hardware::Return<"
- << GetCppVariableType(api.return_type_hidl(0)) << "> ";
- } else {
- out << "::android::hardware::Return<void> ";
- }
- // Generate function call.
- out << api.name() << "(\n";
- out.indent();
- for (int index = 0; index < api.arg_size(); index++) {
- const auto& arg = api.arg(index);
- out << GetCppVariableType(arg, IsConstType(arg.type())) << " arg"
- << index;
- if (index != (api.arg_size() - 1)) out << ",\n";
- }
- if (api.return_type_hidl_size() == 0 || CanElideCallback(api)) {
- out << ") override;\n\n";
- } else { // handle the case of callbacks.
- out << (api.arg_size() != 0 ? ", " : "");
- out << "std::function<void(";
- for (int index = 0; index < api.return_type_hidl_size(); index++) {
- const auto& return_val = api.return_type_hidl(index);
- out << GetCppVariableType(return_val, IsConstType(return_val.type()))
- << " arg" << index;
- if (index != (api.return_type_hidl_size() - 1)) out << ",";
- }
- out << ")> cb) override;\n\n";
- }
- out.unindent();
- }
- out << "\n";
- out.unindent();
- out << " private:\n";
- out.indent();
- out << "string callback_socket_name_;\n";
- out.unindent();
- out << "};\n\n";
-
- out << "sp<" << component_fq_name.cppName() << "> VtsFuzzerCreate"
- << component_name_token << "(const string& callback_socket_name);\n\n";
-}
-
-void HalHidlCodeGen::GenerateClassImpl(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) {
- if (message.component_name() != "types") {
- for (const auto& attribute : message.interface().attribute()) {
- GenerateAllFunctionImplForAttribute(out, attribute);
- }
- GenerateGetServiceImpl(out, message, fuzzer_extended_class_name);
- DriverCodeGenBase::GenerateClassImpl(out, message,
- fuzzer_extended_class_name);
- } else {
- for (const auto& attribute : message.attribute()) {
- GenerateAllFunctionImplForAttribute(out, attribute);
- }
- }
-}
-
-void HalHidlCodeGen::GenerateHeaderIncludeFiles(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) {
- DriverCodeGenBase::GenerateHeaderIncludeFiles(out, message,
- fuzzer_extended_class_name);
- out << "#include <" << GetPackagePath(message) << "/" << GetVersion(message)
- << "/" << GetComponentName(message) << ".h>"
- << "\n";
- out << "#include <hidl/HidlSupport.h>" << "\n";
-
- for (const auto& import : message.import()) {
- FQName import_name;
- if (!FQName::parse(import, &import_name)) {
- abort();
- }
-
- string import_package_name = import_name.package();
- string import_package_version = import_name.version();
- string import_component_name = import_name.name();
- string import_package_path = import_package_name;
- ReplaceSubString(import_package_path, ".", "/");
-
- out << "#include <" << import_package_path << "/" << import_package_version
- << "/" << import_component_name << ".h>\n";
- // Exclude the base hal in include list.
- if (import_package_name.find("android.hidl.base") == std::string::npos) {
- if (import_component_name[0] == 'I') {
- import_component_name = import_component_name.substr(1);
- }
- out << "#include <" << import_package_path << "/"
- << import_package_version << "/" << import_component_name
- << ".vts.h>\n";
- }
- }
-
- out << "\n\n";
-}
-
-void HalHidlCodeGen::GenerateSourceIncludeFiles(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) {
- DriverCodeGenBase::GenerateSourceIncludeFiles(out, message,
- fuzzer_extended_class_name);
- out << "#include <android/hidl/allocator/1.0/IAllocator.h>\n";
- out << "#include <fcntl.h>\n";
- out << "#include <fmq/MessageQueue.h>\n";
- out << "#include <sys/stat.h>\n";
- out << "#include <unistd.h>\n";
-}
-
-void HalHidlCodeGen::GenerateAdditionalFuctionDeclarations(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& /*fuzzer_extended_class_name*/) {
- if (message.component_name() != "types") {
- out << "bool GetService(bool get_stub, const char* service_name);"
- << "\n\n";
- }
-}
-
-void HalHidlCodeGen::GeneratePublicFunctionDeclarations(
- Formatter& out, const ComponentSpecificationMessage& /*message*/) {
- out << "uint64_t GetHidlInterfaceProxy() const {\n";
- out.indent();
- out << "return reinterpret_cast<uintptr_t>(" << kInstanceVariableName
- << ".get());\n";
- out.unindent();
- out << "}\n";
-}
-
-void HalHidlCodeGen::GeneratePrivateMemberDeclarations(Formatter& out,
- const ComponentSpecificationMessage& message) {
- FQName fqname = GetFQName(message);
- out << "sp<" << fqname.cppName() << "> " << kInstanceVariableName << ";\n";
-}
-
-void HalHidlCodeGen::GenerateRandomFunctionDeclForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute) {
- if (attribute.type() == TYPE_ENUM) {
- if (attribute.enum_value().enumerator_size() == 0) {
- // empty enum without any actual enumerator.
- return;
- }
- string attribute_name = ClearStringWithNameSpaceAccess(attribute.name());
- out << attribute.enum_value().scalar_type() << " "
- << "Random" << attribute_name << "();\n";
- }
-}
-
-void HalHidlCodeGen::GenerateRandomFunctionImplForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute) {
- // Random value generator
- if (attribute.type() == TYPE_ENUM) {
- if (attribute.enum_value().enumerator_size() == 0) {
- // empty enum without any actual enumerator.
- return;
- }
- string attribute_name = ClearStringWithNameSpaceAccess(attribute.name());
- out << attribute.enum_value().scalar_type() << " Random" << attribute_name
- << "() {\n";
- out.indent();
- out << attribute.enum_value().scalar_type() << " choice = " << "("
- << attribute.enum_value().scalar_type() << ") " << "rand() / "
- << attribute.enum_value().enumerator().size() << ";" << "\n";
- if (attribute.enum_value().scalar_type().find("u") != 0) {
- out << "if (choice < 0) choice *= -1;" << "\n";
- }
- for (int index = 0; index < attribute.enum_value().enumerator().size();
- index++) {
- out << "if (choice == ";
- out << "(" << attribute.enum_value().scalar_type() << ") ";
- if (attribute.enum_value().scalar_type() == "int8_t") {
- out << attribute.enum_value().scalar_value(index).int8_t();
- } else if (attribute.enum_value().scalar_type() == "uint8_t") {
- out << attribute.enum_value().scalar_value(index).uint8_t() << "U";
- } else if (attribute.enum_value().scalar_type() == "int16_t") {
- out << attribute.enum_value().scalar_value(index).int16_t();
- } else if (attribute.enum_value().scalar_type() == "uint16_t") {
- out << attribute.enum_value().scalar_value(index).uint16_t() << "U";
- } else if (attribute.enum_value().scalar_type() == "int32_t") {
- out << attribute.enum_value().scalar_value(index).int32_t() << "L";
- } else if (attribute.enum_value().scalar_type() == "uint32_t") {
- out << attribute.enum_value().scalar_value(index).uint32_t() << "UL";
- } else if (attribute.enum_value().scalar_type() == "int64_t") {
- if (attribute.enum_value().scalar_value(index).int64_t() == LLONG_MIN) {
- out << "LLONG_MIN";
- } else {
- out << attribute.enum_value().scalar_value(index).int64_t() << "LL";
- }
- } else if (attribute.enum_value().scalar_type() == "uint64_t") {
- out << attribute.enum_value().scalar_value(index).uint64_t() << "ULL";
- } else {
- cerr << __func__ << ":" << __LINE__ << " ERROR unsupported enum type "
- << attribute.enum_value().scalar_type() << "\n";
- exit(-1);
- }
- out << ") return static_cast<" << attribute.enum_value().scalar_type()
- << ">(" << attribute.name()
- << "::" << attribute.enum_value().enumerator(index) << ");\n";
- }
- out << "return static_cast<" << attribute.enum_value().scalar_type() << ">("
- << attribute.name() << "::" << attribute.enum_value().enumerator(0)
- << ");\n";
- out.unindent();
- out << "}" << "\n";
- }
-}
-
-void HalHidlCodeGen::GenerateDriverDeclForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute) {
- if (!IsUserDefinedType(attribute.type())) {
- cerr << attribute.type() << " is not a user defined type\n";
- exit(-1);
- }
- for (const auto& sub_struct : attribute.sub_struct()) {
- GenerateDriverDeclForAttribute(out, sub_struct);
- }
- for (const auto& sub_union : attribute.sub_union()) {
- GenerateDriverDeclForAttribute(out, sub_union);
- }
- for (const auto& sub_safe_union : attribute.sub_safe_union()) {
- GenerateDriverDeclForAttribute(out, sub_safe_union);
- }
- string func_name =
- "MessageTo" + ClearStringWithNameSpaceAccess(attribute.name());
- // Add extern C to allow resource_manager to dynamically load this function.
- out << "extern \"C\" ";
- out << "void " << func_name
- << "(const VariableSpecificationMessage& var_msg, " << attribute.name()
- << "* arg, const string& callback_socket_name);\n";
-}
-
-void HalHidlCodeGen::GenerateDriverImplForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute) {
- if (!IsUserDefinedType(attribute.type())) {
- cerr << attribute.type() << " is not a user defined type\n";
- exit(-1);
- }
- // Recursively generate driver implementation method for all sub_types.
- for (const auto& sub_struct : attribute.sub_struct()) {
- GenerateDriverImplForAttribute(out, sub_struct);
- }
- for (const auto& sub_union : attribute.sub_union()) {
- GenerateDriverImplForAttribute(out, sub_union);
- }
- for (const auto& sub_safe_union : attribute.sub_safe_union()) {
- GenerateDriverImplForAttribute(out, sub_safe_union);
- }
- string func_name =
- "MessageTo" + ClearStringWithNameSpaceAccess(attribute.name());
- // Add extern C to allow resource_manager to dynamically load this
- // function.
- out << "extern \"C\" ";
- out << "void " << func_name
- << "(const VariableSpecificationMessage& "
- "var_msg __attribute__((__unused__)), "
- << attribute.name() << "* arg __attribute__((__unused__)), "
- << "const string& callback_socket_name __attribute__((__unused__))) {"
- << "\n";
- out.indent();
-
- switch (attribute.type()) {
- case TYPE_ENUM: {
- out << "*arg = (" << attribute.name() << ")var_msg.scalar_value()."
- << attribute.enum_value().scalar_type() << "();\n";
- break;
- }
- case TYPE_STRUCT: {
- int struct_index = 0;
- for (const auto& struct_value : attribute.struct_value()) {
- GenerateDriverImplForTypedVariable(
- out, struct_value, "arg->" + struct_value.name(),
- "var_msg.struct_value(" + std::to_string(struct_index) + ")");
- struct_index++;
- }
- break;
- }
- case TYPE_UNION: {
- int union_index = 0;
- for (const auto& union_value : attribute.union_value()) {
- out << "if (var_msg.union_value(" << union_index << ").name() == \""
- << union_value.name() << "\") {"
- << "\n";
- out.indent();
- GenerateDriverImplForTypedVariable(
- out, union_value, "arg->" + union_value.name(),
- "var_msg.union_value(" + std::to_string(union_index) + ")");
- union_index++;
- out.unindent();
- out << "}\n";
- }
- break;
- }
- case TYPE_SAFE_UNION: {
- out << "LOG(ERROR) << \"TYPE_SAFE_UNION is not supported yet. \";\n";
- break;
- }
- default: {
- cerr << __func__ << " unsupported attribute type " << attribute.type()
- << "\n";
- exit(-1);
- }
- }
- out.unindent();
- out << "}\n";
-}
-
-void HalHidlCodeGen::GenerateGetServiceImpl(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) {
- out << "bool " << fuzzer_extended_class_name
- << "::GetService(bool get_stub, const char* service_name) {" << "\n";
- out.indent();
- out << "static bool initialized = false;" << "\n";
- out << "if (!initialized) {" << "\n";
- out.indent();
- out << "LOG(INFO) << \"HIDL getService\";"
- << "\n";
- out << "if (service_name) {\n"
- << " LOG(INFO) << \" - service name: \" << service_name;"
- << "\n"
- << "}\n";
- FQName fqname = GetFQName(message);
- out << kInstanceVariableName << " = " << fqname.cppName() << "::getService("
- << "service_name, get_stub);" << "\n";
- out << "if (" << kInstanceVariableName << " == nullptr) {\n";
- out.indent();
- out << "LOG(ERROR) << \"getService() returned a null pointer.\";\n";
- out << "return false;\n";
- out.unindent();
- out << "}\n";
- out << "LOG(DEBUG) << \"" << kInstanceVariableName << " = \" << "
- << kInstanceVariableName << ".get();"
- << "\n";
- out << "initialized = true;" << "\n";
- out.unindent();
- out << "}" << "\n";
- out << "return true;" << "\n";
- out.unindent();
- out << "}" << "\n" << "\n";
-}
-
-void HalHidlCodeGen::GenerateDriverImplForTypedVariable(Formatter& out,
- const VariableSpecificationMessage& val, const string& arg_name,
- const string& arg_value_name) {
- switch (val.type()) {
- case TYPE_SCALAR:
- {
- out << arg_name << " = " << arg_value_name << ".scalar_value()."
- << val.scalar_type() << "();\n";
- break;
- }
- case TYPE_STRING:
- {
- out << arg_name << " = ::android::hardware::hidl_string("
- << arg_value_name << ".string_value().message());\n";
- break;
- }
- case TYPE_ENUM:
- {
- if (val.has_predefined_type()) {
- string func_name =
- "MessageTo" + ClearStringWithNameSpaceAccess(val.predefined_type());
- out << func_name << "(" << arg_value_name << ", &(" << arg_name
- << "), callback_socket_name);\n";
- } else {
- out << arg_name << " = (" << val.name() << ")" << arg_value_name << "."
- << "enum_value().scalar_value(0)." << val.enum_value().scalar_type()
- << "();\n";
- }
- break;
- }
- case TYPE_MASK:
- {
- out << arg_name << " = " << arg_value_name << ".scalar_value()."
- << val.scalar_type() << "();\n";
- break;
- }
- case TYPE_VECTOR:
- {
- out << arg_name << ".resize(" << arg_value_name
- << ".vector_value_size());\n";
- std::string index_name = GetVarString(arg_name) + "_index";
- out << "for (int " << index_name << " = 0; " << index_name << " < "
- << arg_value_name << ".vector_value_size(); " << index_name
- << "++) {\n";
- out.indent();
- GenerateDriverImplForTypedVariable(
- out, val.vector_value(0), arg_name + "[" + index_name + "]",
- arg_value_name + ".vector_value(" + index_name + ")");
- out.unindent();
- out << "}\n";
- break;
- }
- case TYPE_ARRAY:
- {
- std::string index_name = GetVarString(arg_name) + "_index";
- out << "for (int " << index_name << " = 0; " << index_name << " < "
- << arg_value_name << ".vector_value_size(); " << index_name
- << "++) {\n";
- out.indent();
- GenerateDriverImplForTypedVariable(
- out, val.vector_value(0), arg_name + "[" + index_name + "]",
- arg_value_name + ".vector_value(" + index_name + ")");
- out.unindent();
- out << "}\n";
- break;
- }
- case TYPE_STRUCT:
- {
- if (val.has_predefined_type()) {
- string func_name = "MessageTo"
- + ClearStringWithNameSpaceAccess(val.predefined_type());
- out << func_name << "(" << arg_value_name << ", &(" << arg_name
- << "), callback_socket_name);\n";
- } else {
- int struct_index = 0;
- for (const auto& struct_field : val.struct_value()) {
- string struct_field_name = arg_name + "." + struct_field.name();
- string struct_field_value_name = arg_value_name + ".struct_value("
- + std::to_string(struct_index) + ")";
- GenerateDriverImplForTypedVariable(out, struct_field,
- struct_field_name,
- struct_field_value_name);
- struct_index++;
- }
- }
- break;
- }
- case TYPE_UNION:
- {
- if (val.has_predefined_type()) {
- string func_name = "MessageTo"
- + ClearStringWithNameSpaceAccess(val.predefined_type());
- out << func_name << "(" << arg_value_name << ", &(" << arg_name
- << "), callback_socket_name);\n";
- } else {
- int union_index = 0;
- for (const auto& union_field : val.union_value()) {
- string union_field_name = arg_name + "." + union_field.name();
- string union_field_value_name = arg_value_name + ".union_value("
- + std::to_string(union_index) + ")";
- GenerateDriverImplForTypedVariable(out, union_field, union_field_name,
- union_field_value_name);
- union_index++;
- }
- }
- break;
- }
- case TYPE_HIDL_CALLBACK:
- {
- string type_name = val.predefined_type();
- ReplaceSubString(type_name, "::", "_");
-
- out << arg_name << " = VtsFuzzerCreateVts" << type_name
- << "(callback_socket_name);\n";
- out << "static_cast<" << "Vts" + type_name << "*>(" << arg_name
- << ".get())->Register(" << arg_value_name << ");\n";
- break;
- }
- case TYPE_HANDLE:
- {
- out << "if (" << arg_value_name << ".has_handle_value()) {\n";
- out.indent();
- out << "if (" << arg_value_name
- << ".handle_value().has_hidl_handle_address()) {\n";
- out.indent(); // if case starts: existing hidl_handle is specified.
- out << arg_name
- << " = *(reinterpret_cast<android::hardware::hidl_handle*>("
- << arg_value_name << ".handle_value().hidl_handle_address()));\n";
- out.unindent(); // if case ends.
- out << "} else {\n";
- out.indent(); // else case starts: create a new handle object.
- out << "native_handle_t* handle = native_handle_create(" << arg_value_name
- << ".handle_value().num_fds(), " << arg_value_name
- << ".handle_value().num_ints());\n";
- out << "if (!handle) {\n";
- out.indent();
- out << "LOG(ERROR) << \"Failed to create handle. \";\n";
- out << "exit(-1);\n";
- out.unindent();
- out << "}\n";
- out << "for (int fd_index = 0; fd_index < " << arg_value_name
- << ".handle_value().num_fds() + " << arg_value_name
- << ".handle_value().num_ints(); fd_index++) {\n";
- out.indent();
- out << "if (fd_index < " << arg_value_name
- << ".handle_value().num_fds()) {\n";
- out.indent();
- out << "FdMessage fd_val = " << arg_value_name
- << ".handle_value().fd_val(fd_index);\n";
- out << "string file_name = fd_val.file_name();\n";
- out << "switch (fd_val.type()) {\n";
- out.indent();
- out << "case FdType::FILE_TYPE:\n";
- out << "{\n";
- out.indent();
- // Create the parent path recursively if not exist.
- out << "size_t pre = 0; size_t pos = 0;\n";
- out << "string dir;\n";
- out << "struct stat st;\n";
- out << "while((pos=file_name.find_first_of('/', pre)) "
- << "!= string::npos){\n";
- out.indent();
- out << "dir = file_name.substr(0, pos++);\n";
- out << "pre = pos;\n";
- out << "if(dir.size() == 0) continue; // ignore leading /\n";
- out << "if (stat(dir.c_str(), &st) == -1) {\n";
- out << "LOG(INFO) << \" Creating dir: \" << dir;\n";
- out.indent();
- out << "mkdir(dir.c_str(), 0700);\n";
- out.unindent();
- out << "}\n";
- out.unindent();
- out << "}\n";
- out << "int fd = open(file_name.c_str(), "
- << "fd_val.flags() | O_CREAT, fd_val.mode());\n";
- out << "if (fd == -1) {\n";
- out.indent();
- out << "LOG(ERROR) << \"Failed to open file: \" << file_name << \" "
- "error: \" << errno;\n";
- out << "exit (-1);\n";
- out.unindent();
- out << "}\n";
- out << "handle->data[fd_index] = fd;\n";
- out << "break;\n";
- out.unindent();
- out << "}\n";
- out << "case FdType::DIR_TYPE:\n";
- out << "{\n";
- out.indent();
- out << "struct stat st;\n";
- out << "if (!stat(file_name.c_str(), &st)) {\n";
- out.indent();
- out << "mkdir(file_name.c_str(), fd_val.mode());\n";
- out.unindent();
- out << "}\n";
- out << "handle->data[fd_index] = open(file_name.c_str(), O_DIRECTORY, "
- << "fd_val.mode());\n";
- out << "break;\n";
- out.unindent();
- out << "}\n";
- out << "case FdType::DEV_TYPE:\n";
- out << "{\n";
- out.indent();
- out << "if(file_name == \"/dev/ashmem\") {\n";
- out.indent();
- out << "handle->data[fd_index] = ashmem_create_region(\"SharedMemory\", "
- << "fd_val.memory().size());\n";
- out.unindent();
- out << "}\n";
- out << "break;\n";
- out.unindent();
- out << "}\n";
- out << "case FdType::PIPE_TYPE:\n";
- out << "case FdType::SOCKET_TYPE:\n";
- out << "case FdType::LINK_TYPE:\n";
- out << "{\n";
- out.indent();
- out << "LOG(ERROR) << \"Not supported yet. \";\n";
- out << "break;\n";
- out.unindent();
- out << "}\n";
- out.unindent();
- out << "}\n";
- out.unindent();
- out << "} else {\n";
- out.indent();
- out << "handle->data[fd_index] = " << arg_value_name
- << ".handle_value().int_val(fd_index -" << arg_value_name
- << ".handle_value().num_fds());\n";
- out.unindent();
- out << "}\n";
- out.unindent();
- out << "}\n";
- out << arg_name << " = handle;\n";
- out.unindent(); // else case (create a new handle object) ends.
- out << "}\n";
- out.unindent();
- out << "} else {\n";
- out.indent();
- out << arg_name << " = nullptr;\n";
- out.unindent();
- out << "}\n";
- break;
- }
- case TYPE_HIDL_INTERFACE:
- {
- string type_name = val.predefined_type();
- out << "if (" << arg_value_name << ".has_hidl_interface_pointer()) {\n";
- out.indent();
- out << arg_name << " = reinterpret_cast<" << type_name << "*>("
- << arg_value_name << ".hidl_interface_pointer());\n";
- out.unindent();
- out << "} else {\n";
- out.indent();
- if (type_name.find("::android::hidl") == 0) {
- out << "LOG(ERROR) << \"general interface is not supported yet. \";\n";
- } else {
- ReplaceSubString(type_name, "::", "_");
- out << arg_name << " = VtsFuzzerCreateVts" << type_name
- << "(callback_socket_name);\n";
- }
- out.unindent();
- out << "}\n";
- break;
- }
- case TYPE_HIDL_MEMORY:
- {
- out << "if (" << arg_value_name
- << ".hidl_memory_value().has_hidl_mem_address()) {\n";
- out.indent(); // if case starts: existing hidl_memory is used.
- out << arg_name
- << " = *(reinterpret_cast<android::hardware::hidl_memory*>("
- << arg_value_name << ".hidl_memory_value().hidl_mem_address()));\n";
- out.unindent(); // if case ends.
- out << "} else {\n";
- out.indent(); // else case starts: allocates new memory region.
- out << "sp<::android::hidl::allocator::V1_0::IAllocator> ashmemAllocator"
- << " = ::android::hidl::allocator::V1_0::IAllocator::getService(\""
- << "ashmem\");\n";
- out << "if (ashmemAllocator == nullptr) {\n";
- out.indent();
- out << "LOG(ERROR) << \"Failed to get ashmemAllocator! \";\n";
- out << "exit(-1);\n";
- out.unindent();
- out << "}\n";
- // TODO(zhuoyao): initialize memory with recorded contents.
- out << "auto res = ashmemAllocator->allocate(" << arg_value_name
- << ".hidl_memory_value().size(), [&](bool success, "
- << "const hardware::hidl_memory& memory) {\n";
- out.indent();
- out << "if (!success) {\n";
- out.indent();
- out << "LOG(ERROR) << \"Failed to allocate memory! \";\n";
- out << arg_name << " = ::android::hardware::hidl_memory();\n";
- out << "return;\n";
- out.unindent();
- out << "}\n";
- out << arg_name << " = memory;\n";
- out.unindent();
- out << "});\n";
- out.unindent(); // else case ends.
- out << "}\n";
- break;
- }
- case TYPE_POINTER:
- {
- out << "LOG(ERROR) << \"TYPE_POINTER is not supported yet. \";\n";
- break;
- }
- case TYPE_FMQ_SYNC:
- case TYPE_FMQ_UNSYNC: {
- if (arg_name.find("->") != std::string::npos) {
- out << "LOG(ERROR) << \"Nested structure with fmq is not supported "
- "yet. \";\n";
- } else {
- // TODO(zhuoyao): consider record and use the queue capacity.
- std::string element_type = GetCppVariableType(val.fmq_value(0));
- std::string queue_name =
- arg_name + (val.type() == TYPE_FMQ_SYNC ? "_sync_q" : "_unsync_q");
- std::string queue_descriptor_type = GetCppVariableType(val);
-
- // When caller wants to reuse an existing queue.
- out << "if (" << arg_value_name << ".fmq_value_size() > 0 && "
- << arg_value_name << ".fmq_value(0).has_fmq_desc_address()) {\n";
- out.indent(); // if case starts
- out << arg_name << " = "
- << "reinterpret_cast<" << queue_descriptor_type << "*>("
- << arg_value_name << ".fmq_value(0).fmq_desc_address());\n";
- out.unindent(); // if case ends
-
- // When caller wants to create a brand new queue and write to it.
- out << "} else {\n";
- out.indent(); // else case starts
- out << "::android::hardware::MessageQueue<" << element_type
- << ", ::android::hardware::"
- << (val.type() == TYPE_FMQ_SYNC ? "kSynchronizedReadWrite"
- : "kUnsynchronizedWrite")
- << "> " << queue_name << "(1024);\n";
- out << "for (int i = 0; i < (int)" << arg_value_name
- << ".fmq_value_size(); i++) {\n";
- out.indent(); // for loop starts
- std::string fmq_item_name = queue_name + "_item";
- out << element_type << " " << fmq_item_name << ";\n";
- GenerateDriverImplForTypedVariable(out, val.fmq_value(0), fmq_item_name,
- arg_value_name + ".fmq_value(i)");
- out << queue_name << ".write(&" << fmq_item_name << ");\n";
- out.unindent(); // for loop ends
- out << "}\n";
- out << arg_name << " = " << queue_name << ".getDesc();\n";
- out.unindent(); // else case ends
- out << "}\n";
- }
- break;
- }
- case TYPE_REF:
- {
- out << "LOG(ERROR) << \"TYPE_REF is not supported yet. \";\n";
- break;
- }
- case TYPE_SAFE_UNION: {
- out << "LOG(ERROR) << \"TYPE_SAFE_UNION is not supported yet. \";\n";
- break;
- }
- default:
- {
- cerr << __func__ << " ERROR: unsupported type " << val.type() << ".\n";
- exit(-1);
- }
- }
-}
-
-// TODO(zhuoyao): Verify results based on verification rules instead of perform
-// an exact match.
-void HalHidlCodeGen::GenerateVerificationFunctionImpl(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) {
- if (message.component_name() != "types") {
- // Generate the main profiler function.
- out << "\nbool " << fuzzer_extended_class_name;
- out.indent();
- out << "::VerifyResults(const FunctionSpecificationMessage& "
- "expected_result __attribute__((__unused__)),"
- << "\n";
- out << "const FunctionSpecificationMessage& actual_result "
- "__attribute__((__unused__))) {\n";
- for (const FunctionSpecificationMessage& api : message.interface().api()) {
- out << "if (!strcmp(actual_result.name().c_str(), \"" << api.name()
- << "\")) {\n";
- out.indent();
- out << "if (actual_result.return_type_hidl_size() != "
- << "expected_result.return_type_hidl_size() "
- << ") { return false; }\n";
- for (int i = 0; i < api.return_type_hidl_size(); i++) {
- std::string expected_result = "expected_result.return_type_hidl("
- + std::to_string(i) + ")";
- std::string actual_result = "actual_result.return_type_hidl("
- + std::to_string(i) + ")";
- GenerateVerificationCodeForTypedVariable(out, api.return_type_hidl(i),
- expected_result,
- actual_result);
- }
- out << "return true;\n";
- out.unindent();
- out << "}\n";
- }
- out << "return false;\n";
- out.unindent();
- out << "}\n\n";
- }
-}
-
-void HalHidlCodeGen::GenerateVerificationCodeForTypedVariable(Formatter& out,
- const VariableSpecificationMessage& val, const string& expected_result,
- const string& actual_result) {
- switch (val.type()) {
- case TYPE_SCALAR:
- {
- out << "if (" << actual_result << ".scalar_value()." << val.scalar_type()
- << "() != " << expected_result << ".scalar_value()."
- << val.scalar_type() << "()) { return false; }\n";
- break;
- }
- case TYPE_STRING:
- {
- out << "if (strcmp(" << actual_result
- << ".string_value().message().c_str(), " << expected_result
- << ".string_value().message().c_str())!= 0)" << "{ return false; }\n";
- break;
- }
- case TYPE_ENUM:
- {
- if (val.has_predefined_type()) {
- string func_name = "Verify"
- + ClearStringWithNameSpaceAccess(val.predefined_type());
- out << "if(!" << func_name << "(" << expected_result << ", "
- << actual_result << ")) { return false; }\n";
- } else {
- out << "if (" << actual_result << ".scalar_value()."
- << val.enum_value().scalar_type() << "() != " << expected_result
- << ".scalar_value()." << val.enum_value().scalar_type()
- << "()) { return false; }\n";
- }
- break;
- }
- case TYPE_MASK:
- {
- out << "if (" << actual_result << ".scalar_value()." << val.scalar_type()
- << "() != " << expected_result << ".scalar_value()."
- << val.scalar_type() << "()) { return false; }\n";
- break;
- }
- case TYPE_VECTOR:
- {
- out << "if (" << actual_result << ".vector_value_size() != "
- << expected_result << ".vector_value_size()) {\n";
- out.indent();
- out << "LOG(ERROR) << \"Verification failed for vector size. expected: "
- "\" << "
- << expected_result << ".vector_value_size() << \" actual: \" << "
- << actual_result << ".vector_value_size();\n";
- out << "return false;\n";
- out.unindent();
- out << "}\n";
- out << "for (int i = 0; i <" << expected_result
- << ".vector_value_size(); i++) {\n";
- out.indent();
- GenerateVerificationCodeForTypedVariable(
- out, val.vector_value(0), expected_result + ".vector_value(i)",
- actual_result + ".vector_value(i)");
- out.unindent();
- out << "}\n";
- break;
- }
- case TYPE_ARRAY:
- {
- out << "if (" << actual_result << ".vector_value_size() != "
- << expected_result << ".vector_value_size()) {\n";
- out.indent();
- out << "LOG(ERROR) << \"Verification failed for vector size. expected: "
- "\" << "
- << expected_result << ".vector_value_size() << \" actual: \" << "
- << actual_result << ".vector_value_size();\n";
- out << "return false;\n";
- out.unindent();
- out << "}\n";
- out << "for (int i = 0; i < " << expected_result
- << ".vector_value_size(); i++) {\n";
- out.indent();
- GenerateVerificationCodeForTypedVariable(
- out, val.vector_value(0), expected_result + ".vector_value(i)",
- actual_result + ".vector_value(i)");
- out.unindent();
- out << "}\n";
- break;
- }
- case TYPE_STRUCT:
- {
- if (val.has_predefined_type()) {
- string func_name = "Verify"
- + ClearStringWithNameSpaceAccess(val.predefined_type());
- out << "if (!" << func_name << "(" << expected_result << ", "
- << actual_result << ")) { return false; }\n";
- } else {
- for (int i = 0; i < val.struct_value_size(); i++) {
- string struct_field_actual_result = actual_result + ".struct_value("
- + std::to_string(i) + ")";
- string struct_field_expected_result = expected_result
- + ".struct_value(" + std::to_string(i) + ")";
- GenerateVerificationCodeForTypedVariable(out, val.struct_value(i),
- struct_field_expected_result,
- struct_field_actual_result);
- }
- }
- break;
- }
- case TYPE_UNION:
- {
- if (val.has_predefined_type()) {
- string func_name = "Verify"
- + ClearStringWithNameSpaceAccess(val.predefined_type());
- out << "if (!" << func_name << "(" << expected_result << ", "
- << actual_result << ")) {return false; }\n";
- } else {
- for (int i = 0; i < val.union_value_size(); i++) {
- string union_field_actual_result = actual_result + ".union_value("
- + std::to_string(i) + ")";
- string union_field_expected_result = expected_result + ".union_value("
- + std::to_string(i) + ")";
- GenerateVerificationCodeForTypedVariable(out, val.union_value(i),
- union_field_expected_result,
- union_field_actual_result);
- }
- }
- break;
- }
- case TYPE_HIDL_CALLBACK:
- {
- out << "LOG(ERROR) << \"TYPE_HILD_CALLBACK is not supported yet. \";\n";
- break;
- }
- case TYPE_HANDLE:
- {
- out << "LOG(ERROR) << \"TYPE_HANDLE is not supported yet. \";\n";
- break;
- }
- case TYPE_HIDL_INTERFACE:
- {
- out << "LOG(ERROR) << \"TYPE_HIDL_INTERFACE is not supported yet. \";\n";
- break;
- }
- case TYPE_HIDL_MEMORY:
- {
- out << "LOG(ERROR) << \"TYPE_HIDL_MEMORY is not supported yet. \";\n";
- break;
- }
- case TYPE_POINTER:
- {
- out << "LOG(ERROR) << \"TYPE_POINTER is not supported yet. \";\n";
- break;
- }
- case TYPE_FMQ_SYNC:
- {
- out << "LOG(ERROR) << \"TYPE_FMQ_SYNC is not supported yet. \";\n";
- break;
- }
- case TYPE_FMQ_UNSYNC:
- {
- out << "LOG(ERROR) << \"TYPE_FMQ_UNSYNC is not supported yet. \";\n";
- break;
- }
- case TYPE_REF:
- {
- out << "LOG(ERROR) << \"TYPE_REF is not supported yet. \";\n";
- break;
- }
- case TYPE_SAFE_UNION: {
- out << "LOG(ERROR) << \"TYPE_SAFE_UNION is Not supported yet. \";\n";
- break;
- }
- default:
- {
- cerr << __func__ << " ERROR: unsupported type " << val.type() << ".\n";
- exit(-1);
- }
- }
-}
-
-void HalHidlCodeGen::GenerateVerificationDeclForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute) {
- if (attribute.type() == TYPE_STRUCT || attribute.type() == TYPE_UNION) {
- // Recursively generate verification method implementation for all sub_types.
- for (const auto& sub_struct : attribute.sub_struct()) {
- GenerateVerificationDeclForAttribute(out, sub_struct);
- }
- for (const auto& sub_union : attribute.sub_union()) {
- GenerateVerificationDeclForAttribute(out, sub_union);
- }
- }
- std::string func_name = "bool Verify"
- + ClearStringWithNameSpaceAccess(attribute.name());
- out << func_name << "(const VariableSpecificationMessage& expected_result, "
- << "const VariableSpecificationMessage& actual_result);\n";
-}
-
-void HalHidlCodeGen::GenerateVerificationImplForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute) {
- if (attribute.type() == TYPE_STRUCT || attribute.type() == TYPE_UNION) {
- // Recursively generate verification method implementation for all sub_types.
- for (const auto& sub_struct : attribute.sub_struct()) {
- GenerateVerificationImplForAttribute(out, sub_struct);
- }
- for (const auto& sub_union : attribute.sub_union()) {
- GenerateVerificationImplForAttribute(out, sub_union);
- }
- }
- std::string func_name = "bool Verify"
- + ClearStringWithNameSpaceAccess(attribute.name());
- out << func_name << "(const VariableSpecificationMessage& expected_result "
- "__attribute__((__unused__)), "
- << "const VariableSpecificationMessage& actual_result "
- "__attribute__((__unused__))){\n";
- out.indent();
- GenerateVerificationCodeForTypedVariable(out, attribute, "expected_result",
- "actual_result");
- out << "return true;\n";
- out.unindent();
- out << "}\n\n";
-}
-
-// TODO(zhuoyao): consider to generalize the pattern for
-// Verification/SetResult/DriverImpl.
-void HalHidlCodeGen::GenerateSetResultCodeForTypedVariable(Formatter& out,
- const VariableSpecificationMessage& val, const string& result_msg,
- const string& result_value) {
- switch (val.type()) {
- case TYPE_SCALAR:
- {
- out << result_msg << "->set_type(TYPE_SCALAR);\n";
- out << result_msg << "->set_scalar_type(\"" << val.scalar_type()
- << "\");\n";
- out << result_msg << "->mutable_scalar_value()->set_" << val.scalar_type()
- << "(" << result_value << ");\n";
- break;
- }
- case TYPE_STRING:
- {
- out << result_msg << "->set_type(TYPE_STRING);\n";
- out << result_msg << "->mutable_string_value()->set_message" << "("
- << result_value << ".c_str());\n";
- out << result_msg << "->mutable_string_value()->set_length" << "("
- << result_value << ".size());\n";
- break;
- }
- case TYPE_ENUM:
- {
- out << result_msg << "->set_type(TYPE_ENUM);\n";
- if (val.has_predefined_type()) {
- string func_name = "SetResult"
- + ClearStringWithNameSpaceAccess(val.predefined_type());
- out << func_name << "(" << result_msg << ", " << result_value << ");\n";
- } else {
- const string scalar_type = val.enum_value().scalar_type();
- out << result_msg << "->set_scalar_type(\"" << scalar_type << "\");\n";
- out << result_msg << "->mutable_scalar_value()->set_" << scalar_type
- << "(static_cast<" << scalar_type << ">(" << result_value
- << "));\n";
- }
- break;
- }
- case TYPE_MASK:
- {
- out << result_msg << "->set_type(TYPE_MASK);\n";
- out << result_msg << "->set_scalar_type(\"" << val.scalar_type()
- << "\");\n";
- out << result_msg << "->mutable_scalar_value()->set_" << val.scalar_type()
- << "(" << result_value << ");\n";
- break;
- }
- case TYPE_VECTOR:
- {
- out << result_msg << "->set_type(TYPE_VECTOR);\n";
- out << result_msg << "->set_vector_size(" << result_value
- << ".size());\n";
- out << "for (int i = 0; i < (int)" << result_value << ".size(); i++) {\n";
- out.indent();
- string vector_element_name = result_msg + "_vector_i";
- out << "auto *" << vector_element_name << " = " << result_msg
- << "->add_vector_value();\n";
- GenerateSetResultCodeForTypedVariable(out, val.vector_value(0),
- vector_element_name,
- result_value + "[i]");
- out.unindent();
- out << "}\n";
- break;
- }
- case TYPE_ARRAY:
- {
- out << result_msg << "->set_type(TYPE_ARRAY);\n";
- out << result_msg << "->set_vector_size(" << val.vector_value_size()
- << ");\n";
- out << "for (int i = 0; i < " << val.vector_value_size() << "; i++) {\n";
- out.indent();
- string array_element_name = result_msg + "_array_i";
- out << "auto *" << array_element_name << " = " << result_msg
- << "->add_vector_value();\n";
- GenerateSetResultCodeForTypedVariable(out, val.vector_value(0),
- array_element_name,
- result_value + "[i]");
- out.unindent();
- out << "}\n";
- break;
- }
- case TYPE_STRUCT:
- {
- out << result_msg << "->set_type(TYPE_STRUCT);\n";
- if (val.has_predefined_type()) {
- string func_name = "SetResult"
- + ClearStringWithNameSpaceAccess(val.predefined_type());
- out << func_name << "(" << result_msg << ", " << result_value << ");\n";
- } else {
- for (const auto& struct_field : val.struct_value()) {
- string struct_field_name = result_msg + "_" + struct_field.name();
- out << "auto *" << struct_field_name << " = " << result_msg
- << "->add_struct_value();\n";
- GenerateSetResultCodeForTypedVariable(
- out, struct_field, struct_field_name,
- result_value + "." + struct_field.name());
- if (struct_field.has_name()) {
- out << struct_field_name << "->set_name(\""
- << struct_field.name() << "\");\n";
- }
- }
- }
- break;
- }
- case TYPE_UNION:
- {
- out << result_msg << "->set_type(TYPE_UNION);\n";
- if (val.has_predefined_type()) {
- string func_name = "SetResult"
- + ClearStringWithNameSpaceAccess(val.predefined_type());
- out << func_name << "(" << result_msg << ", " << result_value << ");\n";
- } else {
- for (const auto& union_field : val.union_value()) {
- string union_field_name = result_msg + "_" + union_field.name();
- out << "auto *" << union_field_name << " = " << result_msg
- << "->add_union_value();\n";
- GenerateSetResultCodeForTypedVariable(
- out, union_field, union_field_name,
- result_value + "." + union_field.name());
- if (union_field.has_name()) {
- out << union_field_name << "->set_name(\"" << union_field.name()
- << "\");\n";
- }
- }
- }
- break;
- }
- case TYPE_HIDL_CALLBACK:
- {
- out << result_msg << "->set_type(TYPE_HIDL_CALLBACK);\n";
- out << "LOG(ERROR) << \"TYPE HIDL_CALLBACK is not supported yet. \";\n";
- break;
- }
- case TYPE_HANDLE:
- {
- out << result_msg << "->set_type(TYPE_HANDLE);\n";
- out << result_msg << "->mutable_handle_value()->set_hidl_handle_address"
- << "(reinterpret_cast<size_t>(new android::hardware::hidl_handle("
- << result_value << ")));\n";
- break;
- }
- case TYPE_HIDL_INTERFACE:
- {
- out << result_msg << "->set_type(TYPE_HIDL_INTERFACE);\n";
- if (!val.has_predefined_type()) {
- cerr << __func__ << ":" << __LINE__
- << " HIDL interface is a return type"
- << "but predefined_type is unset." << endl;
- exit(-1);
- }
- out << result_msg << "->set_predefined_type(\"" << val.predefined_type()
- << "\");\n";
- out << "if (" << result_value << " != nullptr) {\n";
- out.indent();
- out << result_value << "->incStrong(" << result_value << ".get());\n";
- out << result_msg << "->set_hidl_interface_pointer("
- << "reinterpret_cast<uintptr_t>(" << result_value << ".get()));\n";
- out.unindent();
- out << "} else {\n";
- out.indent();
- out << result_msg << "->set_hidl_interface_pointer(0);\n";
- out.unindent();
- out << "}\n";
- break;
- }
- case TYPE_HIDL_MEMORY:
- {
- out << result_msg << "->set_type(TYPE_HIDL_MEMORY);\n";
- out << result_msg << "->mutable_hidl_memory_value()->set_hidl_mem_address"
- << "(reinterpret_cast<size_t>(new android::hardware::hidl_memory("
- << result_value << ")));\n";
- break;
- }
- case TYPE_POINTER:
- {
- out << result_msg << "->set_type(TYPE_POINTER);\n";
- out << "LOG(ERROR) << \"TYPE_POINTER is not supported yet. \";\n";
- break;
- }
- case TYPE_FMQ_SYNC:
- case TYPE_FMQ_UNSYNC:
- {
- out << result_msg << "->set_type("
- << (val.type() == TYPE_FMQ_SYNC ? "TYPE_FMQ_SYNC" : "TYPE_FMQ_UNSYNC")
- << ");\n";
- string item_name = result_msg + "_item";
- out << "VariableSpecificationMessage* " << item_name << " = "
- << result_msg << "->add_fmq_value();\n";
- if (val.fmq_value(0).type() == TYPE_SCALAR) {
- // This FMQ uses scalar type, stores type name in
- // scalar_type field.
- out << item_name << "->set_type(TYPE_SCALAR);\n";
- out << item_name << "->set_scalar_type(\""
- << val.fmq_value(0).scalar_type() << "\");\n";
- } else if (val.fmq_value(0).type() == TYPE_ENUM) {
- // This FMQ uses enum type, stores type name in
- // predefined_type field.
- out << item_name << "->set_type(TYPE_ENUM);\n";
- out << item_name << "->set_predefined_type(\""
- << val.fmq_value(0).predefined_type() << "\");\n";
- } else if (val.fmq_value(0).type() == TYPE_STRUCT) {
- // This FMQ uses struct type, stores type name in
- // predefined_type field.
- out << item_name << "->set_type(TYPE_STRUCT);\n";
- out << item_name << "->set_predefined_type(\""
- << val.fmq_value(0).predefined_type() << "\");\n";
- } else if (val.fmq_value(0).type() == TYPE_UNION) {
- // This FMQ uses union type, stores type name in
- // predefined_type field.
- out << item_name << "->set_type(TYPE_UNION);\n";
- out << item_name << "->set_predefined_type(\""
- << val.fmq_value(0).predefined_type() << "\");\n";
- } else {
- // FMQ doesn't support string, vector, or array type.
- out << "LOG(ERROR) << \"Unsupport type of data in FMQ\";\n";
- }
- // Cast result into address, and save it in proto.
- out << item_name << "->set_fmq_desc_address("
- << "reinterpret_cast<size_t>(new (std::nothrow) "
- << GetCppVariableType(val) << "(" << result_value << ")));\n";
- break;
- }
- case TYPE_REF:
- {
- out << result_msg << "->set_type(TYPE_REF);\n";
- out << "LOG(ERROR) << \"TYPE_REF is not supported yet. \";\n";
- break;
- }
- case TYPE_SAFE_UNION: {
- out << result_msg << "->set_type(TYPE_SAFE_UNION);\n";
- out << "LOG(ERROR) << \"TYPE_SAFE_UNION is not supported yet. \";\n";
- break;
- }
- default:
- {
- cerr << __func__ << " ERROR: unsupported type " << val.type() << ".\n";
- exit(-1);
- }
- }
-}
-
-void HalHidlCodeGen::GenerateSetResultDeclForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute) {
- if (attribute.type() == TYPE_STRUCT || attribute.type() == TYPE_UNION ||
- attribute.type() == TYPE_SAFE_UNION) {
- // Recursively generate SetResult method implementation for all sub_types.
- for (const auto& sub_struct : attribute.sub_struct()) {
- GenerateSetResultDeclForAttribute(out, sub_struct);
- }
- for (const auto& sub_union : attribute.sub_union()) {
- GenerateSetResultDeclForAttribute(out, sub_union);
- }
- for (const auto& sub_safe_union : attribute.sub_safe_union()) {
- GenerateSetResultDeclForAttribute(out, sub_safe_union);
- }
- }
- // Add extern C to allow resource_manager to dynamically load this function.
- out << "extern \"C\" ";
- string func_name = "void SetResult"
- + ClearStringWithNameSpaceAccess(attribute.name());
- out << func_name << "(VariableSpecificationMessage* result_msg, "
- << attribute.name() << " result_value);\n";
-}
-
-void HalHidlCodeGen::GenerateSetResultImplForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute) {
- if (attribute.type() == TYPE_STRUCT || attribute.type() == TYPE_UNION ||
- attribute.type() == TYPE_SAFE_UNION) {
- // Recursively generate SetResult method implementation for all sub_types.
- for (const auto& sub_struct : attribute.sub_struct()) {
- GenerateSetResultImplForAttribute(out, sub_struct);
- }
- for (const auto& sub_union : attribute.sub_union()) {
- GenerateSetResultImplForAttribute(out, sub_union);
- }
- for (const auto& sub_safe_union : attribute.sub_safe_union()) {
- GenerateSetResultImplForAttribute(out, sub_safe_union);
- }
- }
- // Add extern C to allow resource_manager to dynamically load this function.
- out << "extern \"C\" ";
- string func_name = "void SetResult"
- + ClearStringWithNameSpaceAccess(attribute.name());
- out << func_name << "(VariableSpecificationMessage* result_msg, "
- << attribute.name() << " result_value __attribute__((__unused__))){\n";
- out.indent();
- GenerateSetResultCodeForTypedVariable(out, attribute, "result_msg",
- "result_value");
- out.unindent();
- out << "}\n\n";
-}
-
-void HalHidlCodeGen::GenerateDefaultReturnValForTypedVariable(
- Formatter& out, const VariableSpecificationMessage& val) {
- switch (val.type()) {
- case TYPE_SCALAR: {
- out << "static_cast<" << GetCppVariableType(val.scalar_type()) << ">(0)";
- break;
- }
- case TYPE_MASK: {
- out << "static_cast<" << GetCppVariableType(val.scalar_type()) << ">("
- << val.predefined_type() << "())";
- break;
- }
- case TYPE_HIDL_CALLBACK:
- case TYPE_HIDL_INTERFACE:
- case TYPE_POINTER:
- case TYPE_REF: {
- out << "nullptr";
- break;
- }
- case TYPE_STRING:
- case TYPE_ENUM:
- case TYPE_VECTOR:
- case TYPE_ARRAY:
- case TYPE_STRUCT:
- case TYPE_UNION:
- case TYPE_SAFE_UNION:
- case TYPE_HANDLE:
- case TYPE_HIDL_MEMORY:
- case TYPE_FMQ_SYNC:
- case TYPE_FMQ_UNSYNC: {
- out << GetCppVariableType(val) << "()";
- break;
- }
- default: {
- cerr << __func__ << " ERROR: unsupported type " << val.type() << ".\n";
- exit(-1);
- }
- }
-}
-
-void HalHidlCodeGen::GenerateAllFunctionDeclForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute) {
- GenerateDriverDeclForAttribute(out, attribute);
- GenerateRandomFunctionDeclForAttribute(out, attribute);
- GenerateVerificationDeclForAttribute(out, attribute);
- GenerateSetResultDeclForAttribute(out, attribute);
-}
-
-void HalHidlCodeGen::GenerateAllFunctionImplForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute) {
- GenerateDriverImplForAttribute(out, attribute);
- GenerateRandomFunctionImplForAttribute(out, attribute);
- GenerateVerificationImplForAttribute(out, attribute);
- GenerateSetResultImplForAttribute(out, attribute);
-}
-
-bool HalHidlCodeGen::CanElideCallback(
- const FunctionSpecificationMessage& func_msg) {
- // Can't elide callback for void or tuple-returning methods
- if (func_msg.return_type_hidl_size() != 1) {
- return false;
- }
- const VariableType& type = func_msg.return_type_hidl(0).type();
- if (type == TYPE_ARRAY || type == TYPE_VECTOR || type == TYPE_REF) {
- return false;
- }
- return IsElidableType(type);
-}
-
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/code_gen/driver/HalHidlCodeGen.h b/compilation_tools/vtsc/code_gen/driver/HalHidlCodeGen.h
deleted file mode 100644
index 4486ca4..0000000
--- a/compilation_tools/vtsc/code_gen/driver/HalHidlCodeGen.h
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_DRIVER_HALHIDLCODEGEN_H_
-#define VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_DRIVER_HALHIDLCODEGEN_H_
-
-#include <string>
-
-#include "code_gen/driver/DriverCodeGenBase.h"
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-class HalHidlCodeGen : public DriverCodeGenBase {
- public:
- explicit HalHidlCodeGen(const char* input_vts_file_path)
- : DriverCodeGenBase(input_vts_file_path) {}
-
- protected:
- void GenerateClassHeader(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) override;
-
- void GenerateClassImpl(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) override;
-
- void GenerateCppBodyFuzzFunction(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) override;
-
- virtual void GenerateDriverFunctionImpl(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) override;
-
- void GenerateVerificationFunctionImpl(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) override;
-
- void GenerateCppBodyGetAttributeFunction(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) override;
-
- void GenerateHeaderInterfaceImpl(
- Formatter& out, const ComponentSpecificationMessage& message) override;
-
- void GenerateCppBodyInterfaceImpl(
- Formatter& out, const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) override;
-
- void GenerateClassConstructionFunction(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) override;
-
- void GenerateHeaderGlobalFunctionDeclarations(Formatter& out,
- const ComponentSpecificationMessage& message,
- const bool print_extern_block = true) override;
-
- void GenerateCppBodyGlobalFunctions(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name,
- const bool print_extern_block = true) override;
-
- void GenerateHeaderIncludeFiles(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) override;
-
- void GenerateSourceIncludeFiles(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) override;
-
- void GenerateAdditionalFuctionDeclarations(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) override;
-
- void GeneratePublicFunctionDeclarations(
- Formatter& out, const ComponentSpecificationMessage& message) override;
-
- void GeneratePrivateMemberDeclarations(Formatter& out,
- const ComponentSpecificationMessage& message) override;
-
- private:
- void GenerateCppBodyFuzzFunction(Formatter& out,
- const StructSpecificationMessage& message,
- const string& fuzzer_extended_class_name,
- const string& original_data_structure_name, const string& parent_path);
-
- // Generates the code to declar the impl class for an interface.
- void GenerateClassDecalrationForInterface(
- Formatter& out, const ComponentSpecificationMessage& message);
-
- // Generates a scalar type in C/C++.
- void GenerateScalarTypeInC(Formatter& out, const string& type);
-
- // Generates the driver function implementation for hidl reserved methods.
- void GenerateDriverImplForReservedMethods(Formatter& out);
-
- // Generates the driver function implementation for a method.
- void GenerateDriverImplForMethod(Formatter& out,
- const FunctionSpecificationMessage& func_msg);
-
- // Generates the code to perform a Hal function call.
- void GenerateHalFunctionCall(Formatter& out,
- const FunctionSpecificationMessage& func_msg);
-
- // Generates the implementation of a callback passed to the Hal function call.
- void GenerateSyncCallbackFunctionImpl(Formatter& out,
- const FunctionSpecificationMessage& func_msg);
-
- // Generates the driver function declaration for attributes defined within
- // an interface or in a types.hal.
- void GenerateDriverDeclForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute);
-
- // Generates the driver function implementation for attributes defined within
- // an interface or in a types.hal.
- void GenerateDriverImplForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute);
-
- // Generates the driver code for a typed variable.
- void GenerateDriverImplForTypedVariable(Formatter& out,
- const VariableSpecificationMessage& val, const string& arg_name,
- const string& arg_value_name);
-
- // Generates the verification function declarations for attributes defined
- // within an interface or in a types.hal.
- void GenerateVerificationDeclForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute);
-
- // Generates the verification function implementation for attributes defined
- // within an interface or in a types.hal.
- void GenerateVerificationImplForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute);
-
- // Generates the verification code for a typed variable.
- void GenerateVerificationCodeForTypedVariable(Formatter& out,
- const VariableSpecificationMessage& val, const string& result_value,
- const string& expected_result);
-
- // Generates the SetResult function declarations for attributes defined
- // within an interface or in a types.hal.
- void GenerateSetResultDeclForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute);
-
- // Generates the SetResult function implementation for attributes defined
- // within an interface or in a types.hal.
- void GenerateSetResultImplForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute);
-
- // Generates the SetResult code for a typed variable.
- void GenerateSetResultCodeForTypedVariable(Formatter& out,
- const VariableSpecificationMessage& val, const string& result_msg,
- const string& result_val);
-
- // Generates the random function declaration for attributes defined within
- // an interface or in a types.hal.
- void GenerateRandomFunctionDeclForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute);
-
- // Generates the default return value for a typed variable.
- void GenerateDefaultReturnValForTypedVariable(
- Formatter& out, const VariableSpecificationMessage& val);
-
- // Generates the random function implementation for attributes defined within
- // an interface or in a types.hal.
- void GenerateRandomFunctionImplForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute);
-
- // Generates the getService function implementation for an interface.
- void GenerateGetServiceImpl(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name);
-
- // Generates all function declaration for an attributed.
- void GenerateAllFunctionDeclForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute);
-
- // Generates all function implementation for an attributed.
- void GenerateAllFunctionImplForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute);
-
- // Returns true if we could omit the callback function and return result
- // directly.
- bool CanElideCallback(const FunctionSpecificationMessage& func_msg);
-
- // instance variable name (e.g., device_);
- static const char* const kInstanceVariableName;
-};
-
-} // namespace vts
-} // namespace android
-
-#endif // VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_DRIVER_HALHIDLCODEGEN_H_
diff --git a/compilation_tools/vtsc/code_gen/driver/LibSharedCodeGen.cpp b/compilation_tools/vtsc/code_gen/driver/LibSharedCodeGen.cpp
deleted file mode 100644
index 2c92ecb..0000000
--- a/compilation_tools/vtsc/code_gen/driver/LibSharedCodeGen.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "code_gen/driver/LibSharedCodeGen.h"
-
-#include <iostream>
-#include <string>
-
-#include "VtsCompilerUtils.h"
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-using namespace std;
-using namespace android;
-
-namespace android {
-namespace vts {
-
-const char* const LibSharedCodeGen::kInstanceVariableName = "sharedlib_";
-
-void LibSharedCodeGen::GenerateCppBodyFuzzFunction(
- Formatter& out, const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) {
- out << "bool " << fuzzer_extended_class_name << "::Fuzz(" << "\n";
- out << " FunctionSpecificationMessage* func_msg," << "\n";
- out << " void** result, const string& callback_socket_name) {" << "\n";
- out.indent();
- out << "const char* func_name = func_msg->name().c_str();" << "\n";
- out << "LOG(INFO) << \"Function: \" << func_name;\n";
-
- for (auto const& api : message.interface().api()) {
- std::stringstream ss;
-
- out << "if (!strcmp(func_name, \"" << api.name() << "\")) {" << "\n";
-
- // args - definition;
- int arg_count = 0;
- for (auto const& arg : api.arg()) {
- if (arg_count == 0 && arg.type() == TYPE_PREDEFINED &&
- !strncmp(arg.predefined_type().c_str(),
- message.original_data_structure_name().c_str(),
- message.original_data_structure_name().length()) &&
- message.original_data_structure_name().length() > 0) {
- out << " " << GetCppVariableType(arg) << " "
- << "arg" << arg_count << " = ";
- out << "reinterpret_cast<" << GetCppVariableType(arg) << ">("
- << kInstanceVariableName << ")";
- } else if (arg.type() == TYPE_SCALAR) {
- if (arg.scalar_type() == "char_pointer" ||
- arg.scalar_type() == "uchar_pointer") {
- if (arg.scalar_type() == "char_pointer") {
- out << " char ";
- } else {
- out << " unsigned char ";
- }
- out << "arg" << arg_count
- << "[func_msg->arg(" << arg_count
- << ").string_value().length() + 1];" << "\n";
- out << " if (func_msg->arg(" << arg_count
- << ").type() == TYPE_SCALAR && "
- << "func_msg->arg(" << arg_count
- << ").string_value().has_message()) {" << "\n";
- out << " strcpy(arg" << arg_count << ", "
- << "func_msg->arg(" << arg_count << ").string_value()"
- << ".message().c_str());" << "\n";
- out << " } else {" << "\n";
- out << " strcpy(arg" << arg_count << ", "
- << GetCppInstanceType(arg) << ");" << "\n";
- out << " }" << "\n";
- } else {
- out << " " << GetCppVariableType(arg) << " "
- << "arg" << arg_count << " = ";
- out << "(func_msg->arg(" << arg_count
- << ").type() == TYPE_SCALAR && "
- << "func_msg->arg(" << arg_count
- << ").scalar_value().has_" << arg.scalar_type() << "()) ? ";
- if (arg.scalar_type() == "void_pointer") {
- out << "reinterpret_cast<" << GetCppVariableType(arg) << ">(";
- }
- out << "func_msg->arg(" << arg_count << ").scalar_value()."
- << arg.scalar_type() << "()";
- if (arg.scalar_type() == "void_pointer") {
- out << ")";
- }
- out << " : " << GetCppInstanceType(arg);
- }
- } else {
- out << " " << GetCppVariableType(arg) << " "
- << "arg" << arg_count << " = ";
- out << GetCppInstanceType(arg);
- }
- out << ";" << "\n";
- out << "LOG(INFO) << \"arg" << arg_count << " = \" << arg" << arg_count
- << ";\n";
- arg_count++;
- }
-
- out << " ";
- out << "typedef void* (*";
- out << "func_type_" << api.name() << ")(...";
- out << ");" << "\n";
-
- // actual function call
- if (!api.has_return_type() || api.return_type().type() == TYPE_VOID) {
- out << "*result = NULL;" << "\n";
- } else {
- out << "*result = const_cast<void*>(reinterpret_cast<const void*>(";
- }
- out << " ";
- out << "((func_type_" << api.name() << ") "
- << "target_loader_.GetLoaderFunction(\"" << api.name() << "\"))(";
- // out << "reinterpret_cast<" << message.original_data_structure_name()
- // << "*>(" << kInstanceVariableName << ")->" << api.name() << "(";
-
- if (arg_count > 0) out << "\n";
-
- for (int index = 0; index < arg_count; index++) {
- out << " arg" << index;
- if (index != (arg_count - 1)) {
- out << "," << "\n";
- }
- }
- if (api.has_return_type() || api.return_type().type() != TYPE_VOID) {
- out << "))";
- }
- out << ");" << "\n";
- out << " return true;" << "\n";
- out << " }" << "\n";
- }
- // TODO: if there were pointers, free them.
- out << "return false;" << "\n";
- out.unindent();
- out << "}" << "\n";
-}
-
-void LibSharedCodeGen::GenerateCppBodyGetAttributeFunction(
- Formatter& out,
- const ComponentSpecificationMessage& /*message*/,
- const string& fuzzer_extended_class_name) {
- out << "bool " << fuzzer_extended_class_name << "::GetAttribute(" << "\n";
- out << " FunctionSpecificationMessage* func_msg," << "\n";
- out << " void** result) {" << "\n";
- out.indent();
- out << "const char* func_name = func_msg->name().c_str();" << "\n";
- out << "LOG(INFO) << \" '\" << func_name << \"'\";\n";
- out << "LOG(ERROR) << \"attribute not supported for shared lib yet.\";"
- << "\n";
- out << "return false;" << "\n";
- out.unindent();
- out << "}" << "\n";
-}
-
-void LibSharedCodeGen::GenerateClassConstructionFunction(Formatter& out,
- const ComponentSpecificationMessage& /*message*/,
- const string& fuzzer_extended_class_name) {
- out << fuzzer_extended_class_name << "() : DriverBase(LIB_SHARED) {}\n";
-}
-
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/code_gen/driver/LibSharedCodeGen.h b/compilation_tools/vtsc/code_gen/driver/LibSharedCodeGen.h
deleted file mode 100644
index c13b109..0000000
--- a/compilation_tools/vtsc/code_gen/driver/LibSharedCodeGen.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_DRIVER_LIBSHARED_CODEGEN_H_
-#define VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_DRIVER_LIBSHARED_CODEGEN_H_
-
-#include <string>
-
-#include "code_gen/driver/HalCodeGen.h"
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-class LibSharedCodeGen : public HalCodeGen {
- public:
- explicit LibSharedCodeGen(const char* input_vts_file_path)
- : HalCodeGen(input_vts_file_path) {}
-
- protected:
- void GenerateCppBodyFuzzFunction(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) override;
-
- void GenerateCppBodyGetAttributeFunction(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) override;
-
- void GenerateClassConstructionFunction(Formatter& out,
- const ComponentSpecificationMessage& message,
- const string& fuzzer_extended_class_name) override;
-
- // instance variable name (e.g., submodule_);
- static const char* const kInstanceVariableName;
-};
-
-} // namespace vts
-} // namespace android
-
-#endif // VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_DRIVER_LIBSHARED_CODEGEN_H_
diff --git a/compilation_tools/vtsc/code_gen/fuzzer/FuzzerCodeGenBase.cpp b/compilation_tools/vtsc/code_gen/fuzzer/FuzzerCodeGenBase.cpp
deleted file mode 100644
index 80505e1..0000000
--- a/compilation_tools/vtsc/code_gen/fuzzer/FuzzerCodeGenBase.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "FuzzerCodeGenBase.h"
-
-#include <iostream>
-
-using std::cerr;
-using std::cout;
-using std::endl;
-using std::string;
-
-namespace android {
-namespace vts {
-
-void FuzzerCodeGenBase::GenerateAll(Formatter & /* header_out */,
- Formatter &source_out) {
- GenerateSourceFile(source_out);
-}
-
-void FuzzerCodeGenBase::GenerateHeaderFile(Formatter & /* out */) {
- cout << "Headers are not generated for fuzzer." << endl;
-}
-
-void FuzzerCodeGenBase::GenerateSourceFile(Formatter &out) {
- if (!comp_spec_.has_interface()) {
- return;
- }
- GenerateWarningComment(out);
- GenerateSourceIncludeFiles(out);
- GenerateUsingDeclaration(out);
- GenerateOpenNameSpaces(out);
- GenerateGlobalVars(out);
- GenerateLLVMFuzzerInitialize(out);
- GenerateLLVMFuzzerTestOneInput(out);
- GenerateCloseNameSpaces(out);
-}
-
-void FuzzerCodeGenBase::GenerateOpenNameSpaces(Formatter &out) {
- out << "namespace android {\n";
- out << "namespace vts {\n\n";
-}
-
-void FuzzerCodeGenBase::GenerateCloseNameSpaces(Formatter &out) {
- out << "} // namespace vts\n";
- out << "} // namespace android\n";
-}
-
-void FuzzerCodeGenBase::GenerateWarningComment(Formatter &out) {
- out << "// This file was auto-generated by VTS compiler.\n\n";
-}
-
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/code_gen/fuzzer/FuzzerCodeGenBase.h b/compilation_tools/vtsc/code_gen/fuzzer/FuzzerCodeGenBase.h
deleted file mode 100644
index e301221..0000000
--- a/compilation_tools/vtsc/code_gen/fuzzer/FuzzerCodeGenBase.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_FUZZER_FUZZERCODEGENBASE_H_
-#define VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_FUZZER_FUZZERCODEGENBASE_H_
-
-#include <hidl-util/Formatter.h>
-#include <iostream>
-#include <string>
-
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-namespace android {
-namespace vts {
-
-// Base class generates LLVM libfuzzer code for HAL interfaces.
-// Takes VTS spec in the form of a ComponentSpecificationMessage and generates
-// one source file per interface function in the spec.
-// All fuzzer code generators should derive from this class.
-class FuzzerCodeGenBase {
- public:
- explicit FuzzerCodeGenBase(const ComponentSpecificationMessage &comp_spec)
- : comp_spec_(comp_spec) {}
-
- virtual ~FuzzerCodeGenBase(){};
-
- // Generates all files.
- void GenerateAll(Formatter &header_out, Formatter &source_out);
- // Generates fuzzer header file.
- void GenerateHeaderFile(Formatter &out);
- // Generates fuzzer source file.
- void GenerateSourceFile(Formatter &out);
-
- protected:
- // Generates "#include" declarations.
- virtual void GenerateSourceIncludeFiles(Formatter &out) = 0;
- // Generates "using" declarations.
- virtual void GenerateUsingDeclaration(Formatter &out) = 0;
- // Generates global variable declarations.
- virtual void GenerateGlobalVars(Formatter &out) = 0;
- // Generates definition of LLVMFuzzerInitialize function.
- virtual void GenerateLLVMFuzzerInitialize(Formatter &out) = 0;
- // Generates definition of LLVMFuzzerTestOneInput function.
- virtual void GenerateLLVMFuzzerTestOneInput(Formatter &out) = 0;
- virtual void GenerateOpenNameSpaces(Formatter &out);
- virtual void GenerateCloseNameSpaces(Formatter &out);
-
- // Generates warning that file was auto-generated.
- virtual void GenerateWarningComment(Formatter &out);
-
- // Contains all information about the component.
- const ComponentSpecificationMessage &comp_spec_;
-};
-
-} // namespace vts
-} // namespace android
-
-#endif // VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_FUZZER_FUZZERCODEGENBASE_H_
diff --git a/compilation_tools/vtsc/code_gen/fuzzer/HalHidlFuzzerCodeGen.cpp b/compilation_tools/vtsc/code_gen/fuzzer/HalHidlFuzzerCodeGen.cpp
deleted file mode 100644
index 3f31163..0000000
--- a/compilation_tools/vtsc/code_gen/fuzzer/HalHidlFuzzerCodeGen.cpp
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "HalHidlFuzzerCodeGen.h"
-#include "VtsCompilerUtils.h"
-#include "code_gen/common/HalHidlCodeGenUtils.h"
-#include "utils/InterfaceSpecUtil.h"
-#include "utils/StringUtil.h"
-
-using std::cerr;
-using std::cout;
-using std::endl;
-using std::vector;
-
-namespace android {
-namespace vts {
-
-void HalHidlFuzzerCodeGen::GenerateSourceIncludeFiles(Formatter &out) {
- out << "#include <iostream>\n\n";
- out << "#include \"FuncFuzzerUtils.h\"\n";
- out << "#include <" << GetPackagePath(comp_spec_) << "/"
- << GetVersion(comp_spec_) << "/" << GetComponentName(comp_spec_)
- << ".h>\n";
- out << "\n";
-}
-
-void HalHidlFuzzerCodeGen::GenerateUsingDeclaration(Formatter &out) {
- out << "using std::cerr;\n";
- out << "using std::endl;\n";
- out << "using std::string;\n\n";
-
- string package_path = comp_spec_.package();
- ReplaceSubString(package_path, ".", "::");
- string comp_version = GetVersion(comp_spec_, true);
-
- out << "using namespace ::" << package_path << "::" << comp_version << ";\n";
- out << "using namespace ::android::hardware;\n";
- out << "\n";
-}
-
-void HalHidlFuzzerCodeGen::GenerateGlobalVars(Formatter &out) {
- out << "static string target_func;\n\n";
-}
-
-void HalHidlFuzzerCodeGen::GenerateLLVMFuzzerInitialize(Formatter &out) {
- out << "extern \"C\" int LLVMFuzzerInitialize(int *argc, char ***argv) "
- "{\n";
- out.indent();
- out << "FuncFuzzerParams params{ExtractFuncFuzzerParams(*argc, *argv)};\n";
- out << "target_func = params.target_func_;\n";
- out << "return 0;\n";
- out.unindent();
- out << "}\n\n";
-}
-
-void HalHidlFuzzerCodeGen::GenerateLLVMFuzzerTestOneInput(Formatter &out) {
- out << "extern \"C\" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t "
- "size) {\n";
- out.indent();
- out << "static ::android::sp<" << comp_spec_.component_name() << "> "
- << GetHalPointerName() << " = " << comp_spec_.component_name()
- << "::getService(true);\n";
- out << "if (" << GetHalPointerName() << " == nullptr) {\n";
- out.indent();
- out << "cerr << \"" << comp_spec_.component_name()
- << "::getService() failed\" << endl;\n";
- out << "exit(1);\n";
- out.unindent();
- out << "}\n\n";
- for (const auto &func_spec : comp_spec_.interface().api()) {
- GenerateHalFunctionCall(out, func_spec);
- }
- out << "{\n";
- out.indent();
- out << "cerr << \"No such function: \" << target_func << endl;\n";
- out << "exit(1);\n";
- out.unindent();
- out << "}\n";
-
- out.unindent();
- out << "}\n\n";
-}
-
-string HalHidlFuzzerCodeGen::GetHalPointerName() {
- string prefix = "android.hardware.";
- string hal_pointer_name = comp_spec_.package().substr(prefix.size());
- ReplaceSubString(hal_pointer_name, ".", "_");
- return hal_pointer_name;
-}
-
-void HalHidlFuzzerCodeGen::GenerateReturnCallback(
- Formatter &out, const FunctionSpecificationMessage &func_spec) {
- if (CanElideCallback(func_spec)) {
- return;
- }
- out << "// No-op. Only need this to make HAL function call.\n";
- out << "auto " << return_cb_name << " = [](";
- size_t num_cb_arg = func_spec.return_type_hidl_size();
- for (size_t i = 0; i < num_cb_arg; ++i) {
- const auto &return_val = func_spec.return_type_hidl(i);
- out << GetCppVariableType(return_val, IsConstType(return_val.type()));
- out << " arg" << i << ((i != num_cb_arg - 1) ? ", " : "");
- }
- out << "){};\n\n";
-}
-
-void HalHidlFuzzerCodeGen::GenerateHalFunctionCall(
- Formatter &out, const FunctionSpecificationMessage &func_spec) {
- string func_name = func_spec.name();
- out << "if (target_func == \"" << func_name << "\") {\n";
- out.indent();
-
- GenerateReturnCallback(out, func_spec);
- vector<string> types{GetFuncArgTypes(func_spec)};
- for (size_t i = 0; i < types.size(); ++i) {
- out << "size_t type_size" << i << " = sizeof(" << types[i] << ");\n";
- out << "if (size < type_size" << i << ") { return 0; }\n";
- out << "size -= type_size" << i << ";\n";
- out << types[i] << " arg" << i << ";\n";
- out << "memcpy(&arg" << i << ", data, type_size" << i << ");\n";
- out << "data += type_size" << i << ";\n\n";
- }
-
- out << GetHalPointerName() << "->" << func_spec.name() << "(";
- for (size_t i = 0; i < types.size(); ++i) {
- out << "arg" << i << ((i != types.size() - 1) ? ", " : "");
- }
- if (!CanElideCallback(func_spec)) {
- if (func_spec.arg_size() > 0) {
- out << ", ";
- }
- out << return_cb_name;
- }
- out << ");\n";
- out << "return 0;\n";
-
- out.unindent();
- out << "} else ";
-}
-
-bool HalHidlFuzzerCodeGen::CanElideCallback(
- const FunctionSpecificationMessage &func_spec) {
- if (func_spec.return_type_hidl_size() == 0) {
- return true;
- }
- // Can't elide callback for void or tuple-returning methods
- if (func_spec.return_type_hidl_size() != 1) {
- return false;
- }
- const VariableType &type = func_spec.return_type_hidl(0).type();
- if (type == TYPE_ARRAY || type == TYPE_VECTOR || type == TYPE_REF) {
- return false;
- }
- return IsElidableType(type);
-}
-
-vector<string> HalHidlFuzzerCodeGen::GetFuncArgTypes(
- const FunctionSpecificationMessage &func_spec) {
- vector<string> types{};
- for (const auto &var_spec : func_spec.arg()) {
- string type = GetCppVariableType(var_spec);
- types.emplace_back(GetCppVariableType(var_spec));
- }
- return types;
-}
-
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/code_gen/fuzzer/HalHidlFuzzerCodeGen.h b/compilation_tools/vtsc/code_gen/fuzzer/HalHidlFuzzerCodeGen.h
deleted file mode 100644
index fbe2ebb..0000000
--- a/compilation_tools/vtsc/code_gen/fuzzer/HalHidlFuzzerCodeGen.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_FUZZER_HALHIDLFUZZERCODEGEN_H_
-#define VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_FUZZER_HALHIDLFUZZERCODEGEN_H_
-
-#include "code_gen/fuzzer/FuzzerCodeGenBase.h"
-
-namespace android {
-namespace vts {
-
-// Generates fuzzer code for HIDL HALs.
-class HalHidlFuzzerCodeGen : public FuzzerCodeGenBase {
- public:
- explicit HalHidlFuzzerCodeGen(const ComponentSpecificationMessage &comp_spec)
- : FuzzerCodeGenBase(comp_spec) {}
-
- void GenerateSourceIncludeFiles(Formatter &out) override;
- void GenerateUsingDeclaration(Formatter &out) override;
- void GenerateGlobalVars(Formatter &out) override;
- void GenerateLLVMFuzzerInitialize(Formatter &out) override;
- void GenerateLLVMFuzzerTestOneInput(Formatter &out) override;
-
- private:
- // Generates return callback function for HAL function being fuzzed.
- void GenerateReturnCallback(Formatter &out,
- const FunctionSpecificationMessage &func_spec);
- // Generates function call.
- void GenerateHalFunctionCall(Formatter &out,
- const FunctionSpecificationMessage &func_spec);
- // Returns name of pointer to hal instance.
- std::string GetHalPointerName();
- // Returns true if we could omit the callback function and return result
- // directly.
- bool CanElideCallback(const FunctionSpecificationMessage &func_spec);
- // Returns a vector of strings containing type names of function arguments.
- std::vector<std::string> GetFuncArgTypes(
- const FunctionSpecificationMessage &func_spec);
- // Name of return callback. Since we only fuzz one function, we'll need at
- // most one return callback.
- const std::string return_cb_name = "hidl_cb";
-};
-
-} // namespace vts
-} // namespace android
-
-#endif // VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_FUZZER_HALHIDLFUZZERCODEGEN_H_
diff --git a/compilation_tools/vtsc/code_gen/profiler/HalHidlProfilerCodeGen.cpp b/compilation_tools/vtsc/code_gen/profiler/HalHidlProfilerCodeGen.cpp
deleted file mode 100644
index 566d6d4..0000000
--- a/compilation_tools/vtsc/code_gen/profiler/HalHidlProfilerCodeGen.cpp
+++ /dev/null
@@ -1,597 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "HalHidlProfilerCodeGen.h"
-#include "VtsCompilerUtils.h"
-#include "utils/InterfaceSpecUtil.h"
-#include "utils/StringUtil.h"
-
-namespace android {
-namespace vts {
-
-void HalHidlProfilerCodeGen::GenerateProfilerForScalarVariable(
- Formatter& out, const VariableSpecificationMessage& val,
- const std::string& arg_name, const std::string& arg_value) {
- out << arg_name << "->set_type(TYPE_SCALAR);\n";
- out << arg_name << "->mutable_scalar_value()->set_" << val.scalar_type()
- << "(" << arg_value << ");\n";
-}
-
-void HalHidlProfilerCodeGen::GenerateProfilerForStringVariable(
- Formatter& out, const VariableSpecificationMessage&,
- const std::string& arg_name, const std::string& arg_value) {
- out << arg_name << "->set_type(TYPE_STRING);\n";
- out << arg_name << "->mutable_string_value()->set_message"
- << "(" << arg_value << ".c_str());\n";
- out << arg_name << "->mutable_string_value()->set_length"
- << "(" << arg_value << ".size());\n";
-}
-
-void HalHidlProfilerCodeGen::GenerateProfilerForEnumVariable(
- Formatter& out, const VariableSpecificationMessage& val,
- const std::string& arg_name, const std::string& arg_value) {
- out << arg_name << "->set_type(TYPE_ENUM);\n";
-
- // For predefined type, call the corresponding profile method.
- if (val.has_predefined_type()) {
- std::string predefined_type = val.predefined_type();
- ReplaceSubString(predefined_type, "::", "__");
- out << "profile__" << predefined_type << "(" << arg_name << ", "
- << arg_value << ");\n";
- } else {
- const std::string scalar_type = val.enum_value().scalar_type();
- out << arg_name << "->mutable_scalar_value()->set_" << scalar_type
- << "(static_cast<" << scalar_type << ">(" << arg_value << "));\n";
- out << arg_name << "->set_scalar_type(\"" << scalar_type << "\");\n";
- }
-}
-
-void HalHidlProfilerCodeGen::GenerateProfilerForVectorVariable(
- Formatter& out, const VariableSpecificationMessage& val,
- const std::string& arg_name, const std::string& arg_value) {
- out << arg_name << "->set_type(TYPE_VECTOR);\n";
- out << arg_name << "->set_vector_size(" << arg_value << ".size());\n";
- std::string index_name = GetVarString(arg_name) + "_index";
- out << "for (int " << index_name << " = 0; " << index_name << " < (int)"
- << arg_value << ".size(); " << index_name << "++) {\n";
- out.indent();
- std::string vector_element_name =
- GetVarString(arg_name) + "_vector_" + index_name;
- out << "auto *" << vector_element_name
- << " __attribute__((__unused__)) = " << arg_name
- << "->add_vector_value();\n";
- GenerateProfilerForTypedVariable(out, val.vector_value(0),
- vector_element_name,
- arg_value + "[" + index_name + "]");
- out.unindent();
- out << "}\n";
-}
-
-void HalHidlProfilerCodeGen::GenerateProfilerForArrayVariable(
- Formatter& out, const VariableSpecificationMessage& val,
- const std::string& arg_name, const std::string& arg_value) {
- out << arg_name << "->set_type(TYPE_ARRAY);\n";
- out << arg_name << "->set_vector_size(" << val.vector_size() << ");\n";
- std::string index_name = GetVarString(arg_name) + "_index";
- out << "for (int " << index_name << " = 0; " << index_name << " < "
- << val.vector_size() << "; " << index_name << "++) {\n";
- out.indent();
- std::string array_element_name =
- GetVarString(arg_name) + "_array_" + index_name;
- out << "auto *" << array_element_name
- << " __attribute__((__unused__)) = " << arg_name
- << "->add_vector_value();\n";
- GenerateProfilerForTypedVariable(out, val.vector_value(0), array_element_name,
- arg_value + "[" + index_name + "]");
- out.unindent();
- out << "}\n";
-}
-
-void HalHidlProfilerCodeGen::GenerateProfilerForStructVariable(
- Formatter& out, const VariableSpecificationMessage& val,
- const std::string& arg_name, const std::string& arg_value) {
- out << arg_name << "->set_type(TYPE_STRUCT);\n";
- // For predefined type, call the corresponding profile method.
- if (val.struct_value().size() == 0 && val.has_predefined_type()) {
- std::string predefined_type = val.predefined_type();
- ReplaceSubString(predefined_type, "::", "__");
- out << "profile__" << predefined_type << "(" << arg_name << ", "
- << arg_value << ");\n";
- } else {
- for (const auto& struct_field : val.struct_value()) {
- std::string struct_field_name = arg_name + "_" + struct_field.name();
- out << "auto *" << struct_field_name
- << " __attribute__((__unused__)) = " << arg_name
- << "->add_struct_value();\n";
- GenerateProfilerForTypedVariable(out, struct_field, struct_field_name,
- arg_value + "." + struct_field.name());
- }
- }
-}
-
-void HalHidlProfilerCodeGen::GenerateProfilerForUnionVariable(
- Formatter& out, const VariableSpecificationMessage& val,
- const std::string& arg_name, const std::string& arg_value) {
- out << arg_name << "->set_type(TYPE_UNION);\n";
- // For predefined type, call the corresponding profile method.
- if (val.union_value().size() == 0 && val.has_predefined_type()) {
- std::string predefined_type = val.predefined_type();
- ReplaceSubString(predefined_type, "::", "__");
- out << "profile__" << predefined_type << "(" << arg_name << ", "
- << arg_value << ");\n";
- } else {
- for (const auto& union_field : val.union_value()) {
- std::string union_field_name = arg_name + "_" + union_field.name();
- out << "auto *" << union_field_name << " = " << arg_name
- << "->add_union_value();\n";
- GenerateProfilerForTypedVariable(out, union_field, union_field_name,
- arg_value + "." + union_field.name());
- }
- }
-}
-
-void HalHidlProfilerCodeGen::GenerateProfilerForHidlCallbackVariable(
- Formatter& out, const VariableSpecificationMessage& val,
- const std::string& arg_name, const std::string&) {
- out << arg_name << "->set_type(TYPE_HIDL_CALLBACK);\n";
- out << arg_name << "->set_predefined_type(\"" << val.predefined_type()
- << "\");\n";
-}
-
-void HalHidlProfilerCodeGen::GenerateProfilerForHidlInterfaceVariable(
- Formatter& out, const VariableSpecificationMessage& val,
- const std::string& arg_name, const std::string&) {
- out << arg_name << "->set_type(TYPE_HIDL_INTERFACE);\n";
- out << arg_name << "->set_predefined_type(\"" << val.predefined_type()
- << "\");\n";
-}
-
-void HalHidlProfilerCodeGen::GenerateProfilerForMaskVariable(
- Formatter& out, const VariableSpecificationMessage& val,
- const std::string& arg_name, const std::string& arg_value) {
- out << arg_name << "->set_type(TYPE_MASK);\n";
- out << arg_name << "->set_scalar_type(\"" << val.scalar_type() << "\");\n";
- out << arg_name << "->mutable_scalar_value()->set_" << val.scalar_type()
- << "(" << arg_value << ");\n";
-}
-
-void HalHidlProfilerCodeGen::GenerateProfilerForHandleVariable(
- Formatter& out, const VariableSpecificationMessage&,
- const std::string& arg_name, const std::string& arg_value) {
- out << arg_name << "->set_type(TYPE_HANDLE);\n";
- std::string handle_name = arg_name + "_h";
- out << "auto " << handle_name << " = " << arg_value
- << ".getNativeHandle();\n";
- out << "if (" << handle_name << ") {\n";
- out.indent();
- out << arg_name << "->mutable_handle_value()->set_version(" << handle_name
- << "->version);\n";
- out << arg_name << "->mutable_handle_value()->set_num_ints(" << handle_name
- << "->numInts);\n";
- out << arg_name << "->mutable_handle_value()->set_num_fds(" << handle_name
- << "->numFds);\n";
- out << "for (int i = 0; i < " << handle_name << "->numInts + " << handle_name
- << "->numFds; i++) {\n";
- out.indent();
- out << "if(i < " << handle_name << "->numFds) {\n";
- out.indent();
- out << "auto* fd_val_i = " << arg_name
- << "->mutable_handle_value()->add_fd_val();\n";
- out << "char filePath[PATH_MAX];\n";
- out << "string procPath = \"/proc/self/fd/\" + to_string(" << handle_name
- << "->data[i]);\n";
- out << "ssize_t r = readlink(procPath.c_str(), filePath, "
- "sizeof(filePath));\n";
- out << "if (r == -1) {\n";
- out.indent();
- out << "LOG(ERROR) << \"Unable to get file path\";\n";
- out << "continue;\n";
- out.unindent();
- out << "}\n";
- out << "filePath[r] = '\\0';\n";
- out << "fd_val_i->set_file_name(filePath);\n";
- out << "struct stat statbuf;\n";
- out << "fstat(" << handle_name << "->data[i], &statbuf);\n";
- out << "fd_val_i->set_mode(statbuf.st_mode);\n";
- out << "if (S_ISREG(statbuf.st_mode) || S_ISDIR(statbuf.st_mode)) {\n";
- out.indent();
- out << "fd_val_i->set_type(S_ISREG(statbuf.st_mode)? FILE_TYPE: DIR_TYPE);\n";
- out << "int flags = fcntl(" << handle_name << "->data[i], F_GETFL);\n";
- out << "fd_val_i->set_flags(flags);\n";
- out.unindent();
- out << "}\n";
- out << "else if (S_ISCHR(statbuf.st_mode) || S_ISBLK(statbuf.st_mode)) {\n";
- out.indent();
- out << "fd_val_i->set_type(DEV_TYPE);\n";
- out << "if (strcmp(filePath, \"/dev/ashmem\") == 0) {\n";
- out.indent();
- out << "int size = ashmem_get_size_region(" << handle_name << "->data[i]);\n";
- out << "fd_val_i->mutable_memory()->set_size(size);\n";
- out.unindent();
- out << "}\n";
- out.unindent();
- out << "}\n";
- out << "else if (S_ISFIFO(statbuf.st_mode)){\n";
- out.indent();
- out << "fd_val_i->set_type(PIPE_TYPE);\n";
- out.unindent();
- out << "}\n";
- out << "else if (S_ISSOCK(statbuf.st_mode)) {\n";
- out.indent();
- out << "fd_val_i->set_type(SOCKET_TYPE);\n";
- out.unindent();
- out << "}\n";
- out << "else {\n";
- out.indent();
- out << "fd_val_i->set_type(LINK_TYPE);\n";
- out.unindent();
- out << "}\n";
- out.unindent();
- out << "} else {\n";
- out.indent();
- out << arg_name << "->mutable_handle_value()->add_int_val(" << handle_name
- << "->data[i]);\n";
- out.unindent();
- out << "}\n";
- out.unindent();
- out << "}\n";
- out.unindent();
- out << "} else {\n";
- out.indent();
- out << "LOG(WARNING) << \"null handle\";\n";
- out << arg_name << "->mutable_handle_value()->set_hidl_handle_address(0);\n";
- out.unindent();
- out << "}\n";
-}
-
-void HalHidlProfilerCodeGen::GenerateProfilerForHidlMemoryVariable(
- Formatter& out, const VariableSpecificationMessage&,
- const std::string& arg_name, const std::string& arg_value) {
- out << arg_name << "->set_type(TYPE_HIDL_MEMORY);\n";
- out << arg_name << "->mutable_hidl_memory_value()->set_size"
- << "(" << arg_value << ".size());\n";
- // Dump the memory contents if specified in system property.
- out << "if (property_get_bool(\"hal.instrumentation.dump.memory\", "
- "false)){\n";
- out.indent();
- string mem_name = arg_name + "_mem";
- string mem_content_name = arg_name + "_mem_char";
- out << "sp<android::hidl::memory::V1_0::IMemory> " << mem_name
- << " = mapMemory(" << arg_value << ");\n";
- out << "if (" << mem_name << " == nullptr) {\n";
- out.indent();
- out << "LOG(WARNING) << \"Unable to map hidl_memory to IMemory object.\";\n";
- out.unindent();
- out << "} else {\n";
- out.indent();
- out << mem_name << "->read();\n";
- out << "char* " << mem_content_name
- << " = static_cast<char*>(static_cast<void*>(" << mem_name
- << "->getPointer()));\n";
- out << arg_name << "->mutable_hidl_memory_value()->set_contents(string("
- << mem_content_name << ", " << arg_value << ".size()));\n";
- out << mem_name << "->commit();\n";
- out.unindent();
- out << "}\n";
- out.unindent();
- out << "}\n";
-}
-
-void HalHidlProfilerCodeGen::GenerateProfilerForPointerVariable(
- Formatter& out, const VariableSpecificationMessage&,
- const std::string& arg_name, const std::string&) {
- out << arg_name << "->set_type(TYPE_POINTER);\n";
- // TODO(zhuoyao): figure the right way to profile pointer type.
-}
-
-void HalHidlProfilerCodeGen::GenerateProfilerForFMQSyncVariable(
- Formatter& out, const VariableSpecificationMessage& val,
- const std::string& arg_name, const std::string& arg_value) {
- out << arg_name << "->set_type(TYPE_FMQ_SYNC);\n";
- string element_type = GetCppVariableType(val.fmq_value(0));
- std::string queue_name = arg_name + "_q";
- std::string temp_result_name = arg_name + "_result";
- out << "MessageQueue<" << element_type << ", kSynchronizedReadWrite> "
- << queue_name << "(" << arg_value << ", false);\n";
- out << "if (" << queue_name << ".isValid()) {\n";
- out.indent();
- out << "for (int i = 0; i < (int)" << queue_name
- << ".availableToRead(); i++) {\n";
- out.indent();
- std::string fmq_item_name = arg_name + "_item_i";
- out << "auto *" << fmq_item_name << " = " << arg_name
- << "->add_fmq_value();\n";
- out << element_type << " " << temp_result_name << ";\n";
- out << queue_name << ".read(&" << temp_result_name << ");\n";
- out << queue_name << ".write(&" << temp_result_name << ");\n";
- GenerateProfilerForTypedVariable(out, val.fmq_value(0), fmq_item_name,
- temp_result_name);
- out.unindent();
- out << "}\n";
- out.unindent();
- out << "}\n";
-}
-
-void HalHidlProfilerCodeGen::GenerateProfilerForFMQUnsyncVariable(
- Formatter& out, const VariableSpecificationMessage& val,
- const std::string& arg_name, const std::string& arg_value) {
- out << arg_name << "->set_type(TYPE_FMQ_UNSYNC);\n";
- string element_type = GetCppVariableType(val.fmq_value(0));
- std::string queue_name = arg_name + "_q";
- std::string temp_result_name = arg_name + "_result";
- out << "MessageQueue<" << element_type << ", kUnsynchronizedWrite> "
- << queue_name << "(" << arg_value << ");\n";
- out << "if (" << queue_name << ".isValid()) {\n";
- out.indent();
- out << "for (int i = 0; i < (int)" << queue_name
- << ".availableToRead(); i++) {\n";
- out.indent();
- std::string fmq_item_name = arg_name + "_item_i";
- out << "auto *" << fmq_item_name << " = " << arg_name
- << "->add_fmq_value();\n";
- out << element_type << " " << temp_result_name << ";\n";
- out << queue_name << ".read(&" << temp_result_name << ");\n";
- GenerateProfilerForTypedVariable(out, val.fmq_value(0), fmq_item_name,
- temp_result_name);
- out.unindent();
- out << "}\n";
- out.unindent();
- out << "}\n";
-}
-
-void HalHidlProfilerCodeGen::GenerateProfilerForSafeUnionVariable(
- Formatter& out, const VariableSpecificationMessage&,
- const std::string& arg_name, const std::string&) {
- out << arg_name << "->set_type(TYPE_SAFE_UNION);\n";
- out << "LOG(ERROR) << \"TYPE_SAFE_UNION is not supported yet. \";\n";
-}
-
-void HalHidlProfilerCodeGen::GenerateProfilerForMethod(
- Formatter& out, const FunctionSpecificationMessage& method) {
- out << "FunctionSpecificationMessage msg;\n";
- out << "msg.set_name(\"" << method.name() << "\");\n";
- out << "if (profiling_for_args) {\n";
- out.indent();
- out << "if (!args) {\n";
- out.indent();
- out << "LOG(WARNING) << \"no argument passed\";\n";
- out.unindent();
- out << "} else {\n";
- out.indent();
- out << "switch (event) {\n";
- out.indent();
- out << "case details::HidlInstrumentor::CLIENT_API_ENTRY:\n";
- out << "case details::HidlInstrumentor::SERVER_API_ENTRY:\n";
- out << "case details::HidlInstrumentor::PASSTHROUGH_ENTRY:\n";
- out << "{\n";
- out.indent();
- ComponentSpecificationMessage message;
- out << "if ((*args).size() != " << method.arg().size() << ") {\n";
- out.indent();
- out << "LOG(ERROR) << \"Number of arguments does not match. expect: "
- << method.arg().size()
- << ", actual: \" << (*args).size() << \", method name: " << method.name()
- << ", event type: \" << event;\n";
- out << "break;\n";
- out.unindent();
- out << "}\n";
- for (int i = 0; i < method.arg().size(); i++) {
- const VariableSpecificationMessage arg = method.arg(i);
- std::string arg_name = "arg_" + std::to_string(i);
- std::string arg_value = "arg_val_" + std::to_string(i);
- out << "auto *" << arg_name
- << " __attribute__((__unused__)) = msg.add_arg();\n";
- out << GetCppVariableType(arg) << " *" << arg_value
- << " __attribute__((__unused__)) = reinterpret_cast<"
- << GetCppVariableType(arg) << "*> ((*args)[" << i << "]);\n";
- out << "if (" << arg_value << " != nullptr) {\n";
- out.indent();
- GenerateProfilerForTypedVariable(out, arg, arg_name,
- "(*" + arg_value + ")");
- out.unindent();
- out << "} else {\n";
- out.indent();
- out << "LOG(WARNING) << \"argument " << i << " is null.\";\n";
- out.unindent();
- out << "}\n";
- }
- out << "break;\n";
- out.unindent();
- out << "}\n";
-
- out << "case details::HidlInstrumentor::CLIENT_API_EXIT:\n";
- out << "case details::HidlInstrumentor::SERVER_API_EXIT:\n";
- out << "case details::HidlInstrumentor::PASSTHROUGH_EXIT:\n";
- out << "{\n";
- out.indent();
- out << "if ((*args).size() != " << method.return_type_hidl().size()
- << ") {\n";
- out.indent();
- out << "LOG(ERROR) << \"Number of return values does not match. expect: "
- << method.return_type_hidl().size()
- << ", actual: \" << (*args).size() << \", method name: " << method.name()
- << ", event type: \" << event;\n";
- out << "break;\n";
- out.unindent();
- out << "}\n";
- for (int i = 0; i < method.return_type_hidl().size(); i++) {
- const VariableSpecificationMessage arg = method.return_type_hidl(i);
- std::string result_name = "result_" + std::to_string(i);
- std::string result_value = "result_val_" + std::to_string(i);
- out << "auto *" << result_name
- << " __attribute__((__unused__)) = msg.add_return_type_hidl();\n";
- out << GetCppVariableType(arg) << " *" << result_value
- << " __attribute__((__unused__)) = reinterpret_cast<"
- << GetCppVariableType(arg) << "*> ((*args)[" << i << "]);\n";
- out << "if (" << result_value << " != nullptr) {\n";
- out.indent();
- GenerateProfilerForTypedVariable(out, arg, result_name,
- "(*" + result_value + ")");
- out.unindent();
- out << "} else {\n";
- out.indent();
- out << "LOG(WARNING) << \"return value " << i << " is null.\";\n";
- out.unindent();
- out << "}\n";
- }
- out << "break;\n";
- out.unindent();
- out << "}\n";
- out << "default:\n";
- out << "{\n";
- out.indent();
- out << "LOG(WARNING) << \"not supported. \";\n";
- out << "break;\n";
- out.unindent();
- out << "}\n";
- out.unindent();
- out << "}\n";
- out.unindent();
- out << "}\n";
- out.unindent();
- out << "}\n";
- out << "profiler.AddTraceEvent(event, package, version, interface, msg);\n";
-}
-
-void HalHidlProfilerCodeGen::GenerateHeaderIncludeFiles(
- Formatter& out, const ComponentSpecificationMessage& message) {
- // Basic includes.
- out << "#include <android-base/logging.h>\n";
- out << "#include <hidl/HidlSupport.h>\n";
- out << "#include <linux/limits.h>\n";
- out << "#include <test/vts/proto/ComponentSpecificationMessage.pb.h>\n";
-
- out << "#include \"VtsProfilingInterface.h\"\n";
- out << "\n";
-
- out << "// HACK: NAN is #defined by math.h which gets included by\n";
- out << "// ComponentSpecificationMessage.pb.h, but some HALs use\n";
- out << "// enums called NAN. Undefine NAN to work around it.\n";
- out << "#undef NAN\n";
- out << "\n";
-
- // Include generated hal classes.
- out << "#include <" << GetPackagePath(message) << "/" << GetVersion(message)
- << "/" << GetComponentName(message) << ".h>\n";
-
- // Include imported classes.
- for (const auto& import : message.import()) {
- FQName import_name;
- if (!FQName::parse(import, &import_name)) {
- abort();
- }
-
- string imported_package_name = import_name.package();
- string imported_package_version = import_name.version();
- string imported_component_name = import_name.name();
- string imported_package_path = imported_package_name;
- ReplaceSubString(imported_package_path, ".", "/");
- out << "#include <" << imported_package_path << "/"
- << imported_package_version << "/" << imported_component_name
- << ".h>\n";
- // Exclude the base hal in include list.
- if (imported_package_name.find("android.hidl.base") == std::string::npos) {
- if (imported_component_name[0] == 'I') {
- imported_component_name = imported_component_name.substr(1);
- }
- out << "#include <" << imported_package_path << "/"
- << imported_package_version << "/" << imported_component_name
- << ".vts.h>\n";
- }
- }
- out << "\n\n";
-}
-
-void HalHidlProfilerCodeGen::GenerateSourceIncludeFiles(
- Formatter& out, const ComponentSpecificationMessage& message) {
- // Include the corresponding profiler header file.
- out << "#include \"" << GetPackagePath(message) << "/" << GetVersion(message)
- << "/" << GetComponentBaseName(message) << ".vts.h\"\n";
- out << "#include <cutils/properties.h>\n";
- if (IncludeHidlNativeType(message, TYPE_HANDLE)) {
- out << "#include <cutils/ashmem.h>\n";
- out << "#include <fcntl.h>\n";
- out << "#include <sys/stat.h>\n";
- }
- if (IncludeHidlNativeType(message, TYPE_FMQ_SYNC) ||
- IncludeHidlNativeType(message, TYPE_FMQ_UNSYNC)) {
- out << "#include <fmq/MessageQueue.h>\n";
- }
- if (IncludeHidlNativeType(message, TYPE_HIDL_MEMORY)) {
- out << "#include <cutils/properties.h>\n";
- out << "#include <android/hidl/memory/1.0/IMemory.h>\n";
- out << "#include <hidlmemory/mapping.h>\n";
- }
- out << "\n";
-}
-
-void HalHidlProfilerCodeGen::GenerateUsingDeclaration(
- Formatter& out, const ComponentSpecificationMessage& message) {
- out << "using namespace ";
- out << GetPackageNamespaceToken(message) << "::" << GetVersion(message, true)
- << ";\n";
- out << "using namespace android::hardware;\n";
- out << "\n";
-}
-
-void HalHidlProfilerCodeGen::GenerateMacros(
- Formatter& out, const ComponentSpecificationMessage&) {
- out << "#define TRACEFILEPREFIX \"/data/local/tmp/\"\n";
- out << "\n";
-}
-
-void HalHidlProfilerCodeGen::GenerateProfilerCheck(
- Formatter& out, const ComponentSpecificationMessage& message) {
- out << "if (strcmp(package, \"" << GetPackageName(message) << "\") != 0) {\n";
- out.indent();
- out << "LOG(WARNING) << \"incorrect package. Expect: "
- << GetPackageName(message) << " actual: \" << package;\n";
- out.unindent();
- out << "}\n";
- out << "std::string version_str = std::string(version);\n";
- out << "int major_version = stoi(version_str.substr(0, "
- "version_str.find('.')));\n";
- out << "int minor_version = stoi(version_str.substr(version_str.find('.') + "
- "1));\n";
- out << "if (major_version != " << GetMajorVersion(message)
- << " || minor_version > " << GetMinorVersion(message) << ") {\n";
- out.indent();
- out << "LOG(WARNING) << \"incorrect version. Expect: " << GetVersion(message)
- << " or lower (if version != x.0), actual: \" << version;\n";
- out.unindent();
- out << "}\n";
-
- out << "if (strcmp(interface, \"" << GetComponentName(message)
- << "\") != 0) {\n";
- out.indent();
- out << "LOG(WARNING) << \"incorrect interface. Expect: "
- << GetComponentName(message) << " actual: \" << interface;\n";
- out.unindent();
- out << "}\n";
- out << "\n";
-}
-
-void HalHidlProfilerCodeGen::GenerateLocalVariableDefinition(
- Formatter& out, const ComponentSpecificationMessage&) {
- // create and initialize the VTS profiler interface.
- out << "VtsProfilingInterface& profiler = "
- << "VtsProfilingInterface::getInstance(TRACEFILEPREFIX);\n\n";
- out << "bool profiling_for_args = "
- "property_get_bool(\"hal.instrumentation.profile.args\", true);\n";
-}
-
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/code_gen/profiler/HalHidlProfilerCodeGen.h b/compilation_tools/vtsc/code_gen/profiler/HalHidlProfilerCodeGen.h
deleted file mode 100644
index fb68247..0000000
--- a/compilation_tools/vtsc/code_gen/profiler/HalHidlProfilerCodeGen.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_PROFILER_HALHIDLPROFILERCODEGEN_H_
-#define VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_PROFILER_HALHIDLPROFILERCODEGEN_H_
-
-#include "code_gen/profiler/ProfilerCodeGenBase.h"
-
-namespace android {
-namespace vts {
-/**
- * Class that generates the profiler code for Hidl HAL.
- */
-class HalHidlProfilerCodeGen : public ProfilerCodeGenBase {
- public:
- HalHidlProfilerCodeGen() : ProfilerCodeGenBase(){};
-
- protected:
- virtual void GenerateProfilerForScalarVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) override;
-
- virtual void GenerateProfilerForStringVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) override;
-
- virtual void GenerateProfilerForEnumVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) override;
-
- virtual void GenerateProfilerForVectorVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) override;
-
- virtual void GenerateProfilerForArrayVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) override;
-
- virtual void GenerateProfilerForStructVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) override;
-
- virtual void GenerateProfilerForUnionVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) override;
-
- virtual void GenerateProfilerForSafeUnionVariable(
- Formatter& out, const VariableSpecificationMessage& val,
- const std::string& arg_name, const std::string& arg_value) override;
-
- virtual void GenerateProfilerForHidlCallbackVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) override;
-
- virtual void GenerateProfilerForHidlInterfaceVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) override;
-
- virtual void GenerateProfilerForMaskVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) override;
-
- virtual void GenerateProfilerForHandleVariable(
- Formatter& out, const VariableSpecificationMessage& val,
- const std::string& arg_name, const std::string& arg_value) override;
-
- virtual void GenerateProfilerForHidlMemoryVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) override;
-
- virtual void GenerateProfilerForPointerVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) override;
-
- virtual void GenerateProfilerForFMQSyncVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) override;
-
- virtual void GenerateProfilerForFMQUnsyncVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) override;
-
- virtual void GenerateProfilerForMethod(Formatter& out,
- const FunctionSpecificationMessage& method) override;
-
- virtual void GenerateHeaderIncludeFiles(Formatter& out,
- const ComponentSpecificationMessage& message) override;
- virtual void GenerateSourceIncludeFiles(Formatter& out,
- const ComponentSpecificationMessage& message) override;
- void GenerateUsingDeclaration(Formatter& out,
- const ComponentSpecificationMessage& message) override;
- void GenerateMacros(Formatter& out,
- const ComponentSpecificationMessage& message) override;
- virtual void GenerateProfilerCheck(
- Formatter& out, const ComponentSpecificationMessage& message) override;
- virtual void GenerateLocalVariableDefinition(Formatter& out,
- const ComponentSpecificationMessage& message) override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN (HalHidlProfilerCodeGen);
-};
-
-} // namespace vts
-} // namespace android
-#endif // VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_PROFILER_HALHIDLPROFILERCODEGEN_H_
diff --git a/compilation_tools/vtsc/code_gen/profiler/ProfilerCodeGenBase.cpp b/compilation_tools/vtsc/code_gen/profiler/ProfilerCodeGenBase.cpp
deleted file mode 100644
index 323d84b..0000000
--- a/compilation_tools/vtsc/code_gen/profiler/ProfilerCodeGenBase.cpp
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "ProfilerCodeGenBase.h"
-#include "utils/InterfaceSpecUtil.h"
-#include "utils/StringUtil.h"
-#include "VtsCompilerUtils.h"
-
-namespace android {
-namespace vts {
-
-void ProfilerCodeGenBase::GenerateAll(
- Formatter& header_out, Formatter& source_out,
- const ComponentSpecificationMessage& message) {
- GenerateHeaderFile(header_out, message);
- GenerateSourceFile(source_out, message);
-}
-
-void ProfilerCodeGenBase::GenerateHeaderFile(
- Formatter& out, const ComponentSpecificationMessage& message) {
- FQName component_fq_name = GetFQName(message);
- out << "#ifndef __VTS_PROFILER_" << component_fq_name.tokenName()
- << "__\n";
- out << "#define __VTS_PROFILER_" << component_fq_name.tokenName()
- << "__\n";
- out << "\n\n";
- GenerateHeaderIncludeFiles(out, message);
- GenerateUsingDeclaration(out, message);
- GenerateOpenNameSpaces(out, message);
-
- if (message.has_interface()) {
- InterfaceSpecificationMessage interface = message.interface();
- // First generate the declaration of profiler functions for all user
- // defined types within the interface.
- for (const auto& attribute : interface.attribute()) {
- GenerateProfilerMethodDeclForAttribute(out, attribute);
- }
-
- out << "extern \"C\" {\n";
- out.indent();
-
- // Generate the declaration of main profiler function.
- FQName component_fq_name = GetFQName(message);
- out << "\nvoid HIDL_INSTRUMENTATION_FUNCTION_" << component_fq_name.tokenName()
- << "(\n";
- out.indent();
- out.indent();
- out << "details::HidlInstrumentor::InstrumentationEvent event,\n";
- out << "const char* package,\n";
- out << "const char* version,\n";
- out << "const char* interface,\n";
- out << "const char* method,\n";
- out << "std::vector<void *> *args);\n";
- out.unindent();
- out.unindent();
-
- out.unindent();
- out << "}\n\n";
- } else {
- // For types.vts, just generate the declaration of profiler functions
- // for all user defined types.
- for (const auto& attribute : message.attribute()) {
- GenerateProfilerMethodDeclForAttribute(out, attribute);
- }
- }
-
- GenerateCloseNameSpaces(out, message);
- out << "#endif\n";
-}
-
-void ProfilerCodeGenBase::GenerateSourceFile(
- Formatter& out, const ComponentSpecificationMessage& message) {
- GenerateSourceIncludeFiles(out, message);
- GenerateUsingDeclaration(out, message);
- GenerateMacros(out, message);
- GenerateOpenNameSpaces(out, message);
-
- if (message.has_interface()) {
- InterfaceSpecificationMessage interface = message.interface();
- // First generate profiler functions for all user defined types within
- // the interface.
- for (const auto& attribute : interface.attribute()) {
- GenerateProfilerMethodImplForAttribute(out, attribute);
- }
- // Generate the main profiler function.
- FQName component_fq_name = GetFQName(message);
- out << "\nvoid HIDL_INSTRUMENTATION_FUNCTION_" << component_fq_name.tokenName()
- << "(\n";
- out.indent();
- out.indent();
- out << "details::HidlInstrumentor::InstrumentationEvent event "
- "__attribute__((__unused__)),\n";
- out << "const char* package,\n";
- out << "const char* version,\n";
- out << "const char* interface,\n";
- out << "const char* method __attribute__((__unused__)),\n";
- out << "std::vector<void *> *args __attribute__((__unused__))) {\n";
- out.unindent();
-
- // Generate code for profiler check.
- GenerateProfilerCheck(out, message);
-
- if (interface.api_size() > 0) {
- // Generate code to define local variables.
- GenerateLocalVariableDefinition(out, message);
-
- // Generate the profiler code for each method.
- for (const FunctionSpecificationMessage& api : interface.api()) {
- out << "if (strcmp(method, \"" << api.name() << "\") == 0) {\n";
- out.indent();
- GenerateProfilerForMethod(out, api);
- out.unindent();
- out << "}\n";
- }
- }
-
- out.unindent();
- out << "}\n\n";
- } else {
- // For types.vts, just generate profiler functions for the user defined
- // types.
- for (const auto& attribute : message.attribute()) {
- GenerateProfilerMethodImplForAttribute(out, attribute);
- }
- }
-
- GenerateCloseNameSpaces(out, message);
-}
-
-void ProfilerCodeGenBase::GenerateProfilerForTypedVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) {
- switch (val.type()) {
- case TYPE_SCALAR:
- {
- GenerateProfilerForScalarVariable(out, val, arg_name, arg_value);
- break;
- }
- case TYPE_STRING:
- {
- GenerateProfilerForStringVariable(out, val, arg_name, arg_value);
- break;
- }
- case TYPE_ENUM:
- {
- GenerateProfilerForEnumVariable(out, val, arg_name, arg_value);
- break;
- }
- case TYPE_VECTOR:
- {
- GenerateProfilerForVectorVariable(out, val, arg_name, arg_value);
- break;
- }
- case TYPE_ARRAY:
- {
- GenerateProfilerForArrayVariable(out, val, arg_name, arg_value);
- break;
- }
- case TYPE_STRUCT:
- {
- GenerateProfilerForStructVariable(out, val, arg_name, arg_value);
- break;
- }
- case TYPE_UNION: {
- GenerateProfilerForUnionVariable(out, val, arg_name, arg_value);
- break;
- }
- case TYPE_HIDL_CALLBACK:
- {
- GenerateProfilerForHidlCallbackVariable(out, val, arg_name, arg_value);
- break;
- }
- case TYPE_HIDL_INTERFACE:
- {
- GenerateProfilerForHidlInterfaceVariable(out, val, arg_name, arg_value);
- break;
- }
- case TYPE_MASK:
- {
- GenerateProfilerForMaskVariable(out, val, arg_name, arg_value);
- break;
- }
- case TYPE_HANDLE: {
- GenerateProfilerForHandleVariable(out, val, arg_name, arg_value);
- break;
- }
- case TYPE_HIDL_MEMORY:
- {
- GenerateProfilerForHidlMemoryVariable(out, val, arg_name, arg_value);
- break;
- }
- case TYPE_POINTER:
- {
- GenerateProfilerForPointerVariable(out, val, arg_name, arg_value);
- break;
- }
- case TYPE_FMQ_SYNC:
- {
- GenerateProfilerForFMQSyncVariable(out, val, arg_name, arg_value);
- break;
- }
- case TYPE_FMQ_UNSYNC:
- {
- GenerateProfilerForFMQUnsyncVariable(out, val, arg_name, arg_value);
- break;
- }
- case TYPE_SAFE_UNION: {
- GenerateProfilerForSafeUnionVariable(out, val, arg_name, arg_value);
- break;
- }
- default: {
- out << "LOG(ERROR) << \"Type " << val.type()
- << "is not supported yet. \";\n";
- }
- }
-}
-
-void ProfilerCodeGenBase::GenerateProfilerMethodDeclForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute) {
- if (attribute.type() == TYPE_STRUCT || attribute.type() == TYPE_UNION ||
- attribute.type() == TYPE_SAFE_UNION) {
- // Recursively generate profiler method declaration for all sub_types.
- for (const auto& sub_struct : attribute.sub_struct()) {
- GenerateProfilerMethodDeclForAttribute(out, sub_struct);
- }
- for (const auto& sub_union : attribute.sub_union()) {
- GenerateProfilerMethodDeclForAttribute(out, sub_union);
- }
- for (const auto& sub_safe_union : attribute.sub_safe_union()) {
- GenerateProfilerMethodDeclForAttribute(out, sub_safe_union);
- }
- }
- std::string attribute_name = attribute.name();
- ReplaceSubString(attribute_name, "::", "__");
- out << "void profile__" << attribute_name
- << "(VariableSpecificationMessage* arg_name,\n" << attribute.name()
- << " arg_val_name);\n";
-}
-
-void ProfilerCodeGenBase::GenerateProfilerMethodImplForAttribute(
- Formatter& out, const VariableSpecificationMessage& attribute) {
- if (attribute.type() == TYPE_STRUCT || attribute.type() == TYPE_UNION ||
- attribute.type() == TYPE_SAFE_UNION) {
- // Recursively generate profiler method implementation for all sub_types.
- for (const auto& sub_struct : attribute.sub_struct()) {
- GenerateProfilerMethodImplForAttribute(out, sub_struct);
- }
- for (const auto& sub_union : attribute.sub_union()) {
- GenerateProfilerMethodImplForAttribute(out, sub_union);
- }
- for (const auto& sub_safe_union : attribute.sub_safe_union()) {
- GenerateProfilerMethodImplForAttribute(out, sub_safe_union);
- }
- }
- std::string attribute_name = attribute.name();
- ReplaceSubString(attribute_name, "::", "__");
- out << "void profile__" << attribute_name
- << "(VariableSpecificationMessage* arg_name,\n"
- << attribute.name() << " arg_val_name __attribute__((__unused__))) {\n";
- out.indent();
- GenerateProfilerForTypedVariable(out, attribute, "arg_name", "arg_val_name");
- out.unindent();
- out << "}\n\n";
-}
-
-void ProfilerCodeGenBase::GenerateOpenNameSpaces(Formatter& out,
- const ComponentSpecificationMessage& /*message*/) {
- out << "namespace android {\n";
- out << "namespace vts {\n";
-}
-
-void ProfilerCodeGenBase::GenerateCloseNameSpaces(Formatter& out,
- const ComponentSpecificationMessage& /*message*/) {
- out << "} // namespace vts\n";
- out << "} // namespace android\n";
-}
-
-bool ProfilerCodeGenBase::IncludeHidlNativeType(
- const ComponentSpecificationMessage& message, const VariableType& type) {
- if (message.has_interface()) {
- InterfaceSpecificationMessage interface = message.interface();
- for (const VariableSpecificationMessage& attribute :
- interface.attribute()) {
- if (IncludeHidlNativeType(attribute, type)) {
- return true;
- }
- }
- for (const FunctionSpecificationMessage& api : interface.api()) {
- for (const VariableSpecificationMessage& arg : api.arg()) {
- if (IncludeHidlNativeType(arg, type)) {
- return true;
- }
- }
- for (const VariableSpecificationMessage& result :
- api.return_type_hidl()) {
- if (IncludeHidlNativeType(result, type)) {
- return true;
- }
- }
- }
- } else {
- for (const VariableSpecificationMessage& attribute : message.attribute()) {
- if (IncludeHidlNativeType(attribute, type)) {
- return true;
- }
- }
- }
- return false;
-}
-
-bool ProfilerCodeGenBase::IncludeHidlNativeType(
- const VariableSpecificationMessage& val, const VariableType& type) {
- if (val.type() == type) {
- return true;
- }
- if (val.type() == TYPE_VECTOR || val.type() == TYPE_ARRAY) {
- if (IncludeHidlNativeType(val.vector_value(0), type)) return true;
- }
- if (val.type() == TYPE_STRUCT) {
- if (!val.has_predefined_type()) {
- for (const auto& sub_struct : val.sub_struct()) {
- if (IncludeHidlNativeType(sub_struct, type)) return true;
- }
- for (const auto& struct_field : val.struct_value()) {
- if (IncludeHidlNativeType(struct_field, type)) return true;
- }
- }
- }
- if (val.type() == TYPE_UNION) {
- if (!val.has_predefined_type()) {
- for (const auto& sub_union : val.sub_union()) {
- if (IncludeHidlNativeType(sub_union, type)) return true;
- }
- for (const auto& union_field : val.union_value()) {
- if (IncludeHidlNativeType(union_field, type)) return true;
- }
- }
- }
- return false;
-}
-
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/code_gen/profiler/ProfilerCodeGenBase.h b/compilation_tools/vtsc/code_gen/profiler/ProfilerCodeGenBase.h
deleted file mode 100644
index 5586a4e..0000000
--- a/compilation_tools/vtsc/code_gen/profiler/ProfilerCodeGenBase.h
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_PROFILER_PROFILERCODEGENBASE_H_
-#define VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_PROFILER_PROFILERCODEGENBASE_H_
-
-#include <android-base/macros.h>
-#include <hidl-util/FQName.h>
-#include <hidl-util/Formatter.h>
-#include <iostream>
-#include <string>
-
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-namespace android {
-namespace vts {
-/**
- * Base class that generates the profiler code for HAL interfaces.
- * It takes the input of a vts proto (i.e. ComponentSpecificationMessage) and
- * generates the header and source file of the corresponding profiler.
- *
- * All the profiler generator for a particular HAL type (e.g. Hidl Hal,
- * Legacy Hal etc.) should derive from this class.
- */
-class ProfilerCodeGenBase {
- public:
- ProfilerCodeGenBase(){};
-
- virtual ~ProfilerCodeGenBase(){};
-
- // Generates both the header and source file for profiler.
- void GenerateAll(Formatter& header_out, Formatter& source_out,
- const ComponentSpecificationMessage& message);
-
- // Generates the header file for profiler.
- virtual void GenerateHeaderFile(Formatter &out,
- const ComponentSpecificationMessage &message);
-
- // Generates the source file for profiler.
- virtual void GenerateSourceFile(Formatter &out,
- const ComponentSpecificationMessage &message);
-
- protected:
- // Generates the profiler code for scalar type.
- virtual void GenerateProfilerForScalarVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) = 0;
-
- // Generates the profiler code for string type.
- virtual void GenerateProfilerForStringVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) = 0;
-
- // Generates the profiler code for enum type.
- virtual void GenerateProfilerForEnumVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) = 0;
-
- // Generates the profiler code for vector type.
- virtual void GenerateProfilerForVectorVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) = 0;
-
- // Generates the profiler code for array type.
- virtual void GenerateProfilerForArrayVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) = 0;
-
- // Generates the profiler code for struct type.
- virtual void GenerateProfilerForStructVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) = 0;
-
- // Generates the profiler code for union type.
- virtual void GenerateProfilerForUnionVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) = 0;
-
- // Generates the profiler code for safe union type.
- virtual void GenerateProfilerForSafeUnionVariable(
- Formatter& out, const VariableSpecificationMessage& val,
- const std::string& arg_name, const std::string& arg_value) = 0;
-
- // Generates the profiler code for hidl callback type.
- virtual void GenerateProfilerForHidlCallbackVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) = 0;
-
- // Generates the profiler code for hidl interface type.
- virtual void GenerateProfilerForHidlInterfaceVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) = 0;
-
- // Generates the profiler code for mask type.
- virtual void GenerateProfilerForMaskVariable(
- Formatter& out, const VariableSpecificationMessage& val,
- const std::string& arg_name, const std::string& arg_value) = 0;
-
- // Generates the profiler code for handle type.
- virtual void GenerateProfilerForHandleVariable(
- Formatter& out, const VariableSpecificationMessage& val,
- const std::string& arg_name, const std::string& arg_value) = 0;
-
- // Generates the profiler code for hidl memory type.
- virtual void GenerateProfilerForHidlMemoryVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) = 0;
-
- // Generates the profiler code for pointer type.
- virtual void GenerateProfilerForPointerVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) = 0;
-
- // Generates the profiler code for fmq sync type.
- virtual void GenerateProfilerForFMQSyncVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) = 0;
-
- // Generates the profiler code for fmq unsync type.
- virtual void GenerateProfilerForFMQUnsyncVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value) = 0;
-
- // Generates the profiler code for method.
- virtual void GenerateProfilerForMethod(Formatter& out,
- const FunctionSpecificationMessage& method) = 0;
-
- // Generates the necessary "#include" code for header file of profiler.
- virtual void GenerateHeaderIncludeFiles(Formatter& out,
- const ComponentSpecificationMessage& message) = 0;
- // Generates the necessary "#include" code for source file of profiler.
- virtual void GenerateSourceIncludeFiles(Formatter& out,
- const ComponentSpecificationMessage& message) = 0;
- // Generates the necessary "using" code for profiler.
- virtual void GenerateUsingDeclaration(Formatter& out,
- const ComponentSpecificationMessage& message) = 0;
- // Generates the necessary "#define" code for profiler.
- virtual void GenerateMacros(Formatter&,
- const ComponentSpecificationMessage&) {};
- // Generates validity check for profiler. These codes will be generated at the
- // beginning of the main profiler function.
- virtual void GenerateProfilerCheck(Formatter&,
- const ComponentSpecificationMessage&){};
- // Generate local variable definition. These codes will be generated after
- // the validity check code.
- virtual void GenerateLocalVariableDefinition(Formatter&,
- const ComponentSpecificationMessage&) {};
-
- // Generates the profiler code for a typed variable.
- virtual void GenerateProfilerForTypedVariable(Formatter& out,
- const VariableSpecificationMessage& val, const std::string& arg_name,
- const std::string& arg_value);
-
- // Generates the profiler method declaration for a user defined type.
- // (e.g. attributes within an interface).
- // The method signature is:
- // void profile__UDTName(VariableSpecificationMessage* arg_name,
- // UDTName arg_val_name);
- virtual void GenerateProfilerMethodDeclForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute);
-
- // Generates the profiler method implementation for a user defined type.
- virtual void GenerateProfilerMethodImplForAttribute(Formatter& out,
- const VariableSpecificationMessage& attribute);
-
- //********** Utility functions *****************
- virtual void GenerateOpenNameSpaces(Formatter& out,
- const ComponentSpecificationMessage& message);
- virtual void GenerateCloseNameSpaces(Formatter& out,
- const ComponentSpecificationMessage& message);
-
- // Utility functions that check whether the given message uses any hidl native
- // types (e.g. fmq, hidl_memory, hidl_handle).
- bool IncludeHidlNativeType(const ComponentSpecificationMessage& message,
- const VariableType& type);
- bool IncludeHidlNativeType(const VariableSpecificationMessage& val,
- const VariableType& type);
-
- std::string input_vts_file_path_;
- DISALLOW_COPY_AND_ASSIGN (ProfilerCodeGenBase);
-};
-
-} // namespace vts
-} // namespace android
-
-#endif // VTS_COMPILATION_TOOLS_VTSC_CODE_GEN_PROFILER_PROFILERCODEGENBASE_H_
diff --git a/compilation_tools/vtsc/test/Android.mk b/compilation_tools/vtsc/test/Android.mk
deleted file mode 100644
index fd85ae6..0000000
--- a/compilation_tools/vtsc/test/Android.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# 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.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := vtsc_test
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_MODULE_CLASS := FAKE
-LOCAL_IS_HOST_MODULE := true
-
-include $(BUILD_SYSTEM)/base_rules.mk
-
-$(LOCAL_BUILT_MODULE): PRIVATE_PY_SCRIPT := $(LOCAL_PATH)/test_vtsc.py
-$(LOCAL_BUILT_MODULE): PRIVATE_OUT_DIR := $(intermediates)/vts/test_out
-$(LOCAL_BUILT_MODULE): PRIVATE_TEMP_DIR := $(intermediates)/vts/temp
-$(LOCAL_BUILT_MODULE): PRIVATE_CANONICAL_DIR := $(LOCAL_PATH)/golden
-$(LOCAL_BUILT_MODULE): PRIVATE_VTSC_EXEC := $(HOST_OUT_EXECUTABLES)/vtsc
-$(LOCAL_BUILT_MODULE): PRIVATE_HIDL_EXEC := $(HOST_OUT_EXECUTABLES)/hidl-gen
-$(LOCAL_BUILT_MODULE): $(PRIVATE_PY_SCRIPT) $(HOST_OUT_EXECUTABLES)/vtsc
-$(LOCAL_BUILT_MODULE): $(PRIVATE_PY_SCRIPT) $(HOST_OUT_EXECUTABLES)/hidl-gen
- @echo "Regression test (build time): $(PRIVATE_MODULE)"
- $(hide) PYTHONPATH=$$PYTHONPATH:external/python/futures:test \
- python $(PRIVATE_PY_SCRIPT) -h $(PRIVATE_HIDL_EXEC) -p $(PRIVATE_VTSC_EXEC) \
- -c $(PRIVATE_CANONICAL_DIR) -o $(PRIVATE_OUT_DIR) -t $(PRIVATE_TEMP_DIR)
- $(hide) touch $@
diff --git a/compilation_tools/vtsc/test/golden/DRIVER/Bar.driver.cpp b/compilation_tools/vtsc/test/golden/DRIVER/Bar.driver.cpp
deleted file mode 100644
index 1cdece8..0000000
--- a/compilation_tools/vtsc/test/golden/DRIVER/Bar.driver.cpp
+++ /dev/null
@@ -1,1571 +0,0 @@
-#include "android/hardware/tests/bar/1.0/Bar.vts.h"
-#include "vts_measurement.h"
-#include <android-base/logging.h>
-#include <android/hidl/allocator/1.0/IAllocator.h>
-#include <fcntl.h>
-#include <fmq/MessageQueue.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-
-using namespace android::hardware::tests::bar::V1_0;
-namespace android {
-namespace vts {
-extern "C" void MessageTo__android__hardware__tests__bar__V1_0__IBar__SomethingRelated(const VariableSpecificationMessage& var_msg __attribute__((__unused__)), ::android::hardware::tests::bar::V1_0::IBar::SomethingRelated* arg __attribute__((__unused__)), const string& callback_socket_name __attribute__((__unused__))) {
- MessageTo__android__hardware__tests__foo__V1_0__Unrelated(var_msg.struct_value(0), &(arg->myRelated), callback_socket_name);
-}
-bool Verify__android__hardware__tests__bar__V1_0__IBar__SomethingRelated(const VariableSpecificationMessage& expected_result __attribute__((__unused__)), const VariableSpecificationMessage& actual_result __attribute__((__unused__))){
- if (!Verify__android__hardware__tests__foo__V1_0__Unrelated(expected_result.struct_value(0), actual_result.struct_value(0))) { return false; }
- return true;
-}
-
-extern "C" void SetResult__android__hardware__tests__bar__V1_0__IBar__SomethingRelated(VariableSpecificationMessage* result_msg, ::android::hardware::tests::bar::V1_0::IBar::SomethingRelated result_value __attribute__((__unused__))){
- result_msg->set_type(TYPE_STRUCT);
- auto *result_msg_myRelated = result_msg->add_struct_value();
- result_msg_myRelated->set_type(TYPE_STRUCT);
- SetResult__android__hardware__tests__foo__V1_0__Unrelated(result_msg_myRelated, result_value.myRelated);
- result_msg_myRelated->set_name("myRelated");
-}
-
-bool FuzzerExtended_android_hardware_tests_bar_V1_0_IBar::GetService(bool get_stub, const char* service_name) {
- static bool initialized = false;
- if (!initialized) {
- LOG(INFO) << "HIDL getService";
- if (service_name) {
- LOG(INFO) << " - service name: " << service_name;
- }
- hw_binder_proxy_ = ::android::hardware::tests::bar::V1_0::IBar::getService(service_name, get_stub);
- if (hw_binder_proxy_ == nullptr) {
- LOG(ERROR) << "getService() returned a null pointer.";
- return false;
- }
- LOG(DEBUG) << "hw_binder_proxy_ = " << hw_binder_proxy_.get();
- initialized = true;
- }
- return true;
-}
-
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::convertToBoolIfSmall(
- ::android::hardware::tests::foo::V1_0::IFoo::Discriminator arg0 __attribute__((__unused__)),
- const ::android::hardware::hidl_vec<::android::hardware::tests::foo::V1_0::IFoo::Union>& arg1 __attribute__((__unused__)), std::function<void(const ::android::hardware::hidl_vec<::android::hardware::tests::foo::V1_0::IFoo::ContainsUnion>& arg0)> cb) {
- LOG(INFO) << "convertToBoolIfSmall called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("convertToBoolIfSmall"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::convertToBoolIfSmall");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_ENUM);
- SetResult__android__hardware__tests__foo__V1_0__IFoo__Discriminator(var_msg0, arg0);
- VariableSpecificationMessage* var_msg1 = callback_message.add_arg();
- var_msg1->set_type(TYPE_VECTOR);
- var_msg1->set_vector_size(arg1.size());
- for (int i = 0; i < (int)arg1.size(); i++) {
- auto *var_msg1_vector_i = var_msg1->add_vector_value();
- var_msg1_vector_i->set_type(TYPE_UNION);
- SetResult__android__hardware__tests__foo__V1_0__IFoo__Union(var_msg1_vector_i, arg1[i]);
- }
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(::android::hardware::hidl_vec<::android::hardware::tests::foo::V1_0::IFoo::ContainsUnion>());
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::doThis(
- float arg0 __attribute__((__unused__))) {
- LOG(INFO) << "doThis called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("doThis"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::doThis");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_SCALAR);
- var_msg0->set_scalar_type("float_t");
- var_msg0->mutable_scalar_value()->set_float_t(arg0);
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<int32_t> Vts_android_hardware_tests_bar_V1_0_IBar::doThatAndReturnSomething(
- int64_t arg0 __attribute__((__unused__))) {
- LOG(INFO) << "doThatAndReturnSomething called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("doThatAndReturnSomething"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::doThatAndReturnSomething");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_SCALAR);
- var_msg0->set_scalar_type("int64_t");
- var_msg0->mutable_scalar_value()->set_int64_t(arg0);
- RpcCallToAgent(callback_message, callback_socket_name_);
- return static_cast<int32_t>(0);
-}
-
-::android::hardware::Return<double> Vts_android_hardware_tests_bar_V1_0_IBar::doQuiteABit(
- int32_t arg0 __attribute__((__unused__)),
- int64_t arg1 __attribute__((__unused__)),
- float arg2 __attribute__((__unused__)),
- double arg3 __attribute__((__unused__))) {
- LOG(INFO) << "doQuiteABit called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("doQuiteABit"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::doQuiteABit");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_SCALAR);
- var_msg0->set_scalar_type("int32_t");
- var_msg0->mutable_scalar_value()->set_int32_t(arg0);
- VariableSpecificationMessage* var_msg1 = callback_message.add_arg();
- var_msg1->set_type(TYPE_SCALAR);
- var_msg1->set_scalar_type("int64_t");
- var_msg1->mutable_scalar_value()->set_int64_t(arg1);
- VariableSpecificationMessage* var_msg2 = callback_message.add_arg();
- var_msg2->set_type(TYPE_SCALAR);
- var_msg2->set_scalar_type("float_t");
- var_msg2->mutable_scalar_value()->set_float_t(arg2);
- VariableSpecificationMessage* var_msg3 = callback_message.add_arg();
- var_msg3->set_type(TYPE_SCALAR);
- var_msg3->set_scalar_type("double_t");
- var_msg3->mutable_scalar_value()->set_double_t(arg3);
- RpcCallToAgent(callback_message, callback_socket_name_);
- return static_cast<double>(0);
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::doSomethingElse(
- const ::android::hardware::hidl_array<int32_t, 15>& arg0 __attribute__((__unused__)), std::function<void(const ::android::hardware::hidl_array<int32_t, 32>& arg0)> cb) {
- LOG(INFO) << "doSomethingElse called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("doSomethingElse"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::doSomethingElse");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_ARRAY);
- var_msg0->set_vector_size(1);
- for (int i = 0; i < 1; i++) {
- auto *var_msg0_array_i = var_msg0->add_vector_value();
- var_msg0_array_i->set_type(TYPE_SCALAR);
- var_msg0_array_i->set_scalar_type("int32_t");
- var_msg0_array_i->mutable_scalar_value()->set_int32_t(arg0[i]);
- }
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(::android::hardware::hidl_array<int32_t, 32>());
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::doStuffAndReturnAString(
- std::function<void(const ::android::hardware::hidl_string& arg0)> cb) {
- LOG(INFO) << "doStuffAndReturnAString called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("doStuffAndReturnAString"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::doStuffAndReturnAString");
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(::android::hardware::hidl_string());
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::mapThisVector(
- const ::android::hardware::hidl_vec<int32_t>& arg0 __attribute__((__unused__)), std::function<void(const ::android::hardware::hidl_vec<int32_t>& arg0)> cb) {
- LOG(INFO) << "mapThisVector called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("mapThisVector"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::mapThisVector");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_VECTOR);
- var_msg0->set_vector_size(arg0.size());
- for (int i = 0; i < (int)arg0.size(); i++) {
- auto *var_msg0_vector_i = var_msg0->add_vector_value();
- var_msg0_vector_i->set_type(TYPE_SCALAR);
- var_msg0_vector_i->set_scalar_type("int32_t");
- var_msg0_vector_i->mutable_scalar_value()->set_int32_t(arg0[i]);
- }
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(::android::hardware::hidl_vec<int32_t>());
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::callMe(
- const sp<::android::hardware::tests::foo::V1_0::IFooCallback>& arg0 __attribute__((__unused__))) {
- LOG(INFO) << "callMe called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("callMe"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::callMe");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_HIDL_CALLBACK);
- LOG(ERROR) << "TYPE HIDL_CALLBACK is not supported yet. ";
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<::android::hardware::tests::foo::V1_0::IFoo::SomeEnum> Vts_android_hardware_tests_bar_V1_0_IBar::useAnEnum(
- ::android::hardware::tests::foo::V1_0::IFoo::SomeEnum arg0 __attribute__((__unused__))) {
- LOG(INFO) << "useAnEnum called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("useAnEnum"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::useAnEnum");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_ENUM);
- SetResult__android__hardware__tests__foo__V1_0__IFoo__SomeEnum(var_msg0, arg0);
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::tests::foo::V1_0::IFoo::SomeEnum();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::haveAGooberVec(
- const ::android::hardware::hidl_vec<::android::hardware::tests::foo::V1_0::IFoo::Goober>& arg0 __attribute__((__unused__))) {
- LOG(INFO) << "haveAGooberVec called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("haveAGooberVec"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::haveAGooberVec");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_VECTOR);
- var_msg0->set_vector_size(arg0.size());
- for (int i = 0; i < (int)arg0.size(); i++) {
- auto *var_msg0_vector_i = var_msg0->add_vector_value();
- var_msg0_vector_i->set_type(TYPE_STRUCT);
- SetResult__android__hardware__tests__foo__V1_0__IFoo__Goober(var_msg0_vector_i, arg0[i]);
- }
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::haveAGoober(
- const ::android::hardware::tests::foo::V1_0::IFoo::Goober& arg0 __attribute__((__unused__))) {
- LOG(INFO) << "haveAGoober called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("haveAGoober"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::haveAGoober");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_STRUCT);
- SetResult__android__hardware__tests__foo__V1_0__IFoo__Goober(var_msg0, arg0);
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::haveAGooberArray(
- const ::android::hardware::hidl_array<::android::hardware::tests::foo::V1_0::IFoo::Goober, 20>& arg0 __attribute__((__unused__))) {
- LOG(INFO) << "haveAGooberArray called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("haveAGooberArray"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::haveAGooberArray");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_ARRAY);
- var_msg0->set_vector_size(1);
- for (int i = 0; i < 1; i++) {
- auto *var_msg0_array_i = var_msg0->add_vector_value();
- var_msg0_array_i->set_type(TYPE_STRUCT);
- auto *var_msg0_array_i_q = var_msg0_array_i->add_struct_value();
- var_msg0_array_i_q->set_type(TYPE_SCALAR);
- var_msg0_array_i_q->set_scalar_type("int32_t");
- var_msg0_array_i_q->mutable_scalar_value()->set_int32_t(arg0[i].q);
- var_msg0_array_i_q->set_name("q");
- auto *var_msg0_array_i_name = var_msg0_array_i->add_struct_value();
- var_msg0_array_i_name->set_type(TYPE_STRING);
- var_msg0_array_i_name->mutable_string_value()->set_message(arg0[i].name.c_str());
- var_msg0_array_i_name->mutable_string_value()->set_length(arg0[i].name.size());
- var_msg0_array_i_name->set_name("name");
- auto *var_msg0_array_i_address = var_msg0_array_i->add_struct_value();
- var_msg0_array_i_address->set_type(TYPE_STRING);
- var_msg0_array_i_address->mutable_string_value()->set_message(arg0[i].address.c_str());
- var_msg0_array_i_address->mutable_string_value()->set_length(arg0[i].address.size());
- var_msg0_array_i_address->set_name("address");
- auto *var_msg0_array_i_numbers = var_msg0_array_i->add_struct_value();
- var_msg0_array_i_numbers->set_type(TYPE_ARRAY);
- var_msg0_array_i_numbers->set_vector_size(1);
- for (int i = 0; i < 1; i++) {
- auto *var_msg0_array_i_numbers_array_i = var_msg0_array_i_numbers->add_vector_value();
- var_msg0_array_i_numbers_array_i->set_type(TYPE_SCALAR);
- var_msg0_array_i_numbers_array_i->set_scalar_type("double_t");
- var_msg0_array_i_numbers_array_i->mutable_scalar_value()->set_double_t(arg0[i].numbers[i]);
- }
- var_msg0_array_i_numbers->set_name("numbers");
- auto *var_msg0_array_i_fumble = var_msg0_array_i->add_struct_value();
- var_msg0_array_i_fumble->set_type(TYPE_STRUCT);
- SetResult__android__hardware__tests__foo__V1_0__IFoo__Fumble(var_msg0_array_i_fumble, arg0[i].fumble);
- var_msg0_array_i_fumble->set_name("fumble");
- auto *var_msg0_array_i_gumble = var_msg0_array_i->add_struct_value();
- var_msg0_array_i_gumble->set_type(TYPE_STRUCT);
- SetResult__android__hardware__tests__foo__V1_0__IFoo__Fumble(var_msg0_array_i_gumble, arg0[i].gumble);
- var_msg0_array_i_gumble->set_name("gumble");
- }
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::haveATypeFromAnotherFile(
- const ::android::hardware::tests::foo::V1_0::Abc& arg0 __attribute__((__unused__))) {
- LOG(INFO) << "haveATypeFromAnotherFile called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("haveATypeFromAnotherFile"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::haveATypeFromAnotherFile");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_STRUCT);
- SetResult__android__hardware__tests__foo__V1_0__Abc(var_msg0, arg0);
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::haveSomeStrings(
- const ::android::hardware::hidl_array<::android::hardware::hidl_string, 3>& arg0 __attribute__((__unused__)), std::function<void(const ::android::hardware::hidl_array<::android::hardware::hidl_string, 2>& arg0)> cb) {
- LOG(INFO) << "haveSomeStrings called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("haveSomeStrings"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::haveSomeStrings");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_ARRAY);
- var_msg0->set_vector_size(1);
- for (int i = 0; i < 1; i++) {
- auto *var_msg0_array_i = var_msg0->add_vector_value();
- var_msg0_array_i->set_type(TYPE_STRING);
- var_msg0_array_i->mutable_string_value()->set_message(arg0[i].c_str());
- var_msg0_array_i->mutable_string_value()->set_length(arg0[i].size());
- }
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(::android::hardware::hidl_array<::android::hardware::hidl_string, 2>());
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::haveAStringVec(
- const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& arg0 __attribute__((__unused__)), std::function<void(const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& arg0)> cb) {
- LOG(INFO) << "haveAStringVec called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("haveAStringVec"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::haveAStringVec");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_VECTOR);
- var_msg0->set_vector_size(arg0.size());
- for (int i = 0; i < (int)arg0.size(); i++) {
- auto *var_msg0_vector_i = var_msg0->add_vector_value();
- var_msg0_vector_i->set_type(TYPE_STRING);
- var_msg0_vector_i->mutable_string_value()->set_message(arg0[i].c_str());
- var_msg0_vector_i->mutable_string_value()->set_length(arg0[i].size());
- }
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(::android::hardware::hidl_vec<::android::hardware::hidl_string>());
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::transposeMe(
- const ::android::hardware::hidl_array<float, 3, 5>& arg0 __attribute__((__unused__)), std::function<void(const ::android::hardware::hidl_array<float, 5, 3>& arg0)> cb) {
- LOG(INFO) << "transposeMe called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("transposeMe"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::transposeMe");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_ARRAY);
- var_msg0->set_vector_size(1);
- for (int i = 0; i < 1; i++) {
- auto *var_msg0_array_i = var_msg0->add_vector_value();
- var_msg0_array_i->set_type(TYPE_ARRAY);
- var_msg0_array_i->set_vector_size(1);
- for (int i = 0; i < 1; i++) {
- auto *var_msg0_array_i_array_i = var_msg0_array_i->add_vector_value();
- var_msg0_array_i_array_i->set_type(TYPE_SCALAR);
- var_msg0_array_i_array_i->set_scalar_type("float_t");
- var_msg0_array_i_array_i->mutable_scalar_value()->set_float_t(arg0[i][i]);
- }
- }
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(::android::hardware::hidl_array<float, 5, 3>());
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::callingDrWho(
- const ::android::hardware::tests::foo::V1_0::IFoo::MultiDimensional& arg0 __attribute__((__unused__)), std::function<void(const ::android::hardware::tests::foo::V1_0::IFoo::MultiDimensional& arg0)> cb) {
- LOG(INFO) << "callingDrWho called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("callingDrWho"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::callingDrWho");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_STRUCT);
- SetResult__android__hardware__tests__foo__V1_0__IFoo__MultiDimensional(var_msg0, arg0);
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(::android::hardware::tests::foo::V1_0::IFoo::MultiDimensional());
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::transpose(
- const ::android::hardware::tests::foo::V1_0::IFoo::StringMatrix5x3& arg0 __attribute__((__unused__)), std::function<void(const ::android::hardware::tests::foo::V1_0::IFoo::StringMatrix3x5& arg0)> cb) {
- LOG(INFO) << "transpose called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("transpose"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::transpose");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_STRUCT);
- SetResult__android__hardware__tests__foo__V1_0__IFoo__StringMatrix5x3(var_msg0, arg0);
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(::android::hardware::tests::foo::V1_0::IFoo::StringMatrix3x5());
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::transpose2(
- const ::android::hardware::hidl_array<::android::hardware::hidl_string, 5, 3>& arg0 __attribute__((__unused__)), std::function<void(const ::android::hardware::hidl_array<::android::hardware::hidl_string, 3, 5>& arg0)> cb) {
- LOG(INFO) << "transpose2 called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("transpose2"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::transpose2");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_ARRAY);
- var_msg0->set_vector_size(1);
- for (int i = 0; i < 1; i++) {
- auto *var_msg0_array_i = var_msg0->add_vector_value();
- var_msg0_array_i->set_type(TYPE_ARRAY);
- var_msg0_array_i->set_vector_size(1);
- for (int i = 0; i < 1; i++) {
- auto *var_msg0_array_i_array_i = var_msg0_array_i->add_vector_value();
- var_msg0_array_i_array_i->set_type(TYPE_STRING);
- var_msg0_array_i_array_i->mutable_string_value()->set_message(arg0[i][i].c_str());
- var_msg0_array_i_array_i->mutable_string_value()->set_length(arg0[i][i].size());
- }
- }
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(::android::hardware::hidl_array<::android::hardware::hidl_string, 3, 5>());
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::sendVec(
- const ::android::hardware::hidl_vec<uint8_t>& arg0 __attribute__((__unused__)), std::function<void(const ::android::hardware::hidl_vec<uint8_t>& arg0)> cb) {
- LOG(INFO) << "sendVec called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("sendVec"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::sendVec");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_VECTOR);
- var_msg0->set_vector_size(arg0.size());
- for (int i = 0; i < (int)arg0.size(); i++) {
- auto *var_msg0_vector_i = var_msg0->add_vector_value();
- var_msg0_vector_i->set_type(TYPE_SCALAR);
- var_msg0_vector_i->set_scalar_type("uint8_t");
- var_msg0_vector_i->mutable_scalar_value()->set_uint8_t(arg0[i]);
- }
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(::android::hardware::hidl_vec<uint8_t>());
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::sendVecVec(
- std::function<void(const ::android::hardware::hidl_vec<::android::hardware::hidl_vec<uint8_t>>& arg0)> cb) {
- LOG(INFO) << "sendVecVec called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("sendVecVec"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::sendVecVec");
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(::android::hardware::hidl_vec<::android::hardware::hidl_vec<uint8_t>>());
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::haveAVectorOfInterfaces(
- const ::android::hardware::hidl_vec<sp<::android::hardware::tests::foo::V1_0::ISimple>>& arg0 __attribute__((__unused__)), std::function<void(const ::android::hardware::hidl_vec<sp<::android::hardware::tests::foo::V1_0::ISimple>>& arg0)> cb) {
- LOG(INFO) << "haveAVectorOfInterfaces called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("haveAVectorOfInterfaces"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::haveAVectorOfInterfaces");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_VECTOR);
- var_msg0->set_vector_size(arg0.size());
- for (int i = 0; i < (int)arg0.size(); i++) {
- auto *var_msg0_vector_i = var_msg0->add_vector_value();
- var_msg0_vector_i->set_type(TYPE_HIDL_INTERFACE);
- var_msg0_vector_i->set_predefined_type("::android::hardware::tests::foo::V1_0::ISimple");
- if (arg0[i] != nullptr) {
- arg0[i]->incStrong(arg0[i].get());
- var_msg0_vector_i->set_hidl_interface_pointer(reinterpret_cast<uintptr_t>(arg0[i].get()));
- } else {
- var_msg0_vector_i->set_hidl_interface_pointer(0);
- }
- }
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(::android::hardware::hidl_vec<sp<::android::hardware::tests::foo::V1_0::ISimple>>());
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::haveAVectorOfGenericInterfaces(
- const ::android::hardware::hidl_vec<sp<::android::hidl::base::V1_0::IBase>>& arg0 __attribute__((__unused__)), std::function<void(const ::android::hardware::hidl_vec<sp<::android::hidl::base::V1_0::IBase>>& arg0)> cb) {
- LOG(INFO) << "haveAVectorOfGenericInterfaces called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("haveAVectorOfGenericInterfaces"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::haveAVectorOfGenericInterfaces");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_VECTOR);
- var_msg0->set_vector_size(arg0.size());
- for (int i = 0; i < (int)arg0.size(); i++) {
- auto *var_msg0_vector_i = var_msg0->add_vector_value();
- var_msg0_vector_i->set_type(TYPE_HIDL_INTERFACE);
- var_msg0_vector_i->set_predefined_type("::android::hidl::base::V1_0::IBase");
- if (arg0[i] != nullptr) {
- arg0[i]->incStrong(arg0[i].get());
- var_msg0_vector_i->set_hidl_interface_pointer(reinterpret_cast<uintptr_t>(arg0[i].get()));
- } else {
- var_msg0_vector_i->set_hidl_interface_pointer(0);
- }
- }
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(::android::hardware::hidl_vec<sp<::android::hidl::base::V1_0::IBase>>());
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::echoNullInterface(
- const sp<::android::hardware::tests::foo::V1_0::IFooCallback>& arg0 __attribute__((__unused__)), std::function<void(bool arg0,const sp<::android::hardware::tests::foo::V1_0::IFooCallback>& arg1)> cb) {
- LOG(INFO) << "echoNullInterface called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("echoNullInterface"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::echoNullInterface");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_HIDL_CALLBACK);
- LOG(ERROR) << "TYPE HIDL_CALLBACK is not supported yet. ";
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(static_cast<bool>(0), nullptr);
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::createMyHandle(
- std::function<void(const ::android::hardware::tests::foo::V1_0::IFoo::MyHandle& arg0)> cb) {
- LOG(INFO) << "createMyHandle called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("createMyHandle"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::createMyHandle");
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(::android::hardware::tests::foo::V1_0::IFoo::MyHandle());
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::createHandles(
- uint32_t arg0 __attribute__((__unused__)), std::function<void(const ::android::hardware::hidl_vec<::android::hardware::hidl_handle>& arg0)> cb) {
- LOG(INFO) << "createHandles called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("createHandles"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::createHandles");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_SCALAR);
- var_msg0->set_scalar_type("uint32_t");
- var_msg0->mutable_scalar_value()->set_uint32_t(arg0);
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(::android::hardware::hidl_vec<::android::hardware::hidl_handle>());
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::closeHandles(
- ) {
- LOG(INFO) << "closeHandles called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("closeHandles"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::closeHandles");
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::repeatWithFmq(
- const ::android::hardware::tests::foo::V1_0::IFoo::WithFmq& arg0 __attribute__((__unused__)), std::function<void(const ::android::hardware::tests::foo::V1_0::IFoo::WithFmq& arg0)> cb) {
- LOG(INFO) << "repeatWithFmq called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("repeatWithFmq"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::repeatWithFmq");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_STRUCT);
- SetResult__android__hardware__tests__foo__V1_0__IFoo__WithFmq(var_msg0, arg0);
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(::android::hardware::tests::foo::V1_0::IFoo::WithFmq());
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::thisIsNew(
- ) {
- LOG(INFO) << "thisIsNew called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("thisIsNew"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::thisIsNew");
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::expectNullHandle(
- const ::android::hardware::hidl_handle& arg0 __attribute__((__unused__)),
- const ::android::hardware::tests::foo::V1_0::Abc& arg1 __attribute__((__unused__)), std::function<void(bool arg0,bool arg1)> cb) {
- LOG(INFO) << "expectNullHandle called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("expectNullHandle"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::expectNullHandle");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_HANDLE);
- var_msg0->mutable_handle_value()->set_hidl_handle_address(reinterpret_cast<size_t>(new android::hardware::hidl_handle(arg0)));
- VariableSpecificationMessage* var_msg1 = callback_message.add_arg();
- var_msg1->set_type(TYPE_STRUCT);
- SetResult__android__hardware__tests__foo__V1_0__Abc(var_msg1, arg1);
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(static_cast<bool>(0), static_cast<bool>(0));
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_bar_V1_0_IBar::takeAMask(
- ::android::hardware::tests::foo::V1_0::IFoo::BitField arg0 __attribute__((__unused__)),
- uint8_t arg1 __attribute__((__unused__)),
- const ::android::hardware::tests::foo::V1_0::IFoo::MyMask& arg2 __attribute__((__unused__)),
- uint8_t arg3 __attribute__((__unused__)), std::function<void(::android::hardware::tests::foo::V1_0::IFoo::BitField arg0,uint8_t arg1,uint8_t arg2,uint8_t arg3)> cb) {
- LOG(INFO) << "takeAMask called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("takeAMask"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::takeAMask");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_ENUM);
- SetResult__android__hardware__tests__foo__V1_0__IFoo__BitField(var_msg0, arg0);
- VariableSpecificationMessage* var_msg1 = callback_message.add_arg();
- var_msg1->set_type(TYPE_MASK);
- var_msg1->set_scalar_type("uint8_t");
- var_msg1->mutable_scalar_value()->set_uint8_t(arg1);
- VariableSpecificationMessage* var_msg2 = callback_message.add_arg();
- var_msg2->set_type(TYPE_STRUCT);
- SetResult__android__hardware__tests__foo__V1_0__IFoo__MyMask(var_msg2, arg2);
- VariableSpecificationMessage* var_msg3 = callback_message.add_arg();
- var_msg3->set_type(TYPE_MASK);
- var_msg3->set_scalar_type("uint8_t");
- var_msg3->mutable_scalar_value()->set_uint8_t(arg3);
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(::android::hardware::tests::foo::V1_0::IFoo::BitField(), static_cast<uint8_t>(0), static_cast<uint8_t>(0), static_cast<uint8_t>(0));
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<sp<::android::hardware::tests::foo::V1_0::ISimple>> Vts_android_hardware_tests_bar_V1_0_IBar::haveAInterface(
- const sp<::android::hardware::tests::foo::V1_0::ISimple>& arg0 __attribute__((__unused__))) {
- LOG(INFO) << "haveAInterface called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("haveAInterface"));
- callback_message.set_name("Vts_android_hardware_tests_bar_V1_0_IBar::haveAInterface");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_HIDL_INTERFACE);
- var_msg0->set_predefined_type("::android::hardware::tests::foo::V1_0::ISimple");
- if (arg0 != nullptr) {
- arg0->incStrong(arg0.get());
- var_msg0->set_hidl_interface_pointer(reinterpret_cast<uintptr_t>(arg0.get()));
- } else {
- var_msg0->set_hidl_interface_pointer(0);
- }
- RpcCallToAgent(callback_message, callback_socket_name_);
- return nullptr;
-}
-
-sp<::android::hardware::tests::bar::V1_0::IBar> VtsFuzzerCreateVts_android_hardware_tests_bar_V1_0_IBar(const string& callback_socket_name) {
- static sp<::android::hardware::tests::bar::V1_0::IBar> result;
- result = new Vts_android_hardware_tests_bar_V1_0_IBar(callback_socket_name);
- return result;
-}
-
-bool FuzzerExtended_android_hardware_tests_bar_V1_0_IBar::Fuzz(
- FunctionSpecificationMessage* /*func_msg*/,
- void** /*result*/, const string& /*callback_socket_name*/) {
- return true;
-}
-bool FuzzerExtended_android_hardware_tests_bar_V1_0_IBar::GetAttribute(
- FunctionSpecificationMessage* /*func_msg*/,
- void** /*result*/) {
- LOG(ERROR) << "attribute not found.";
- return false;
-}
-bool FuzzerExtended_android_hardware_tests_bar_V1_0_IBar::CallFunction(
- const FunctionSpecificationMessage& func_msg,
- const string& callback_socket_name __attribute__((__unused__)),
- FunctionSpecificationMessage* result_msg) {
- const char* func_name = func_msg.name().c_str();
- if (hw_binder_proxy_ == nullptr) {
- LOG(ERROR) << "hw_binder_proxy_ is null. ";
- return false;
- }
- if (!strcmp(func_name, "convertToBoolIfSmall")) {
- ::android::hardware::tests::foo::V1_0::IFoo::Discriminator arg0;
- MessageTo__android__hardware__tests__foo__V1_0__IFoo__Discriminator(func_msg.arg(0), &(arg0), callback_socket_name);
- ::android::hardware::hidl_vec<::android::hardware::tests::foo::V1_0::IFoo::Union> arg1;
- arg1.resize(func_msg.arg(1).vector_value_size());
- for (int arg1_index = 0; arg1_index < func_msg.arg(1).vector_value_size(); arg1_index++) {
- MessageTo__android__hardware__tests__foo__V1_0__IFoo__Union(func_msg.arg(1).vector_value(arg1_index), &(arg1[arg1_index]), callback_socket_name);
- }
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->convertToBoolIfSmall(arg0, arg1, [&](const ::android::hardware::hidl_vec<::android::hardware::tests::foo::V1_0::IFoo::ContainsUnion>& arg0 __attribute__((__unused__))){
- LOG(INFO) << "callback convertToBoolIfSmall called";
- result_msg->set_name("convertToBoolIfSmall");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_VECTOR);
- result_val_0->set_vector_size(arg0.size());
- for (int i = 0; i < (int)arg0.size(); i++) {
- auto *result_val_0_vector_i = result_val_0->add_vector_value();
- result_val_0_vector_i->set_type(TYPE_STRUCT);
- SetResult__android__hardware__tests__foo__V1_0__IFoo__ContainsUnion(result_val_0_vector_i, arg0[i]);
- }
- });
- return true;
- }
- if (!strcmp(func_name, "doThis")) {
- float arg0 = 0;
- arg0 = func_msg.arg(0).scalar_value().float_t();
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->doThis(arg0);
- result_msg->set_name("doThis");
- return true;
- }
- if (!strcmp(func_name, "doThatAndReturnSomething")) {
- int64_t arg0 = 0;
- arg0 = func_msg.arg(0).scalar_value().int64_t();
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- int32_t result0 = hw_binder_proxy_->doThatAndReturnSomething(arg0);
- result_msg->set_name("doThatAndReturnSomething");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_SCALAR);
- result_val_0->set_scalar_type("int32_t");
- result_val_0->mutable_scalar_value()->set_int32_t(result0);
- return true;
- }
- if (!strcmp(func_name, "doQuiteABit")) {
- int32_t arg0 = 0;
- arg0 = func_msg.arg(0).scalar_value().int32_t();
- int64_t arg1 = 0;
- arg1 = func_msg.arg(1).scalar_value().int64_t();
- float arg2 = 0;
- arg2 = func_msg.arg(2).scalar_value().float_t();
- double arg3 = 0;
- arg3 = func_msg.arg(3).scalar_value().double_t();
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- double result0 = hw_binder_proxy_->doQuiteABit(arg0, arg1, arg2, arg3);
- result_msg->set_name("doQuiteABit");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_SCALAR);
- result_val_0->set_scalar_type("double_t");
- result_val_0->mutable_scalar_value()->set_double_t(result0);
- return true;
- }
- if (!strcmp(func_name, "doSomethingElse")) {
- ::android::hardware::hidl_array<int32_t, 15> arg0;
- for (int arg0_index = 0; arg0_index < func_msg.arg(0).vector_value_size(); arg0_index++) {
- arg0[arg0_index] = func_msg.arg(0).vector_value(arg0_index).scalar_value().int32_t();
- }
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->doSomethingElse(arg0, [&](const ::android::hardware::hidl_array<int32_t, 32>& arg0 __attribute__((__unused__))){
- LOG(INFO) << "callback doSomethingElse called";
- result_msg->set_name("doSomethingElse");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_ARRAY);
- result_val_0->set_vector_size(1);
- for (int i = 0; i < 1; i++) {
- auto *result_val_0_array_i = result_val_0->add_vector_value();
- result_val_0_array_i->set_type(TYPE_SCALAR);
- result_val_0_array_i->set_scalar_type("int32_t");
- result_val_0_array_i->mutable_scalar_value()->set_int32_t(arg0[i]);
- }
- });
- return true;
- }
- if (!strcmp(func_name, "doStuffAndReturnAString")) {
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->doStuffAndReturnAString([&](const ::android::hardware::hidl_string& arg0 __attribute__((__unused__))){
- LOG(INFO) << "callback doStuffAndReturnAString called";
- result_msg->set_name("doStuffAndReturnAString");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_STRING);
- result_val_0->mutable_string_value()->set_message(arg0.c_str());
- result_val_0->mutable_string_value()->set_length(arg0.size());
- });
- return true;
- }
- if (!strcmp(func_name, "mapThisVector")) {
- ::android::hardware::hidl_vec<int32_t> arg0;
- arg0.resize(func_msg.arg(0).vector_value_size());
- for (int arg0_index = 0; arg0_index < func_msg.arg(0).vector_value_size(); arg0_index++) {
- arg0[arg0_index] = func_msg.arg(0).vector_value(arg0_index).scalar_value().int32_t();
- }
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->mapThisVector(arg0, [&](const ::android::hardware::hidl_vec<int32_t>& arg0 __attribute__((__unused__))){
- LOG(INFO) << "callback mapThisVector called";
- result_msg->set_name("mapThisVector");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_VECTOR);
- result_val_0->set_vector_size(arg0.size());
- for (int i = 0; i < (int)arg0.size(); i++) {
- auto *result_val_0_vector_i = result_val_0->add_vector_value();
- result_val_0_vector_i->set_type(TYPE_SCALAR);
- result_val_0_vector_i->set_scalar_type("int32_t");
- result_val_0_vector_i->mutable_scalar_value()->set_int32_t(arg0[i]);
- }
- });
- return true;
- }
- if (!strcmp(func_name, "callMe")) {
- sp<::android::hardware::tests::foo::V1_0::IFooCallback> arg0;
- arg0 = VtsFuzzerCreateVts_android_hardware_tests_foo_V1_0_IFooCallback(callback_socket_name);
- static_cast<Vts_android_hardware_tests_foo_V1_0_IFooCallback*>(arg0.get())->Register(func_msg.arg(0));
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->callMe(arg0);
- result_msg->set_name("callMe");
- return true;
- }
- if (!strcmp(func_name, "useAnEnum")) {
- ::android::hardware::tests::foo::V1_0::IFoo::SomeEnum arg0;
- MessageTo__android__hardware__tests__foo__V1_0__IFoo__SomeEnum(func_msg.arg(0), &(arg0), callback_socket_name);
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- ::android::hardware::tests::foo::V1_0::IFoo::SomeEnum result0 = hw_binder_proxy_->useAnEnum(arg0);
- result_msg->set_name("useAnEnum");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_ENUM);
- SetResult__android__hardware__tests__foo__V1_0__IFoo__SomeEnum(result_val_0, result0);
- return true;
- }
- if (!strcmp(func_name, "haveAGooberVec")) {
- ::android::hardware::hidl_vec<::android::hardware::tests::foo::V1_0::IFoo::Goober> arg0;
- arg0.resize(func_msg.arg(0).vector_value_size());
- for (int arg0_index = 0; arg0_index < func_msg.arg(0).vector_value_size(); arg0_index++) {
- MessageTo__android__hardware__tests__foo__V1_0__IFoo__Goober(func_msg.arg(0).vector_value(arg0_index), &(arg0[arg0_index]), callback_socket_name);
- }
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->haveAGooberVec(arg0);
- result_msg->set_name("haveAGooberVec");
- return true;
- }
- if (!strcmp(func_name, "haveAGoober")) {
- ::android::hardware::tests::foo::V1_0::IFoo::Goober arg0;
- MessageTo__android__hardware__tests__foo__V1_0__IFoo__Goober(func_msg.arg(0), &(arg0), callback_socket_name);
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->haveAGoober(arg0);
- result_msg->set_name("haveAGoober");
- return true;
- }
- if (!strcmp(func_name, "haveAGooberArray")) {
- ::android::hardware::hidl_array<::android::hardware::tests::foo::V1_0::IFoo::Goober, 20> arg0;
- for (int arg0_index = 0; arg0_index < func_msg.arg(0).vector_value_size(); arg0_index++) {
- arg0[arg0_index].q = func_msg.arg(0).vector_value(arg0_index).struct_value(0).scalar_value().int32_t();
- arg0[arg0_index].name = ::android::hardware::hidl_string(func_msg.arg(0).vector_value(arg0_index).struct_value(1).string_value().message());
- arg0[arg0_index].address = ::android::hardware::hidl_string(func_msg.arg(0).vector_value(arg0_index).struct_value(2).string_value().message());
- for (int arg0_arg0_index__numbers_index = 0; arg0_arg0_index__numbers_index < func_msg.arg(0).vector_value(arg0_index).struct_value(3).vector_value_size(); arg0_arg0_index__numbers_index++) {
- arg0[arg0_index].numbers[arg0_arg0_index__numbers_index] = func_msg.arg(0).vector_value(arg0_index).struct_value(3).vector_value(arg0_arg0_index__numbers_index).scalar_value().double_t();
- }
- MessageTo__android__hardware__tests__foo__V1_0__IFoo__Fumble(func_msg.arg(0).vector_value(arg0_index).struct_value(4), &(arg0[arg0_index].fumble), callback_socket_name);
- MessageTo__android__hardware__tests__foo__V1_0__IFoo__Fumble(func_msg.arg(0).vector_value(arg0_index).struct_value(5), &(arg0[arg0_index].gumble), callback_socket_name);
- }
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->haveAGooberArray(arg0);
- result_msg->set_name("haveAGooberArray");
- return true;
- }
- if (!strcmp(func_name, "haveATypeFromAnotherFile")) {
- ::android::hardware::tests::foo::V1_0::Abc arg0;
- MessageTo__android__hardware__tests__foo__V1_0__Abc(func_msg.arg(0), &(arg0), callback_socket_name);
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->haveATypeFromAnotherFile(arg0);
- result_msg->set_name("haveATypeFromAnotherFile");
- return true;
- }
- if (!strcmp(func_name, "haveSomeStrings")) {
- ::android::hardware::hidl_array<::android::hardware::hidl_string, 3> arg0;
- for (int arg0_index = 0; arg0_index < func_msg.arg(0).vector_value_size(); arg0_index++) {
- arg0[arg0_index] = ::android::hardware::hidl_string(func_msg.arg(0).vector_value(arg0_index).string_value().message());
- }
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->haveSomeStrings(arg0, [&](const ::android::hardware::hidl_array<::android::hardware::hidl_string, 2>& arg0 __attribute__((__unused__))){
- LOG(INFO) << "callback haveSomeStrings called";
- result_msg->set_name("haveSomeStrings");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_ARRAY);
- result_val_0->set_vector_size(1);
- for (int i = 0; i < 1; i++) {
- auto *result_val_0_array_i = result_val_0->add_vector_value();
- result_val_0_array_i->set_type(TYPE_STRING);
- result_val_0_array_i->mutable_string_value()->set_message(arg0[i].c_str());
- result_val_0_array_i->mutable_string_value()->set_length(arg0[i].size());
- }
- });
- return true;
- }
- if (!strcmp(func_name, "haveAStringVec")) {
- ::android::hardware::hidl_vec<::android::hardware::hidl_string> arg0;
- arg0.resize(func_msg.arg(0).vector_value_size());
- for (int arg0_index = 0; arg0_index < func_msg.arg(0).vector_value_size(); arg0_index++) {
- arg0[arg0_index] = ::android::hardware::hidl_string(func_msg.arg(0).vector_value(arg0_index).string_value().message());
- }
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->haveAStringVec(arg0, [&](const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& arg0 __attribute__((__unused__))){
- LOG(INFO) << "callback haveAStringVec called";
- result_msg->set_name("haveAStringVec");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_VECTOR);
- result_val_0->set_vector_size(arg0.size());
- for (int i = 0; i < (int)arg0.size(); i++) {
- auto *result_val_0_vector_i = result_val_0->add_vector_value();
- result_val_0_vector_i->set_type(TYPE_STRING);
- result_val_0_vector_i->mutable_string_value()->set_message(arg0[i].c_str());
- result_val_0_vector_i->mutable_string_value()->set_length(arg0[i].size());
- }
- });
- return true;
- }
- if (!strcmp(func_name, "transposeMe")) {
- ::android::hardware::hidl_array<float, 3, 5> arg0;
- for (int arg0_index = 0; arg0_index < func_msg.arg(0).vector_value_size(); arg0_index++) {
- for (int arg0_arg0_index__index = 0; arg0_arg0_index__index < func_msg.arg(0).vector_value(arg0_index).vector_value_size(); arg0_arg0_index__index++) {
- arg0[arg0_index][arg0_arg0_index__index] = func_msg.arg(0).vector_value(arg0_index).vector_value(arg0_arg0_index__index).scalar_value().float_t();
- }
- }
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->transposeMe(arg0, [&](const ::android::hardware::hidl_array<float, 5, 3>& arg0 __attribute__((__unused__))){
- LOG(INFO) << "callback transposeMe called";
- result_msg->set_name("transposeMe");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_ARRAY);
- result_val_0->set_vector_size(1);
- for (int i = 0; i < 1; i++) {
- auto *result_val_0_array_i = result_val_0->add_vector_value();
- result_val_0_array_i->set_type(TYPE_ARRAY);
- result_val_0_array_i->set_vector_size(1);
- for (int i = 0; i < 1; i++) {
- auto *result_val_0_array_i_array_i = result_val_0_array_i->add_vector_value();
- result_val_0_array_i_array_i->set_type(TYPE_SCALAR);
- result_val_0_array_i_array_i->set_scalar_type("float_t");
- result_val_0_array_i_array_i->mutable_scalar_value()->set_float_t(arg0[i][i]);
- }
- }
- });
- return true;
- }
- if (!strcmp(func_name, "callingDrWho")) {
- ::android::hardware::tests::foo::V1_0::IFoo::MultiDimensional arg0;
- MessageTo__android__hardware__tests__foo__V1_0__IFoo__MultiDimensional(func_msg.arg(0), &(arg0), callback_socket_name);
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->callingDrWho(arg0, [&](const ::android::hardware::tests::foo::V1_0::IFoo::MultiDimensional& arg0 __attribute__((__unused__))){
- LOG(INFO) << "callback callingDrWho called";
- result_msg->set_name("callingDrWho");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_STRUCT);
- SetResult__android__hardware__tests__foo__V1_0__IFoo__MultiDimensional(result_val_0, arg0);
- });
- return true;
- }
- if (!strcmp(func_name, "transpose")) {
- ::android::hardware::tests::foo::V1_0::IFoo::StringMatrix5x3 arg0;
- MessageTo__android__hardware__tests__foo__V1_0__IFoo__StringMatrix5x3(func_msg.arg(0), &(arg0), callback_socket_name);
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->transpose(arg0, [&](const ::android::hardware::tests::foo::V1_0::IFoo::StringMatrix3x5& arg0 __attribute__((__unused__))){
- LOG(INFO) << "callback transpose called";
- result_msg->set_name("transpose");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_STRUCT);
- SetResult__android__hardware__tests__foo__V1_0__IFoo__StringMatrix3x5(result_val_0, arg0);
- });
- return true;
- }
- if (!strcmp(func_name, "transpose2")) {
- ::android::hardware::hidl_array<::android::hardware::hidl_string, 5, 3> arg0;
- for (int arg0_index = 0; arg0_index < func_msg.arg(0).vector_value_size(); arg0_index++) {
- for (int arg0_arg0_index__index = 0; arg0_arg0_index__index < func_msg.arg(0).vector_value(arg0_index).vector_value_size(); arg0_arg0_index__index++) {
- arg0[arg0_index][arg0_arg0_index__index] = ::android::hardware::hidl_string(func_msg.arg(0).vector_value(arg0_index).vector_value(arg0_arg0_index__index).string_value().message());
- }
- }
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->transpose2(arg0, [&](const ::android::hardware::hidl_array<::android::hardware::hidl_string, 3, 5>& arg0 __attribute__((__unused__))){
- LOG(INFO) << "callback transpose2 called";
- result_msg->set_name("transpose2");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_ARRAY);
- result_val_0->set_vector_size(1);
- for (int i = 0; i < 1; i++) {
- auto *result_val_0_array_i = result_val_0->add_vector_value();
- result_val_0_array_i->set_type(TYPE_ARRAY);
- result_val_0_array_i->set_vector_size(1);
- for (int i = 0; i < 1; i++) {
- auto *result_val_0_array_i_array_i = result_val_0_array_i->add_vector_value();
- result_val_0_array_i_array_i->set_type(TYPE_STRING);
- result_val_0_array_i_array_i->mutable_string_value()->set_message(arg0[i][i].c_str());
- result_val_0_array_i_array_i->mutable_string_value()->set_length(arg0[i][i].size());
- }
- }
- });
- return true;
- }
- if (!strcmp(func_name, "sendVec")) {
- ::android::hardware::hidl_vec<uint8_t> arg0;
- arg0.resize(func_msg.arg(0).vector_value_size());
- for (int arg0_index = 0; arg0_index < func_msg.arg(0).vector_value_size(); arg0_index++) {
- arg0[arg0_index] = func_msg.arg(0).vector_value(arg0_index).scalar_value().uint8_t();
- }
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->sendVec(arg0, [&](const ::android::hardware::hidl_vec<uint8_t>& arg0 __attribute__((__unused__))){
- LOG(INFO) << "callback sendVec called";
- result_msg->set_name("sendVec");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_VECTOR);
- result_val_0->set_vector_size(arg0.size());
- for (int i = 0; i < (int)arg0.size(); i++) {
- auto *result_val_0_vector_i = result_val_0->add_vector_value();
- result_val_0_vector_i->set_type(TYPE_SCALAR);
- result_val_0_vector_i->set_scalar_type("uint8_t");
- result_val_0_vector_i->mutable_scalar_value()->set_uint8_t(arg0[i]);
- }
- });
- return true;
- }
- if (!strcmp(func_name, "sendVecVec")) {
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->sendVecVec([&](const ::android::hardware::hidl_vec<::android::hardware::hidl_vec<uint8_t>>& arg0 __attribute__((__unused__))){
- LOG(INFO) << "callback sendVecVec called";
- result_msg->set_name("sendVecVec");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_VECTOR);
- result_val_0->set_vector_size(arg0.size());
- for (int i = 0; i < (int)arg0.size(); i++) {
- auto *result_val_0_vector_i = result_val_0->add_vector_value();
- result_val_0_vector_i->set_type(TYPE_VECTOR);
- result_val_0_vector_i->set_vector_size(arg0[i].size());
- for (int i = 0; i < (int)arg0[i].size(); i++) {
- auto *result_val_0_vector_i_vector_i = result_val_0_vector_i->add_vector_value();
- result_val_0_vector_i_vector_i->set_type(TYPE_SCALAR);
- result_val_0_vector_i_vector_i->set_scalar_type("uint8_t");
- result_val_0_vector_i_vector_i->mutable_scalar_value()->set_uint8_t(arg0[i][i]);
- }
- }
- });
- return true;
- }
- if (!strcmp(func_name, "haveAVectorOfInterfaces")) {
- ::android::hardware::hidl_vec<sp<::android::hardware::tests::foo::V1_0::ISimple>> arg0;
- arg0.resize(func_msg.arg(0).vector_value_size());
- for (int arg0_index = 0; arg0_index < func_msg.arg(0).vector_value_size(); arg0_index++) {
- if (func_msg.arg(0).vector_value(arg0_index).has_hidl_interface_pointer()) {
- arg0[arg0_index] = reinterpret_cast<::android::hardware::tests::foo::V1_0::ISimple*>(func_msg.arg(0).vector_value(arg0_index).hidl_interface_pointer());
- } else {
- arg0[arg0_index] = VtsFuzzerCreateVts_android_hardware_tests_foo_V1_0_ISimple(callback_socket_name);
- }
- }
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->haveAVectorOfInterfaces(arg0, [&](const ::android::hardware::hidl_vec<sp<::android::hardware::tests::foo::V1_0::ISimple>>& arg0 __attribute__((__unused__))){
- LOG(INFO) << "callback haveAVectorOfInterfaces called";
- result_msg->set_name("haveAVectorOfInterfaces");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_VECTOR);
- result_val_0->set_vector_size(arg0.size());
- for (int i = 0; i < (int)arg0.size(); i++) {
- auto *result_val_0_vector_i = result_val_0->add_vector_value();
- result_val_0_vector_i->set_type(TYPE_HIDL_INTERFACE);
- result_val_0_vector_i->set_predefined_type("::android::hardware::tests::foo::V1_0::ISimple");
- if (arg0[i] != nullptr) {
- arg0[i]->incStrong(arg0[i].get());
- result_val_0_vector_i->set_hidl_interface_pointer(reinterpret_cast<uintptr_t>(arg0[i].get()));
- } else {
- result_val_0_vector_i->set_hidl_interface_pointer(0);
- }
- }
- });
- return true;
- }
- if (!strcmp(func_name, "haveAVectorOfGenericInterfaces")) {
- ::android::hardware::hidl_vec<sp<::android::hidl::base::V1_0::IBase>> arg0;
- arg0.resize(func_msg.arg(0).vector_value_size());
- for (int arg0_index = 0; arg0_index < func_msg.arg(0).vector_value_size(); arg0_index++) {
- if (func_msg.arg(0).vector_value(arg0_index).has_hidl_interface_pointer()) {
- arg0[arg0_index] = reinterpret_cast<::android::hidl::base::V1_0::IBase*>(func_msg.arg(0).vector_value(arg0_index).hidl_interface_pointer());
- } else {
- LOG(ERROR) << "general interface is not supported yet. ";
- }
- }
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->haveAVectorOfGenericInterfaces(arg0, [&](const ::android::hardware::hidl_vec<sp<::android::hidl::base::V1_0::IBase>>& arg0 __attribute__((__unused__))){
- LOG(INFO) << "callback haveAVectorOfGenericInterfaces called";
- result_msg->set_name("haveAVectorOfGenericInterfaces");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_VECTOR);
- result_val_0->set_vector_size(arg0.size());
- for (int i = 0; i < (int)arg0.size(); i++) {
- auto *result_val_0_vector_i = result_val_0->add_vector_value();
- result_val_0_vector_i->set_type(TYPE_HIDL_INTERFACE);
- result_val_0_vector_i->set_predefined_type("::android::hidl::base::V1_0::IBase");
- if (arg0[i] != nullptr) {
- arg0[i]->incStrong(arg0[i].get());
- result_val_0_vector_i->set_hidl_interface_pointer(reinterpret_cast<uintptr_t>(arg0[i].get()));
- } else {
- result_val_0_vector_i->set_hidl_interface_pointer(0);
- }
- }
- });
- return true;
- }
- if (!strcmp(func_name, "echoNullInterface")) {
- sp<::android::hardware::tests::foo::V1_0::IFooCallback> arg0;
- arg0 = VtsFuzzerCreateVts_android_hardware_tests_foo_V1_0_IFooCallback(callback_socket_name);
- static_cast<Vts_android_hardware_tests_foo_V1_0_IFooCallback*>(arg0.get())->Register(func_msg.arg(0));
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->echoNullInterface(arg0, [&](bool arg0 __attribute__((__unused__)),const sp<::android::hardware::tests::foo::V1_0::IFooCallback>& arg1 __attribute__((__unused__))){
- LOG(INFO) << "callback echoNullInterface called";
- result_msg->set_name("echoNullInterface");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_SCALAR);
- result_val_0->set_scalar_type("bool_t");
- result_val_0->mutable_scalar_value()->set_bool_t(arg0);
- VariableSpecificationMessage* result_val_1 = result_msg->add_return_type_hidl();
- result_val_1->set_type(TYPE_HIDL_CALLBACK);
- LOG(ERROR) << "TYPE HIDL_CALLBACK is not supported yet. ";
- });
- return true;
- }
- if (!strcmp(func_name, "createMyHandle")) {
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->createMyHandle([&](const ::android::hardware::tests::foo::V1_0::IFoo::MyHandle& arg0 __attribute__((__unused__))){
- LOG(INFO) << "callback createMyHandle called";
- result_msg->set_name("createMyHandle");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_STRUCT);
- SetResult__android__hardware__tests__foo__V1_0__IFoo__MyHandle(result_val_0, arg0);
- });
- return true;
- }
- if (!strcmp(func_name, "createHandles")) {
- uint32_t arg0 = 0;
- arg0 = func_msg.arg(0).scalar_value().uint32_t();
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->createHandles(arg0, [&](const ::android::hardware::hidl_vec<::android::hardware::hidl_handle>& arg0 __attribute__((__unused__))){
- LOG(INFO) << "callback createHandles called";
- result_msg->set_name("createHandles");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_VECTOR);
- result_val_0->set_vector_size(arg0.size());
- for (int i = 0; i < (int)arg0.size(); i++) {
- auto *result_val_0_vector_i = result_val_0->add_vector_value();
- result_val_0_vector_i->set_type(TYPE_HANDLE);
- result_val_0_vector_i->mutable_handle_value()->set_hidl_handle_address(reinterpret_cast<size_t>(new android::hardware::hidl_handle(arg0[i])));
- }
- });
- return true;
- }
- if (!strcmp(func_name, "closeHandles")) {
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->closeHandles();
- result_msg->set_name("closeHandles");
- return true;
- }
- if (!strcmp(func_name, "repeatWithFmq")) {
- ::android::hardware::tests::foo::V1_0::IFoo::WithFmq arg0;
- MessageTo__android__hardware__tests__foo__V1_0__IFoo__WithFmq(func_msg.arg(0), &(arg0), callback_socket_name);
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->repeatWithFmq(arg0, [&](const ::android::hardware::tests::foo::V1_0::IFoo::WithFmq& arg0 __attribute__((__unused__))){
- LOG(INFO) << "callback repeatWithFmq called";
- result_msg->set_name("repeatWithFmq");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_STRUCT);
- SetResult__android__hardware__tests__foo__V1_0__IFoo__WithFmq(result_val_0, arg0);
- });
- return true;
- }
- if (!strcmp(func_name, "thisIsNew")) {
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->thisIsNew();
- result_msg->set_name("thisIsNew");
- return true;
- }
- if (!strcmp(func_name, "expectNullHandle")) {
- ::android::hardware::hidl_handle arg0;
- if (func_msg.arg(0).has_handle_value()) {
- if (func_msg.arg(0).handle_value().has_hidl_handle_address()) {
- arg0 = *(reinterpret_cast<android::hardware::hidl_handle*>(func_msg.arg(0).handle_value().hidl_handle_address()));
- } else {
- native_handle_t* handle = native_handle_create(func_msg.arg(0).handle_value().num_fds(), func_msg.arg(0).handle_value().num_ints());
- if (!handle) {
- LOG(ERROR) << "Failed to create handle. ";
- exit(-1);
- }
- for (int fd_index = 0; fd_index < func_msg.arg(0).handle_value().num_fds() + func_msg.arg(0).handle_value().num_ints(); fd_index++) {
- if (fd_index < func_msg.arg(0).handle_value().num_fds()) {
- FdMessage fd_val = func_msg.arg(0).handle_value().fd_val(fd_index);
- string file_name = fd_val.file_name();
- switch (fd_val.type()) {
- case FdType::FILE_TYPE:
- {
- size_t pre = 0; size_t pos = 0;
- string dir;
- struct stat st;
- while((pos=file_name.find_first_of('/', pre)) != string::npos){
- dir = file_name.substr(0, pos++);
- pre = pos;
- if(dir.size() == 0) continue; // ignore leading /
- if (stat(dir.c_str(), &st) == -1) {
- LOG(INFO) << " Creating dir: " << dir;
- mkdir(dir.c_str(), 0700);
- }
- }
- int fd = open(file_name.c_str(), fd_val.flags() | O_CREAT, fd_val.mode());
- if (fd == -1) {
- LOG(ERROR) << "Failed to open file: " << file_name << " error: " << errno;
- exit (-1);
- }
- handle->data[fd_index] = fd;
- break;
- }
- case FdType::DIR_TYPE:
- {
- struct stat st;
- if (!stat(file_name.c_str(), &st)) {
- mkdir(file_name.c_str(), fd_val.mode());
- }
- handle->data[fd_index] = open(file_name.c_str(), O_DIRECTORY, fd_val.mode());
- break;
- }
- case FdType::DEV_TYPE:
- {
- if(file_name == "/dev/ashmem") {
- handle->data[fd_index] = ashmem_create_region("SharedMemory", fd_val.memory().size());
- }
- break;
- }
- case FdType::PIPE_TYPE:
- case FdType::SOCKET_TYPE:
- case FdType::LINK_TYPE:
- {
- LOG(ERROR) << "Not supported yet. ";
- break;
- }
- }
- } else {
- handle->data[fd_index] = func_msg.arg(0).handle_value().int_val(fd_index -func_msg.arg(0).handle_value().num_fds());
- }
- }
- arg0 = handle;
- }
- } else {
- arg0 = nullptr;
- }
- ::android::hardware::tests::foo::V1_0::Abc arg1;
- MessageTo__android__hardware__tests__foo__V1_0__Abc(func_msg.arg(1), &(arg1), callback_socket_name);
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->expectNullHandle(arg0, arg1, [&](bool arg0 __attribute__((__unused__)),bool arg1 __attribute__((__unused__))){
- LOG(INFO) << "callback expectNullHandle called";
- result_msg->set_name("expectNullHandle");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_SCALAR);
- result_val_0->set_scalar_type("bool_t");
- result_val_0->mutable_scalar_value()->set_bool_t(arg0);
- VariableSpecificationMessage* result_val_1 = result_msg->add_return_type_hidl();
- result_val_1->set_type(TYPE_SCALAR);
- result_val_1->set_scalar_type("bool_t");
- result_val_1->mutable_scalar_value()->set_bool_t(arg1);
- });
- return true;
- }
- if (!strcmp(func_name, "takeAMask")) {
- ::android::hardware::tests::foo::V1_0::IFoo::BitField arg0;
- MessageTo__android__hardware__tests__foo__V1_0__IFoo__BitField(func_msg.arg(0), &(arg0), callback_socket_name);
- uint8_t arg1;
- arg1 = func_msg.arg(1).scalar_value().uint8_t();
- ::android::hardware::tests::foo::V1_0::IFoo::MyMask arg2;
- MessageTo__android__hardware__tests__foo__V1_0__IFoo__MyMask(func_msg.arg(2), &(arg2), callback_socket_name);
- uint8_t arg3;
- arg3 = func_msg.arg(3).scalar_value().uint8_t();
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->takeAMask(arg0, arg1, arg2, arg3, [&](::android::hardware::tests::foo::V1_0::IFoo::BitField arg0 __attribute__((__unused__)),uint8_t arg1 __attribute__((__unused__)),uint8_t arg2 __attribute__((__unused__)),uint8_t arg3 __attribute__((__unused__))){
- LOG(INFO) << "callback takeAMask called";
- result_msg->set_name("takeAMask");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_ENUM);
- SetResult__android__hardware__tests__foo__V1_0__IFoo__BitField(result_val_0, arg0);
- VariableSpecificationMessage* result_val_1 = result_msg->add_return_type_hidl();
- result_val_1->set_type(TYPE_SCALAR);
- result_val_1->set_scalar_type("uint8_t");
- result_val_1->mutable_scalar_value()->set_uint8_t(arg1);
- VariableSpecificationMessage* result_val_2 = result_msg->add_return_type_hidl();
- result_val_2->set_type(TYPE_SCALAR);
- result_val_2->set_scalar_type("uint8_t");
- result_val_2->mutable_scalar_value()->set_uint8_t(arg2);
- VariableSpecificationMessage* result_val_3 = result_msg->add_return_type_hidl();
- result_val_3->set_type(TYPE_SCALAR);
- result_val_3->set_scalar_type("uint8_t");
- result_val_3->mutable_scalar_value()->set_uint8_t(arg3);
- });
- return true;
- }
- if (!strcmp(func_name, "haveAInterface")) {
- sp<::android::hardware::tests::foo::V1_0::ISimple> arg0;
- if (func_msg.arg(0).has_hidl_interface_pointer()) {
- arg0 = reinterpret_cast<::android::hardware::tests::foo::V1_0::ISimple*>(func_msg.arg(0).hidl_interface_pointer());
- } else {
- arg0 = VtsFuzzerCreateVts_android_hardware_tests_foo_V1_0_ISimple(callback_socket_name);
- }
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- sp<::android::hardware::tests::foo::V1_0::ISimple> result0 = hw_binder_proxy_->haveAInterface(arg0);
- result_msg->set_name("haveAInterface");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_HIDL_INTERFACE);
- result_val_0->set_predefined_type("::android::hardware::tests::foo::V1_0::ISimple");
- if (result0 != nullptr) {
- result0->incStrong(result0.get());
- result_val_0->set_hidl_interface_pointer(reinterpret_cast<uintptr_t>(result0.get()));
- } else {
- result_val_0->set_hidl_interface_pointer(0);
- }
- return true;
- }
- if (!strcmp(func_name, "notifySyspropsChanged")) {
- LOG(INFO) << "Call notifySyspropsChanged";
- hw_binder_proxy_->notifySyspropsChanged();
- result_msg->set_name("notifySyspropsChanged");
- return true;
- }
- return false;
-}
-
-bool FuzzerExtended_android_hardware_tests_bar_V1_0_IBar::VerifyResults(const FunctionSpecificationMessage& expected_result __attribute__((__unused__)),
- const FunctionSpecificationMessage& actual_result __attribute__((__unused__))) {
- if (!strcmp(actual_result.name().c_str(), "convertToBoolIfSmall")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).vector_value_size() != expected_result.return_type_hidl(0).vector_value_size()) {
- LOG(ERROR) << "Verification failed for vector size. expected: " << expected_result.return_type_hidl(0).vector_value_size() << " actual: " << actual_result.return_type_hidl(0).vector_value_size();
- return false;
- }
- for (int i = 0; i <expected_result.return_type_hidl(0).vector_value_size(); i++) {
- if (!Verify__android__hardware__tests__foo__V1_0__IFoo__ContainsUnion(expected_result.return_type_hidl(0).vector_value(i), actual_result.return_type_hidl(0).vector_value(i))) { return false; }
- }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "doThis")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "doThatAndReturnSomething")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).scalar_value().int32_t() != expected_result.return_type_hidl(0).scalar_value().int32_t()) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "doQuiteABit")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).scalar_value().double_t() != expected_result.return_type_hidl(0).scalar_value().double_t()) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "doSomethingElse")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).vector_value_size() != expected_result.return_type_hidl(0).vector_value_size()) {
- LOG(ERROR) << "Verification failed for vector size. expected: " << expected_result.return_type_hidl(0).vector_value_size() << " actual: " << actual_result.return_type_hidl(0).vector_value_size();
- return false;
- }
- for (int i = 0; i < expected_result.return_type_hidl(0).vector_value_size(); i++) {
- if (actual_result.return_type_hidl(0).vector_value(i).scalar_value().int32_t() != expected_result.return_type_hidl(0).vector_value(i).scalar_value().int32_t()) { return false; }
- }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "doStuffAndReturnAString")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (strcmp(actual_result.return_type_hidl(0).string_value().message().c_str(), expected_result.return_type_hidl(0).string_value().message().c_str())!= 0){ return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "mapThisVector")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).vector_value_size() != expected_result.return_type_hidl(0).vector_value_size()) {
- LOG(ERROR) << "Verification failed for vector size. expected: " << expected_result.return_type_hidl(0).vector_value_size() << " actual: " << actual_result.return_type_hidl(0).vector_value_size();
- return false;
- }
- for (int i = 0; i <expected_result.return_type_hidl(0).vector_value_size(); i++) {
- if (actual_result.return_type_hidl(0).vector_value(i).scalar_value().int32_t() != expected_result.return_type_hidl(0).vector_value(i).scalar_value().int32_t()) { return false; }
- }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "callMe")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "useAnEnum")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if(!Verify__android__hardware__tests__foo__V1_0__IFoo__SomeEnum(expected_result.return_type_hidl(0), actual_result.return_type_hidl(0))) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "haveAGooberVec")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "haveAGoober")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "haveAGooberArray")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "haveATypeFromAnotherFile")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "haveSomeStrings")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).vector_value_size() != expected_result.return_type_hidl(0).vector_value_size()) {
- LOG(ERROR) << "Verification failed for vector size. expected: " << expected_result.return_type_hidl(0).vector_value_size() << " actual: " << actual_result.return_type_hidl(0).vector_value_size();
- return false;
- }
- for (int i = 0; i < expected_result.return_type_hidl(0).vector_value_size(); i++) {
- if (strcmp(actual_result.return_type_hidl(0).vector_value(i).string_value().message().c_str(), expected_result.return_type_hidl(0).vector_value(i).string_value().message().c_str())!= 0){ return false; }
- }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "haveAStringVec")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).vector_value_size() != expected_result.return_type_hidl(0).vector_value_size()) {
- LOG(ERROR) << "Verification failed for vector size. expected: " << expected_result.return_type_hidl(0).vector_value_size() << " actual: " << actual_result.return_type_hidl(0).vector_value_size();
- return false;
- }
- for (int i = 0; i <expected_result.return_type_hidl(0).vector_value_size(); i++) {
- if (strcmp(actual_result.return_type_hidl(0).vector_value(i).string_value().message().c_str(), expected_result.return_type_hidl(0).vector_value(i).string_value().message().c_str())!= 0){ return false; }
- }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "transposeMe")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).vector_value_size() != expected_result.return_type_hidl(0).vector_value_size()) {
- LOG(ERROR) << "Verification failed for vector size. expected: " << expected_result.return_type_hidl(0).vector_value_size() << " actual: " << actual_result.return_type_hidl(0).vector_value_size();
- return false;
- }
- for (int i = 0; i < expected_result.return_type_hidl(0).vector_value_size(); i++) {
- if (actual_result.return_type_hidl(0).vector_value(i).vector_value_size() != expected_result.return_type_hidl(0).vector_value(i).vector_value_size()) {
- LOG(ERROR) << "Verification failed for vector size. expected: " << expected_result.return_type_hidl(0).vector_value(i).vector_value_size() << " actual: " << actual_result.return_type_hidl(0).vector_value(i).vector_value_size();
- return false;
- }
- for (int i = 0; i < expected_result.return_type_hidl(0).vector_value(i).vector_value_size(); i++) {
- if (actual_result.return_type_hidl(0).vector_value(i).vector_value(i).scalar_value().float_t() != expected_result.return_type_hidl(0).vector_value(i).vector_value(i).scalar_value().float_t()) { return false; }
- }
- }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "callingDrWho")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (!Verify__android__hardware__tests__foo__V1_0__IFoo__MultiDimensional(expected_result.return_type_hidl(0), actual_result.return_type_hidl(0))) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "transpose")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (!Verify__android__hardware__tests__foo__V1_0__IFoo__StringMatrix3x5(expected_result.return_type_hidl(0), actual_result.return_type_hidl(0))) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "transpose2")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).vector_value_size() != expected_result.return_type_hidl(0).vector_value_size()) {
- LOG(ERROR) << "Verification failed for vector size. expected: " << expected_result.return_type_hidl(0).vector_value_size() << " actual: " << actual_result.return_type_hidl(0).vector_value_size();
- return false;
- }
- for (int i = 0; i < expected_result.return_type_hidl(0).vector_value_size(); i++) {
- if (actual_result.return_type_hidl(0).vector_value(i).vector_value_size() != expected_result.return_type_hidl(0).vector_value(i).vector_value_size()) {
- LOG(ERROR) << "Verification failed for vector size. expected: " << expected_result.return_type_hidl(0).vector_value(i).vector_value_size() << " actual: " << actual_result.return_type_hidl(0).vector_value(i).vector_value_size();
- return false;
- }
- for (int i = 0; i < expected_result.return_type_hidl(0).vector_value(i).vector_value_size(); i++) {
- if (strcmp(actual_result.return_type_hidl(0).vector_value(i).vector_value(i).string_value().message().c_str(), expected_result.return_type_hidl(0).vector_value(i).vector_value(i).string_value().message().c_str())!= 0){ return false; }
- }
- }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "sendVec")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).vector_value_size() != expected_result.return_type_hidl(0).vector_value_size()) {
- LOG(ERROR) << "Verification failed for vector size. expected: " << expected_result.return_type_hidl(0).vector_value_size() << " actual: " << actual_result.return_type_hidl(0).vector_value_size();
- return false;
- }
- for (int i = 0; i <expected_result.return_type_hidl(0).vector_value_size(); i++) {
- if (actual_result.return_type_hidl(0).vector_value(i).scalar_value().uint8_t() != expected_result.return_type_hidl(0).vector_value(i).scalar_value().uint8_t()) { return false; }
- }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "sendVecVec")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).vector_value_size() != expected_result.return_type_hidl(0).vector_value_size()) {
- LOG(ERROR) << "Verification failed for vector size. expected: " << expected_result.return_type_hidl(0).vector_value_size() << " actual: " << actual_result.return_type_hidl(0).vector_value_size();
- return false;
- }
- for (int i = 0; i <expected_result.return_type_hidl(0).vector_value_size(); i++) {
- if (actual_result.return_type_hidl(0).vector_value(i).vector_value_size() != expected_result.return_type_hidl(0).vector_value(i).vector_value_size()) {
- LOG(ERROR) << "Verification failed for vector size. expected: " << expected_result.return_type_hidl(0).vector_value(i).vector_value_size() << " actual: " << actual_result.return_type_hidl(0).vector_value(i).vector_value_size();
- return false;
- }
- for (int i = 0; i <expected_result.return_type_hidl(0).vector_value(i).vector_value_size(); i++) {
- if (actual_result.return_type_hidl(0).vector_value(i).vector_value(i).scalar_value().uint8_t() != expected_result.return_type_hidl(0).vector_value(i).vector_value(i).scalar_value().uint8_t()) { return false; }
- }
- }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "haveAVectorOfInterfaces")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).vector_value_size() != expected_result.return_type_hidl(0).vector_value_size()) {
- LOG(ERROR) << "Verification failed for vector size. expected: " << expected_result.return_type_hidl(0).vector_value_size() << " actual: " << actual_result.return_type_hidl(0).vector_value_size();
- return false;
- }
- for (int i = 0; i <expected_result.return_type_hidl(0).vector_value_size(); i++) {
- LOG(ERROR) << "TYPE_HIDL_INTERFACE is not supported yet. ";
- }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "haveAVectorOfGenericInterfaces")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).vector_value_size() != expected_result.return_type_hidl(0).vector_value_size()) {
- LOG(ERROR) << "Verification failed for vector size. expected: " << expected_result.return_type_hidl(0).vector_value_size() << " actual: " << actual_result.return_type_hidl(0).vector_value_size();
- return false;
- }
- for (int i = 0; i <expected_result.return_type_hidl(0).vector_value_size(); i++) {
- LOG(ERROR) << "TYPE_HIDL_INTERFACE is not supported yet. ";
- }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "echoNullInterface")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).scalar_value().bool_t() != expected_result.return_type_hidl(0).scalar_value().bool_t()) { return false; }
- LOG(ERROR) << "TYPE_HILD_CALLBACK is not supported yet. ";
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "createMyHandle")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (!Verify__android__hardware__tests__foo__V1_0__IFoo__MyHandle(expected_result.return_type_hidl(0), actual_result.return_type_hidl(0))) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "createHandles")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).vector_value_size() != expected_result.return_type_hidl(0).vector_value_size()) {
- LOG(ERROR) << "Verification failed for vector size. expected: " << expected_result.return_type_hidl(0).vector_value_size() << " actual: " << actual_result.return_type_hidl(0).vector_value_size();
- return false;
- }
- for (int i = 0; i <expected_result.return_type_hidl(0).vector_value_size(); i++) {
- LOG(ERROR) << "TYPE_HANDLE is not supported yet. ";
- }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "closeHandles")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "repeatWithFmq")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (!Verify__android__hardware__tests__foo__V1_0__IFoo__WithFmq(expected_result.return_type_hidl(0), actual_result.return_type_hidl(0))) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "thisIsNew")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "expectNullHandle")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).scalar_value().bool_t() != expected_result.return_type_hidl(0).scalar_value().bool_t()) { return false; }
- if (actual_result.return_type_hidl(1).scalar_value().bool_t() != expected_result.return_type_hidl(1).scalar_value().bool_t()) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "takeAMask")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if(!Verify__android__hardware__tests__foo__V1_0__IFoo__BitField(expected_result.return_type_hidl(0), actual_result.return_type_hidl(0))) { return false; }
- if (actual_result.return_type_hidl(1).scalar_value().uint8_t() != expected_result.return_type_hidl(1).scalar_value().uint8_t()) { return false; }
- if (actual_result.return_type_hidl(2).scalar_value().uint8_t() != expected_result.return_type_hidl(2).scalar_value().uint8_t()) { return false; }
- if (actual_result.return_type_hidl(3).scalar_value().uint8_t() != expected_result.return_type_hidl(3).scalar_value().uint8_t()) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "haveAInterface")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- LOG(ERROR) << "TYPE_HIDL_INTERFACE is not supported yet. ";
- return true;
- }
- return false;
-}
-
-extern "C" {
-android::vts::DriverBase* vts_func_4_android_hardware_tests_bar_V1_0_IBar_() {
- return (android::vts::DriverBase*) new android::vts::FuzzerExtended_android_hardware_tests_bar_V1_0_IBar();
-}
-
-android::vts::DriverBase* vts_func_4_android_hardware_tests_bar_V1_0_IBar_with_arg(uint64_t hw_binder_proxy) {
- ::android::hardware::tests::bar::V1_0::IBar* arg = nullptr;
- if (hw_binder_proxy) {
- arg = reinterpret_cast<::android::hardware::tests::bar::V1_0::IBar*>(hw_binder_proxy);
- } else {
- LOG(INFO) << " Creating DriverBase with null proxy.";
- }
- android::vts::DriverBase* result =
- new android::vts::FuzzerExtended_android_hardware_tests_bar_V1_0_IBar(
- arg);
- if (arg != nullptr) {
- arg->decStrong(arg);
- }
- return result;
-}
-
-}
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/test/golden/DRIVER/Bar.vts.h b/compilation_tools/vtsc/test/golden/DRIVER/Bar.vts.h
deleted file mode 100644
index b9870c2..0000000
--- a/compilation_tools/vtsc/test/golden/DRIVER/Bar.vts.h
+++ /dev/null
@@ -1,186 +0,0 @@
-#ifndef __VTS_DRIVER__android_hardware_tests_bar_V1_0_IBar__
-#define __VTS_DRIVER__android_hardware_tests_bar_V1_0_IBar__
-
-#undef LOG_TAG
-#define LOG_TAG "FuzzerExtended_android_hardware_tests_bar_V1_0_IBar"
-
-#include <log/log.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <driver_base/DriverBase.h>
-#include <driver_base/DriverCallbackBase.h>
-
-#include <VtsDriverCommUtil.h>
-
-#include <android/hardware/tests/bar/1.0/IBar.h>
-#include <hidl/HidlSupport.h>
-#include <android/hardware/tests/foo/1.0/IFoo.h>
-#include <android/hardware/tests/foo/1.0/Foo.vts.h>
-#include <android/hardware/tests/foo/1.0/IFooCallback.h>
-#include <android/hardware/tests/foo/1.0/FooCallback.vts.h>
-#include <android/hardware/tests/foo/1.0/IMyTypes.h>
-#include <android/hardware/tests/foo/1.0/MyTypes.vts.h>
-#include <android/hardware/tests/foo/1.0/ISimple.h>
-#include <android/hardware/tests/foo/1.0/Simple.vts.h>
-#include <android/hardware/tests/foo/1.0/ITheirTypes.h>
-#include <android/hardware/tests/foo/1.0/TheirTypes.vts.h>
-#include <android/hardware/tests/foo/1.0/types.h>
-#include <android/hardware/tests/foo/1.0/types.vts.h>
-#include <android/hidl/base/1.0/types.h>
-
-
-using namespace android::hardware::tests::bar::V1_0;
-namespace android {
-namespace vts {
-extern "C" void MessageTo__android__hardware__tests__bar__V1_0__IBar__SomethingRelated(const VariableSpecificationMessage& var_msg, ::android::hardware::tests::bar::V1_0::IBar::SomethingRelated* arg, const string& callback_socket_name);
-bool Verify__android__hardware__tests__bar__V1_0__IBar__SomethingRelated(const VariableSpecificationMessage& expected_result, const VariableSpecificationMessage& actual_result);
-extern "C" void SetResult__android__hardware__tests__bar__V1_0__IBar__SomethingRelated(VariableSpecificationMessage* result_msg, ::android::hardware::tests::bar::V1_0::IBar::SomethingRelated result_value);
-
-class Vts_android_hardware_tests_bar_V1_0_IBar : public ::android::hardware::tests::bar::V1_0::IBar, public DriverCallbackBase {
- public:
- Vts_android_hardware_tests_bar_V1_0_IBar(const string& callback_socket_name)
- : callback_socket_name_(callback_socket_name) {};
-
- virtual ~Vts_android_hardware_tests_bar_V1_0_IBar() = default;
-
- ::android::hardware::Return<void> convertToBoolIfSmall(
- ::android::hardware::tests::foo::V1_0::IFoo::Discriminator arg0,
- const ::android::hardware::hidl_vec<::android::hardware::tests::foo::V1_0::IFoo::Union>& arg1, std::function<void(const ::android::hardware::hidl_vec<::android::hardware::tests::foo::V1_0::IFoo::ContainsUnion>& arg0)> cb) override;
-
- ::android::hardware::Return<void> doThis(
- float arg0) override;
-
- ::android::hardware::Return<int32_t> doThatAndReturnSomething(
- int64_t arg0) override;
-
- ::android::hardware::Return<double> doQuiteABit(
- int32_t arg0,
- int64_t arg1,
- float arg2,
- double arg3) override;
-
- ::android::hardware::Return<void> doSomethingElse(
- const ::android::hardware::hidl_array<int32_t, 15>& arg0, std::function<void(const ::android::hardware::hidl_array<int32_t, 32>& arg0)> cb) override;
-
- ::android::hardware::Return<void> doStuffAndReturnAString(
- std::function<void(const ::android::hardware::hidl_string& arg0)> cb) override;
-
- ::android::hardware::Return<void> mapThisVector(
- const ::android::hardware::hidl_vec<int32_t>& arg0, std::function<void(const ::android::hardware::hidl_vec<int32_t>& arg0)> cb) override;
-
- ::android::hardware::Return<void> callMe(
- const sp<::android::hardware::tests::foo::V1_0::IFooCallback>& arg0) override;
-
- ::android::hardware::Return<::android::hardware::tests::foo::V1_0::IFoo::SomeEnum> useAnEnum(
- ::android::hardware::tests::foo::V1_0::IFoo::SomeEnum arg0) override;
-
- ::android::hardware::Return<void> haveAGooberVec(
- const ::android::hardware::hidl_vec<::android::hardware::tests::foo::V1_0::IFoo::Goober>& arg0) override;
-
- ::android::hardware::Return<void> haveAGoober(
- const ::android::hardware::tests::foo::V1_0::IFoo::Goober& arg0) override;
-
- ::android::hardware::Return<void> haveAGooberArray(
- const ::android::hardware::hidl_array<::android::hardware::tests::foo::V1_0::IFoo::Goober, 20>& arg0) override;
-
- ::android::hardware::Return<void> haveATypeFromAnotherFile(
- const ::android::hardware::tests::foo::V1_0::Abc& arg0) override;
-
- ::android::hardware::Return<void> haveSomeStrings(
- const ::android::hardware::hidl_array<::android::hardware::hidl_string, 3>& arg0, std::function<void(const ::android::hardware::hidl_array<::android::hardware::hidl_string, 2>& arg0)> cb) override;
-
- ::android::hardware::Return<void> haveAStringVec(
- const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& arg0, std::function<void(const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& arg0)> cb) override;
-
- ::android::hardware::Return<void> transposeMe(
- const ::android::hardware::hidl_array<float, 3, 5>& arg0, std::function<void(const ::android::hardware::hidl_array<float, 5, 3>& arg0)> cb) override;
-
- ::android::hardware::Return<void> callingDrWho(
- const ::android::hardware::tests::foo::V1_0::IFoo::MultiDimensional& arg0, std::function<void(const ::android::hardware::tests::foo::V1_0::IFoo::MultiDimensional& arg0)> cb) override;
-
- ::android::hardware::Return<void> transpose(
- const ::android::hardware::tests::foo::V1_0::IFoo::StringMatrix5x3& arg0, std::function<void(const ::android::hardware::tests::foo::V1_0::IFoo::StringMatrix3x5& arg0)> cb) override;
-
- ::android::hardware::Return<void> transpose2(
- const ::android::hardware::hidl_array<::android::hardware::hidl_string, 5, 3>& arg0, std::function<void(const ::android::hardware::hidl_array<::android::hardware::hidl_string, 3, 5>& arg0)> cb) override;
-
- ::android::hardware::Return<void> sendVec(
- const ::android::hardware::hidl_vec<uint8_t>& arg0, std::function<void(const ::android::hardware::hidl_vec<uint8_t>& arg0)> cb) override;
-
- ::android::hardware::Return<void> sendVecVec(
- std::function<void(const ::android::hardware::hidl_vec<::android::hardware::hidl_vec<uint8_t>>& arg0)> cb) override;
-
- ::android::hardware::Return<void> haveAVectorOfInterfaces(
- const ::android::hardware::hidl_vec<sp<::android::hardware::tests::foo::V1_0::ISimple>>& arg0, std::function<void(const ::android::hardware::hidl_vec<sp<::android::hardware::tests::foo::V1_0::ISimple>>& arg0)> cb) override;
-
- ::android::hardware::Return<void> haveAVectorOfGenericInterfaces(
- const ::android::hardware::hidl_vec<sp<::android::hidl::base::V1_0::IBase>>& arg0, std::function<void(const ::android::hardware::hidl_vec<sp<::android::hidl::base::V1_0::IBase>>& arg0)> cb) override;
-
- ::android::hardware::Return<void> echoNullInterface(
- const sp<::android::hardware::tests::foo::V1_0::IFooCallback>& arg0, std::function<void(bool arg0,const sp<::android::hardware::tests::foo::V1_0::IFooCallback>& arg1)> cb) override;
-
- ::android::hardware::Return<void> createMyHandle(
- std::function<void(const ::android::hardware::tests::foo::V1_0::IFoo::MyHandle& arg0)> cb) override;
-
- ::android::hardware::Return<void> createHandles(
- uint32_t arg0, std::function<void(const ::android::hardware::hidl_vec<::android::hardware::hidl_handle>& arg0)> cb) override;
-
- ::android::hardware::Return<void> closeHandles(
- ) override;
-
- ::android::hardware::Return<void> repeatWithFmq(
- const ::android::hardware::tests::foo::V1_0::IFoo::WithFmq& arg0, std::function<void(const ::android::hardware::tests::foo::V1_0::IFoo::WithFmq& arg0)> cb) override;
-
- ::android::hardware::Return<void> thisIsNew(
- ) override;
-
- ::android::hardware::Return<void> expectNullHandle(
- const ::android::hardware::hidl_handle& arg0,
- const ::android::hardware::tests::foo::V1_0::Abc& arg1, std::function<void(bool arg0,bool arg1)> cb) override;
-
- ::android::hardware::Return<void> takeAMask(
- ::android::hardware::tests::foo::V1_0::IFoo::BitField arg0,
- uint8_t arg1,
- const ::android::hardware::tests::foo::V1_0::IFoo::MyMask& arg2,
- uint8_t arg3, std::function<void(::android::hardware::tests::foo::V1_0::IFoo::BitField arg0,uint8_t arg1,uint8_t arg2,uint8_t arg3)> cb) override;
-
- ::android::hardware::Return<sp<::android::hardware::tests::foo::V1_0::ISimple>> haveAInterface(
- const sp<::android::hardware::tests::foo::V1_0::ISimple>& arg0) override;
-
-
- private:
- string callback_socket_name_;
-};
-
-sp<::android::hardware::tests::bar::V1_0::IBar> VtsFuzzerCreateVts_android_hardware_tests_bar_V1_0_IBar(const string& callback_socket_name);
-
-class FuzzerExtended_android_hardware_tests_bar_V1_0_IBar : public DriverBase {
- public:
- FuzzerExtended_android_hardware_tests_bar_V1_0_IBar() : DriverBase(HAL_HIDL), hw_binder_proxy_() {}
-
- explicit FuzzerExtended_android_hardware_tests_bar_V1_0_IBar(::android::hardware::tests::bar::V1_0::IBar* hw_binder_proxy) : DriverBase(HAL_HIDL), hw_binder_proxy_(hw_binder_proxy) {}
- uint64_t GetHidlInterfaceProxy() const {
- return reinterpret_cast<uintptr_t>(hw_binder_proxy_.get());
- }
- protected:
- bool Fuzz(FunctionSpecificationMessage* func_msg, void** result, const string& callback_socket_name);
- bool CallFunction(const FunctionSpecificationMessage& func_msg, const string& callback_socket_name, FunctionSpecificationMessage* result_msg);
- bool VerifyResults(const FunctionSpecificationMessage& expected_result, const FunctionSpecificationMessage& actual_result);
- bool GetAttribute(FunctionSpecificationMessage* func_msg, void** result);
- bool GetService(bool get_stub, const char* service_name);
-
- private:
- sp<::android::hardware::tests::bar::V1_0::IBar> hw_binder_proxy_;
-};
-
-
-extern "C" {
-extern android::vts::DriverBase* vts_func_4_android_hardware_tests_bar_V1_0_IBar_();
-extern android::vts::DriverBase* vts_func_4_android_hardware_tests_bar_V1_0_IBar_with_arg(uint64_t hw_binder_proxy);
-}
-} // namespace vts
-} // namespace android
-#endif
diff --git a/compilation_tools/vtsc/test/golden/DRIVER/MemoryTest.driver.cpp b/compilation_tools/vtsc/test/golden/DRIVER/MemoryTest.driver.cpp
deleted file mode 100644
index 0221930..0000000
--- a/compilation_tools/vtsc/test/golden/DRIVER/MemoryTest.driver.cpp
+++ /dev/null
@@ -1,295 +0,0 @@
-#include "android/hardware/tests/memory/1.0/MemoryTest.vts.h"
-#include "vts_measurement.h"
-#include <android-base/logging.h>
-#include <android/hidl/allocator/1.0/IAllocator.h>
-#include <fcntl.h>
-#include <fmq/MessageQueue.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-
-using namespace android::hardware::tests::memory::V1_0;
-namespace android {
-namespace vts {
-bool FuzzerExtended_android_hardware_tests_memory_V1_0_IMemoryTest::GetService(bool get_stub, const char* service_name) {
- static bool initialized = false;
- if (!initialized) {
- LOG(INFO) << "HIDL getService";
- if (service_name) {
- LOG(INFO) << " - service name: " << service_name;
- }
- hw_binder_proxy_ = ::android::hardware::tests::memory::V1_0::IMemoryTest::getService(service_name, get_stub);
- if (hw_binder_proxy_ == nullptr) {
- LOG(ERROR) << "getService() returned a null pointer.";
- return false;
- }
- LOG(DEBUG) << "hw_binder_proxy_ = " << hw_binder_proxy_.get();
- initialized = true;
- }
- return true;
-}
-
-
-::android::hardware::Return<void> Vts_android_hardware_tests_memory_V1_0_IMemoryTest::haveSomeMemory(
- const ::android::hardware::hidl_memory& arg0 __attribute__((__unused__)), std::function<void(const ::android::hardware::hidl_memory& arg0)> cb) {
- LOG(INFO) << "haveSomeMemory called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("haveSomeMemory"));
- callback_message.set_name("Vts_android_hardware_tests_memory_V1_0_IMemoryTest::haveSomeMemory");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_HIDL_MEMORY);
- var_msg0->mutable_hidl_memory_value()->set_hidl_mem_address(reinterpret_cast<size_t>(new android::hardware::hidl_memory(arg0)));
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(::android::hardware::hidl_memory());
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_memory_V1_0_IMemoryTest::fillMemory(
- const ::android::hardware::hidl_memory& arg0 __attribute__((__unused__)),
- uint8_t arg1 __attribute__((__unused__))) {
- LOG(INFO) << "fillMemory called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("fillMemory"));
- callback_message.set_name("Vts_android_hardware_tests_memory_V1_0_IMemoryTest::fillMemory");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_HIDL_MEMORY);
- var_msg0->mutable_hidl_memory_value()->set_hidl_mem_address(reinterpret_cast<size_t>(new android::hardware::hidl_memory(arg0)));
- VariableSpecificationMessage* var_msg1 = callback_message.add_arg();
- var_msg1->set_type(TYPE_SCALAR);
- var_msg1->set_scalar_type("uint8_t");
- var_msg1->mutable_scalar_value()->set_uint8_t(arg1);
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_memory_V1_0_IMemoryTest::haveSomeMemoryBlock(
- const ::android::hidl::memory::block::V1_0::MemoryBlock& arg0 __attribute__((__unused__)), std::function<void(const ::android::hidl::memory::block::V1_0::MemoryBlock& arg0)> cb) {
- LOG(INFO) << "haveSomeMemoryBlock called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("haveSomeMemoryBlock"));
- callback_message.set_name("Vts_android_hardware_tests_memory_V1_0_IMemoryTest::haveSomeMemoryBlock");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_STRUCT);
- SetResult__android__hidl__memory__block__V1_0__MemoryBlock(var_msg0, arg0);
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(::android::hidl::memory::block::V1_0::MemoryBlock());
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_memory_V1_0_IMemoryTest::set(
- const ::android::hardware::hidl_memory& arg0 __attribute__((__unused__))) {
- LOG(INFO) << "set called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("set"));
- callback_message.set_name("Vts_android_hardware_tests_memory_V1_0_IMemoryTest::set");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_HIDL_MEMORY);
- var_msg0->mutable_hidl_memory_value()->set_hidl_mem_address(reinterpret_cast<size_t>(new android::hardware::hidl_memory(arg0)));
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<sp<::android::hidl::memory::token::V1_0::IMemoryToken>> Vts_android_hardware_tests_memory_V1_0_IMemoryTest::get(
- ) {
- LOG(INFO) << "get called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("get"));
- callback_message.set_name("Vts_android_hardware_tests_memory_V1_0_IMemoryTest::get");
- RpcCallToAgent(callback_message, callback_socket_name_);
- return nullptr;
-}
-
-sp<::android::hardware::tests::memory::V1_0::IMemoryTest> VtsFuzzerCreateVts_android_hardware_tests_memory_V1_0_IMemoryTest(const string& callback_socket_name) {
- static sp<::android::hardware::tests::memory::V1_0::IMemoryTest> result;
- result = new Vts_android_hardware_tests_memory_V1_0_IMemoryTest(callback_socket_name);
- return result;
-}
-
-bool FuzzerExtended_android_hardware_tests_memory_V1_0_IMemoryTest::Fuzz(
- FunctionSpecificationMessage* /*func_msg*/,
- void** /*result*/, const string& /*callback_socket_name*/) {
- return true;
-}
-bool FuzzerExtended_android_hardware_tests_memory_V1_0_IMemoryTest::GetAttribute(
- FunctionSpecificationMessage* /*func_msg*/,
- void** /*result*/) {
- LOG(ERROR) << "attribute not found.";
- return false;
-}
-bool FuzzerExtended_android_hardware_tests_memory_V1_0_IMemoryTest::CallFunction(
- const FunctionSpecificationMessage& func_msg,
- const string& callback_socket_name __attribute__((__unused__)),
- FunctionSpecificationMessage* result_msg) {
- const char* func_name = func_msg.name().c_str();
- if (hw_binder_proxy_ == nullptr) {
- LOG(ERROR) << "hw_binder_proxy_ is null. ";
- return false;
- }
- if (!strcmp(func_name, "haveSomeMemory")) {
- ::android::hardware::hidl_memory arg0;
- if (func_msg.arg(0).hidl_memory_value().has_hidl_mem_address()) {
- arg0 = *(reinterpret_cast<android::hardware::hidl_memory*>(func_msg.arg(0).hidl_memory_value().hidl_mem_address()));
- } else {
- sp<::android::hidl::allocator::V1_0::IAllocator> ashmemAllocator = ::android::hidl::allocator::V1_0::IAllocator::getService("ashmem");
- if (ashmemAllocator == nullptr) {
- LOG(ERROR) << "Failed to get ashmemAllocator! ";
- exit(-1);
- }
- auto res = ashmemAllocator->allocate(func_msg.arg(0).hidl_memory_value().size(), [&](bool success, const hardware::hidl_memory& memory) {
- if (!success) {
- LOG(ERROR) << "Failed to allocate memory! ";
- arg0 = ::android::hardware::hidl_memory();
- return;
- }
- arg0 = memory;
- });
- }
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->haveSomeMemory(arg0, [&](const ::android::hardware::hidl_memory& arg0 __attribute__((__unused__))){
- LOG(INFO) << "callback haveSomeMemory called";
- result_msg->set_name("haveSomeMemory");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_HIDL_MEMORY);
- result_val_0->mutable_hidl_memory_value()->set_hidl_mem_address(reinterpret_cast<size_t>(new android::hardware::hidl_memory(arg0)));
- });
- return true;
- }
- if (!strcmp(func_name, "fillMemory")) {
- ::android::hardware::hidl_memory arg0;
- if (func_msg.arg(0).hidl_memory_value().has_hidl_mem_address()) {
- arg0 = *(reinterpret_cast<android::hardware::hidl_memory*>(func_msg.arg(0).hidl_memory_value().hidl_mem_address()));
- } else {
- sp<::android::hidl::allocator::V1_0::IAllocator> ashmemAllocator = ::android::hidl::allocator::V1_0::IAllocator::getService("ashmem");
- if (ashmemAllocator == nullptr) {
- LOG(ERROR) << "Failed to get ashmemAllocator! ";
- exit(-1);
- }
- auto res = ashmemAllocator->allocate(func_msg.arg(0).hidl_memory_value().size(), [&](bool success, const hardware::hidl_memory& memory) {
- if (!success) {
- LOG(ERROR) << "Failed to allocate memory! ";
- arg0 = ::android::hardware::hidl_memory();
- return;
- }
- arg0 = memory;
- });
- }
- uint8_t arg1 = 0;
- arg1 = func_msg.arg(1).scalar_value().uint8_t();
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->fillMemory(arg0, arg1);
- result_msg->set_name("fillMemory");
- return true;
- }
- if (!strcmp(func_name, "haveSomeMemoryBlock")) {
- ::android::hidl::memory::block::V1_0::MemoryBlock arg0;
- MessageTo__android__hidl__memory__block__V1_0__MemoryBlock(func_msg.arg(0), &(arg0), callback_socket_name);
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->haveSomeMemoryBlock(arg0, [&](const ::android::hidl::memory::block::V1_0::MemoryBlock& arg0 __attribute__((__unused__))){
- LOG(INFO) << "callback haveSomeMemoryBlock called";
- result_msg->set_name("haveSomeMemoryBlock");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_STRUCT);
- SetResult__android__hidl__memory__block__V1_0__MemoryBlock(result_val_0, arg0);
- });
- return true;
- }
- if (!strcmp(func_name, "set")) {
- ::android::hardware::hidl_memory arg0;
- if (func_msg.arg(0).hidl_memory_value().has_hidl_mem_address()) {
- arg0 = *(reinterpret_cast<android::hardware::hidl_memory*>(func_msg.arg(0).hidl_memory_value().hidl_mem_address()));
- } else {
- sp<::android::hidl::allocator::V1_0::IAllocator> ashmemAllocator = ::android::hidl::allocator::V1_0::IAllocator::getService("ashmem");
- if (ashmemAllocator == nullptr) {
- LOG(ERROR) << "Failed to get ashmemAllocator! ";
- exit(-1);
- }
- auto res = ashmemAllocator->allocate(func_msg.arg(0).hidl_memory_value().size(), [&](bool success, const hardware::hidl_memory& memory) {
- if (!success) {
- LOG(ERROR) << "Failed to allocate memory! ";
- arg0 = ::android::hardware::hidl_memory();
- return;
- }
- arg0 = memory;
- });
- }
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->set(arg0);
- result_msg->set_name("set");
- return true;
- }
- if (!strcmp(func_name, "get")) {
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- sp<::android::hidl::memory::token::V1_0::IMemoryToken> result0 = hw_binder_proxy_->get();
- result_msg->set_name("get");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_HIDL_INTERFACE);
- result_val_0->set_predefined_type("::android::hidl::memory::token::V1_0::IMemoryToken");
- if (result0 != nullptr) {
- result0->incStrong(result0.get());
- result_val_0->set_hidl_interface_pointer(reinterpret_cast<uintptr_t>(result0.get()));
- } else {
- result_val_0->set_hidl_interface_pointer(0);
- }
- return true;
- }
- if (!strcmp(func_name, "notifySyspropsChanged")) {
- LOG(INFO) << "Call notifySyspropsChanged";
- hw_binder_proxy_->notifySyspropsChanged();
- result_msg->set_name("notifySyspropsChanged");
- return true;
- }
- return false;
-}
-
-bool FuzzerExtended_android_hardware_tests_memory_V1_0_IMemoryTest::VerifyResults(const FunctionSpecificationMessage& expected_result __attribute__((__unused__)),
- const FunctionSpecificationMessage& actual_result __attribute__((__unused__))) {
- if (!strcmp(actual_result.name().c_str(), "haveSomeMemory")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- LOG(ERROR) << "TYPE_HIDL_MEMORY is not supported yet. ";
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "fillMemory")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "haveSomeMemoryBlock")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (!Verify__android__hidl__memory__block__V1_0__MemoryBlock(expected_result.return_type_hidl(0), actual_result.return_type_hidl(0))) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "set")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "get")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- LOG(ERROR) << "TYPE_HIDL_INTERFACE is not supported yet. ";
- return true;
- }
- return false;
-}
-
-extern "C" {
-android::vts::DriverBase* vts_func_4_android_hardware_tests_memory_V1_0_IMemoryTest_() {
- return (android::vts::DriverBase*) new android::vts::FuzzerExtended_android_hardware_tests_memory_V1_0_IMemoryTest();
-}
-
-android::vts::DriverBase* vts_func_4_android_hardware_tests_memory_V1_0_IMemoryTest_with_arg(uint64_t hw_binder_proxy) {
- ::android::hardware::tests::memory::V1_0::IMemoryTest* arg = nullptr;
- if (hw_binder_proxy) {
- arg = reinterpret_cast<::android::hardware::tests::memory::V1_0::IMemoryTest*>(hw_binder_proxy);
- } else {
- LOG(INFO) << " Creating DriverBase with null proxy.";
- }
- android::vts::DriverBase* result =
- new android::vts::FuzzerExtended_android_hardware_tests_memory_V1_0_IMemoryTest(
- arg);
- if (arg != nullptr) {
- arg->decStrong(arg);
- }
- return result;
-}
-
-}
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/test/golden/DRIVER/MemoryTest.vts.h b/compilation_tools/vtsc/test/golden/DRIVER/MemoryTest.vts.h
deleted file mode 100644
index 6c1bfe6..0000000
--- a/compilation_tools/vtsc/test/golden/DRIVER/MemoryTest.vts.h
+++ /dev/null
@@ -1,87 +0,0 @@
-#ifndef __VTS_DRIVER__android_hardware_tests_memory_V1_0_IMemoryTest__
-#define __VTS_DRIVER__android_hardware_tests_memory_V1_0_IMemoryTest__
-
-#undef LOG_TAG
-#define LOG_TAG "FuzzerExtended_android_hardware_tests_memory_V1_0_IMemoryTest"
-
-#include <log/log.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <driver_base/DriverBase.h>
-#include <driver_base/DriverCallbackBase.h>
-
-#include <VtsDriverCommUtil.h>
-
-#include <android/hardware/tests/memory/1.0/IMemoryTest.h>
-#include <hidl/HidlSupport.h>
-#include <android/hidl/base/1.0/types.h>
-#include <android/hidl/memory/block/1.0/types.h>
-#include <android/hidl/memory/block/1.0/types.vts.h>
-#include <android/hidl/memory/token/1.0/IMemoryToken.h>
-#include <android/hidl/memory/token/1.0/MemoryToken.vts.h>
-
-
-using namespace android::hardware::tests::memory::V1_0;
-namespace android {
-namespace vts {
-
-class Vts_android_hardware_tests_memory_V1_0_IMemoryTest : public ::android::hardware::tests::memory::V1_0::IMemoryTest, public DriverCallbackBase {
- public:
- Vts_android_hardware_tests_memory_V1_0_IMemoryTest(const string& callback_socket_name)
- : callback_socket_name_(callback_socket_name) {};
-
- virtual ~Vts_android_hardware_tests_memory_V1_0_IMemoryTest() = default;
-
- ::android::hardware::Return<void> haveSomeMemory(
- const ::android::hardware::hidl_memory& arg0, std::function<void(const ::android::hardware::hidl_memory& arg0)> cb) override;
-
- ::android::hardware::Return<void> fillMemory(
- const ::android::hardware::hidl_memory& arg0,
- uint8_t arg1) override;
-
- ::android::hardware::Return<void> haveSomeMemoryBlock(
- const ::android::hidl::memory::block::V1_0::MemoryBlock& arg0, std::function<void(const ::android::hidl::memory::block::V1_0::MemoryBlock& arg0)> cb) override;
-
- ::android::hardware::Return<void> set(
- const ::android::hardware::hidl_memory& arg0) override;
-
- ::android::hardware::Return<sp<::android::hidl::memory::token::V1_0::IMemoryToken>> get(
- ) override;
-
-
- private:
- string callback_socket_name_;
-};
-
-sp<::android::hardware::tests::memory::V1_0::IMemoryTest> VtsFuzzerCreateVts_android_hardware_tests_memory_V1_0_IMemoryTest(const string& callback_socket_name);
-
-class FuzzerExtended_android_hardware_tests_memory_V1_0_IMemoryTest : public DriverBase {
- public:
- FuzzerExtended_android_hardware_tests_memory_V1_0_IMemoryTest() : DriverBase(HAL_HIDL), hw_binder_proxy_() {}
-
- explicit FuzzerExtended_android_hardware_tests_memory_V1_0_IMemoryTest(::android::hardware::tests::memory::V1_0::IMemoryTest* hw_binder_proxy) : DriverBase(HAL_HIDL), hw_binder_proxy_(hw_binder_proxy) {}
- uint64_t GetHidlInterfaceProxy() const {
- return reinterpret_cast<uintptr_t>(hw_binder_proxy_.get());
- }
- protected:
- bool Fuzz(FunctionSpecificationMessage* func_msg, void** result, const string& callback_socket_name);
- bool CallFunction(const FunctionSpecificationMessage& func_msg, const string& callback_socket_name, FunctionSpecificationMessage* result_msg);
- bool VerifyResults(const FunctionSpecificationMessage& expected_result, const FunctionSpecificationMessage& actual_result);
- bool GetAttribute(FunctionSpecificationMessage* func_msg, void** result);
- bool GetService(bool get_stub, const char* service_name);
-
- private:
- sp<::android::hardware::tests::memory::V1_0::IMemoryTest> hw_binder_proxy_;
-};
-
-
-extern "C" {
-extern android::vts::DriverBase* vts_func_4_android_hardware_tests_memory_V1_0_IMemoryTest_();
-extern android::vts::DriverBase* vts_func_4_android_hardware_tests_memory_V1_0_IMemoryTest_with_arg(uint64_t hw_binder_proxy);
-}
-} // namespace vts
-} // namespace android
-#endif
diff --git a/compilation_tools/vtsc/test/golden/DRIVER/Nfc.driver.cpp b/compilation_tools/vtsc/test/golden/DRIVER/Nfc.driver.cpp
deleted file mode 100644
index 62b1948..0000000
--- a/compilation_tools/vtsc/test/golden/DRIVER/Nfc.driver.cpp
+++ /dev/null
@@ -1,299 +0,0 @@
-#include "android/hardware/nfc/1.0/Nfc.vts.h"
-#include "vts_measurement.h"
-#include <android-base/logging.h>
-#include <android/hidl/allocator/1.0/IAllocator.h>
-#include <fcntl.h>
-#include <fmq/MessageQueue.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-
-using namespace android::hardware::nfc::V1_0;
-namespace android {
-namespace vts {
-bool FuzzerExtended_android_hardware_nfc_V1_0_INfc::GetService(bool get_stub, const char* service_name) {
- static bool initialized = false;
- if (!initialized) {
- LOG(INFO) << "HIDL getService";
- if (service_name) {
- LOG(INFO) << " - service name: " << service_name;
- }
- hw_binder_proxy_ = ::android::hardware::nfc::V1_0::INfc::getService(service_name, get_stub);
- if (hw_binder_proxy_ == nullptr) {
- LOG(ERROR) << "getService() returned a null pointer.";
- return false;
- }
- LOG(DEBUG) << "hw_binder_proxy_ = " << hw_binder_proxy_.get();
- initialized = true;
- }
- return true;
-}
-
-
-::android::hardware::Return<::android::hardware::nfc::V1_0::NfcStatus> Vts_android_hardware_nfc_V1_0_INfc::open(
- const sp<::android::hardware::nfc::V1_0::INfcClientCallback>& arg0 __attribute__((__unused__))) {
- LOG(INFO) << "open called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("open"));
- callback_message.set_name("Vts_android_hardware_nfc_V1_0_INfc::open");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_HIDL_CALLBACK);
- LOG(ERROR) << "TYPE HIDL_CALLBACK is not supported yet. ";
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::nfc::V1_0::NfcStatus();
-}
-
-::android::hardware::Return<uint32_t> Vts_android_hardware_nfc_V1_0_INfc::write(
- const ::android::hardware::hidl_vec<uint8_t>& arg0 __attribute__((__unused__))) {
- LOG(INFO) << "write called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("write"));
- callback_message.set_name("Vts_android_hardware_nfc_V1_0_INfc::write");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_VECTOR);
- var_msg0->set_vector_size(arg0.size());
- for (int i = 0; i < (int)arg0.size(); i++) {
- auto *var_msg0_vector_i = var_msg0->add_vector_value();
- var_msg0_vector_i->set_type(TYPE_SCALAR);
- var_msg0_vector_i->set_scalar_type("uint8_t");
- var_msg0_vector_i->mutable_scalar_value()->set_uint8_t(arg0[i]);
- }
- RpcCallToAgent(callback_message, callback_socket_name_);
- return static_cast<uint32_t>(0);
-}
-
-::android::hardware::Return<::android::hardware::nfc::V1_0::NfcStatus> Vts_android_hardware_nfc_V1_0_INfc::coreInitialized(
- const ::android::hardware::hidl_vec<uint8_t>& arg0 __attribute__((__unused__))) {
- LOG(INFO) << "coreInitialized called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("coreInitialized"));
- callback_message.set_name("Vts_android_hardware_nfc_V1_0_INfc::coreInitialized");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_VECTOR);
- var_msg0->set_vector_size(arg0.size());
- for (int i = 0; i < (int)arg0.size(); i++) {
- auto *var_msg0_vector_i = var_msg0->add_vector_value();
- var_msg0_vector_i->set_type(TYPE_SCALAR);
- var_msg0_vector_i->set_scalar_type("uint8_t");
- var_msg0_vector_i->mutable_scalar_value()->set_uint8_t(arg0[i]);
- }
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::nfc::V1_0::NfcStatus();
-}
-
-::android::hardware::Return<::android::hardware::nfc::V1_0::NfcStatus> Vts_android_hardware_nfc_V1_0_INfc::prediscover(
- ) {
- LOG(INFO) << "prediscover called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("prediscover"));
- callback_message.set_name("Vts_android_hardware_nfc_V1_0_INfc::prediscover");
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::nfc::V1_0::NfcStatus();
-}
-
-::android::hardware::Return<::android::hardware::nfc::V1_0::NfcStatus> Vts_android_hardware_nfc_V1_0_INfc::close(
- ) {
- LOG(INFO) << "close called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("close"));
- callback_message.set_name("Vts_android_hardware_nfc_V1_0_INfc::close");
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::nfc::V1_0::NfcStatus();
-}
-
-::android::hardware::Return<::android::hardware::nfc::V1_0::NfcStatus> Vts_android_hardware_nfc_V1_0_INfc::controlGranted(
- ) {
- LOG(INFO) << "controlGranted called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("controlGranted"));
- callback_message.set_name("Vts_android_hardware_nfc_V1_0_INfc::controlGranted");
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::nfc::V1_0::NfcStatus();
-}
-
-::android::hardware::Return<::android::hardware::nfc::V1_0::NfcStatus> Vts_android_hardware_nfc_V1_0_INfc::powerCycle(
- ) {
- LOG(INFO) << "powerCycle called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("powerCycle"));
- callback_message.set_name("Vts_android_hardware_nfc_V1_0_INfc::powerCycle");
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::nfc::V1_0::NfcStatus();
-}
-
-sp<::android::hardware::nfc::V1_0::INfc> VtsFuzzerCreateVts_android_hardware_nfc_V1_0_INfc(const string& callback_socket_name) {
- static sp<::android::hardware::nfc::V1_0::INfc> result;
- result = new Vts_android_hardware_nfc_V1_0_INfc(callback_socket_name);
- return result;
-}
-
-bool FuzzerExtended_android_hardware_nfc_V1_0_INfc::Fuzz(
- FunctionSpecificationMessage* /*func_msg*/,
- void** /*result*/, const string& /*callback_socket_name*/) {
- return true;
-}
-bool FuzzerExtended_android_hardware_nfc_V1_0_INfc::GetAttribute(
- FunctionSpecificationMessage* /*func_msg*/,
- void** /*result*/) {
- LOG(ERROR) << "attribute not found.";
- return false;
-}
-bool FuzzerExtended_android_hardware_nfc_V1_0_INfc::CallFunction(
- const FunctionSpecificationMessage& func_msg,
- const string& callback_socket_name __attribute__((__unused__)),
- FunctionSpecificationMessage* result_msg) {
- const char* func_name = func_msg.name().c_str();
- if (hw_binder_proxy_ == nullptr) {
- LOG(ERROR) << "hw_binder_proxy_ is null. ";
- return false;
- }
- if (!strcmp(func_name, "open")) {
- sp<::android::hardware::nfc::V1_0::INfcClientCallback> arg0;
- arg0 = VtsFuzzerCreateVts_android_hardware_nfc_V1_0_INfcClientCallback(callback_socket_name);
- static_cast<Vts_android_hardware_nfc_V1_0_INfcClientCallback*>(arg0.get())->Register(func_msg.arg(0));
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- ::android::hardware::nfc::V1_0::NfcStatus result0 = hw_binder_proxy_->open(arg0);
- result_msg->set_name("open");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_ENUM);
- SetResult__android__hardware__nfc__V1_0__NfcStatus(result_val_0, result0);
- return true;
- }
- if (!strcmp(func_name, "write")) {
- ::android::hardware::hidl_vec<uint8_t> arg0;
- arg0.resize(func_msg.arg(0).vector_value_size());
- for (int arg0_index = 0; arg0_index < func_msg.arg(0).vector_value_size(); arg0_index++) {
- arg0[arg0_index] = func_msg.arg(0).vector_value(arg0_index).scalar_value().uint8_t();
- }
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- uint32_t result0 = hw_binder_proxy_->write(arg0);
- result_msg->set_name("write");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_SCALAR);
- result_val_0->set_scalar_type("uint32_t");
- result_val_0->mutable_scalar_value()->set_uint32_t(result0);
- return true;
- }
- if (!strcmp(func_name, "coreInitialized")) {
- ::android::hardware::hidl_vec<uint8_t> arg0;
- arg0.resize(func_msg.arg(0).vector_value_size());
- for (int arg0_index = 0; arg0_index < func_msg.arg(0).vector_value_size(); arg0_index++) {
- arg0[arg0_index] = func_msg.arg(0).vector_value(arg0_index).scalar_value().uint8_t();
- }
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- ::android::hardware::nfc::V1_0::NfcStatus result0 = hw_binder_proxy_->coreInitialized(arg0);
- result_msg->set_name("coreInitialized");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_ENUM);
- SetResult__android__hardware__nfc__V1_0__NfcStatus(result_val_0, result0);
- return true;
- }
- if (!strcmp(func_name, "prediscover")) {
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- ::android::hardware::nfc::V1_0::NfcStatus result0 = hw_binder_proxy_->prediscover();
- result_msg->set_name("prediscover");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_ENUM);
- SetResult__android__hardware__nfc__V1_0__NfcStatus(result_val_0, result0);
- return true;
- }
- if (!strcmp(func_name, "close")) {
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- ::android::hardware::nfc::V1_0::NfcStatus result0 = hw_binder_proxy_->close();
- result_msg->set_name("close");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_ENUM);
- SetResult__android__hardware__nfc__V1_0__NfcStatus(result_val_0, result0);
- return true;
- }
- if (!strcmp(func_name, "controlGranted")) {
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- ::android::hardware::nfc::V1_0::NfcStatus result0 = hw_binder_proxy_->controlGranted();
- result_msg->set_name("controlGranted");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_ENUM);
- SetResult__android__hardware__nfc__V1_0__NfcStatus(result_val_0, result0);
- return true;
- }
- if (!strcmp(func_name, "powerCycle")) {
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- ::android::hardware::nfc::V1_0::NfcStatus result0 = hw_binder_proxy_->powerCycle();
- result_msg->set_name("powerCycle");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_ENUM);
- SetResult__android__hardware__nfc__V1_0__NfcStatus(result_val_0, result0);
- return true;
- }
- if (!strcmp(func_name, "notifySyspropsChanged")) {
- LOG(INFO) << "Call notifySyspropsChanged";
- hw_binder_proxy_->notifySyspropsChanged();
- result_msg->set_name("notifySyspropsChanged");
- return true;
- }
- return false;
-}
-
-bool FuzzerExtended_android_hardware_nfc_V1_0_INfc::VerifyResults(const FunctionSpecificationMessage& expected_result __attribute__((__unused__)),
- const FunctionSpecificationMessage& actual_result __attribute__((__unused__))) {
- if (!strcmp(actual_result.name().c_str(), "open")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if(!Verify__android__hardware__nfc__V1_0__NfcStatus(expected_result.return_type_hidl(0), actual_result.return_type_hidl(0))) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "write")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).scalar_value().uint32_t() != expected_result.return_type_hidl(0).scalar_value().uint32_t()) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "coreInitialized")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if(!Verify__android__hardware__nfc__V1_0__NfcStatus(expected_result.return_type_hidl(0), actual_result.return_type_hidl(0))) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "prediscover")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if(!Verify__android__hardware__nfc__V1_0__NfcStatus(expected_result.return_type_hidl(0), actual_result.return_type_hidl(0))) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "close")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if(!Verify__android__hardware__nfc__V1_0__NfcStatus(expected_result.return_type_hidl(0), actual_result.return_type_hidl(0))) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "controlGranted")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if(!Verify__android__hardware__nfc__V1_0__NfcStatus(expected_result.return_type_hidl(0), actual_result.return_type_hidl(0))) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "powerCycle")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if(!Verify__android__hardware__nfc__V1_0__NfcStatus(expected_result.return_type_hidl(0), actual_result.return_type_hidl(0))) { return false; }
- return true;
- }
- return false;
-}
-
-extern "C" {
-android::vts::DriverBase* vts_func_4_android_hardware_nfc_V1_0_INfc_() {
- return (android::vts::DriverBase*) new android::vts::FuzzerExtended_android_hardware_nfc_V1_0_INfc();
-}
-
-android::vts::DriverBase* vts_func_4_android_hardware_nfc_V1_0_INfc_with_arg(uint64_t hw_binder_proxy) {
- ::android::hardware::nfc::V1_0::INfc* arg = nullptr;
- if (hw_binder_proxy) {
- arg = reinterpret_cast<::android::hardware::nfc::V1_0::INfc*>(hw_binder_proxy);
- } else {
- LOG(INFO) << " Creating DriverBase with null proxy.";
- }
- android::vts::DriverBase* result =
- new android::vts::FuzzerExtended_android_hardware_nfc_V1_0_INfc(
- arg);
- if (arg != nullptr) {
- arg->decStrong(arg);
- }
- return result;
-}
-
-}
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/test/golden/DRIVER/Nfc.vts.h b/compilation_tools/vtsc/test/golden/DRIVER/Nfc.vts.h
deleted file mode 100644
index 107ae2d..0000000
--- a/compilation_tools/vtsc/test/golden/DRIVER/Nfc.vts.h
+++ /dev/null
@@ -1,92 +0,0 @@
-#ifndef __VTS_DRIVER__android_hardware_nfc_V1_0_INfc__
-#define __VTS_DRIVER__android_hardware_nfc_V1_0_INfc__
-
-#undef LOG_TAG
-#define LOG_TAG "FuzzerExtended_android_hardware_nfc_V1_0_INfc"
-
-#include <log/log.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <driver_base/DriverBase.h>
-#include <driver_base/DriverCallbackBase.h>
-
-#include <VtsDriverCommUtil.h>
-
-#include <android/hardware/nfc/1.0/INfc.h>
-#include <hidl/HidlSupport.h>
-#include <android/hardware/nfc/1.0/INfcClientCallback.h>
-#include <android/hardware/nfc/1.0/NfcClientCallback.vts.h>
-#include <android/hardware/nfc/1.0/types.h>
-#include <android/hardware/nfc/1.0/types.vts.h>
-#include <android/hidl/base/1.0/types.h>
-
-
-using namespace android::hardware::nfc::V1_0;
-namespace android {
-namespace vts {
-
-class Vts_android_hardware_nfc_V1_0_INfc : public ::android::hardware::nfc::V1_0::INfc, public DriverCallbackBase {
- public:
- Vts_android_hardware_nfc_V1_0_INfc(const string& callback_socket_name)
- : callback_socket_name_(callback_socket_name) {};
-
- virtual ~Vts_android_hardware_nfc_V1_0_INfc() = default;
-
- ::android::hardware::Return<::android::hardware::nfc::V1_0::NfcStatus> open(
- const sp<::android::hardware::nfc::V1_0::INfcClientCallback>& arg0) override;
-
- ::android::hardware::Return<uint32_t> write(
- const ::android::hardware::hidl_vec<uint8_t>& arg0) override;
-
- ::android::hardware::Return<::android::hardware::nfc::V1_0::NfcStatus> coreInitialized(
- const ::android::hardware::hidl_vec<uint8_t>& arg0) override;
-
- ::android::hardware::Return<::android::hardware::nfc::V1_0::NfcStatus> prediscover(
- ) override;
-
- ::android::hardware::Return<::android::hardware::nfc::V1_0::NfcStatus> close(
- ) override;
-
- ::android::hardware::Return<::android::hardware::nfc::V1_0::NfcStatus> controlGranted(
- ) override;
-
- ::android::hardware::Return<::android::hardware::nfc::V1_0::NfcStatus> powerCycle(
- ) override;
-
-
- private:
- string callback_socket_name_;
-};
-
-sp<::android::hardware::nfc::V1_0::INfc> VtsFuzzerCreateVts_android_hardware_nfc_V1_0_INfc(const string& callback_socket_name);
-
-class FuzzerExtended_android_hardware_nfc_V1_0_INfc : public DriverBase {
- public:
- FuzzerExtended_android_hardware_nfc_V1_0_INfc() : DriverBase(HAL_HIDL), hw_binder_proxy_() {}
-
- explicit FuzzerExtended_android_hardware_nfc_V1_0_INfc(::android::hardware::nfc::V1_0::INfc* hw_binder_proxy) : DriverBase(HAL_HIDL), hw_binder_proxy_(hw_binder_proxy) {}
- uint64_t GetHidlInterfaceProxy() const {
- return reinterpret_cast<uintptr_t>(hw_binder_proxy_.get());
- }
- protected:
- bool Fuzz(FunctionSpecificationMessage* func_msg, void** result, const string& callback_socket_name);
- bool CallFunction(const FunctionSpecificationMessage& func_msg, const string& callback_socket_name, FunctionSpecificationMessage* result_msg);
- bool VerifyResults(const FunctionSpecificationMessage& expected_result, const FunctionSpecificationMessage& actual_result);
- bool GetAttribute(FunctionSpecificationMessage* func_msg, void** result);
- bool GetService(bool get_stub, const char* service_name);
-
- private:
- sp<::android::hardware::nfc::V1_0::INfc> hw_binder_proxy_;
-};
-
-
-extern "C" {
-extern android::vts::DriverBase* vts_func_4_android_hardware_nfc_V1_0_INfc_();
-extern android::vts::DriverBase* vts_func_4_android_hardware_nfc_V1_0_INfc_with_arg(uint64_t hw_binder_proxy);
-}
-} // namespace vts
-} // namespace android
-#endif
diff --git a/compilation_tools/vtsc/test/golden/DRIVER/NfcClientCallback.driver.cpp b/compilation_tools/vtsc/test/golden/DRIVER/NfcClientCallback.driver.cpp
deleted file mode 100644
index f345fad..0000000
--- a/compilation_tools/vtsc/test/golden/DRIVER/NfcClientCallback.driver.cpp
+++ /dev/null
@@ -1,161 +0,0 @@
-#include "android/hardware/nfc/1.0/NfcClientCallback.vts.h"
-#include "vts_measurement.h"
-#include <android-base/logging.h>
-#include <android/hidl/allocator/1.0/IAllocator.h>
-#include <fcntl.h>
-#include <fmq/MessageQueue.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-
-using namespace android::hardware::nfc::V1_0;
-namespace android {
-namespace vts {
-bool FuzzerExtended_android_hardware_nfc_V1_0_INfcClientCallback::GetService(bool get_stub, const char* service_name) {
- static bool initialized = false;
- if (!initialized) {
- LOG(INFO) << "HIDL getService";
- if (service_name) {
- LOG(INFO) << " - service name: " << service_name;
- }
- hw_binder_proxy_ = ::android::hardware::nfc::V1_0::INfcClientCallback::getService(service_name, get_stub);
- if (hw_binder_proxy_ == nullptr) {
- LOG(ERROR) << "getService() returned a null pointer.";
- return false;
- }
- LOG(DEBUG) << "hw_binder_proxy_ = " << hw_binder_proxy_.get();
- initialized = true;
- }
- return true;
-}
-
-
-::android::hardware::Return<void> Vts_android_hardware_nfc_V1_0_INfcClientCallback::sendEvent(
- ::android::hardware::nfc::V1_0::NfcEvent arg0 __attribute__((__unused__)),
- ::android::hardware::nfc::V1_0::NfcStatus arg1 __attribute__((__unused__))) {
- LOG(INFO) << "sendEvent called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("sendEvent"));
- callback_message.set_name("Vts_android_hardware_nfc_V1_0_INfcClientCallback::sendEvent");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_ENUM);
- SetResult__android__hardware__nfc__V1_0__NfcEvent(var_msg0, arg0);
- VariableSpecificationMessage* var_msg1 = callback_message.add_arg();
- var_msg1->set_type(TYPE_ENUM);
- SetResult__android__hardware__nfc__V1_0__NfcStatus(var_msg1, arg1);
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_nfc_V1_0_INfcClientCallback::sendData(
- const ::android::hardware::hidl_vec<uint8_t>& arg0 __attribute__((__unused__))) {
- LOG(INFO) << "sendData called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("sendData"));
- callback_message.set_name("Vts_android_hardware_nfc_V1_0_INfcClientCallback::sendData");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_VECTOR);
- var_msg0->set_vector_size(arg0.size());
- for (int i = 0; i < (int)arg0.size(); i++) {
- auto *var_msg0_vector_i = var_msg0->add_vector_value();
- var_msg0_vector_i->set_type(TYPE_SCALAR);
- var_msg0_vector_i->set_scalar_type("uint8_t");
- var_msg0_vector_i->mutable_scalar_value()->set_uint8_t(arg0[i]);
- }
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::Void();
-}
-
-sp<::android::hardware::nfc::V1_0::INfcClientCallback> VtsFuzzerCreateVts_android_hardware_nfc_V1_0_INfcClientCallback(const string& callback_socket_name) {
- static sp<::android::hardware::nfc::V1_0::INfcClientCallback> result;
- result = new Vts_android_hardware_nfc_V1_0_INfcClientCallback(callback_socket_name);
- return result;
-}
-
-bool FuzzerExtended_android_hardware_nfc_V1_0_INfcClientCallback::Fuzz(
- FunctionSpecificationMessage* /*func_msg*/,
- void** /*result*/, const string& /*callback_socket_name*/) {
- return true;
-}
-bool FuzzerExtended_android_hardware_nfc_V1_0_INfcClientCallback::GetAttribute(
- FunctionSpecificationMessage* /*func_msg*/,
- void** /*result*/) {
- LOG(ERROR) << "attribute not found.";
- return false;
-}
-bool FuzzerExtended_android_hardware_nfc_V1_0_INfcClientCallback::CallFunction(
- const FunctionSpecificationMessage& func_msg,
- const string& callback_socket_name __attribute__((__unused__)),
- FunctionSpecificationMessage* result_msg) {
- const char* func_name = func_msg.name().c_str();
- if (hw_binder_proxy_ == nullptr) {
- LOG(ERROR) << "hw_binder_proxy_ is null. ";
- return false;
- }
- if (!strcmp(func_name, "sendEvent")) {
- ::android::hardware::nfc::V1_0::NfcEvent arg0;
- MessageTo__android__hardware__nfc__V1_0__NfcEvent(func_msg.arg(0), &(arg0), callback_socket_name);
- ::android::hardware::nfc::V1_0::NfcStatus arg1;
- MessageTo__android__hardware__nfc__V1_0__NfcStatus(func_msg.arg(1), &(arg1), callback_socket_name);
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->sendEvent(arg0, arg1);
- result_msg->set_name("sendEvent");
- return true;
- }
- if (!strcmp(func_name, "sendData")) {
- ::android::hardware::hidl_vec<uint8_t> arg0;
- arg0.resize(func_msg.arg(0).vector_value_size());
- for (int arg0_index = 0; arg0_index < func_msg.arg(0).vector_value_size(); arg0_index++) {
- arg0[arg0_index] = func_msg.arg(0).vector_value(arg0_index).scalar_value().uint8_t();
- }
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->sendData(arg0);
- result_msg->set_name("sendData");
- return true;
- }
- if (!strcmp(func_name, "notifySyspropsChanged")) {
- LOG(INFO) << "Call notifySyspropsChanged";
- hw_binder_proxy_->notifySyspropsChanged();
- result_msg->set_name("notifySyspropsChanged");
- return true;
- }
- return false;
-}
-
-bool FuzzerExtended_android_hardware_nfc_V1_0_INfcClientCallback::VerifyResults(const FunctionSpecificationMessage& expected_result __attribute__((__unused__)),
- const FunctionSpecificationMessage& actual_result __attribute__((__unused__))) {
- if (!strcmp(actual_result.name().c_str(), "sendEvent")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "sendData")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- return true;
- }
- return false;
-}
-
-extern "C" {
-android::vts::DriverBase* vts_func_4_android_hardware_nfc_V1_0_INfcClientCallback_() {
- return (android::vts::DriverBase*) new android::vts::FuzzerExtended_android_hardware_nfc_V1_0_INfcClientCallback();
-}
-
-android::vts::DriverBase* vts_func_4_android_hardware_nfc_V1_0_INfcClientCallback_with_arg(uint64_t hw_binder_proxy) {
- ::android::hardware::nfc::V1_0::INfcClientCallback* arg = nullptr;
- if (hw_binder_proxy) {
- arg = reinterpret_cast<::android::hardware::nfc::V1_0::INfcClientCallback*>(hw_binder_proxy);
- } else {
- LOG(INFO) << " Creating DriverBase with null proxy.";
- }
- android::vts::DriverBase* result =
- new android::vts::FuzzerExtended_android_hardware_nfc_V1_0_INfcClientCallback(
- arg);
- if (arg != nullptr) {
- arg->decStrong(arg);
- }
- return result;
-}
-
-}
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/test/golden/DRIVER/NfcClientCallback.vts.h b/compilation_tools/vtsc/test/golden/DRIVER/NfcClientCallback.vts.h
deleted file mode 100644
index 9626955..0000000
--- a/compilation_tools/vtsc/test/golden/DRIVER/NfcClientCallback.vts.h
+++ /dev/null
@@ -1,76 +0,0 @@
-#ifndef __VTS_DRIVER__android_hardware_nfc_V1_0_INfcClientCallback__
-#define __VTS_DRIVER__android_hardware_nfc_V1_0_INfcClientCallback__
-
-#undef LOG_TAG
-#define LOG_TAG "FuzzerExtended_android_hardware_nfc_V1_0_INfcClientCallback"
-
-#include <log/log.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <driver_base/DriverBase.h>
-#include <driver_base/DriverCallbackBase.h>
-
-#include <VtsDriverCommUtil.h>
-
-#include <android/hardware/nfc/1.0/INfcClientCallback.h>
-#include <hidl/HidlSupport.h>
-#include <android/hardware/nfc/1.0/types.h>
-#include <android/hardware/nfc/1.0/types.vts.h>
-#include <android/hidl/base/1.0/types.h>
-
-
-using namespace android::hardware::nfc::V1_0;
-namespace android {
-namespace vts {
-
-class Vts_android_hardware_nfc_V1_0_INfcClientCallback : public ::android::hardware::nfc::V1_0::INfcClientCallback, public DriverCallbackBase {
- public:
- Vts_android_hardware_nfc_V1_0_INfcClientCallback(const string& callback_socket_name)
- : callback_socket_name_(callback_socket_name) {};
-
- virtual ~Vts_android_hardware_nfc_V1_0_INfcClientCallback() = default;
-
- ::android::hardware::Return<void> sendEvent(
- ::android::hardware::nfc::V1_0::NfcEvent arg0,
- ::android::hardware::nfc::V1_0::NfcStatus arg1) override;
-
- ::android::hardware::Return<void> sendData(
- const ::android::hardware::hidl_vec<uint8_t>& arg0) override;
-
-
- private:
- string callback_socket_name_;
-};
-
-sp<::android::hardware::nfc::V1_0::INfcClientCallback> VtsFuzzerCreateVts_android_hardware_nfc_V1_0_INfcClientCallback(const string& callback_socket_name);
-
-class FuzzerExtended_android_hardware_nfc_V1_0_INfcClientCallback : public DriverBase {
- public:
- FuzzerExtended_android_hardware_nfc_V1_0_INfcClientCallback() : DriverBase(HAL_HIDL), hw_binder_proxy_() {}
-
- explicit FuzzerExtended_android_hardware_nfc_V1_0_INfcClientCallback(::android::hardware::nfc::V1_0::INfcClientCallback* hw_binder_proxy) : DriverBase(HAL_HIDL), hw_binder_proxy_(hw_binder_proxy) {}
- uint64_t GetHidlInterfaceProxy() const {
- return reinterpret_cast<uintptr_t>(hw_binder_proxy_.get());
- }
- protected:
- bool Fuzz(FunctionSpecificationMessage* func_msg, void** result, const string& callback_socket_name);
- bool CallFunction(const FunctionSpecificationMessage& func_msg, const string& callback_socket_name, FunctionSpecificationMessage* result_msg);
- bool VerifyResults(const FunctionSpecificationMessage& expected_result, const FunctionSpecificationMessage& actual_result);
- bool GetAttribute(FunctionSpecificationMessage* func_msg, void** result);
- bool GetService(bool get_stub, const char* service_name);
-
- private:
- sp<::android::hardware::nfc::V1_0::INfcClientCallback> hw_binder_proxy_;
-};
-
-
-extern "C" {
-extern android::vts::DriverBase* vts_func_4_android_hardware_nfc_V1_0_INfcClientCallback_();
-extern android::vts::DriverBase* vts_func_4_android_hardware_nfc_V1_0_INfcClientCallback_with_arg(uint64_t hw_binder_proxy);
-}
-} // namespace vts
-} // namespace android
-#endif
diff --git a/compilation_tools/vtsc/test/golden/DRIVER/TestMsgQ.driver.cpp b/compilation_tools/vtsc/test/golden/DRIVER/TestMsgQ.driver.cpp
deleted file mode 100644
index b5031da..0000000
--- a/compilation_tools/vtsc/test/golden/DRIVER/TestMsgQ.driver.cpp
+++ /dev/null
@@ -1,416 +0,0 @@
-#include "android/hardware/tests/msgq/1.0/TestMsgQ.vts.h"
-#include "vts_measurement.h"
-#include <android-base/logging.h>
-#include <android/hidl/allocator/1.0/IAllocator.h>
-#include <fcntl.h>
-#include <fmq/MessageQueue.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-
-using namespace android::hardware::tests::msgq::V1_0;
-namespace android {
-namespace vts {
-extern "C" void MessageTo__android__hardware__tests__msgq__V1_0__ITestMsgQ__EventFlagBits(const VariableSpecificationMessage& var_msg __attribute__((__unused__)), ::android::hardware::tests::msgq::V1_0::ITestMsgQ::EventFlagBits* arg __attribute__((__unused__)), const string& callback_socket_name __attribute__((__unused__))) {
- *arg = (::android::hardware::tests::msgq::V1_0::ITestMsgQ::EventFlagBits)var_msg.scalar_value().uint32_t();
-}
-uint32_t Random__android__hardware__tests__msgq__V1_0__ITestMsgQ__EventFlagBits() {
- uint32_t choice = (uint32_t) rand() / 2;
- if (choice == (uint32_t) 1UL) return static_cast<uint32_t>(::android::hardware::tests::msgq::V1_0::ITestMsgQ::EventFlagBits::FMQ_NOT_EMPTY);
- if (choice == (uint32_t) 2UL) return static_cast<uint32_t>(::android::hardware::tests::msgq::V1_0::ITestMsgQ::EventFlagBits::FMQ_NOT_FULL);
- return static_cast<uint32_t>(::android::hardware::tests::msgq::V1_0::ITestMsgQ::EventFlagBits::FMQ_NOT_EMPTY);
-}
-bool Verify__android__hardware__tests__msgq__V1_0__ITestMsgQ__EventFlagBits(const VariableSpecificationMessage& expected_result __attribute__((__unused__)), const VariableSpecificationMessage& actual_result __attribute__((__unused__))){
- if (actual_result.scalar_value().uint32_t() != expected_result.scalar_value().uint32_t()) { return false; }
- return true;
-}
-
-extern "C" void SetResult__android__hardware__tests__msgq__V1_0__ITestMsgQ__EventFlagBits(VariableSpecificationMessage* result_msg, ::android::hardware::tests::msgq::V1_0::ITestMsgQ::EventFlagBits result_value __attribute__((__unused__))){
- result_msg->set_type(TYPE_ENUM);
- result_msg->set_scalar_type("uint32_t");
- result_msg->mutable_scalar_value()->set_uint32_t(static_cast<uint32_t>(result_value));
-}
-
-bool FuzzerExtended_android_hardware_tests_msgq_V1_0_ITestMsgQ::GetService(bool get_stub, const char* service_name) {
- static bool initialized = false;
- if (!initialized) {
- LOG(INFO) << "HIDL getService";
- if (service_name) {
- LOG(INFO) << " - service name: " << service_name;
- }
- hw_binder_proxy_ = ::android::hardware::tests::msgq::V1_0::ITestMsgQ::getService(service_name, get_stub);
- if (hw_binder_proxy_ == nullptr) {
- LOG(ERROR) << "getService() returned a null pointer.";
- return false;
- }
- LOG(DEBUG) << "hw_binder_proxy_ = " << hw_binder_proxy_.get();
- initialized = true;
- }
- return true;
-}
-
-
-::android::hardware::Return<bool> Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ::configureFmqSyncReadWrite(
- const ::android::hardware::MQDescriptorSync<int32_t>& arg0 __attribute__((__unused__))) {
- LOG(INFO) << "configureFmqSyncReadWrite called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("configureFmqSyncReadWrite"));
- callback_message.set_name("Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ::configureFmqSyncReadWrite");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_FMQ_SYNC);
- VariableSpecificationMessage* var_msg0_item = var_msg0->add_fmq_value();
- var_msg0_item->set_type(TYPE_SCALAR);
- var_msg0_item->set_scalar_type("int32_t");
- var_msg0_item->set_fmq_desc_address(reinterpret_cast<size_t>(new (std::nothrow) ::android::hardware::MQDescriptorSync<int32_t>(arg0)));
- RpcCallToAgent(callback_message, callback_socket_name_);
- return static_cast<bool>(0);
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ::getFmqUnsyncWrite(
- bool arg0 __attribute__((__unused__)),
- bool arg1 __attribute__((__unused__)), std::function<void(bool arg0,const ::android::hardware::MQDescriptorUnsync<int32_t>& arg1)> cb) {
- LOG(INFO) << "getFmqUnsyncWrite called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("getFmqUnsyncWrite"));
- callback_message.set_name("Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ::getFmqUnsyncWrite");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_SCALAR);
- var_msg0->set_scalar_type("bool_t");
- var_msg0->mutable_scalar_value()->set_bool_t(arg0);
- VariableSpecificationMessage* var_msg1 = callback_message.add_arg();
- var_msg1->set_type(TYPE_SCALAR);
- var_msg1->set_scalar_type("bool_t");
- var_msg1->mutable_scalar_value()->set_bool_t(arg1);
- RpcCallToAgent(callback_message, callback_socket_name_);
- cb(static_cast<bool>(0), ::android::hardware::MQDescriptorUnsync<int32_t>());
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<bool> Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ::requestWriteFmqSync(
- int32_t arg0 __attribute__((__unused__))) {
- LOG(INFO) << "requestWriteFmqSync called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("requestWriteFmqSync"));
- callback_message.set_name("Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ::requestWriteFmqSync");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_SCALAR);
- var_msg0->set_scalar_type("int32_t");
- var_msg0->mutable_scalar_value()->set_int32_t(arg0);
- RpcCallToAgent(callback_message, callback_socket_name_);
- return static_cast<bool>(0);
-}
-
-::android::hardware::Return<bool> Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ::requestReadFmqSync(
- int32_t arg0 __attribute__((__unused__))) {
- LOG(INFO) << "requestReadFmqSync called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("requestReadFmqSync"));
- callback_message.set_name("Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ::requestReadFmqSync");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_SCALAR);
- var_msg0->set_scalar_type("int32_t");
- var_msg0->mutable_scalar_value()->set_int32_t(arg0);
- RpcCallToAgent(callback_message, callback_socket_name_);
- return static_cast<bool>(0);
-}
-
-::android::hardware::Return<bool> Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ::requestWriteFmqUnsync(
- int32_t arg0 __attribute__((__unused__))) {
- LOG(INFO) << "requestWriteFmqUnsync called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("requestWriteFmqUnsync"));
- callback_message.set_name("Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ::requestWriteFmqUnsync");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_SCALAR);
- var_msg0->set_scalar_type("int32_t");
- var_msg0->mutable_scalar_value()->set_int32_t(arg0);
- RpcCallToAgent(callback_message, callback_socket_name_);
- return static_cast<bool>(0);
-}
-
-::android::hardware::Return<bool> Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ::requestReadFmqUnsync(
- int32_t arg0 __attribute__((__unused__))) {
- LOG(INFO) << "requestReadFmqUnsync called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("requestReadFmqUnsync"));
- callback_message.set_name("Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ::requestReadFmqUnsync");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_SCALAR);
- var_msg0->set_scalar_type("int32_t");
- var_msg0->mutable_scalar_value()->set_int32_t(arg0);
- RpcCallToAgent(callback_message, callback_socket_name_);
- return static_cast<bool>(0);
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ::requestBlockingRead(
- int32_t arg0 __attribute__((__unused__))) {
- LOG(INFO) << "requestBlockingRead called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("requestBlockingRead"));
- callback_message.set_name("Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ::requestBlockingRead");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_SCALAR);
- var_msg0->set_scalar_type("int32_t");
- var_msg0->mutable_scalar_value()->set_int32_t(arg0);
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ::requestBlockingReadDefaultEventFlagBits(
- int32_t arg0 __attribute__((__unused__))) {
- LOG(INFO) << "requestBlockingReadDefaultEventFlagBits called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("requestBlockingReadDefaultEventFlagBits"));
- callback_message.set_name("Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ::requestBlockingReadDefaultEventFlagBits");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_SCALAR);
- var_msg0->set_scalar_type("int32_t");
- var_msg0->mutable_scalar_value()->set_int32_t(arg0);
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::Void();
-}
-
-::android::hardware::Return<void> Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ::requestBlockingReadRepeat(
- int32_t arg0 __attribute__((__unused__)),
- int32_t arg1 __attribute__((__unused__))) {
- LOG(INFO) << "requestBlockingReadRepeat called";
- AndroidSystemCallbackRequestMessage callback_message;
- callback_message.set_id(GetCallbackID("requestBlockingReadRepeat"));
- callback_message.set_name("Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ::requestBlockingReadRepeat");
- VariableSpecificationMessage* var_msg0 = callback_message.add_arg();
- var_msg0->set_type(TYPE_SCALAR);
- var_msg0->set_scalar_type("int32_t");
- var_msg0->mutable_scalar_value()->set_int32_t(arg0);
- VariableSpecificationMessage* var_msg1 = callback_message.add_arg();
- var_msg1->set_type(TYPE_SCALAR);
- var_msg1->set_scalar_type("int32_t");
- var_msg1->mutable_scalar_value()->set_int32_t(arg1);
- RpcCallToAgent(callback_message, callback_socket_name_);
- return ::android::hardware::Void();
-}
-
-sp<::android::hardware::tests::msgq::V1_0::ITestMsgQ> VtsFuzzerCreateVts_android_hardware_tests_msgq_V1_0_ITestMsgQ(const string& callback_socket_name) {
- static sp<::android::hardware::tests::msgq::V1_0::ITestMsgQ> result;
- result = new Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ(callback_socket_name);
- return result;
-}
-
-bool FuzzerExtended_android_hardware_tests_msgq_V1_0_ITestMsgQ::Fuzz(
- FunctionSpecificationMessage* /*func_msg*/,
- void** /*result*/, const string& /*callback_socket_name*/) {
- return true;
-}
-bool FuzzerExtended_android_hardware_tests_msgq_V1_0_ITestMsgQ::GetAttribute(
- FunctionSpecificationMessage* /*func_msg*/,
- void** /*result*/) {
- LOG(ERROR) << "attribute not found.";
- return false;
-}
-bool FuzzerExtended_android_hardware_tests_msgq_V1_0_ITestMsgQ::CallFunction(
- const FunctionSpecificationMessage& func_msg,
- const string& callback_socket_name __attribute__((__unused__)),
- FunctionSpecificationMessage* result_msg) {
- const char* func_name = func_msg.name().c_str();
- if (hw_binder_proxy_ == nullptr) {
- LOG(ERROR) << "hw_binder_proxy_ is null. ";
- return false;
- }
- if (!strcmp(func_name, "configureFmqSyncReadWrite")) {
- const ::android::hardware::MQDescriptorSync<int32_t>* arg0;
- if (func_msg.arg(0).fmq_value_size() > 0 && func_msg.arg(0).fmq_value(0).has_fmq_desc_address()) {
- arg0 = reinterpret_cast<::android::hardware::MQDescriptorSync<int32_t>*>(func_msg.arg(0).fmq_value(0).fmq_desc_address());
- } else {
- ::android::hardware::MessageQueue<int32_t, ::android::hardware::kSynchronizedReadWrite> arg0_sync_q(1024);
- for (int i = 0; i < (int)func_msg.arg(0).fmq_value_size(); i++) {
- int32_t arg0_sync_q_item;
- arg0_sync_q_item = func_msg.arg(0).fmq_value(i).scalar_value().int32_t();
- arg0_sync_q.write(&arg0_sync_q_item);
- }
- arg0 = arg0_sync_q.getDesc();
- }
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- bool result0 = hw_binder_proxy_->configureFmqSyncReadWrite(*arg0);
- result_msg->set_name("configureFmqSyncReadWrite");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_SCALAR);
- result_val_0->set_scalar_type("bool_t");
- result_val_0->mutable_scalar_value()->set_bool_t(result0);
- return true;
- }
- if (!strcmp(func_name, "getFmqUnsyncWrite")) {
- bool arg0 = 0;
- arg0 = func_msg.arg(0).scalar_value().bool_t();
- bool arg1 = 0;
- arg1 = func_msg.arg(1).scalar_value().bool_t();
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->getFmqUnsyncWrite(arg0, arg1, [&](bool arg0 __attribute__((__unused__)),const ::android::hardware::MQDescriptorUnsync<int32_t>& arg1 __attribute__((__unused__))){
- LOG(INFO) << "callback getFmqUnsyncWrite called";
- result_msg->set_name("getFmqUnsyncWrite");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_SCALAR);
- result_val_0->set_scalar_type("bool_t");
- result_val_0->mutable_scalar_value()->set_bool_t(arg0);
- VariableSpecificationMessage* result_val_1 = result_msg->add_return_type_hidl();
- result_val_1->set_type(TYPE_FMQ_UNSYNC);
- VariableSpecificationMessage* result_val_1_item = result_val_1->add_fmq_value();
- result_val_1_item->set_type(TYPE_SCALAR);
- result_val_1_item->set_scalar_type("int32_t");
- result_val_1_item->set_fmq_desc_address(reinterpret_cast<size_t>(new (std::nothrow) ::android::hardware::MQDescriptorUnsync<int32_t>(arg1)));
- });
- return true;
- }
- if (!strcmp(func_name, "requestWriteFmqSync")) {
- int32_t arg0 = 0;
- arg0 = func_msg.arg(0).scalar_value().int32_t();
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- bool result0 = hw_binder_proxy_->requestWriteFmqSync(arg0);
- result_msg->set_name("requestWriteFmqSync");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_SCALAR);
- result_val_0->set_scalar_type("bool_t");
- result_val_0->mutable_scalar_value()->set_bool_t(result0);
- return true;
- }
- if (!strcmp(func_name, "requestReadFmqSync")) {
- int32_t arg0 = 0;
- arg0 = func_msg.arg(0).scalar_value().int32_t();
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- bool result0 = hw_binder_proxy_->requestReadFmqSync(arg0);
- result_msg->set_name("requestReadFmqSync");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_SCALAR);
- result_val_0->set_scalar_type("bool_t");
- result_val_0->mutable_scalar_value()->set_bool_t(result0);
- return true;
- }
- if (!strcmp(func_name, "requestWriteFmqUnsync")) {
- int32_t arg0 = 0;
- arg0 = func_msg.arg(0).scalar_value().int32_t();
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- bool result0 = hw_binder_proxy_->requestWriteFmqUnsync(arg0);
- result_msg->set_name("requestWriteFmqUnsync");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_SCALAR);
- result_val_0->set_scalar_type("bool_t");
- result_val_0->mutable_scalar_value()->set_bool_t(result0);
- return true;
- }
- if (!strcmp(func_name, "requestReadFmqUnsync")) {
- int32_t arg0 = 0;
- arg0 = func_msg.arg(0).scalar_value().int32_t();
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- bool result0 = hw_binder_proxy_->requestReadFmqUnsync(arg0);
- result_msg->set_name("requestReadFmqUnsync");
- VariableSpecificationMessage* result_val_0 = result_msg->add_return_type_hidl();
- result_val_0->set_type(TYPE_SCALAR);
- result_val_0->set_scalar_type("bool_t");
- result_val_0->mutable_scalar_value()->set_bool_t(result0);
- return true;
- }
- if (!strcmp(func_name, "requestBlockingRead")) {
- int32_t arg0 = 0;
- arg0 = func_msg.arg(0).scalar_value().int32_t();
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->requestBlockingRead(arg0);
- result_msg->set_name("requestBlockingRead");
- return true;
- }
- if (!strcmp(func_name, "requestBlockingReadDefaultEventFlagBits")) {
- int32_t arg0 = 0;
- arg0 = func_msg.arg(0).scalar_value().int32_t();
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->requestBlockingReadDefaultEventFlagBits(arg0);
- result_msg->set_name("requestBlockingReadDefaultEventFlagBits");
- return true;
- }
- if (!strcmp(func_name, "requestBlockingReadRepeat")) {
- int32_t arg0 = 0;
- arg0 = func_msg.arg(0).scalar_value().int32_t();
- int32_t arg1 = 0;
- arg1 = func_msg.arg(1).scalar_value().int32_t();
- LOG(DEBUG) << "local_device = " << hw_binder_proxy_.get();
- hw_binder_proxy_->requestBlockingReadRepeat(arg0, arg1);
- result_msg->set_name("requestBlockingReadRepeat");
- return true;
- }
- if (!strcmp(func_name, "notifySyspropsChanged")) {
- LOG(INFO) << "Call notifySyspropsChanged";
- hw_binder_proxy_->notifySyspropsChanged();
- result_msg->set_name("notifySyspropsChanged");
- return true;
- }
- return false;
-}
-
-bool FuzzerExtended_android_hardware_tests_msgq_V1_0_ITestMsgQ::VerifyResults(const FunctionSpecificationMessage& expected_result __attribute__((__unused__)),
- const FunctionSpecificationMessage& actual_result __attribute__((__unused__))) {
- if (!strcmp(actual_result.name().c_str(), "configureFmqSyncReadWrite")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).scalar_value().bool_t() != expected_result.return_type_hidl(0).scalar_value().bool_t()) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "getFmqUnsyncWrite")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).scalar_value().bool_t() != expected_result.return_type_hidl(0).scalar_value().bool_t()) { return false; }
- LOG(ERROR) << "TYPE_FMQ_UNSYNC is not supported yet. ";
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "requestWriteFmqSync")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).scalar_value().bool_t() != expected_result.return_type_hidl(0).scalar_value().bool_t()) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "requestReadFmqSync")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).scalar_value().bool_t() != expected_result.return_type_hidl(0).scalar_value().bool_t()) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "requestWriteFmqUnsync")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).scalar_value().bool_t() != expected_result.return_type_hidl(0).scalar_value().bool_t()) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "requestReadFmqUnsync")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- if (actual_result.return_type_hidl(0).scalar_value().bool_t() != expected_result.return_type_hidl(0).scalar_value().bool_t()) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "requestBlockingRead")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "requestBlockingReadDefaultEventFlagBits")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- return true;
- }
- if (!strcmp(actual_result.name().c_str(), "requestBlockingReadRepeat")) {
- if (actual_result.return_type_hidl_size() != expected_result.return_type_hidl_size() ) { return false; }
- return true;
- }
- return false;
-}
-
-extern "C" {
-android::vts::DriverBase* vts_func_4_android_hardware_tests_msgq_V1_0_ITestMsgQ_() {
- return (android::vts::DriverBase*) new android::vts::FuzzerExtended_android_hardware_tests_msgq_V1_0_ITestMsgQ();
-}
-
-android::vts::DriverBase* vts_func_4_android_hardware_tests_msgq_V1_0_ITestMsgQ_with_arg(uint64_t hw_binder_proxy) {
- ::android::hardware::tests::msgq::V1_0::ITestMsgQ* arg = nullptr;
- if (hw_binder_proxy) {
- arg = reinterpret_cast<::android::hardware::tests::msgq::V1_0::ITestMsgQ*>(hw_binder_proxy);
- } else {
- LOG(INFO) << " Creating DriverBase with null proxy.";
- }
- android::vts::DriverBase* result =
- new android::vts::FuzzerExtended_android_hardware_tests_msgq_V1_0_ITestMsgQ(
- arg);
- if (arg != nullptr) {
- arg->decStrong(arg);
- }
- return result;
-}
-
-}
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/test/golden/DRIVER/TestMsgQ.vts.h b/compilation_tools/vtsc/test/golden/DRIVER/TestMsgQ.vts.h
deleted file mode 100644
index d66e5b2..0000000
--- a/compilation_tools/vtsc/test/golden/DRIVER/TestMsgQ.vts.h
+++ /dev/null
@@ -1,100 +0,0 @@
-#ifndef __VTS_DRIVER__android_hardware_tests_msgq_V1_0_ITestMsgQ__
-#define __VTS_DRIVER__android_hardware_tests_msgq_V1_0_ITestMsgQ__
-
-#undef LOG_TAG
-#define LOG_TAG "FuzzerExtended_android_hardware_tests_msgq_V1_0_ITestMsgQ"
-
-#include <log/log.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <driver_base/DriverBase.h>
-#include <driver_base/DriverCallbackBase.h>
-
-#include <VtsDriverCommUtil.h>
-
-#include <android/hardware/tests/msgq/1.0/ITestMsgQ.h>
-#include <hidl/HidlSupport.h>
-#include <android/hidl/base/1.0/types.h>
-
-
-using namespace android::hardware::tests::msgq::V1_0;
-namespace android {
-namespace vts {
-extern "C" void MessageTo__android__hardware__tests__msgq__V1_0__ITestMsgQ__EventFlagBits(const VariableSpecificationMessage& var_msg, ::android::hardware::tests::msgq::V1_0::ITestMsgQ::EventFlagBits* arg, const string& callback_socket_name);
-uint32_t Random__android__hardware__tests__msgq__V1_0__ITestMsgQ__EventFlagBits();
-bool Verify__android__hardware__tests__msgq__V1_0__ITestMsgQ__EventFlagBits(const VariableSpecificationMessage& expected_result, const VariableSpecificationMessage& actual_result);
-extern "C" void SetResult__android__hardware__tests__msgq__V1_0__ITestMsgQ__EventFlagBits(VariableSpecificationMessage* result_msg, ::android::hardware::tests::msgq::V1_0::ITestMsgQ::EventFlagBits result_value);
-
-class Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ : public ::android::hardware::tests::msgq::V1_0::ITestMsgQ, public DriverCallbackBase {
- public:
- Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ(const string& callback_socket_name)
- : callback_socket_name_(callback_socket_name) {};
-
- virtual ~Vts_android_hardware_tests_msgq_V1_0_ITestMsgQ() = default;
-
- ::android::hardware::Return<bool> configureFmqSyncReadWrite(
- const ::android::hardware::MQDescriptorSync<int32_t>& arg0) override;
-
- ::android::hardware::Return<void> getFmqUnsyncWrite(
- bool arg0,
- bool arg1, std::function<void(bool arg0,const ::android::hardware::MQDescriptorUnsync<int32_t>& arg1)> cb) override;
-
- ::android::hardware::Return<bool> requestWriteFmqSync(
- int32_t arg0) override;
-
- ::android::hardware::Return<bool> requestReadFmqSync(
- int32_t arg0) override;
-
- ::android::hardware::Return<bool> requestWriteFmqUnsync(
- int32_t arg0) override;
-
- ::android::hardware::Return<bool> requestReadFmqUnsync(
- int32_t arg0) override;
-
- ::android::hardware::Return<void> requestBlockingRead(
- int32_t arg0) override;
-
- ::android::hardware::Return<void> requestBlockingReadDefaultEventFlagBits(
- int32_t arg0) override;
-
- ::android::hardware::Return<void> requestBlockingReadRepeat(
- int32_t arg0,
- int32_t arg1) override;
-
-
- private:
- string callback_socket_name_;
-};
-
-sp<::android::hardware::tests::msgq::V1_0::ITestMsgQ> VtsFuzzerCreateVts_android_hardware_tests_msgq_V1_0_ITestMsgQ(const string& callback_socket_name);
-
-class FuzzerExtended_android_hardware_tests_msgq_V1_0_ITestMsgQ : public DriverBase {
- public:
- FuzzerExtended_android_hardware_tests_msgq_V1_0_ITestMsgQ() : DriverBase(HAL_HIDL), hw_binder_proxy_() {}
-
- explicit FuzzerExtended_android_hardware_tests_msgq_V1_0_ITestMsgQ(::android::hardware::tests::msgq::V1_0::ITestMsgQ* hw_binder_proxy) : DriverBase(HAL_HIDL), hw_binder_proxy_(hw_binder_proxy) {}
- uint64_t GetHidlInterfaceProxy() const {
- return reinterpret_cast<uintptr_t>(hw_binder_proxy_.get());
- }
- protected:
- bool Fuzz(FunctionSpecificationMessage* func_msg, void** result, const string& callback_socket_name);
- bool CallFunction(const FunctionSpecificationMessage& func_msg, const string& callback_socket_name, FunctionSpecificationMessage* result_msg);
- bool VerifyResults(const FunctionSpecificationMessage& expected_result, const FunctionSpecificationMessage& actual_result);
- bool GetAttribute(FunctionSpecificationMessage* func_msg, void** result);
- bool GetService(bool get_stub, const char* service_name);
-
- private:
- sp<::android::hardware::tests::msgq::V1_0::ITestMsgQ> hw_binder_proxy_;
-};
-
-
-extern "C" {
-extern android::vts::DriverBase* vts_func_4_android_hardware_tests_msgq_V1_0_ITestMsgQ_();
-extern android::vts::DriverBase* vts_func_4_android_hardware_tests_msgq_V1_0_ITestMsgQ_with_arg(uint64_t hw_binder_proxy);
-}
-} // namespace vts
-} // namespace android
-#endif
diff --git a/compilation_tools/vtsc/test/golden/DRIVER/libcV1.driver.cpp b/compilation_tools/vtsc/test/golden/DRIVER/libcV1.driver.cpp
deleted file mode 100644
index 49354f2..0000000
--- a/compilation_tools/vtsc/test/golden/DRIVER/libcV1.driver.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-#include "test/vts/specification/lib/ndk/bionic/1.0/libcV1.vts.h"
-#include <unistd.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <linux/socket.h>
-#include "vts_datatype.h"
-#include "vts_measurement.h"
-#include <android-base/logging.h>
-
-
-namespace android {
-namespace vts {
-bool FuzzerExtended_libc::Fuzz(
- FunctionSpecificationMessage* func_msg,
- void** result, const string& callback_socket_name) {
- const char* func_name = func_msg->name().c_str();
- LOG(INFO) << "Function: " << func_name;
- if (!strcmp(func_name, "socket")) {
- int32_t arg0 = (func_msg->arg(0).type() == TYPE_SCALAR && func_msg->arg(0).scalar_value().has_int32_t()) ? func_msg->arg(0).scalar_value().int32_t() : RandomInt32();
- LOG(INFO) << "arg0 = " << arg0;
- int32_t arg1 = (func_msg->arg(1).type() == TYPE_SCALAR && func_msg->arg(1).scalar_value().has_int32_t()) ? func_msg->arg(1).scalar_value().int32_t() : RandomInt32();
- LOG(INFO) << "arg1 = " << arg1;
- int32_t arg2 = (func_msg->arg(2).type() == TYPE_SCALAR && func_msg->arg(2).scalar_value().has_int32_t()) ? func_msg->arg(2).scalar_value().int32_t() : RandomInt32();
- LOG(INFO) << "arg2 = " << arg2;
- typedef void* (*func_type_socket)(...);
- *result = const_cast<void*>(reinterpret_cast<const void*>( ((func_type_socket) target_loader_.GetLoaderFunction("socket"))(
- arg0,
- arg1,
- arg2)));
- return true;
- }
- if (!strcmp(func_name, "accept")) {
- int32_t arg0 = (func_msg->arg(0).type() == TYPE_SCALAR && func_msg->arg(0).scalar_value().has_int32_t()) ? func_msg->arg(0).scalar_value().int32_t() : RandomInt32();
- LOG(INFO) << "arg0 = " << arg0;
- struct sockaddr* arg1 = (struct sockaddr*) malloc(sizeof(struct sockaddr));
- LOG(INFO) << "arg1 = " << arg1;
- socklen_t* arg2 = (socklen_t*) malloc(sizeof(socklen_t));
- LOG(INFO) << "arg2 = " << arg2;
- typedef void* (*func_type_accept)(...);
- *result = const_cast<void*>(reinterpret_cast<const void*>( ((func_type_accept) target_loader_.GetLoaderFunction("accept"))(
- arg0,
- arg1,
- arg2)));
- return true;
- }
- if (!strcmp(func_name, "bind")) {
- int32_t arg0 = (func_msg->arg(0).type() == TYPE_SCALAR && func_msg->arg(0).scalar_value().has_int32_t()) ? func_msg->arg(0).scalar_value().int32_t() : RandomInt32();
- LOG(INFO) << "arg0 = " << arg0;
- struct sockaddr* arg1 = (struct sockaddr*) malloc(sizeof(struct sockaddr));
- LOG(INFO) << "arg1 = " << arg1;
- socklen_t* arg2 = (socklen_t*) malloc(sizeof(socklen_t));
- LOG(INFO) << "arg2 = " << arg2;
- typedef void* (*func_type_bind)(...);
- *result = const_cast<void*>(reinterpret_cast<const void*>( ((func_type_bind) target_loader_.GetLoaderFunction("bind"))(
- arg0,
- arg1,
- arg2)));
- return true;
- }
- if (!strcmp(func_name, "connect")) {
- int32_t arg0 = (func_msg->arg(0).type() == TYPE_SCALAR && func_msg->arg(0).scalar_value().has_int32_t()) ? func_msg->arg(0).scalar_value().int32_t() : RandomInt32();
- LOG(INFO) << "arg0 = " << arg0;
- struct sockaddr* arg1 = (struct sockaddr*) malloc(sizeof(struct sockaddr));
- LOG(INFO) << "arg1 = " << arg1;
- socklen_t* arg2 = (socklen_t*) malloc(sizeof(socklen_t));
- LOG(INFO) << "arg2 = " << arg2;
- typedef void* (*func_type_connect)(...);
- *result = const_cast<void*>(reinterpret_cast<const void*>( ((func_type_connect) target_loader_.GetLoaderFunction("connect"))(
- arg0,
- arg1,
- arg2)));
- return true;
- }
- if (!strcmp(func_name, "listen")) {
- int32_t arg0 = (func_msg->arg(0).type() == TYPE_SCALAR && func_msg->arg(0).scalar_value().has_int32_t()) ? func_msg->arg(0).scalar_value().int32_t() : RandomInt32();
- LOG(INFO) << "arg0 = " << arg0;
- int32_t arg1 = (func_msg->arg(1).type() == TYPE_SCALAR && func_msg->arg(1).scalar_value().has_int32_t()) ? func_msg->arg(1).scalar_value().int32_t() : RandomInt32();
- LOG(INFO) << "arg1 = " << arg1;
- typedef void* (*func_type_listen)(...);
- *result = const_cast<void*>(reinterpret_cast<const void*>( ((func_type_listen) target_loader_.GetLoaderFunction("listen"))(
- arg0,
- arg1)));
- return true;
- }
- if (!strcmp(func_name, "recv")) {
- int32_t arg0 = (func_msg->arg(0).type() == TYPE_SCALAR && func_msg->arg(0).scalar_value().has_int32_t()) ? func_msg->arg(0).scalar_value().int32_t() : RandomInt32();
- LOG(INFO) << "arg0 = " << arg0;
- void* arg1 = (func_msg->arg(1).type() == TYPE_SCALAR && func_msg->arg(1).scalar_value().has_void_pointer()) ? reinterpret_cast<void*>(func_msg->arg(1).scalar_value().void_pointer()) : RandomVoidPointer();
- LOG(INFO) << "arg1 = " << arg1;
- uint32_t arg2 = (func_msg->arg(2).type() == TYPE_SCALAR && func_msg->arg(2).scalar_value().has_uint32_t()) ? func_msg->arg(2).scalar_value().uint32_t() : RandomUint32();
- LOG(INFO) << "arg2 = " << arg2;
- int32_t arg3 = (func_msg->arg(3).type() == TYPE_SCALAR && func_msg->arg(3).scalar_value().has_int32_t()) ? func_msg->arg(3).scalar_value().int32_t() : RandomInt32();
- LOG(INFO) << "arg3 = " << arg3;
- typedef void* (*func_type_recv)(...);
- *result = const_cast<void*>(reinterpret_cast<const void*>( ((func_type_recv) target_loader_.GetLoaderFunction("recv"))(
- arg0,
- arg1,
- arg2,
- arg3)));
- return true;
- }
- if (!strcmp(func_name, "send")) {
- int32_t arg0 = (func_msg->arg(0).type() == TYPE_SCALAR && func_msg->arg(0).scalar_value().has_int32_t()) ? func_msg->arg(0).scalar_value().int32_t() : RandomInt32();
- LOG(INFO) << "arg0 = " << arg0;
- void* arg1 = (func_msg->arg(1).type() == TYPE_SCALAR && func_msg->arg(1).scalar_value().has_void_pointer()) ? reinterpret_cast<void*>(func_msg->arg(1).scalar_value().void_pointer()) : RandomVoidPointer();
- LOG(INFO) << "arg1 = " << arg1;
- uint32_t arg2 = (func_msg->arg(2).type() == TYPE_SCALAR && func_msg->arg(2).scalar_value().has_uint32_t()) ? func_msg->arg(2).scalar_value().uint32_t() : RandomUint32();
- LOG(INFO) << "arg2 = " << arg2;
- int32_t arg3 = (func_msg->arg(3).type() == TYPE_SCALAR && func_msg->arg(3).scalar_value().has_int32_t()) ? func_msg->arg(3).scalar_value().int32_t() : RandomInt32();
- LOG(INFO) << "arg3 = " << arg3;
- typedef void* (*func_type_send)(...);
- *result = const_cast<void*>(reinterpret_cast<const void*>( ((func_type_send) target_loader_.GetLoaderFunction("send"))(
- arg0,
- arg1,
- arg2,
- arg3)));
- return true;
- }
- if (!strcmp(func_name, "fopen")) {
- char arg0[func_msg->arg(0).string_value().length() + 1];
- if (func_msg->arg(0).type() == TYPE_SCALAR && func_msg->arg(0).string_value().has_message()) {
- strcpy(arg0, func_msg->arg(0).string_value().message().c_str());
- } else {
- strcpy(arg0, RandomCharPointer());
- }
- ;
- LOG(INFO) << "arg0 = " << arg0;
- char arg1[func_msg->arg(1).string_value().length() + 1];
- if (func_msg->arg(1).type() == TYPE_SCALAR && func_msg->arg(1).string_value().has_message()) {
- strcpy(arg1, func_msg->arg(1).string_value().message().c_str());
- } else {
- strcpy(arg1, RandomCharPointer());
- }
- ;
- LOG(INFO) << "arg1 = " << arg1;
- typedef void* (*func_type_fopen)(...);
- *result = const_cast<void*>(reinterpret_cast<const void*>( ((func_type_fopen) target_loader_.GetLoaderFunction("fopen"))(
- arg0,
- arg1)));
- return true;
- }
- if (!strcmp(func_name, "read")) {
- int32_t arg0 = (func_msg->arg(0).type() == TYPE_SCALAR && func_msg->arg(0).scalar_value().has_int32_t()) ? func_msg->arg(0).scalar_value().int32_t() : RandomInt32();
- LOG(INFO) << "arg0 = " << arg0;
- void* arg1 = (func_msg->arg(1).type() == TYPE_SCALAR && func_msg->arg(1).scalar_value().has_void_pointer()) ? reinterpret_cast<void*>(func_msg->arg(1).scalar_value().void_pointer()) : RandomVoidPointer();
- LOG(INFO) << "arg1 = " << arg1;
- uint32_t arg2 = (func_msg->arg(2).type() == TYPE_SCALAR && func_msg->arg(2).scalar_value().has_uint32_t()) ? func_msg->arg(2).scalar_value().uint32_t() : RandomUint32();
- LOG(INFO) << "arg2 = " << arg2;
- typedef void* (*func_type_read)(...);
- *result = const_cast<void*>(reinterpret_cast<const void*>( ((func_type_read) target_loader_.GetLoaderFunction("read"))(
- arg0,
- arg1,
- arg2)));
- return true;
- }
- if (!strcmp(func_name, "write")) {
- int32_t arg0 = (func_msg->arg(0).type() == TYPE_SCALAR && func_msg->arg(0).scalar_value().has_int32_t()) ? func_msg->arg(0).scalar_value().int32_t() : RandomInt32();
- LOG(INFO) << "arg0 = " << arg0;
- void* arg1 = (func_msg->arg(1).type() == TYPE_SCALAR && func_msg->arg(1).scalar_value().has_void_pointer()) ? reinterpret_cast<void*>(func_msg->arg(1).scalar_value().void_pointer()) : RandomVoidPointer();
- LOG(INFO) << "arg1 = " << arg1;
- int32_t arg2 = (func_msg->arg(2).type() == TYPE_SCALAR && func_msg->arg(2).scalar_value().has_int32_t()) ? func_msg->arg(2).scalar_value().int32_t() : RandomInt32();
- LOG(INFO) << "arg2 = " << arg2;
- typedef void* (*func_type_write)(...);
- *result = const_cast<void*>(reinterpret_cast<const void*>( ((func_type_write) target_loader_.GetLoaderFunction("write"))(
- arg0,
- arg1,
- arg2)));
- return true;
- }
- if (!strcmp(func_name, "lseek")) {
- int32_t arg0 = (func_msg->arg(0).type() == TYPE_SCALAR && func_msg->arg(0).scalar_value().has_int32_t()) ? func_msg->arg(0).scalar_value().int32_t() : RandomInt32();
- LOG(INFO) << "arg0 = " << arg0;
- int32_t arg1 = (func_msg->arg(1).type() == TYPE_SCALAR && func_msg->arg(1).scalar_value().has_int32_t()) ? func_msg->arg(1).scalar_value().int32_t() : RandomInt32();
- LOG(INFO) << "arg1 = " << arg1;
- int32_t arg2 = (func_msg->arg(2).type() == TYPE_SCALAR && func_msg->arg(2).scalar_value().has_int32_t()) ? func_msg->arg(2).scalar_value().int32_t() : RandomInt32();
- LOG(INFO) << "arg2 = " << arg2;
- typedef void* (*func_type_lseek)(...);
- *result = const_cast<void*>(reinterpret_cast<const void*>( ((func_type_lseek) target_loader_.GetLoaderFunction("lseek"))(
- arg0,
- arg1,
- arg2)));
- return true;
- }
- if (!strcmp(func_name, "close")) {
- int32_t arg0 = (func_msg->arg(0).type() == TYPE_SCALAR && func_msg->arg(0).scalar_value().has_int32_t()) ? func_msg->arg(0).scalar_value().int32_t() : RandomInt32();
- LOG(INFO) << "arg0 = " << arg0;
- typedef void* (*func_type_close)(...);
- *result = const_cast<void*>(reinterpret_cast<const void*>( ((func_type_close) target_loader_.GetLoaderFunction("close"))(
- arg0)));
- return true;
- }
- return false;
-}
-bool FuzzerExtended_libc::GetAttribute(
- FunctionSpecificationMessage* func_msg,
- void** result) {
- const char* func_name = func_msg->name().c_str();
- LOG(INFO) << " '" << func_name << "'";
- LOG(ERROR) << "attribute not supported for shared lib yet.";
- return false;
-}
-bool FuzzerExtended_libc::CallFunction(const FunctionSpecificationMessage&, const string&, FunctionSpecificationMessage* ) {
- /* No implementation yet. */
- return true;
-}
-bool FuzzerExtended_libc::VerifyResults(const FunctionSpecificationMessage&, const FunctionSpecificationMessage&) {
- /* No implementation yet. */
- return true;
-}
-extern "C" {
-android::vts::DriverBase* vts_func_11_1002_V1_0_() {
- return (android::vts::DriverBase*) new android::vts::FuzzerExtended_libc();
-}
-
-}
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/test/golden/DRIVER/test/vts/specification/lib/ndk/bionic/1.0/libcV1.vts.h b/compilation_tools/vtsc/test/golden/DRIVER/test/vts/specification/lib/ndk/bionic/1.0/libcV1.vts.h
deleted file mode 100644
index 92fce14..0000000
--- a/compilation_tools/vtsc/test/golden/DRIVER/test/vts/specification/lib/ndk/bionic/1.0/libcV1.vts.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef __VTS_DRIVER__lib_shared_bionic_libc_V1_0__
-#define __VTS_DRIVER__lib_shared_bionic_libc_V1_0__
-
-#undef LOG_TAG
-#define LOG_TAG "FuzzerExtended_libc"
-#include <unistd.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <linux/socket.h>
-
-#include <log/log.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <driver_base/DriverBase.h>
-#include <driver_base/DriverCallbackBase.h>
-
-namespace android {
-namespace vts {
-class FuzzerExtended_libc : public DriverBase {
- public:
- FuzzerExtended_libc() : DriverBase(LIB_SHARED) {}
- protected:
- bool Fuzz(FunctionSpecificationMessage* func_msg, void** result, const string& callback_socket_name);
- bool CallFunction(const FunctionSpecificationMessage& func_msg, const string& callback_socket_name, FunctionSpecificationMessage* result_msg);
- bool VerifyResults(const FunctionSpecificationMessage& expected_result, const FunctionSpecificationMessage& actual_result);
- bool GetAttribute(FunctionSpecificationMessage* func_msg, void** result);
- private:
-};
-
-
-extern "C" {
-extern android::vts::DriverBase* vts_func_11_1002_V1_0_();
-}
-} // namespace vts
-} // namespace android
-#endif
diff --git a/compilation_tools/vtsc/test/golden/DRIVER/types.driver.cpp b/compilation_tools/vtsc/test/golden/DRIVER/types.driver.cpp
deleted file mode 100644
index 63d0b9a..0000000
--- a/compilation_tools/vtsc/test/golden/DRIVER/types.driver.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-#include "android/hardware/nfc/1.0/types.vts.h"
-#include "vts_measurement.h"
-#include <android-base/logging.h>
-#include <android/hidl/allocator/1.0/IAllocator.h>
-#include <fcntl.h>
-#include <fmq/MessageQueue.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-
-using namespace android::hardware::nfc::V1_0;
-namespace android {
-namespace vts {
-extern "C" void MessageTo__android__hardware__nfc__V1_0__NfcEvent(const VariableSpecificationMessage& var_msg __attribute__((__unused__)), ::android::hardware::nfc::V1_0::NfcEvent* arg __attribute__((__unused__)), const string& callback_socket_name __attribute__((__unused__))) {
- *arg = (::android::hardware::nfc::V1_0::NfcEvent)var_msg.scalar_value().uint32_t();
-}
-uint32_t Random__android__hardware__nfc__V1_0__NfcEvent() {
- uint32_t choice = (uint32_t) rand() / 7;
- if (choice == (uint32_t) 0UL) return static_cast<uint32_t>(::android::hardware::nfc::V1_0::NfcEvent::OPEN_CPLT);
- if (choice == (uint32_t) 1UL) return static_cast<uint32_t>(::android::hardware::nfc::V1_0::NfcEvent::CLOSE_CPLT);
- if (choice == (uint32_t) 2UL) return static_cast<uint32_t>(::android::hardware::nfc::V1_0::NfcEvent::POST_INIT_CPLT);
- if (choice == (uint32_t) 3UL) return static_cast<uint32_t>(::android::hardware::nfc::V1_0::NfcEvent::PRE_DISCOVER_CPLT);
- if (choice == (uint32_t) 4UL) return static_cast<uint32_t>(::android::hardware::nfc::V1_0::NfcEvent::REQUEST_CONTROL);
- if (choice == (uint32_t) 5UL) return static_cast<uint32_t>(::android::hardware::nfc::V1_0::NfcEvent::RELEASE_CONTROL);
- if (choice == (uint32_t) 6UL) return static_cast<uint32_t>(::android::hardware::nfc::V1_0::NfcEvent::ERROR);
- return static_cast<uint32_t>(::android::hardware::nfc::V1_0::NfcEvent::OPEN_CPLT);
-}
-bool Verify__android__hardware__nfc__V1_0__NfcEvent(const VariableSpecificationMessage& expected_result __attribute__((__unused__)), const VariableSpecificationMessage& actual_result __attribute__((__unused__))){
- if (actual_result.scalar_value().uint32_t() != expected_result.scalar_value().uint32_t()) { return false; }
- return true;
-}
-
-extern "C" void SetResult__android__hardware__nfc__V1_0__NfcEvent(VariableSpecificationMessage* result_msg, ::android::hardware::nfc::V1_0::NfcEvent result_value __attribute__((__unused__))){
- result_msg->set_type(TYPE_ENUM);
- result_msg->set_scalar_type("uint32_t");
- result_msg->mutable_scalar_value()->set_uint32_t(static_cast<uint32_t>(result_value));
-}
-
-extern "C" void MessageTo__android__hardware__nfc__V1_0__NfcStatus(const VariableSpecificationMessage& var_msg __attribute__((__unused__)), ::android::hardware::nfc::V1_0::NfcStatus* arg __attribute__((__unused__)), const string& callback_socket_name __attribute__((__unused__))) {
- *arg = (::android::hardware::nfc::V1_0::NfcStatus)var_msg.scalar_value().uint32_t();
-}
-uint32_t Random__android__hardware__nfc__V1_0__NfcStatus() {
- uint32_t choice = (uint32_t) rand() / 5;
- if (choice == (uint32_t) 0UL) return static_cast<uint32_t>(::android::hardware::nfc::V1_0::NfcStatus::OK);
- if (choice == (uint32_t) 1UL) return static_cast<uint32_t>(::android::hardware::nfc::V1_0::NfcStatus::FAILED);
- if (choice == (uint32_t) 2UL) return static_cast<uint32_t>(::android::hardware::nfc::V1_0::NfcStatus::ERR_TRANSPORT);
- if (choice == (uint32_t) 3UL) return static_cast<uint32_t>(::android::hardware::nfc::V1_0::NfcStatus::ERR_CMD_TIMEOUT);
- if (choice == (uint32_t) 4UL) return static_cast<uint32_t>(::android::hardware::nfc::V1_0::NfcStatus::REFUSED);
- return static_cast<uint32_t>(::android::hardware::nfc::V1_0::NfcStatus::OK);
-}
-bool Verify__android__hardware__nfc__V1_0__NfcStatus(const VariableSpecificationMessage& expected_result __attribute__((__unused__)), const VariableSpecificationMessage& actual_result __attribute__((__unused__))){
- if (actual_result.scalar_value().uint32_t() != expected_result.scalar_value().uint32_t()) { return false; }
- return true;
-}
-
-extern "C" void SetResult__android__hardware__nfc__V1_0__NfcStatus(VariableSpecificationMessage* result_msg, ::android::hardware::nfc::V1_0::NfcStatus result_value __attribute__((__unused__))){
- result_msg->set_type(TYPE_ENUM);
- result_msg->set_scalar_type("uint32_t");
- result_msg->mutable_scalar_value()->set_uint32_t(static_cast<uint32_t>(result_value));
-}
-
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/test/golden/DRIVER/types.vts.h b/compilation_tools/vtsc/test/golden/DRIVER/types.vts.h
deleted file mode 100644
index 0447d4a..0000000
--- a/compilation_tools/vtsc/test/golden/DRIVER/types.vts.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef __VTS_DRIVER__android_hardware_nfc_V1_0_types__
-#define __VTS_DRIVER__android_hardware_nfc_V1_0_types__
-
-#undef LOG_TAG
-#define LOG_TAG "FuzzerExtended_android_hardware_nfc_V1_0_types"
-
-#include <log/log.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <driver_base/DriverBase.h>
-#include <driver_base/DriverCallbackBase.h>
-
-#include <VtsDriverCommUtil.h>
-
-#include <android/hardware/nfc/1.0/types.h>
-#include <hidl/HidlSupport.h>
-
-
-using namespace android::hardware::nfc::V1_0;
-namespace android {
-namespace vts {
-extern "C" void MessageTo__android__hardware__nfc__V1_0__NfcEvent(const VariableSpecificationMessage& var_msg, ::android::hardware::nfc::V1_0::NfcEvent* arg, const string& callback_socket_name);
-uint32_t Random__android__hardware__nfc__V1_0__NfcEvent();
-bool Verify__android__hardware__nfc__V1_0__NfcEvent(const VariableSpecificationMessage& expected_result, const VariableSpecificationMessage& actual_result);
-extern "C" void SetResult__android__hardware__nfc__V1_0__NfcEvent(VariableSpecificationMessage* result_msg, ::android::hardware::nfc::V1_0::NfcEvent result_value);
-extern "C" void MessageTo__android__hardware__nfc__V1_0__NfcStatus(const VariableSpecificationMessage& var_msg, ::android::hardware::nfc::V1_0::NfcStatus* arg, const string& callback_socket_name);
-uint32_t Random__android__hardware__nfc__V1_0__NfcStatus();
-bool Verify__android__hardware__nfc__V1_0__NfcStatus(const VariableSpecificationMessage& expected_result, const VariableSpecificationMessage& actual_result);
-extern "C" void SetResult__android__hardware__nfc__V1_0__NfcStatus(VariableSpecificationMessage* result_msg, ::android::hardware::nfc::V1_0::NfcStatus result_value);
-
-
-} // namespace vts
-} // namespace android
-#endif
diff --git a/compilation_tools/vtsc/test/golden/FUZZER/Context.fuzzer.cpp b/compilation_tools/vtsc/test/golden/FUZZER/Context.fuzzer.cpp
deleted file mode 100644
index bc61e44..0000000
--- a/compilation_tools/vtsc/test/golden/FUZZER/Context.fuzzer.cpp
+++ /dev/null
@@ -1,2112 +0,0 @@
-// This file was auto-generated by VTS compiler.
-
-#include <iostream>
-
-#include "FuncFuzzerUtils.h"
-#include <android/hardware/renderscript/1.0/IContext.h>
-
-using std::cerr;
-using std::endl;
-using std::string;
-
-using namespace ::android::hardware::renderscript::V1_0;
-using namespace ::android::hardware;
-
-namespace android {
-namespace vts {
-
-static string target_func;
-
-extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
- FuncFuzzerParams params{ExtractFuncFuzzerParams(*argc, *argv)};
- target_func = params.target_func_;
- return 0;
-}
-
-extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- static ::android::sp<IContext> renderscript = IContext::getService(true);
- if (renderscript == nullptr) {
- cerr << "IContext::getService() failed" << endl;
- exit(1);
- }
-
- if (target_func == "allocationAdapterCreate") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint64_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint64_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- renderscript->allocationAdapterCreate(arg0, arg1);
- return 0;
- } else if (target_func == "allocationAdapterOffset") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(::android::hardware::hidl_vec<uint32_t>);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- ::android::hardware::hidl_vec<uint32_t> arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- renderscript->allocationAdapterOffset(arg0, arg1);
- return 0;
- } else if (target_func == "allocationGetType") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- renderscript->allocationGetType(arg0);
- return 0;
- } else if (target_func == "allocationCreateTyped") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(::android::hardware::renderscript::V1_0::AllocationMipmapControl);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- ::android::hardware::renderscript::V1_0::AllocationMipmapControl arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(int32_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- int32_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(void*);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- void* arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- renderscript->allocationCreateTyped(arg0, arg1, arg2, arg3);
- return 0;
- } else if (target_func == "allocationCreateFromBitmap") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(::android::hardware::renderscript::V1_0::AllocationMipmapControl);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- ::android::hardware::renderscript::V1_0::AllocationMipmapControl arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(::android::hardware::hidl_vec<uint8_t>);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- ::android::hardware::hidl_vec<uint8_t> arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(int32_t);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- int32_t arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- renderscript->allocationCreateFromBitmap(arg0, arg1, arg2, arg3);
- return 0;
- } else if (target_func == "allocationCubeCreateFromBitmap") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(::android::hardware::renderscript::V1_0::AllocationMipmapControl);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- ::android::hardware::renderscript::V1_0::AllocationMipmapControl arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(::android::hardware::hidl_vec<uint8_t>);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- ::android::hardware::hidl_vec<uint8_t> arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(int32_t);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- int32_t arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- renderscript->allocationCubeCreateFromBitmap(arg0, arg1, arg2, arg3);
- return 0;
- } else if (target_func == "allocationGetNativeWindow") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- renderscript->allocationGetNativeWindow(arg0);
- return 0;
- } else if (target_func == "allocationSetNativeWindow") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint64_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint64_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- renderscript->allocationSetNativeWindow(arg0, arg1);
- return 0;
- } else if (target_func == "allocationSetupBufferQueue") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- renderscript->allocationSetupBufferQueue(arg0, arg1);
- return 0;
- } else if (target_func == "allocationShareBufferQueue") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint64_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint64_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- renderscript->allocationShareBufferQueue(arg0, arg1);
- return 0;
- } else if (target_func == "allocationCopyToBitmap") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(void*);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- void* arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(uint64_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- uint64_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- renderscript->allocationCopyToBitmap(arg0, arg1, arg2);
- return 0;
- } else if (target_func == "allocation1DWrite") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(uint32_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- uint32_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(uint32_t);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- uint32_t arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- size_t type_size4 = sizeof(::android::hardware::hidl_vec<uint8_t>);
- if (size < type_size4) { return 0; }
- size -= type_size4;
- ::android::hardware::hidl_vec<uint8_t> arg4;
- memcpy(&arg4, data, type_size4);
- data += type_size4;
-
- renderscript->allocation1DWrite(arg0, arg1, arg2, arg3, arg4);
- return 0;
- } else if (target_func == "allocationElementWrite") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(uint32_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- uint32_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(uint32_t);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- uint32_t arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- size_t type_size4 = sizeof(uint32_t);
- if (size < type_size4) { return 0; }
- size -= type_size4;
- uint32_t arg4;
- memcpy(&arg4, data, type_size4);
- data += type_size4;
-
- size_t type_size5 = sizeof(::android::hardware::hidl_vec<uint8_t>);
- if (size < type_size5) { return 0; }
- size -= type_size5;
- ::android::hardware::hidl_vec<uint8_t> arg5;
- memcpy(&arg5, data, type_size5);
- data += type_size5;
-
- size_t type_size6 = sizeof(uint64_t);
- if (size < type_size6) { return 0; }
- size -= type_size6;
- uint64_t arg6;
- memcpy(&arg6, data, type_size6);
- data += type_size6;
-
- renderscript->allocationElementWrite(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
- return 0;
- } else if (target_func == "allocation2DWrite") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(uint32_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- uint32_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(uint32_t);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- uint32_t arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- size_t type_size4 = sizeof(::android::hardware::renderscript::V1_0::AllocationCubemapFace);
- if (size < type_size4) { return 0; }
- size -= type_size4;
- ::android::hardware::renderscript::V1_0::AllocationCubemapFace arg4;
- memcpy(&arg4, data, type_size4);
- data += type_size4;
-
- size_t type_size5 = sizeof(uint32_t);
- if (size < type_size5) { return 0; }
- size -= type_size5;
- uint32_t arg5;
- memcpy(&arg5, data, type_size5);
- data += type_size5;
-
- size_t type_size6 = sizeof(uint32_t);
- if (size < type_size6) { return 0; }
- size -= type_size6;
- uint32_t arg6;
- memcpy(&arg6, data, type_size6);
- data += type_size6;
-
- size_t type_size7 = sizeof(::android::hardware::hidl_vec<uint8_t>);
- if (size < type_size7) { return 0; }
- size -= type_size7;
- ::android::hardware::hidl_vec<uint8_t> arg7;
- memcpy(&arg7, data, type_size7);
- data += type_size7;
-
- size_t type_size8 = sizeof(uint64_t);
- if (size < type_size8) { return 0; }
- size -= type_size8;
- uint64_t arg8;
- memcpy(&arg8, data, type_size8);
- data += type_size8;
-
- renderscript->allocation2DWrite(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
- return 0;
- } else if (target_func == "allocation3DWrite") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(uint32_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- uint32_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(uint32_t);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- uint32_t arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- size_t type_size4 = sizeof(uint32_t);
- if (size < type_size4) { return 0; }
- size -= type_size4;
- uint32_t arg4;
- memcpy(&arg4, data, type_size4);
- data += type_size4;
-
- size_t type_size5 = sizeof(uint32_t);
- if (size < type_size5) { return 0; }
- size -= type_size5;
- uint32_t arg5;
- memcpy(&arg5, data, type_size5);
- data += type_size5;
-
- size_t type_size6 = sizeof(uint32_t);
- if (size < type_size6) { return 0; }
- size -= type_size6;
- uint32_t arg6;
- memcpy(&arg6, data, type_size6);
- data += type_size6;
-
- size_t type_size7 = sizeof(uint32_t);
- if (size < type_size7) { return 0; }
- size -= type_size7;
- uint32_t arg7;
- memcpy(&arg7, data, type_size7);
- data += type_size7;
-
- size_t type_size8 = sizeof(::android::hardware::hidl_vec<uint8_t>);
- if (size < type_size8) { return 0; }
- size -= type_size8;
- ::android::hardware::hidl_vec<uint8_t> arg8;
- memcpy(&arg8, data, type_size8);
- data += type_size8;
-
- size_t type_size9 = sizeof(uint64_t);
- if (size < type_size9) { return 0; }
- size -= type_size9;
- uint64_t arg9;
- memcpy(&arg9, data, type_size9);
- data += type_size9;
-
- renderscript->allocation3DWrite(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
- return 0;
- } else if (target_func == "allocationGenerateMipmaps") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- renderscript->allocationGenerateMipmaps(arg0);
- return 0;
- } else if (target_func == "allocationRead") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(void*);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- void* arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(uint64_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- uint64_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- renderscript->allocationRead(arg0, arg1, arg2);
- return 0;
- } else if (target_func == "allocation1DRead") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(uint32_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- uint32_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(uint32_t);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- uint32_t arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- size_t type_size4 = sizeof(void*);
- if (size < type_size4) { return 0; }
- size -= type_size4;
- void* arg4;
- memcpy(&arg4, data, type_size4);
- data += type_size4;
-
- size_t type_size5 = sizeof(uint64_t);
- if (size < type_size5) { return 0; }
- size -= type_size5;
- uint64_t arg5;
- memcpy(&arg5, data, type_size5);
- data += type_size5;
-
- renderscript->allocation1DRead(arg0, arg1, arg2, arg3, arg4, arg5);
- return 0;
- } else if (target_func == "allocationElementRead") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(uint32_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- uint32_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(uint32_t);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- uint32_t arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- size_t type_size4 = sizeof(uint32_t);
- if (size < type_size4) { return 0; }
- size -= type_size4;
- uint32_t arg4;
- memcpy(&arg4, data, type_size4);
- data += type_size4;
-
- size_t type_size5 = sizeof(void*);
- if (size < type_size5) { return 0; }
- size -= type_size5;
- void* arg5;
- memcpy(&arg5, data, type_size5);
- data += type_size5;
-
- size_t type_size6 = sizeof(uint64_t);
- if (size < type_size6) { return 0; }
- size -= type_size6;
- uint64_t arg6;
- memcpy(&arg6, data, type_size6);
- data += type_size6;
-
- size_t type_size7 = sizeof(uint64_t);
- if (size < type_size7) { return 0; }
- size -= type_size7;
- uint64_t arg7;
- memcpy(&arg7, data, type_size7);
- data += type_size7;
-
- renderscript->allocationElementRead(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
- return 0;
- } else if (target_func == "allocation2DRead") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(uint32_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- uint32_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(uint32_t);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- uint32_t arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- size_t type_size4 = sizeof(::android::hardware::renderscript::V1_0::AllocationCubemapFace);
- if (size < type_size4) { return 0; }
- size -= type_size4;
- ::android::hardware::renderscript::V1_0::AllocationCubemapFace arg4;
- memcpy(&arg4, data, type_size4);
- data += type_size4;
-
- size_t type_size5 = sizeof(uint32_t);
- if (size < type_size5) { return 0; }
- size -= type_size5;
- uint32_t arg5;
- memcpy(&arg5, data, type_size5);
- data += type_size5;
-
- size_t type_size6 = sizeof(uint32_t);
- if (size < type_size6) { return 0; }
- size -= type_size6;
- uint32_t arg6;
- memcpy(&arg6, data, type_size6);
- data += type_size6;
-
- size_t type_size7 = sizeof(void*);
- if (size < type_size7) { return 0; }
- size -= type_size7;
- void* arg7;
- memcpy(&arg7, data, type_size7);
- data += type_size7;
-
- size_t type_size8 = sizeof(uint64_t);
- if (size < type_size8) { return 0; }
- size -= type_size8;
- uint64_t arg8;
- memcpy(&arg8, data, type_size8);
- data += type_size8;
-
- size_t type_size9 = sizeof(uint64_t);
- if (size < type_size9) { return 0; }
- size -= type_size9;
- uint64_t arg9;
- memcpy(&arg9, data, type_size9);
- data += type_size9;
-
- renderscript->allocation2DRead(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
- return 0;
- } else if (target_func == "allocation3DRead") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(uint32_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- uint32_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(uint32_t);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- uint32_t arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- size_t type_size4 = sizeof(uint32_t);
- if (size < type_size4) { return 0; }
- size -= type_size4;
- uint32_t arg4;
- memcpy(&arg4, data, type_size4);
- data += type_size4;
-
- size_t type_size5 = sizeof(uint32_t);
- if (size < type_size5) { return 0; }
- size -= type_size5;
- uint32_t arg5;
- memcpy(&arg5, data, type_size5);
- data += type_size5;
-
- size_t type_size6 = sizeof(uint32_t);
- if (size < type_size6) { return 0; }
- size -= type_size6;
- uint32_t arg6;
- memcpy(&arg6, data, type_size6);
- data += type_size6;
-
- size_t type_size7 = sizeof(uint32_t);
- if (size < type_size7) { return 0; }
- size -= type_size7;
- uint32_t arg7;
- memcpy(&arg7, data, type_size7);
- data += type_size7;
-
- size_t type_size8 = sizeof(void*);
- if (size < type_size8) { return 0; }
- size -= type_size8;
- void* arg8;
- memcpy(&arg8, data, type_size8);
- data += type_size8;
-
- size_t type_size9 = sizeof(uint64_t);
- if (size < type_size9) { return 0; }
- size -= type_size9;
- uint64_t arg9;
- memcpy(&arg9, data, type_size9);
- data += type_size9;
-
- size_t type_size10 = sizeof(uint64_t);
- if (size < type_size10) { return 0; }
- size -= type_size10;
- uint64_t arg10;
- memcpy(&arg10, data, type_size10);
- data += type_size10;
-
- renderscript->allocation3DRead(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
- return 0;
- } else if (target_func == "allocationSyncAll") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(::android::hardware::renderscript::V1_0::AllocationUsageType);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- ::android::hardware::renderscript::V1_0::AllocationUsageType arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- renderscript->allocationSyncAll(arg0, arg1);
- return 0;
- } else if (target_func == "allocationResize1D") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- renderscript->allocationResize1D(arg0, arg1);
- return 0;
- } else if (target_func == "allocationCopy2DRange") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(uint32_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- uint32_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(uint32_t);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- uint32_t arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- size_t type_size4 = sizeof(::android::hardware::renderscript::V1_0::AllocationCubemapFace);
- if (size < type_size4) { return 0; }
- size -= type_size4;
- ::android::hardware::renderscript::V1_0::AllocationCubemapFace arg4;
- memcpy(&arg4, data, type_size4);
- data += type_size4;
-
- size_t type_size5 = sizeof(uint32_t);
- if (size < type_size5) { return 0; }
- size -= type_size5;
- uint32_t arg5;
- memcpy(&arg5, data, type_size5);
- data += type_size5;
-
- size_t type_size6 = sizeof(uint32_t);
- if (size < type_size6) { return 0; }
- size -= type_size6;
- uint32_t arg6;
- memcpy(&arg6, data, type_size6);
- data += type_size6;
-
- size_t type_size7 = sizeof(uint64_t);
- if (size < type_size7) { return 0; }
- size -= type_size7;
- uint64_t arg7;
- memcpy(&arg7, data, type_size7);
- data += type_size7;
-
- size_t type_size8 = sizeof(uint32_t);
- if (size < type_size8) { return 0; }
- size -= type_size8;
- uint32_t arg8;
- memcpy(&arg8, data, type_size8);
- data += type_size8;
-
- size_t type_size9 = sizeof(uint32_t);
- if (size < type_size9) { return 0; }
- size -= type_size9;
- uint32_t arg9;
- memcpy(&arg9, data, type_size9);
- data += type_size9;
-
- size_t type_size10 = sizeof(uint32_t);
- if (size < type_size10) { return 0; }
- size -= type_size10;
- uint32_t arg10;
- memcpy(&arg10, data, type_size10);
- data += type_size10;
-
- size_t type_size11 = sizeof(::android::hardware::renderscript::V1_0::AllocationCubemapFace);
- if (size < type_size11) { return 0; }
- size -= type_size11;
- ::android::hardware::renderscript::V1_0::AllocationCubemapFace arg11;
- memcpy(&arg11, data, type_size11);
- data += type_size11;
-
- renderscript->allocationCopy2DRange(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11);
- return 0;
- } else if (target_func == "allocationCopy3DRange") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(uint32_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- uint32_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(uint32_t);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- uint32_t arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- size_t type_size4 = sizeof(uint32_t);
- if (size < type_size4) { return 0; }
- size -= type_size4;
- uint32_t arg4;
- memcpy(&arg4, data, type_size4);
- data += type_size4;
-
- size_t type_size5 = sizeof(uint32_t);
- if (size < type_size5) { return 0; }
- size -= type_size5;
- uint32_t arg5;
- memcpy(&arg5, data, type_size5);
- data += type_size5;
-
- size_t type_size6 = sizeof(uint32_t);
- if (size < type_size6) { return 0; }
- size -= type_size6;
- uint32_t arg6;
- memcpy(&arg6, data, type_size6);
- data += type_size6;
-
- size_t type_size7 = sizeof(uint32_t);
- if (size < type_size7) { return 0; }
- size -= type_size7;
- uint32_t arg7;
- memcpy(&arg7, data, type_size7);
- data += type_size7;
-
- size_t type_size8 = sizeof(uint64_t);
- if (size < type_size8) { return 0; }
- size -= type_size8;
- uint64_t arg8;
- memcpy(&arg8, data, type_size8);
- data += type_size8;
-
- size_t type_size9 = sizeof(uint32_t);
- if (size < type_size9) { return 0; }
- size -= type_size9;
- uint32_t arg9;
- memcpy(&arg9, data, type_size9);
- data += type_size9;
-
- size_t type_size10 = sizeof(uint32_t);
- if (size < type_size10) { return 0; }
- size -= type_size10;
- uint32_t arg10;
- memcpy(&arg10, data, type_size10);
- data += type_size10;
-
- size_t type_size11 = sizeof(uint32_t);
- if (size < type_size11) { return 0; }
- size -= type_size11;
- uint32_t arg11;
- memcpy(&arg11, data, type_size11);
- data += type_size11;
-
- size_t type_size12 = sizeof(uint32_t);
- if (size < type_size12) { return 0; }
- size -= type_size12;
- uint32_t arg12;
- memcpy(&arg12, data, type_size12);
- data += type_size12;
-
- renderscript->allocationCopy3DRange(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
- return 0;
- } else if (target_func == "allocationIoSend") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- renderscript->allocationIoSend(arg0);
- return 0;
- } else if (target_func == "allocationIoReceive") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- renderscript->allocationIoReceive(arg0);
- return 0;
- } else if (target_func == "allocationGetPointer") {
- // No-op. Only need this to make HAL function call.
- auto hidl_cb = [](void* arg0, uint64_t arg1){};
-
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(::android::hardware::renderscript::V1_0::AllocationCubemapFace);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- ::android::hardware::renderscript::V1_0::AllocationCubemapFace arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(uint32_t);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- uint32_t arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- renderscript->allocationGetPointer(arg0, arg1, arg2, arg3, hidl_cb);
- return 0;
- } else if (target_func == "elementGetNativeMetadata") {
- // No-op. Only need this to make HAL function call.
- auto hidl_cb = [](const ::android::hardware::hidl_vec<uint32_t>& arg0){};
-
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- renderscript->elementGetNativeMetadata(arg0, hidl_cb);
- return 0;
- } else if (target_func == "elementGetSubElements") {
- // No-op. Only need this to make HAL function call.
- auto hidl_cb = [](const ::android::hardware::hidl_vec<uint64_t>& arg0, const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& arg1, const ::android::hardware::hidl_vec<uint64_t>& arg2){};
-
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint64_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint64_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- renderscript->elementGetSubElements(arg0, arg1, hidl_cb);
- return 0;
- } else if (target_func == "elementCreate") {
- size_t type_size0 = sizeof(::android::hardware::renderscript::V1_0::DataType);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- ::android::hardware::renderscript::V1_0::DataType arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(::android::hardware::renderscript::V1_0::DataKind);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- ::android::hardware::renderscript::V1_0::DataKind arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(bool);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- bool arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(uint32_t);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- uint32_t arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- renderscript->elementCreate(arg0, arg1, arg2, arg3);
- return 0;
- } else if (target_func == "elementComplexCreate") {
- size_t type_size0 = sizeof(::android::hardware::hidl_vec<uint64_t>);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- ::android::hardware::hidl_vec<uint64_t> arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(::android::hardware::hidl_vec<::android::hardware::hidl_string>);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- ::android::hardware::hidl_vec<::android::hardware::hidl_string> arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(::android::hardware::hidl_vec<uint64_t>);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- ::android::hardware::hidl_vec<uint64_t> arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- renderscript->elementComplexCreate(arg0, arg1, arg2);
- return 0;
- } else if (target_func == "typeGetNativeMetadata") {
- // No-op. Only need this to make HAL function call.
- auto hidl_cb = [](const ::android::hardware::hidl_vec<uint64_t>& arg0){};
-
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- renderscript->typeGetNativeMetadata(arg0, hidl_cb);
- return 0;
- } else if (target_func == "typeCreate") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(uint32_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- uint32_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(uint32_t);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- uint32_t arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- size_t type_size4 = sizeof(bool);
- if (size < type_size4) { return 0; }
- size -= type_size4;
- bool arg4;
- memcpy(&arg4, data, type_size4);
- data += type_size4;
-
- size_t type_size5 = sizeof(bool);
- if (size < type_size5) { return 0; }
- size -= type_size5;
- bool arg5;
- memcpy(&arg5, data, type_size5);
- data += type_size5;
-
- size_t type_size6 = sizeof(::android::hardware::renderscript::V1_0::YuvFormat);
- if (size < type_size6) { return 0; }
- size -= type_size6;
- ::android::hardware::renderscript::V1_0::YuvFormat arg6;
- memcpy(&arg6, data, type_size6);
- data += type_size6;
-
- renderscript->typeCreate(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
- return 0;
- } else if (target_func == "contextDestroy") {
- renderscript->contextDestroy();
- return 0;
- } else if (target_func == "contextGetMessage") {
- // No-op. Only need this to make HAL function call.
- auto hidl_cb = [](::android::hardware::renderscript::V1_0::MessageToClientType arg0, uint64_t arg1){};
-
- size_t type_size0 = sizeof(void*);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- void* arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint64_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint64_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- renderscript->contextGetMessage(arg0, arg1, hidl_cb);
- return 0;
- } else if (target_func == "contextPeekMessage") {
- // No-op. Only need this to make HAL function call.
- auto hidl_cb = [](::android::hardware::renderscript::V1_0::MessageToClientType arg0, uint64_t arg1, uint32_t arg2){};
-
- renderscript->contextPeekMessage(hidl_cb);
- return 0;
- } else if (target_func == "contextSendMessage") {
- size_t type_size0 = sizeof(uint32_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint32_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(::android::hardware::hidl_vec<uint8_t>);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- ::android::hardware::hidl_vec<uint8_t> arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- renderscript->contextSendMessage(arg0, arg1);
- return 0;
- } else if (target_func == "contextInitToClient") {
- renderscript->contextInitToClient();
- return 0;
- } else if (target_func == "contextDeinitToClient") {
- renderscript->contextDeinitToClient();
- return 0;
- } else if (target_func == "contextFinish") {
- renderscript->contextFinish();
- return 0;
- } else if (target_func == "contextLog") {
- renderscript->contextLog();
- return 0;
- } else if (target_func == "contextSetCacheDir") {
- size_t type_size0 = sizeof(::android::hardware::hidl_string);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- ::android::hardware::hidl_string arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- renderscript->contextSetCacheDir(arg0);
- return 0;
- } else if (target_func == "contextSetPriority") {
- size_t type_size0 = sizeof(::android::hardware::renderscript::V1_0::ThreadPriorities);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- ::android::hardware::renderscript::V1_0::ThreadPriorities arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- renderscript->contextSetPriority(arg0);
- return 0;
- } else if (target_func == "assignName") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(::android::hardware::hidl_string);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- ::android::hardware::hidl_string arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- renderscript->assignName(arg0, arg1);
- return 0;
- } else if (target_func == "getName") {
- // No-op. Only need this to make HAL function call.
- auto hidl_cb = [](const ::android::hardware::hidl_string& arg0){};
-
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- renderscript->getName(arg0, hidl_cb);
- return 0;
- } else if (target_func == "closureCreate") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint64_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint64_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(::android::hardware::hidl_vec<uint64_t>);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- ::android::hardware::hidl_vec<uint64_t> arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(::android::hardware::hidl_vec<int64_t>);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- ::android::hardware::hidl_vec<int64_t> arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- size_t type_size4 = sizeof(::android::hardware::hidl_vec<int32_t>);
- if (size < type_size4) { return 0; }
- size -= type_size4;
- ::android::hardware::hidl_vec<int32_t> arg4;
- memcpy(&arg4, data, type_size4);
- data += type_size4;
-
- size_t type_size5 = sizeof(::android::hardware::hidl_vec<uint64_t>);
- if (size < type_size5) { return 0; }
- size -= type_size5;
- ::android::hardware::hidl_vec<uint64_t> arg5;
- memcpy(&arg5, data, type_size5);
- data += type_size5;
-
- size_t type_size6 = sizeof(::android::hardware::hidl_vec<uint64_t>);
- if (size < type_size6) { return 0; }
- size -= type_size6;
- ::android::hardware::hidl_vec<uint64_t> arg6;
- memcpy(&arg6, data, type_size6);
- data += type_size6;
-
- renderscript->closureCreate(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
- return 0;
- } else if (target_func == "invokeClosureCreate") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(::android::hardware::hidl_vec<uint8_t>);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- ::android::hardware::hidl_vec<uint8_t> arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(::android::hardware::hidl_vec<uint64_t>);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- ::android::hardware::hidl_vec<uint64_t> arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(::android::hardware::hidl_vec<int64_t>);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- ::android::hardware::hidl_vec<int64_t> arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- size_t type_size4 = sizeof(::android::hardware::hidl_vec<int32_t>);
- if (size < type_size4) { return 0; }
- size -= type_size4;
- ::android::hardware::hidl_vec<int32_t> arg4;
- memcpy(&arg4, data, type_size4);
- data += type_size4;
-
- renderscript->invokeClosureCreate(arg0, arg1, arg2, arg3, arg4);
- return 0;
- } else if (target_func == "closureSetArg") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(void*);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- void* arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(int32_t);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- int32_t arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- renderscript->closureSetArg(arg0, arg1, arg2, arg3);
- return 0;
- } else if (target_func == "closureSetGlobal") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint64_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint64_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(int64_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- int64_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(int32_t);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- int32_t arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- renderscript->closureSetGlobal(arg0, arg1, arg2, arg3);
- return 0;
- } else if (target_func == "scriptKernelIDCreate") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(int32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- int32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(int32_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- int32_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- renderscript->scriptKernelIDCreate(arg0, arg1, arg2);
- return 0;
- } else if (target_func == "scriptInvokeIDCreate") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(int32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- int32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- renderscript->scriptInvokeIDCreate(arg0, arg1);
- return 0;
- } else if (target_func == "scriptFieldIDCreate") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(int32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- int32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- renderscript->scriptFieldIDCreate(arg0, arg1);
- return 0;
- } else if (target_func == "scriptGroupCreate") {
- size_t type_size0 = sizeof(::android::hardware::hidl_vec<uint64_t>);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- ::android::hardware::hidl_vec<uint64_t> arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(::android::hardware::hidl_vec<uint64_t>);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- ::android::hardware::hidl_vec<uint64_t> arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(::android::hardware::hidl_vec<uint64_t>);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- ::android::hardware::hidl_vec<uint64_t> arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(::android::hardware::hidl_vec<uint64_t>);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- ::android::hardware::hidl_vec<uint64_t> arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- size_t type_size4 = sizeof(::android::hardware::hidl_vec<uint64_t>);
- if (size < type_size4) { return 0; }
- size -= type_size4;
- ::android::hardware::hidl_vec<uint64_t> arg4;
- memcpy(&arg4, data, type_size4);
- data += type_size4;
-
- renderscript->scriptGroupCreate(arg0, arg1, arg2, arg3, arg4);
- return 0;
- } else if (target_func == "scriptGroup2Create") {
- size_t type_size0 = sizeof(::android::hardware::hidl_string);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- ::android::hardware::hidl_string arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(::android::hardware::hidl_string);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- ::android::hardware::hidl_string arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(::android::hardware::hidl_vec<uint64_t>);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- ::android::hardware::hidl_vec<uint64_t> arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- renderscript->scriptGroup2Create(arg0, arg1, arg2);
- return 0;
- } else if (target_func == "scriptGroupSetOutput") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint64_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint64_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(uint64_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- uint64_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- renderscript->scriptGroupSetOutput(arg0, arg1, arg2);
- return 0;
- } else if (target_func == "scriptGroupSetInput") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint64_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint64_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(uint64_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- uint64_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- renderscript->scriptGroupSetInput(arg0, arg1, arg2);
- return 0;
- } else if (target_func == "scriptGroupExecute") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- renderscript->scriptGroupExecute(arg0);
- return 0;
- } else if (target_func == "objDestroy") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- renderscript->objDestroy(arg0);
- return 0;
- } else if (target_func == "samplerCreate") {
- size_t type_size0 = sizeof(::android::hardware::renderscript::V1_0::SamplerValue);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- ::android::hardware::renderscript::V1_0::SamplerValue arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(::android::hardware::renderscript::V1_0::SamplerValue);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- ::android::hardware::renderscript::V1_0::SamplerValue arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(::android::hardware::renderscript::V1_0::SamplerValue);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- ::android::hardware::renderscript::V1_0::SamplerValue arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(::android::hardware::renderscript::V1_0::SamplerValue);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- ::android::hardware::renderscript::V1_0::SamplerValue arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- size_t type_size4 = sizeof(::android::hardware::renderscript::V1_0::SamplerValue);
- if (size < type_size4) { return 0; }
- size -= type_size4;
- ::android::hardware::renderscript::V1_0::SamplerValue arg4;
- memcpy(&arg4, data, type_size4);
- data += type_size4;
-
- size_t type_size5 = sizeof(float);
- if (size < type_size5) { return 0; }
- size -= type_size5;
- float arg5;
- memcpy(&arg5, data, type_size5);
- data += type_size5;
-
- renderscript->samplerCreate(arg0, arg1, arg2, arg3, arg4, arg5);
- return 0;
- } else if (target_func == "scriptBindAllocation") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint64_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint64_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(uint32_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- uint32_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- renderscript->scriptBindAllocation(arg0, arg1, arg2);
- return 0;
- } else if (target_func == "scriptSetTimeZone") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(::android::hardware::hidl_string);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- ::android::hardware::hidl_string arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- renderscript->scriptSetTimeZone(arg0, arg1);
- return 0;
- } else if (target_func == "scriptInvoke") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- renderscript->scriptInvoke(arg0, arg1);
- return 0;
- } else if (target_func == "scriptInvokeV") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(::android::hardware::hidl_vec<uint8_t>);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- ::android::hardware::hidl_vec<uint8_t> arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- renderscript->scriptInvokeV(arg0, arg1, arg2);
- return 0;
- } else if (target_func == "scriptForEach") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(::android::hardware::hidl_vec<uint64_t>);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- ::android::hardware::hidl_vec<uint64_t> arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(uint64_t);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- uint64_t arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- size_t type_size4 = sizeof(::android::hardware::hidl_vec<uint8_t>);
- if (size < type_size4) { return 0; }
- size -= type_size4;
- ::android::hardware::hidl_vec<uint8_t> arg4;
- memcpy(&arg4, data, type_size4);
- data += type_size4;
-
- size_t type_size5 = sizeof(void*);
- if (size < type_size5) { return 0; }
- size -= type_size5;
- void* arg5;
- memcpy(&arg5, data, type_size5);
- data += type_size5;
-
- renderscript->scriptForEach(arg0, arg1, arg2, arg3, arg4, arg5);
- return 0;
- } else if (target_func == "scriptReduce") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(::android::hardware::hidl_vec<uint64_t>);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- ::android::hardware::hidl_vec<uint64_t> arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(uint64_t);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- uint64_t arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- size_t type_size4 = sizeof(void*);
- if (size < type_size4) { return 0; }
- size -= type_size4;
- void* arg4;
- memcpy(&arg4, data, type_size4);
- data += type_size4;
-
- renderscript->scriptReduce(arg0, arg1, arg2, arg3, arg4);
- return 0;
- } else if (target_func == "scriptSetVarI") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(int32_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- int32_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- renderscript->scriptSetVarI(arg0, arg1, arg2);
- return 0;
- } else if (target_func == "scriptSetVarObj") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(uint64_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- uint64_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- renderscript->scriptSetVarObj(arg0, arg1, arg2);
- return 0;
- } else if (target_func == "scriptSetVarJ") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(int64_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- int64_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- renderscript->scriptSetVarJ(arg0, arg1, arg2);
- return 0;
- } else if (target_func == "scriptSetVarF") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(float);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- float arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- renderscript->scriptSetVarF(arg0, arg1, arg2);
- return 0;
- } else if (target_func == "scriptSetVarD") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(double);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- double arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- renderscript->scriptSetVarD(arg0, arg1, arg2);
- return 0;
- } else if (target_func == "scriptSetVarV") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(::android::hardware::hidl_vec<uint8_t>);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- ::android::hardware::hidl_vec<uint8_t> arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- renderscript->scriptSetVarV(arg0, arg1, arg2);
- return 0;
- } else if (target_func == "scriptGetVarV") {
- // No-op. Only need this to make HAL function call.
- auto hidl_cb = [](const ::android::hardware::hidl_vec<uint8_t>& arg0){};
-
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(uint64_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- uint64_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- renderscript->scriptGetVarV(arg0, arg1, arg2, hidl_cb);
- return 0;
- } else if (target_func == "scriptSetVarVE") {
- size_t type_size0 = sizeof(uint64_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint64_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint32_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint32_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(::android::hardware::hidl_vec<uint8_t>);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- ::android::hardware::hidl_vec<uint8_t> arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- size_t type_size3 = sizeof(uint64_t);
- if (size < type_size3) { return 0; }
- size -= type_size3;
- uint64_t arg3;
- memcpy(&arg3, data, type_size3);
- data += type_size3;
-
- size_t type_size4 = sizeof(::android::hardware::hidl_vec<uint32_t>);
- if (size < type_size4) { return 0; }
- size -= type_size4;
- ::android::hardware::hidl_vec<uint32_t> arg4;
- memcpy(&arg4, data, type_size4);
- data += type_size4;
-
- renderscript->scriptSetVarVE(arg0, arg1, arg2, arg3, arg4);
- return 0;
- } else if (target_func == "scriptCCreate") {
- size_t type_size0 = sizeof(::android::hardware::hidl_string);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- ::android::hardware::hidl_string arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(::android::hardware::hidl_string);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- ::android::hardware::hidl_string arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(::android::hardware::hidl_vec<uint8_t>);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- ::android::hardware::hidl_vec<uint8_t> arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- renderscript->scriptCCreate(arg0, arg1, arg2);
- return 0;
- } else if (target_func == "scriptIntrinsicCreate") {
- size_t type_size0 = sizeof(::android::hardware::renderscript::V1_0::ScriptIntrinsicID);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- ::android::hardware::renderscript::V1_0::ScriptIntrinsicID arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(uint64_t);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- uint64_t arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- renderscript->scriptIntrinsicCreate(arg0, arg1);
- return 0;
- } else {
- cerr << "No such function: " << target_func << endl;
- exit(1);
- }
-}
-
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/test/golden/FUZZER/Device.fuzzer.cpp b/compilation_tools/vtsc/test/golden/FUZZER/Device.fuzzer.cpp
deleted file mode 100644
index 83623e8..0000000
--- a/compilation_tools/vtsc/test/golden/FUZZER/Device.fuzzer.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-// This file was auto-generated by VTS compiler.
-
-#include <iostream>
-
-#include "FuncFuzzerUtils.h"
-#include <android/hardware/renderscript/1.0/IDevice.h>
-
-using std::cerr;
-using std::endl;
-using std::string;
-
-using namespace ::android::hardware::renderscript::V1_0;
-using namespace ::android::hardware;
-
-namespace android {
-namespace vts {
-
-static string target_func;
-
-extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
- FuncFuzzerParams params{ExtractFuncFuzzerParams(*argc, *argv)};
- target_func = params.target_func_;
- return 0;
-}
-
-extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- static ::android::sp<IDevice> renderscript = IDevice::getService(true);
- if (renderscript == nullptr) {
- cerr << "IDevice::getService() failed" << endl;
- exit(1);
- }
-
- if (target_func == "contextCreate") {
- size_t type_size0 = sizeof(uint32_t);
- if (size < type_size0) { return 0; }
- size -= type_size0;
- uint32_t arg0;
- memcpy(&arg0, data, type_size0);
- data += type_size0;
-
- size_t type_size1 = sizeof(::android::hardware::renderscript::V1_0::ContextType);
- if (size < type_size1) { return 0; }
- size -= type_size1;
- ::android::hardware::renderscript::V1_0::ContextType arg1;
- memcpy(&arg1, data, type_size1);
- data += type_size1;
-
- size_t type_size2 = sizeof(int32_t);
- if (size < type_size2) { return 0; }
- size -= type_size2;
- int32_t arg2;
- memcpy(&arg2, data, type_size2);
- data += type_size2;
-
- renderscript->contextCreate(arg0, arg1, arg2);
- return 0;
- } else {
- cerr << "No such function: " << target_func << endl;
- exit(1);
- }
-}
-
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/test/golden/FUZZER/types.fuzzer.cpp b/compilation_tools/vtsc/test/golden/FUZZER/types.fuzzer.cpp
deleted file mode 100644
index e69de29..0000000
--- a/compilation_tools/vtsc/test/golden/FUZZER/types.fuzzer.cpp
+++ /dev/null
diff --git a/compilation_tools/vtsc/test/golden/PROFILER/Bar.profiler.cpp b/compilation_tools/vtsc/test/golden/PROFILER/Bar.profiler.cpp
deleted file mode 100644
index 2dcb002..0000000
--- a/compilation_tools/vtsc/test/golden/PROFILER/Bar.profiler.cpp
+++ /dev/null
@@ -1,2051 +0,0 @@
-#include "android/hardware/tests/bar/1.0/Bar.vts.h"
-#include <cutils/properties.h>
-#include <cutils/ashmem.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-
-using namespace android::hardware::tests::bar::V1_0;
-using namespace android::hardware;
-
-#define TRACEFILEPREFIX "/data/local/tmp/"
-
-namespace android {
-namespace vts {
-void profile____android__hardware__tests__bar__V1_0__IBar__SomethingRelated(VariableSpecificationMessage* arg_name,
-::android::hardware::tests::bar::V1_0::IBar::SomethingRelated arg_val_name __attribute__((__unused__))) {
- arg_name->set_type(TYPE_STRUCT);
- auto *arg_name_myRelated __attribute__((__unused__)) = arg_name->add_struct_value();
- arg_name_myRelated->set_type(TYPE_STRUCT);
- profile____android__hardware__tests__foo__V1_0__Unrelated(arg_name_myRelated, arg_val_name.myRelated);
-}
-
-
-void HIDL_INSTRUMENTATION_FUNCTION_android_hardware_tests_bar_V1_0_IBar(
- details::HidlInstrumentor::InstrumentationEvent event __attribute__((__unused__)),
- const char* package,
- const char* version,
- const char* interface,
- const char* method __attribute__((__unused__)),
- std::vector<void *> *args __attribute__((__unused__))) {
- if (strcmp(package, "android.hardware.tests.bar") != 0) {
- LOG(WARNING) << "incorrect package. Expect: android.hardware.tests.bar actual: " << package;
- }
- std::string version_str = std::string(version);
- int major_version = stoi(version_str.substr(0, version_str.find('.')));
- int minor_version = stoi(version_str.substr(version_str.find('.') + 1));
- if (major_version != 1 || minor_version > 0) {
- LOG(WARNING) << "incorrect version. Expect: 1.0 or lower (if version != x.0), actual: " << version;
- }
- if (strcmp(interface, "IBar") != 0) {
- LOG(WARNING) << "incorrect interface. Expect: IBar actual: " << interface;
- }
-
- VtsProfilingInterface& profiler = VtsProfilingInterface::getInstance(TRACEFILEPREFIX);
-
- bool profiling_for_args = property_get_bool("hal.instrumentation.profile.args", true);
- if (strcmp(method, "convertToBoolIfSmall") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("convertToBoolIfSmall");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 2) {
- LOG(ERROR) << "Number of arguments does not match. expect: 2, actual: " << (*args).size() << ", method name: convertToBoolIfSmall, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::tests::foo::V1_0::IFoo::Discriminator *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::tests::foo::V1_0::IFoo::Discriminator*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_ENUM);
- profile____android__hardware__tests__foo__V1_0__IFoo__Discriminator(arg_0, (*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- auto *arg_1 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::hidl_vec<::android::hardware::tests::foo::V1_0::IFoo::Union> *arg_val_1 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_vec<::android::hardware::tests::foo::V1_0::IFoo::Union>*> ((*args)[1]);
- if (arg_val_1 != nullptr) {
- arg_1->set_type(TYPE_VECTOR);
- arg_1->set_vector_size((*arg_val_1).size());
- for (int arg_1_index = 0; arg_1_index < (int)(*arg_val_1).size(); arg_1_index++) {
- auto *arg_1_vector_arg_1_index __attribute__((__unused__)) = arg_1->add_vector_value();
- arg_1_vector_arg_1_index->set_type(TYPE_UNION);
- profile____android__hardware__tests__foo__V1_0__IFoo__Union(arg_1_vector_arg_1_index, (*arg_val_1)[arg_1_index]);
- }
- } else {
- LOG(WARNING) << "argument 1 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: convertToBoolIfSmall, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::hidl_vec<::android::hardware::tests::foo::V1_0::IFoo::ContainsUnion> *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_vec<::android::hardware::tests::foo::V1_0::IFoo::ContainsUnion>*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_VECTOR);
- result_0->set_vector_size((*result_val_0).size());
- for (int result_0_index = 0; result_0_index < (int)(*result_val_0).size(); result_0_index++) {
- auto *result_0_vector_result_0_index __attribute__((__unused__)) = result_0->add_vector_value();
- result_0_vector_result_0_index->set_type(TYPE_STRUCT);
- profile____android__hardware__tests__foo__V1_0__IFoo__ContainsUnion(result_0_vector_result_0_index, (*result_val_0)[result_0_index]);
- }
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "doThis") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("doThis");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: doThis, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- float *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<float*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_SCALAR);
- arg_0->mutable_scalar_value()->set_float_t((*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of return values does not match. expect: 0, actual: " << (*args).size() << ", method name: doThis, event type: " << event;
- break;
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "doThatAndReturnSomething") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("doThatAndReturnSomething");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: doThatAndReturnSomething, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- int64_t *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<int64_t*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_SCALAR);
- arg_0->mutable_scalar_value()->set_int64_t((*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: doThatAndReturnSomething, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- int32_t *result_val_0 __attribute__((__unused__)) = reinterpret_cast<int32_t*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_SCALAR);
- result_0->mutable_scalar_value()->set_int32_t((*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "doQuiteABit") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("doQuiteABit");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 4) {
- LOG(ERROR) << "Number of arguments does not match. expect: 4, actual: " << (*args).size() << ", method name: doQuiteABit, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- int32_t *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<int32_t*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_SCALAR);
- arg_0->mutable_scalar_value()->set_int32_t((*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- auto *arg_1 __attribute__((__unused__)) = msg.add_arg();
- int64_t *arg_val_1 __attribute__((__unused__)) = reinterpret_cast<int64_t*> ((*args)[1]);
- if (arg_val_1 != nullptr) {
- arg_1->set_type(TYPE_SCALAR);
- arg_1->mutable_scalar_value()->set_int64_t((*arg_val_1));
- } else {
- LOG(WARNING) << "argument 1 is null.";
- }
- auto *arg_2 __attribute__((__unused__)) = msg.add_arg();
- float *arg_val_2 __attribute__((__unused__)) = reinterpret_cast<float*> ((*args)[2]);
- if (arg_val_2 != nullptr) {
- arg_2->set_type(TYPE_SCALAR);
- arg_2->mutable_scalar_value()->set_float_t((*arg_val_2));
- } else {
- LOG(WARNING) << "argument 2 is null.";
- }
- auto *arg_3 __attribute__((__unused__)) = msg.add_arg();
- double *arg_val_3 __attribute__((__unused__)) = reinterpret_cast<double*> ((*args)[3]);
- if (arg_val_3 != nullptr) {
- arg_3->set_type(TYPE_SCALAR);
- arg_3->mutable_scalar_value()->set_double_t((*arg_val_3));
- } else {
- LOG(WARNING) << "argument 3 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: doQuiteABit, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- double *result_val_0 __attribute__((__unused__)) = reinterpret_cast<double*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_SCALAR);
- result_0->mutable_scalar_value()->set_double_t((*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "doSomethingElse") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("doSomethingElse");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: doSomethingElse, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::hidl_array<int32_t, 15> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_array<int32_t, 15>*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_ARRAY);
- arg_0->set_vector_size(15);
- for (int arg_0_index = 0; arg_0_index < 15; arg_0_index++) {
- auto *arg_0_array_arg_0_index __attribute__((__unused__)) = arg_0->add_vector_value();
- arg_0_array_arg_0_index->set_type(TYPE_SCALAR);
- arg_0_array_arg_0_index->mutable_scalar_value()->set_int32_t((*arg_val_0)[arg_0_index]);
- }
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: doSomethingElse, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::hidl_array<int32_t, 32> *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_array<int32_t, 32>*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_ARRAY);
- result_0->set_vector_size(32);
- for (int result_0_index = 0; result_0_index < 32; result_0_index++) {
- auto *result_0_array_result_0_index __attribute__((__unused__)) = result_0->add_vector_value();
- result_0_array_result_0_index->set_type(TYPE_SCALAR);
- result_0_array_result_0_index->mutable_scalar_value()->set_int32_t((*result_val_0)[result_0_index]);
- }
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "doStuffAndReturnAString") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("doStuffAndReturnAString");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of arguments does not match. expect: 0, actual: " << (*args).size() << ", method name: doStuffAndReturnAString, event type: " << event;
- break;
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: doStuffAndReturnAString, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::hidl_string *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_string*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_STRING);
- result_0->mutable_string_value()->set_message((*result_val_0).c_str());
- result_0->mutable_string_value()->set_length((*result_val_0).size());
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "mapThisVector") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("mapThisVector");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: mapThisVector, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::hidl_vec<int32_t> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_vec<int32_t>*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_VECTOR);
- arg_0->set_vector_size((*arg_val_0).size());
- for (int arg_0_index = 0; arg_0_index < (int)(*arg_val_0).size(); arg_0_index++) {
- auto *arg_0_vector_arg_0_index __attribute__((__unused__)) = arg_0->add_vector_value();
- arg_0_vector_arg_0_index->set_type(TYPE_SCALAR);
- arg_0_vector_arg_0_index->mutable_scalar_value()->set_int32_t((*arg_val_0)[arg_0_index]);
- }
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: mapThisVector, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::hidl_vec<int32_t> *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_vec<int32_t>*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_VECTOR);
- result_0->set_vector_size((*result_val_0).size());
- for (int result_0_index = 0; result_0_index < (int)(*result_val_0).size(); result_0_index++) {
- auto *result_0_vector_result_0_index __attribute__((__unused__)) = result_0->add_vector_value();
- result_0_vector_result_0_index->set_type(TYPE_SCALAR);
- result_0_vector_result_0_index->mutable_scalar_value()->set_int32_t((*result_val_0)[result_0_index]);
- }
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "callMe") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("callMe");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: callMe, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- sp<::android::hardware::tests::foo::V1_0::IFooCallback> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<sp<::android::hardware::tests::foo::V1_0::IFooCallback>*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_HIDL_CALLBACK);
- arg_0->set_predefined_type("::android::hardware::tests::foo::V1_0::IFooCallback");
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of return values does not match. expect: 0, actual: " << (*args).size() << ", method name: callMe, event type: " << event;
- break;
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "useAnEnum") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("useAnEnum");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: useAnEnum, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::tests::foo::V1_0::IFoo::SomeEnum *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::tests::foo::V1_0::IFoo::SomeEnum*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_ENUM);
- profile____android__hardware__tests__foo__V1_0__IFoo__SomeEnum(arg_0, (*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: useAnEnum, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::tests::foo::V1_0::IFoo::SomeEnum *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::tests::foo::V1_0::IFoo::SomeEnum*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_ENUM);
- profile____android__hardware__tests__foo__V1_0__IFoo__SomeEnum(result_0, (*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "haveAGooberVec") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("haveAGooberVec");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: haveAGooberVec, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::hidl_vec<::android::hardware::tests::foo::V1_0::IFoo::Goober> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_vec<::android::hardware::tests::foo::V1_0::IFoo::Goober>*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_VECTOR);
- arg_0->set_vector_size((*arg_val_0).size());
- for (int arg_0_index = 0; arg_0_index < (int)(*arg_val_0).size(); arg_0_index++) {
- auto *arg_0_vector_arg_0_index __attribute__((__unused__)) = arg_0->add_vector_value();
- arg_0_vector_arg_0_index->set_type(TYPE_STRUCT);
- profile____android__hardware__tests__foo__V1_0__IFoo__Goober(arg_0_vector_arg_0_index, (*arg_val_0)[arg_0_index]);
- }
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of return values does not match. expect: 0, actual: " << (*args).size() << ", method name: haveAGooberVec, event type: " << event;
- break;
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "haveAGoober") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("haveAGoober");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: haveAGoober, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::tests::foo::V1_0::IFoo::Goober *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::tests::foo::V1_0::IFoo::Goober*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_STRUCT);
- profile____android__hardware__tests__foo__V1_0__IFoo__Goober(arg_0, (*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of return values does not match. expect: 0, actual: " << (*args).size() << ", method name: haveAGoober, event type: " << event;
- break;
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "haveAGooberArray") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("haveAGooberArray");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: haveAGooberArray, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::hidl_array<::android::hardware::tests::foo::V1_0::IFoo::Goober, 20> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_array<::android::hardware::tests::foo::V1_0::IFoo::Goober, 20>*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_ARRAY);
- arg_0->set_vector_size(20);
- for (int arg_0_index = 0; arg_0_index < 20; arg_0_index++) {
- auto *arg_0_array_arg_0_index __attribute__((__unused__)) = arg_0->add_vector_value();
- arg_0_array_arg_0_index->set_type(TYPE_STRUCT);
- auto *arg_0_array_arg_0_index_q __attribute__((__unused__)) = arg_0_array_arg_0_index->add_struct_value();
- arg_0_array_arg_0_index_q->set_type(TYPE_SCALAR);
- arg_0_array_arg_0_index_q->mutable_scalar_value()->set_int32_t((*arg_val_0)[arg_0_index].q);
- auto *arg_0_array_arg_0_index_name __attribute__((__unused__)) = arg_0_array_arg_0_index->add_struct_value();
- arg_0_array_arg_0_index_name->set_type(TYPE_STRING);
- arg_0_array_arg_0_index_name->mutable_string_value()->set_message((*arg_val_0)[arg_0_index].name.c_str());
- arg_0_array_arg_0_index_name->mutable_string_value()->set_length((*arg_val_0)[arg_0_index].name.size());
- auto *arg_0_array_arg_0_index_address __attribute__((__unused__)) = arg_0_array_arg_0_index->add_struct_value();
- arg_0_array_arg_0_index_address->set_type(TYPE_STRING);
- arg_0_array_arg_0_index_address->mutable_string_value()->set_message((*arg_val_0)[arg_0_index].address.c_str());
- arg_0_array_arg_0_index_address->mutable_string_value()->set_length((*arg_val_0)[arg_0_index].address.size());
- auto *arg_0_array_arg_0_index_numbers __attribute__((__unused__)) = arg_0_array_arg_0_index->add_struct_value();
- arg_0_array_arg_0_index_numbers->set_type(TYPE_ARRAY);
- arg_0_array_arg_0_index_numbers->set_vector_size(10);
- for (int arg_0_array_arg_0_index_numbers_index = 0; arg_0_array_arg_0_index_numbers_index < 10; arg_0_array_arg_0_index_numbers_index++) {
- auto *arg_0_array_arg_0_index_numbers_array_arg_0_array_arg_0_index_numbers_index __attribute__((__unused__)) = arg_0_array_arg_0_index_numbers->add_vector_value();
- arg_0_array_arg_0_index_numbers_array_arg_0_array_arg_0_index_numbers_index->set_type(TYPE_SCALAR);
- arg_0_array_arg_0_index_numbers_array_arg_0_array_arg_0_index_numbers_index->mutable_scalar_value()->set_double_t((*arg_val_0)[arg_0_index].numbers[arg_0_array_arg_0_index_numbers_index]);
- }
- auto *arg_0_array_arg_0_index_fumble __attribute__((__unused__)) = arg_0_array_arg_0_index->add_struct_value();
- arg_0_array_arg_0_index_fumble->set_type(TYPE_STRUCT);
- profile____android__hardware__tests__foo__V1_0__IFoo__Fumble(arg_0_array_arg_0_index_fumble, (*arg_val_0)[arg_0_index].fumble);
- auto *arg_0_array_arg_0_index_gumble __attribute__((__unused__)) = arg_0_array_arg_0_index->add_struct_value();
- arg_0_array_arg_0_index_gumble->set_type(TYPE_STRUCT);
- profile____android__hardware__tests__foo__V1_0__IFoo__Fumble(arg_0_array_arg_0_index_gumble, (*arg_val_0)[arg_0_index].gumble);
- }
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of return values does not match. expect: 0, actual: " << (*args).size() << ", method name: haveAGooberArray, event type: " << event;
- break;
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "haveATypeFromAnotherFile") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("haveATypeFromAnotherFile");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: haveATypeFromAnotherFile, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::tests::foo::V1_0::Abc *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::tests::foo::V1_0::Abc*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_STRUCT);
- profile____android__hardware__tests__foo__V1_0__Abc(arg_0, (*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of return values does not match. expect: 0, actual: " << (*args).size() << ", method name: haveATypeFromAnotherFile, event type: " << event;
- break;
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "haveSomeStrings") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("haveSomeStrings");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: haveSomeStrings, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::hidl_array<::android::hardware::hidl_string, 3> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_array<::android::hardware::hidl_string, 3>*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_ARRAY);
- arg_0->set_vector_size(3);
- for (int arg_0_index = 0; arg_0_index < 3; arg_0_index++) {
- auto *arg_0_array_arg_0_index __attribute__((__unused__)) = arg_0->add_vector_value();
- arg_0_array_arg_0_index->set_type(TYPE_STRING);
- arg_0_array_arg_0_index->mutable_string_value()->set_message((*arg_val_0)[arg_0_index].c_str());
- arg_0_array_arg_0_index->mutable_string_value()->set_length((*arg_val_0)[arg_0_index].size());
- }
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: haveSomeStrings, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::hidl_array<::android::hardware::hidl_string, 2> *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_array<::android::hardware::hidl_string, 2>*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_ARRAY);
- result_0->set_vector_size(2);
- for (int result_0_index = 0; result_0_index < 2; result_0_index++) {
- auto *result_0_array_result_0_index __attribute__((__unused__)) = result_0->add_vector_value();
- result_0_array_result_0_index->set_type(TYPE_STRING);
- result_0_array_result_0_index->mutable_string_value()->set_message((*result_val_0)[result_0_index].c_str());
- result_0_array_result_0_index->mutable_string_value()->set_length((*result_val_0)[result_0_index].size());
- }
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "haveAStringVec") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("haveAStringVec");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: haveAStringVec, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::hidl_vec<::android::hardware::hidl_string> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_vec<::android::hardware::hidl_string>*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_VECTOR);
- arg_0->set_vector_size((*arg_val_0).size());
- for (int arg_0_index = 0; arg_0_index < (int)(*arg_val_0).size(); arg_0_index++) {
- auto *arg_0_vector_arg_0_index __attribute__((__unused__)) = arg_0->add_vector_value();
- arg_0_vector_arg_0_index->set_type(TYPE_STRING);
- arg_0_vector_arg_0_index->mutable_string_value()->set_message((*arg_val_0)[arg_0_index].c_str());
- arg_0_vector_arg_0_index->mutable_string_value()->set_length((*arg_val_0)[arg_0_index].size());
- }
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: haveAStringVec, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::hidl_vec<::android::hardware::hidl_string> *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_vec<::android::hardware::hidl_string>*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_VECTOR);
- result_0->set_vector_size((*result_val_0).size());
- for (int result_0_index = 0; result_0_index < (int)(*result_val_0).size(); result_0_index++) {
- auto *result_0_vector_result_0_index __attribute__((__unused__)) = result_0->add_vector_value();
- result_0_vector_result_0_index->set_type(TYPE_STRING);
- result_0_vector_result_0_index->mutable_string_value()->set_message((*result_val_0)[result_0_index].c_str());
- result_0_vector_result_0_index->mutable_string_value()->set_length((*result_val_0)[result_0_index].size());
- }
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "transposeMe") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("transposeMe");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: transposeMe, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::hidl_array<float, 3, 5> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_array<float, 3, 5>*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_ARRAY);
- arg_0->set_vector_size(3);
- for (int arg_0_index = 0; arg_0_index < 3; arg_0_index++) {
- auto *arg_0_array_arg_0_index __attribute__((__unused__)) = arg_0->add_vector_value();
- arg_0_array_arg_0_index->set_type(TYPE_ARRAY);
- arg_0_array_arg_0_index->set_vector_size(5);
- for (int arg_0_array_arg_0_index_index = 0; arg_0_array_arg_0_index_index < 5; arg_0_array_arg_0_index_index++) {
- auto *arg_0_array_arg_0_index_array_arg_0_array_arg_0_index_index __attribute__((__unused__)) = arg_0_array_arg_0_index->add_vector_value();
- arg_0_array_arg_0_index_array_arg_0_array_arg_0_index_index->set_type(TYPE_SCALAR);
- arg_0_array_arg_0_index_array_arg_0_array_arg_0_index_index->mutable_scalar_value()->set_float_t((*arg_val_0)[arg_0_index][arg_0_array_arg_0_index_index]);
- }
- }
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: transposeMe, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::hidl_array<float, 5, 3> *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_array<float, 5, 3>*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_ARRAY);
- result_0->set_vector_size(5);
- for (int result_0_index = 0; result_0_index < 5; result_0_index++) {
- auto *result_0_array_result_0_index __attribute__((__unused__)) = result_0->add_vector_value();
- result_0_array_result_0_index->set_type(TYPE_ARRAY);
- result_0_array_result_0_index->set_vector_size(3);
- for (int result_0_array_result_0_index_index = 0; result_0_array_result_0_index_index < 3; result_0_array_result_0_index_index++) {
- auto *result_0_array_result_0_index_array_result_0_array_result_0_index_index __attribute__((__unused__)) = result_0_array_result_0_index->add_vector_value();
- result_0_array_result_0_index_array_result_0_array_result_0_index_index->set_type(TYPE_SCALAR);
- result_0_array_result_0_index_array_result_0_array_result_0_index_index->mutable_scalar_value()->set_float_t((*result_val_0)[result_0_index][result_0_array_result_0_index_index]);
- }
- }
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "callingDrWho") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("callingDrWho");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: callingDrWho, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::tests::foo::V1_0::IFoo::MultiDimensional *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::tests::foo::V1_0::IFoo::MultiDimensional*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_STRUCT);
- profile____android__hardware__tests__foo__V1_0__IFoo__MultiDimensional(arg_0, (*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: callingDrWho, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::tests::foo::V1_0::IFoo::MultiDimensional *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::tests::foo::V1_0::IFoo::MultiDimensional*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_STRUCT);
- profile____android__hardware__tests__foo__V1_0__IFoo__MultiDimensional(result_0, (*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "transpose") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("transpose");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: transpose, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::tests::foo::V1_0::IFoo::StringMatrix5x3 *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::tests::foo::V1_0::IFoo::StringMatrix5x3*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_STRUCT);
- profile____android__hardware__tests__foo__V1_0__IFoo__StringMatrix5x3(arg_0, (*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: transpose, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::tests::foo::V1_0::IFoo::StringMatrix3x5 *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::tests::foo::V1_0::IFoo::StringMatrix3x5*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_STRUCT);
- profile____android__hardware__tests__foo__V1_0__IFoo__StringMatrix3x5(result_0, (*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "transpose2") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("transpose2");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: transpose2, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::hidl_array<::android::hardware::hidl_string, 5, 3> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_array<::android::hardware::hidl_string, 5, 3>*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_ARRAY);
- arg_0->set_vector_size(5);
- for (int arg_0_index = 0; arg_0_index < 5; arg_0_index++) {
- auto *arg_0_array_arg_0_index __attribute__((__unused__)) = arg_0->add_vector_value();
- arg_0_array_arg_0_index->set_type(TYPE_ARRAY);
- arg_0_array_arg_0_index->set_vector_size(3);
- for (int arg_0_array_arg_0_index_index = 0; arg_0_array_arg_0_index_index < 3; arg_0_array_arg_0_index_index++) {
- auto *arg_0_array_arg_0_index_array_arg_0_array_arg_0_index_index __attribute__((__unused__)) = arg_0_array_arg_0_index->add_vector_value();
- arg_0_array_arg_0_index_array_arg_0_array_arg_0_index_index->set_type(TYPE_STRING);
- arg_0_array_arg_0_index_array_arg_0_array_arg_0_index_index->mutable_string_value()->set_message((*arg_val_0)[arg_0_index][arg_0_array_arg_0_index_index].c_str());
- arg_0_array_arg_0_index_array_arg_0_array_arg_0_index_index->mutable_string_value()->set_length((*arg_val_0)[arg_0_index][arg_0_array_arg_0_index_index].size());
- }
- }
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: transpose2, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::hidl_array<::android::hardware::hidl_string, 3, 5> *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_array<::android::hardware::hidl_string, 3, 5>*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_ARRAY);
- result_0->set_vector_size(3);
- for (int result_0_index = 0; result_0_index < 3; result_0_index++) {
- auto *result_0_array_result_0_index __attribute__((__unused__)) = result_0->add_vector_value();
- result_0_array_result_0_index->set_type(TYPE_ARRAY);
- result_0_array_result_0_index->set_vector_size(5);
- for (int result_0_array_result_0_index_index = 0; result_0_array_result_0_index_index < 5; result_0_array_result_0_index_index++) {
- auto *result_0_array_result_0_index_array_result_0_array_result_0_index_index __attribute__((__unused__)) = result_0_array_result_0_index->add_vector_value();
- result_0_array_result_0_index_array_result_0_array_result_0_index_index->set_type(TYPE_STRING);
- result_0_array_result_0_index_array_result_0_array_result_0_index_index->mutable_string_value()->set_message((*result_val_0)[result_0_index][result_0_array_result_0_index_index].c_str());
- result_0_array_result_0_index_array_result_0_array_result_0_index_index->mutable_string_value()->set_length((*result_val_0)[result_0_index][result_0_array_result_0_index_index].size());
- }
- }
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "sendVec") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("sendVec");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: sendVec, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::hidl_vec<uint8_t> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_vec<uint8_t>*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_VECTOR);
- arg_0->set_vector_size((*arg_val_0).size());
- for (int arg_0_index = 0; arg_0_index < (int)(*arg_val_0).size(); arg_0_index++) {
- auto *arg_0_vector_arg_0_index __attribute__((__unused__)) = arg_0->add_vector_value();
- arg_0_vector_arg_0_index->set_type(TYPE_SCALAR);
- arg_0_vector_arg_0_index->mutable_scalar_value()->set_uint8_t((*arg_val_0)[arg_0_index]);
- }
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: sendVec, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::hidl_vec<uint8_t> *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_vec<uint8_t>*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_VECTOR);
- result_0->set_vector_size((*result_val_0).size());
- for (int result_0_index = 0; result_0_index < (int)(*result_val_0).size(); result_0_index++) {
- auto *result_0_vector_result_0_index __attribute__((__unused__)) = result_0->add_vector_value();
- result_0_vector_result_0_index->set_type(TYPE_SCALAR);
- result_0_vector_result_0_index->mutable_scalar_value()->set_uint8_t((*result_val_0)[result_0_index]);
- }
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "sendVecVec") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("sendVecVec");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of arguments does not match. expect: 0, actual: " << (*args).size() << ", method name: sendVecVec, event type: " << event;
- break;
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: sendVecVec, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::hidl_vec<::android::hardware::hidl_vec<uint8_t>> *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_vec<::android::hardware::hidl_vec<uint8_t>>*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_VECTOR);
- result_0->set_vector_size((*result_val_0).size());
- for (int result_0_index = 0; result_0_index < (int)(*result_val_0).size(); result_0_index++) {
- auto *result_0_vector_result_0_index __attribute__((__unused__)) = result_0->add_vector_value();
- result_0_vector_result_0_index->set_type(TYPE_VECTOR);
- result_0_vector_result_0_index->set_vector_size((*result_val_0)[result_0_index].size());
- for (int result_0_vector_result_0_index_index = 0; result_0_vector_result_0_index_index < (int)(*result_val_0)[result_0_index].size(); result_0_vector_result_0_index_index++) {
- auto *result_0_vector_result_0_index_vector_result_0_vector_result_0_index_index __attribute__((__unused__)) = result_0_vector_result_0_index->add_vector_value();
- result_0_vector_result_0_index_vector_result_0_vector_result_0_index_index->set_type(TYPE_SCALAR);
- result_0_vector_result_0_index_vector_result_0_vector_result_0_index_index->mutable_scalar_value()->set_uint8_t((*result_val_0)[result_0_index][result_0_vector_result_0_index_index]);
- }
- }
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "haveAVectorOfInterfaces") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("haveAVectorOfInterfaces");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: haveAVectorOfInterfaces, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::hidl_vec<sp<::android::hardware::tests::foo::V1_0::ISimple>> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_vec<sp<::android::hardware::tests::foo::V1_0::ISimple>>*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_VECTOR);
- arg_0->set_vector_size((*arg_val_0).size());
- for (int arg_0_index = 0; arg_0_index < (int)(*arg_val_0).size(); arg_0_index++) {
- auto *arg_0_vector_arg_0_index __attribute__((__unused__)) = arg_0->add_vector_value();
- arg_0_vector_arg_0_index->set_type(TYPE_HIDL_INTERFACE);
- arg_0_vector_arg_0_index->set_predefined_type("::android::hardware::tests::foo::V1_0::ISimple");
- }
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: haveAVectorOfInterfaces, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::hidl_vec<sp<::android::hardware::tests::foo::V1_0::ISimple>> *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_vec<sp<::android::hardware::tests::foo::V1_0::ISimple>>*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_VECTOR);
- result_0->set_vector_size((*result_val_0).size());
- for (int result_0_index = 0; result_0_index < (int)(*result_val_0).size(); result_0_index++) {
- auto *result_0_vector_result_0_index __attribute__((__unused__)) = result_0->add_vector_value();
- result_0_vector_result_0_index->set_type(TYPE_HIDL_INTERFACE);
- result_0_vector_result_0_index->set_predefined_type("::android::hardware::tests::foo::V1_0::ISimple");
- }
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "haveAVectorOfGenericInterfaces") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("haveAVectorOfGenericInterfaces");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: haveAVectorOfGenericInterfaces, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::hidl_vec<sp<::android::hidl::base::V1_0::IBase>> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_vec<sp<::android::hidl::base::V1_0::IBase>>*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_VECTOR);
- arg_0->set_vector_size((*arg_val_0).size());
- for (int arg_0_index = 0; arg_0_index < (int)(*arg_val_0).size(); arg_0_index++) {
- auto *arg_0_vector_arg_0_index __attribute__((__unused__)) = arg_0->add_vector_value();
- arg_0_vector_arg_0_index->set_type(TYPE_HIDL_INTERFACE);
- arg_0_vector_arg_0_index->set_predefined_type("::android::hidl::base::V1_0::IBase");
- }
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: haveAVectorOfGenericInterfaces, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::hidl_vec<sp<::android::hidl::base::V1_0::IBase>> *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_vec<sp<::android::hidl::base::V1_0::IBase>>*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_VECTOR);
- result_0->set_vector_size((*result_val_0).size());
- for (int result_0_index = 0; result_0_index < (int)(*result_val_0).size(); result_0_index++) {
- auto *result_0_vector_result_0_index __attribute__((__unused__)) = result_0->add_vector_value();
- result_0_vector_result_0_index->set_type(TYPE_HIDL_INTERFACE);
- result_0_vector_result_0_index->set_predefined_type("::android::hidl::base::V1_0::IBase");
- }
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "echoNullInterface") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("echoNullInterface");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: echoNullInterface, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- sp<::android::hardware::tests::foo::V1_0::IFooCallback> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<sp<::android::hardware::tests::foo::V1_0::IFooCallback>*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_HIDL_CALLBACK);
- arg_0->set_predefined_type("::android::hardware::tests::foo::V1_0::IFooCallback");
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 2) {
- LOG(ERROR) << "Number of return values does not match. expect: 2, actual: " << (*args).size() << ", method name: echoNullInterface, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- bool *result_val_0 __attribute__((__unused__)) = reinterpret_cast<bool*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_SCALAR);
- result_0->mutable_scalar_value()->set_bool_t((*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- auto *result_1 __attribute__((__unused__)) = msg.add_return_type_hidl();
- sp<::android::hardware::tests::foo::V1_0::IFooCallback> *result_val_1 __attribute__((__unused__)) = reinterpret_cast<sp<::android::hardware::tests::foo::V1_0::IFooCallback>*> ((*args)[1]);
- if (result_val_1 != nullptr) {
- result_1->set_type(TYPE_HIDL_CALLBACK);
- result_1->set_predefined_type("::android::hardware::tests::foo::V1_0::IFooCallback");
- } else {
- LOG(WARNING) << "return value 1 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "createMyHandle") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("createMyHandle");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of arguments does not match. expect: 0, actual: " << (*args).size() << ", method name: createMyHandle, event type: " << event;
- break;
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: createMyHandle, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::tests::foo::V1_0::IFoo::MyHandle *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::tests::foo::V1_0::IFoo::MyHandle*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_STRUCT);
- profile____android__hardware__tests__foo__V1_0__IFoo__MyHandle(result_0, (*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "createHandles") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("createHandles");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: createHandles, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- uint32_t *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<uint32_t*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_SCALAR);
- arg_0->mutable_scalar_value()->set_uint32_t((*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: createHandles, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::hidl_vec<::android::hardware::hidl_handle> *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_vec<::android::hardware::hidl_handle>*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_VECTOR);
- result_0->set_vector_size((*result_val_0).size());
- for (int result_0_index = 0; result_0_index < (int)(*result_val_0).size(); result_0_index++) {
- auto *result_0_vector_result_0_index __attribute__((__unused__)) = result_0->add_vector_value();
- result_0_vector_result_0_index->set_type(TYPE_HANDLE);
- auto result_0_vector_result_0_index_h = (*result_val_0)[result_0_index].getNativeHandle();
- if (result_0_vector_result_0_index_h) {
- result_0_vector_result_0_index->mutable_handle_value()->set_version(result_0_vector_result_0_index_h->version);
- result_0_vector_result_0_index->mutable_handle_value()->set_num_ints(result_0_vector_result_0_index_h->numInts);
- result_0_vector_result_0_index->mutable_handle_value()->set_num_fds(result_0_vector_result_0_index_h->numFds);
- for (int i = 0; i < result_0_vector_result_0_index_h->numInts + result_0_vector_result_0_index_h->numFds; i++) {
- if(i < result_0_vector_result_0_index_h->numFds) {
- auto* fd_val_i = result_0_vector_result_0_index->mutable_handle_value()->add_fd_val();
- char filePath[PATH_MAX];
- string procPath = "/proc/self/fd/" + to_string(result_0_vector_result_0_index_h->data[i]);
- ssize_t r = readlink(procPath.c_str(), filePath, sizeof(filePath));
- if (r == -1) {
- LOG(ERROR) << "Unable to get file path";
- continue;
- }
- filePath[r] = '\0';
- fd_val_i->set_file_name(filePath);
- struct stat statbuf;
- fstat(result_0_vector_result_0_index_h->data[i], &statbuf);
- fd_val_i->set_mode(statbuf.st_mode);
- if (S_ISREG(statbuf.st_mode) || S_ISDIR(statbuf.st_mode)) {
- fd_val_i->set_type(S_ISREG(statbuf.st_mode)? FILE_TYPE: DIR_TYPE);
- int flags = fcntl(result_0_vector_result_0_index_h->data[i], F_GETFL);
- fd_val_i->set_flags(flags);
- }
- else if (S_ISCHR(statbuf.st_mode) || S_ISBLK(statbuf.st_mode)) {
- fd_val_i->set_type(DEV_TYPE);
- if (strcmp(filePath, "/dev/ashmem") == 0) {
- int size = ashmem_get_size_region(result_0_vector_result_0_index_h->data[i]);
- fd_val_i->mutable_memory()->set_size(size);
- }
- }
- else if (S_ISFIFO(statbuf.st_mode)){
- fd_val_i->set_type(PIPE_TYPE);
- }
- else if (S_ISSOCK(statbuf.st_mode)) {
- fd_val_i->set_type(SOCKET_TYPE);
- }
- else {
- fd_val_i->set_type(LINK_TYPE);
- }
- } else {
- result_0_vector_result_0_index->mutable_handle_value()->add_int_val(result_0_vector_result_0_index_h->data[i]);
- }
- }
- } else {
- LOG(WARNING) << "null handle";
- result_0_vector_result_0_index->mutable_handle_value()->set_hidl_handle_address(0);
- }
- }
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "closeHandles") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("closeHandles");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of arguments does not match. expect: 0, actual: " << (*args).size() << ", method name: closeHandles, event type: " << event;
- break;
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of return values does not match. expect: 0, actual: " << (*args).size() << ", method name: closeHandles, event type: " << event;
- break;
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "repeatWithFmq") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("repeatWithFmq");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: repeatWithFmq, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::tests::foo::V1_0::IFoo::WithFmq *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::tests::foo::V1_0::IFoo::WithFmq*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_STRUCT);
- profile____android__hardware__tests__foo__V1_0__IFoo__WithFmq(arg_0, (*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: repeatWithFmq, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::tests::foo::V1_0::IFoo::WithFmq *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::tests::foo::V1_0::IFoo::WithFmq*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_STRUCT);
- profile____android__hardware__tests__foo__V1_0__IFoo__WithFmq(result_0, (*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "thisIsNew") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("thisIsNew");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of arguments does not match. expect: 0, actual: " << (*args).size() << ", method name: thisIsNew, event type: " << event;
- break;
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of return values does not match. expect: 0, actual: " << (*args).size() << ", method name: thisIsNew, event type: " << event;
- break;
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "expectNullHandle") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("expectNullHandle");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 2) {
- LOG(ERROR) << "Number of arguments does not match. expect: 2, actual: " << (*args).size() << ", method name: expectNullHandle, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::hidl_handle *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_handle*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_HANDLE);
- auto arg_0_h = (*arg_val_0).getNativeHandle();
- if (arg_0_h) {
- arg_0->mutable_handle_value()->set_version(arg_0_h->version);
- arg_0->mutable_handle_value()->set_num_ints(arg_0_h->numInts);
- arg_0->mutable_handle_value()->set_num_fds(arg_0_h->numFds);
- for (int i = 0; i < arg_0_h->numInts + arg_0_h->numFds; i++) {
- if(i < arg_0_h->numFds) {
- auto* fd_val_i = arg_0->mutable_handle_value()->add_fd_val();
- char filePath[PATH_MAX];
- string procPath = "/proc/self/fd/" + to_string(arg_0_h->data[i]);
- ssize_t r = readlink(procPath.c_str(), filePath, sizeof(filePath));
- if (r == -1) {
- LOG(ERROR) << "Unable to get file path";
- continue;
- }
- filePath[r] = '\0';
- fd_val_i->set_file_name(filePath);
- struct stat statbuf;
- fstat(arg_0_h->data[i], &statbuf);
- fd_val_i->set_mode(statbuf.st_mode);
- if (S_ISREG(statbuf.st_mode) || S_ISDIR(statbuf.st_mode)) {
- fd_val_i->set_type(S_ISREG(statbuf.st_mode)? FILE_TYPE: DIR_TYPE);
- int flags = fcntl(arg_0_h->data[i], F_GETFL);
- fd_val_i->set_flags(flags);
- }
- else if (S_ISCHR(statbuf.st_mode) || S_ISBLK(statbuf.st_mode)) {
- fd_val_i->set_type(DEV_TYPE);
- if (strcmp(filePath, "/dev/ashmem") == 0) {
- int size = ashmem_get_size_region(arg_0_h->data[i]);
- fd_val_i->mutable_memory()->set_size(size);
- }
- }
- else if (S_ISFIFO(statbuf.st_mode)){
- fd_val_i->set_type(PIPE_TYPE);
- }
- else if (S_ISSOCK(statbuf.st_mode)) {
- fd_val_i->set_type(SOCKET_TYPE);
- }
- else {
- fd_val_i->set_type(LINK_TYPE);
- }
- } else {
- arg_0->mutable_handle_value()->add_int_val(arg_0_h->data[i]);
- }
- }
- } else {
- LOG(WARNING) << "null handle";
- arg_0->mutable_handle_value()->set_hidl_handle_address(0);
- }
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- auto *arg_1 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::tests::foo::V1_0::Abc *arg_val_1 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::tests::foo::V1_0::Abc*> ((*args)[1]);
- if (arg_val_1 != nullptr) {
- arg_1->set_type(TYPE_STRUCT);
- profile____android__hardware__tests__foo__V1_0__Abc(arg_1, (*arg_val_1));
- } else {
- LOG(WARNING) << "argument 1 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 2) {
- LOG(ERROR) << "Number of return values does not match. expect: 2, actual: " << (*args).size() << ", method name: expectNullHandle, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- bool *result_val_0 __attribute__((__unused__)) = reinterpret_cast<bool*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_SCALAR);
- result_0->mutable_scalar_value()->set_bool_t((*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- auto *result_1 __attribute__((__unused__)) = msg.add_return_type_hidl();
- bool *result_val_1 __attribute__((__unused__)) = reinterpret_cast<bool*> ((*args)[1]);
- if (result_val_1 != nullptr) {
- result_1->set_type(TYPE_SCALAR);
- result_1->mutable_scalar_value()->set_bool_t((*result_val_1));
- } else {
- LOG(WARNING) << "return value 1 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "takeAMask") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("takeAMask");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 4) {
- LOG(ERROR) << "Number of arguments does not match. expect: 4, actual: " << (*args).size() << ", method name: takeAMask, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::tests::foo::V1_0::IFoo::BitField *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::tests::foo::V1_0::IFoo::BitField*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_ENUM);
- profile____android__hardware__tests__foo__V1_0__IFoo__BitField(arg_0, (*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- auto *arg_1 __attribute__((__unused__)) = msg.add_arg();
- uint8_t *arg_val_1 __attribute__((__unused__)) = reinterpret_cast<uint8_t*> ((*args)[1]);
- if (arg_val_1 != nullptr) {
- arg_1->set_type(TYPE_MASK);
- arg_1->set_scalar_type("uint8_t");
- arg_1->mutable_scalar_value()->set_uint8_t((*arg_val_1));
- } else {
- LOG(WARNING) << "argument 1 is null.";
- }
- auto *arg_2 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::tests::foo::V1_0::IFoo::MyMask *arg_val_2 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::tests::foo::V1_0::IFoo::MyMask*> ((*args)[2]);
- if (arg_val_2 != nullptr) {
- arg_2->set_type(TYPE_STRUCT);
- profile____android__hardware__tests__foo__V1_0__IFoo__MyMask(arg_2, (*arg_val_2));
- } else {
- LOG(WARNING) << "argument 2 is null.";
- }
- auto *arg_3 __attribute__((__unused__)) = msg.add_arg();
- uint8_t *arg_val_3 __attribute__((__unused__)) = reinterpret_cast<uint8_t*> ((*args)[3]);
- if (arg_val_3 != nullptr) {
- arg_3->set_type(TYPE_MASK);
- arg_3->set_scalar_type("uint8_t");
- arg_3->mutable_scalar_value()->set_uint8_t((*arg_val_3));
- } else {
- LOG(WARNING) << "argument 3 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 4) {
- LOG(ERROR) << "Number of return values does not match. expect: 4, actual: " << (*args).size() << ", method name: takeAMask, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::tests::foo::V1_0::IFoo::BitField *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::tests::foo::V1_0::IFoo::BitField*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_ENUM);
- profile____android__hardware__tests__foo__V1_0__IFoo__BitField(result_0, (*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- auto *result_1 __attribute__((__unused__)) = msg.add_return_type_hidl();
- uint8_t *result_val_1 __attribute__((__unused__)) = reinterpret_cast<uint8_t*> ((*args)[1]);
- if (result_val_1 != nullptr) {
- result_1->set_type(TYPE_SCALAR);
- result_1->mutable_scalar_value()->set_uint8_t((*result_val_1));
- } else {
- LOG(WARNING) << "return value 1 is null.";
- }
- auto *result_2 __attribute__((__unused__)) = msg.add_return_type_hidl();
- uint8_t *result_val_2 __attribute__((__unused__)) = reinterpret_cast<uint8_t*> ((*args)[2]);
- if (result_val_2 != nullptr) {
- result_2->set_type(TYPE_SCALAR);
- result_2->mutable_scalar_value()->set_uint8_t((*result_val_2));
- } else {
- LOG(WARNING) << "return value 2 is null.";
- }
- auto *result_3 __attribute__((__unused__)) = msg.add_return_type_hidl();
- uint8_t *result_val_3 __attribute__((__unused__)) = reinterpret_cast<uint8_t*> ((*args)[3]);
- if (result_val_3 != nullptr) {
- result_3->set_type(TYPE_SCALAR);
- result_3->mutable_scalar_value()->set_uint8_t((*result_val_3));
- } else {
- LOG(WARNING) << "return value 3 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "haveAInterface") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("haveAInterface");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: haveAInterface, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- sp<::android::hardware::tests::foo::V1_0::ISimple> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<sp<::android::hardware::tests::foo::V1_0::ISimple>*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_HIDL_INTERFACE);
- arg_0->set_predefined_type("::android::hardware::tests::foo::V1_0::ISimple");
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: haveAInterface, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- sp<::android::hardware::tests::foo::V1_0::ISimple> *result_val_0 __attribute__((__unused__)) = reinterpret_cast<sp<::android::hardware::tests::foo::V1_0::ISimple>*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_HIDL_INTERFACE);
- result_0->set_predefined_type("::android::hardware::tests::foo::V1_0::ISimple");
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
-}
-
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/test/golden/PROFILER/Bar.vts.h b/compilation_tools/vtsc/test/golden/PROFILER/Bar.vts.h
deleted file mode 100644
index bcc4c6f..0000000
--- a/compilation_tools/vtsc/test/golden/PROFILER/Bar.vts.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef __VTS_PROFILER_android_hardware_tests_bar_V1_0_IBar__
-#define __VTS_PROFILER_android_hardware_tests_bar_V1_0_IBar__
-
-
-#include <android-base/logging.h>
-#include <hidl/HidlSupport.h>
-#include <linux/limits.h>
-#include <test/vts/proto/ComponentSpecificationMessage.pb.h>
-#include "VtsProfilingInterface.h"
-
-// HACK: NAN is #defined by math.h which gets included by
-// ComponentSpecificationMessage.pb.h, but some HALs use
-// enums called NAN. Undefine NAN to work around it.
-#undef NAN
-
-#include <android/hardware/tests/bar/1.0/IBar.h>
-#include <android/hardware/tests/foo/1.0/IFoo.h>
-#include <android/hardware/tests/foo/1.0/Foo.vts.h>
-#include <android/hardware/tests/foo/1.0/IFooCallback.h>
-#include <android/hardware/tests/foo/1.0/FooCallback.vts.h>
-#include <android/hardware/tests/foo/1.0/IMyTypes.h>
-#include <android/hardware/tests/foo/1.0/MyTypes.vts.h>
-#include <android/hardware/tests/foo/1.0/ISimple.h>
-#include <android/hardware/tests/foo/1.0/Simple.vts.h>
-#include <android/hardware/tests/foo/1.0/ITheirTypes.h>
-#include <android/hardware/tests/foo/1.0/TheirTypes.vts.h>
-#include <android/hardware/tests/foo/1.0/types.h>
-#include <android/hardware/tests/foo/1.0/types.vts.h>
-#include <android/hidl/base/1.0/types.h>
-
-
-using namespace android::hardware::tests::bar::V1_0;
-using namespace android::hardware;
-
-namespace android {
-namespace vts {
-void profile____android__hardware__tests__bar__V1_0__IBar__SomethingRelated(VariableSpecificationMessage* arg_name,
-::android::hardware::tests::bar::V1_0::IBar::SomethingRelated arg_val_name);
-extern "C" {
-
- void HIDL_INSTRUMENTATION_FUNCTION_android_hardware_tests_bar_V1_0_IBar(
- details::HidlInstrumentor::InstrumentationEvent event,
- const char* package,
- const char* version,
- const char* interface,
- const char* method,
- std::vector<void *> *args);
-}
-
-} // namespace vts
-} // namespace android
-#endif
diff --git a/compilation_tools/vtsc/test/golden/PROFILER/MemoryTest.profiler.cpp b/compilation_tools/vtsc/test/golden/PROFILER/MemoryTest.profiler.cpp
deleted file mode 100644
index 4c12429..0000000
--- a/compilation_tools/vtsc/test/golden/PROFILER/MemoryTest.profiler.cpp
+++ /dev/null
@@ -1,339 +0,0 @@
-#include "android/hardware/tests/memory/1.0/MemoryTest.vts.h"
-#include <cutils/properties.h>
-#include <cutils/properties.h>
-#include <android/hidl/memory/1.0/IMemory.h>
-#include <hidlmemory/mapping.h>
-
-using namespace android::hardware::tests::memory::V1_0;
-using namespace android::hardware;
-
-#define TRACEFILEPREFIX "/data/local/tmp/"
-
-namespace android {
-namespace vts {
-
-void HIDL_INSTRUMENTATION_FUNCTION_android_hardware_tests_memory_V1_0_IMemoryTest(
- details::HidlInstrumentor::InstrumentationEvent event __attribute__((__unused__)),
- const char* package,
- const char* version,
- const char* interface,
- const char* method __attribute__((__unused__)),
- std::vector<void *> *args __attribute__((__unused__))) {
- if (strcmp(package, "android.hardware.tests.memory") != 0) {
- LOG(WARNING) << "incorrect package. Expect: android.hardware.tests.memory actual: " << package;
- }
- std::string version_str = std::string(version);
- int major_version = stoi(version_str.substr(0, version_str.find('.')));
- int minor_version = stoi(version_str.substr(version_str.find('.') + 1));
- if (major_version != 1 || minor_version > 0) {
- LOG(WARNING) << "incorrect version. Expect: 1.0 or lower (if version != x.0), actual: " << version;
- }
- if (strcmp(interface, "IMemoryTest") != 0) {
- LOG(WARNING) << "incorrect interface. Expect: IMemoryTest actual: " << interface;
- }
-
- VtsProfilingInterface& profiler = VtsProfilingInterface::getInstance(TRACEFILEPREFIX);
-
- bool profiling_for_args = property_get_bool("hal.instrumentation.profile.args", true);
- if (strcmp(method, "haveSomeMemory") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("haveSomeMemory");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: haveSomeMemory, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::hidl_memory *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_memory*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_HIDL_MEMORY);
- arg_0->mutable_hidl_memory_value()->set_size((*arg_val_0).size());
- if (property_get_bool("hal.instrumentation.dump.memory", false)){
- sp<android::hidl::memory::V1_0::IMemory> arg_0_mem = mapMemory((*arg_val_0));
- if (arg_0_mem == nullptr) {
- LOG(WARNING) << "Unable to map hidl_memory to IMemory object.";
- } else {
- arg_0_mem->read();
- char* arg_0_mem_char = static_cast<char*>(static_cast<void*>(arg_0_mem->getPointer()));
- arg_0->mutable_hidl_memory_value()->set_contents(string(arg_0_mem_char, (*arg_val_0).size()));
- arg_0_mem->commit();
- }
- }
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: haveSomeMemory, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::hidl_memory *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_memory*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_HIDL_MEMORY);
- result_0->mutable_hidl_memory_value()->set_size((*result_val_0).size());
- if (property_get_bool("hal.instrumentation.dump.memory", false)){
- sp<android::hidl::memory::V1_0::IMemory> result_0_mem = mapMemory((*result_val_0));
- if (result_0_mem == nullptr) {
- LOG(WARNING) << "Unable to map hidl_memory to IMemory object.";
- } else {
- result_0_mem->read();
- char* result_0_mem_char = static_cast<char*>(static_cast<void*>(result_0_mem->getPointer()));
- result_0->mutable_hidl_memory_value()->set_contents(string(result_0_mem_char, (*result_val_0).size()));
- result_0_mem->commit();
- }
- }
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "fillMemory") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("fillMemory");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 2) {
- LOG(ERROR) << "Number of arguments does not match. expect: 2, actual: " << (*args).size() << ", method name: fillMemory, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::hidl_memory *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_memory*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_HIDL_MEMORY);
- arg_0->mutable_hidl_memory_value()->set_size((*arg_val_0).size());
- if (property_get_bool("hal.instrumentation.dump.memory", false)){
- sp<android::hidl::memory::V1_0::IMemory> arg_0_mem = mapMemory((*arg_val_0));
- if (arg_0_mem == nullptr) {
- LOG(WARNING) << "Unable to map hidl_memory to IMemory object.";
- } else {
- arg_0_mem->read();
- char* arg_0_mem_char = static_cast<char*>(static_cast<void*>(arg_0_mem->getPointer()));
- arg_0->mutable_hidl_memory_value()->set_contents(string(arg_0_mem_char, (*arg_val_0).size()));
- arg_0_mem->commit();
- }
- }
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- auto *arg_1 __attribute__((__unused__)) = msg.add_arg();
- uint8_t *arg_val_1 __attribute__((__unused__)) = reinterpret_cast<uint8_t*> ((*args)[1]);
- if (arg_val_1 != nullptr) {
- arg_1->set_type(TYPE_SCALAR);
- arg_1->mutable_scalar_value()->set_uint8_t((*arg_val_1));
- } else {
- LOG(WARNING) << "argument 1 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of return values does not match. expect: 0, actual: " << (*args).size() << ", method name: fillMemory, event type: " << event;
- break;
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "haveSomeMemoryBlock") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("haveSomeMemoryBlock");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: haveSomeMemoryBlock, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hidl::memory::block::V1_0::MemoryBlock *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hidl::memory::block::V1_0::MemoryBlock*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_STRUCT);
- profile____android__hidl__memory__block__V1_0__MemoryBlock(arg_0, (*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: haveSomeMemoryBlock, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hidl::memory::block::V1_0::MemoryBlock *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hidl::memory::block::V1_0::MemoryBlock*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_STRUCT);
- profile____android__hidl__memory__block__V1_0__MemoryBlock(result_0, (*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "set") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("set");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: set, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::hidl_memory *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_memory*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_HIDL_MEMORY);
- arg_0->mutable_hidl_memory_value()->set_size((*arg_val_0).size());
- if (property_get_bool("hal.instrumentation.dump.memory", false)){
- sp<android::hidl::memory::V1_0::IMemory> arg_0_mem = mapMemory((*arg_val_0));
- if (arg_0_mem == nullptr) {
- LOG(WARNING) << "Unable to map hidl_memory to IMemory object.";
- } else {
- arg_0_mem->read();
- char* arg_0_mem_char = static_cast<char*>(static_cast<void*>(arg_0_mem->getPointer()));
- arg_0->mutable_hidl_memory_value()->set_contents(string(arg_0_mem_char, (*arg_val_0).size()));
- arg_0_mem->commit();
- }
- }
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of return values does not match. expect: 0, actual: " << (*args).size() << ", method name: set, event type: " << event;
- break;
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "get") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("get");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of arguments does not match. expect: 0, actual: " << (*args).size() << ", method name: get, event type: " << event;
- break;
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: get, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- sp<::android::hidl::memory::token::V1_0::IMemoryToken> *result_val_0 __attribute__((__unused__)) = reinterpret_cast<sp<::android::hidl::memory::token::V1_0::IMemoryToken>*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_HIDL_INTERFACE);
- result_0->set_predefined_type("::android::hidl::memory::token::V1_0::IMemoryToken");
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
-}
-
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/test/golden/PROFILER/MemoryTest.vts.h b/compilation_tools/vtsc/test/golden/PROFILER/MemoryTest.vts.h
deleted file mode 100644
index f713771..0000000
--- a/compilation_tools/vtsc/test/golden/PROFILER/MemoryTest.vts.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef __VTS_PROFILER_android_hardware_tests_memory_V1_0_IMemoryTest__
-#define __VTS_PROFILER_android_hardware_tests_memory_V1_0_IMemoryTest__
-
-
-#include <android-base/logging.h>
-#include <hidl/HidlSupport.h>
-#include <linux/limits.h>
-#include <test/vts/proto/ComponentSpecificationMessage.pb.h>
-#include "VtsProfilingInterface.h"
-
-// HACK: NAN is #defined by math.h which gets included by
-// ComponentSpecificationMessage.pb.h, but some HALs use
-// enums called NAN. Undefine NAN to work around it.
-#undef NAN
-
-#include <android/hardware/tests/memory/1.0/IMemoryTest.h>
-#include <android/hidl/base/1.0/types.h>
-#include <android/hidl/memory/block/1.0/types.h>
-#include <android/hidl/memory/block/1.0/types.vts.h>
-#include <android/hidl/memory/token/1.0/IMemoryToken.h>
-#include <android/hidl/memory/token/1.0/MemoryToken.vts.h>
-
-
-using namespace android::hardware::tests::memory::V1_0;
-using namespace android::hardware;
-
-namespace android {
-namespace vts {
-extern "C" {
-
- void HIDL_INSTRUMENTATION_FUNCTION_android_hardware_tests_memory_V1_0_IMemoryTest(
- details::HidlInstrumentor::InstrumentationEvent event,
- const char* package,
- const char* version,
- const char* interface,
- const char* method,
- std::vector<void *> *args);
-}
-
-} // namespace vts
-} // namespace android
-#endif
diff --git a/compilation_tools/vtsc/test/golden/PROFILER/Nfc.profiler.cpp b/compilation_tools/vtsc/test/golden/PROFILER/Nfc.profiler.cpp
deleted file mode 100644
index eae5d45..0000000
--- a/compilation_tools/vtsc/test/golden/PROFILER/Nfc.profiler.cpp
+++ /dev/null
@@ -1,394 +0,0 @@
-#include "android/hardware/nfc/1.0/Nfc.vts.h"
-#include <cutils/properties.h>
-
-using namespace android::hardware::nfc::V1_0;
-using namespace android::hardware;
-
-#define TRACEFILEPREFIX "/data/local/tmp/"
-
-namespace android {
-namespace vts {
-
-void HIDL_INSTRUMENTATION_FUNCTION_android_hardware_nfc_V1_0_INfc(
- details::HidlInstrumentor::InstrumentationEvent event __attribute__((__unused__)),
- const char* package,
- const char* version,
- const char* interface,
- const char* method __attribute__((__unused__)),
- std::vector<void *> *args __attribute__((__unused__))) {
- if (strcmp(package, "android.hardware.nfc") != 0) {
- LOG(WARNING) << "incorrect package. Expect: android.hardware.nfc actual: " << package;
- }
- std::string version_str = std::string(version);
- int major_version = stoi(version_str.substr(0, version_str.find('.')));
- int minor_version = stoi(version_str.substr(version_str.find('.') + 1));
- if (major_version != 1 || minor_version > 0) {
- LOG(WARNING) << "incorrect version. Expect: 1.0 or lower (if version != x.0), actual: " << version;
- }
- if (strcmp(interface, "INfc") != 0) {
- LOG(WARNING) << "incorrect interface. Expect: INfc actual: " << interface;
- }
-
- VtsProfilingInterface& profiler = VtsProfilingInterface::getInstance(TRACEFILEPREFIX);
-
- bool profiling_for_args = property_get_bool("hal.instrumentation.profile.args", true);
- if (strcmp(method, "open") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("open");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: open, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- sp<::android::hardware::nfc::V1_0::INfcClientCallback> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<sp<::android::hardware::nfc::V1_0::INfcClientCallback>*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_HIDL_CALLBACK);
- arg_0->set_predefined_type("::android::hardware::nfc::V1_0::INfcClientCallback");
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: open, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::nfc::V1_0::NfcStatus *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::nfc::V1_0::NfcStatus*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_ENUM);
- profile____android__hardware__nfc__V1_0__NfcStatus(result_0, (*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "write") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("write");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: write, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::hidl_vec<uint8_t> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_vec<uint8_t>*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_VECTOR);
- arg_0->set_vector_size((*arg_val_0).size());
- for (int arg_0_index = 0; arg_0_index < (int)(*arg_val_0).size(); arg_0_index++) {
- auto *arg_0_vector_arg_0_index __attribute__((__unused__)) = arg_0->add_vector_value();
- arg_0_vector_arg_0_index->set_type(TYPE_SCALAR);
- arg_0_vector_arg_0_index->mutable_scalar_value()->set_uint8_t((*arg_val_0)[arg_0_index]);
- }
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: write, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- uint32_t *result_val_0 __attribute__((__unused__)) = reinterpret_cast<uint32_t*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_SCALAR);
- result_0->mutable_scalar_value()->set_uint32_t((*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "coreInitialized") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("coreInitialized");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: coreInitialized, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::hidl_vec<uint8_t> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_vec<uint8_t>*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_VECTOR);
- arg_0->set_vector_size((*arg_val_0).size());
- for (int arg_0_index = 0; arg_0_index < (int)(*arg_val_0).size(); arg_0_index++) {
- auto *arg_0_vector_arg_0_index __attribute__((__unused__)) = arg_0->add_vector_value();
- arg_0_vector_arg_0_index->set_type(TYPE_SCALAR);
- arg_0_vector_arg_0_index->mutable_scalar_value()->set_uint8_t((*arg_val_0)[arg_0_index]);
- }
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: coreInitialized, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::nfc::V1_0::NfcStatus *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::nfc::V1_0::NfcStatus*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_ENUM);
- profile____android__hardware__nfc__V1_0__NfcStatus(result_0, (*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "prediscover") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("prediscover");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of arguments does not match. expect: 0, actual: " << (*args).size() << ", method name: prediscover, event type: " << event;
- break;
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: prediscover, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::nfc::V1_0::NfcStatus *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::nfc::V1_0::NfcStatus*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_ENUM);
- profile____android__hardware__nfc__V1_0__NfcStatus(result_0, (*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "close") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("close");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of arguments does not match. expect: 0, actual: " << (*args).size() << ", method name: close, event type: " << event;
- break;
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: close, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::nfc::V1_0::NfcStatus *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::nfc::V1_0::NfcStatus*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_ENUM);
- profile____android__hardware__nfc__V1_0__NfcStatus(result_0, (*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "controlGranted") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("controlGranted");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of arguments does not match. expect: 0, actual: " << (*args).size() << ", method name: controlGranted, event type: " << event;
- break;
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: controlGranted, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::nfc::V1_0::NfcStatus *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::nfc::V1_0::NfcStatus*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_ENUM);
- profile____android__hardware__nfc__V1_0__NfcStatus(result_0, (*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "powerCycle") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("powerCycle");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of arguments does not match. expect: 0, actual: " << (*args).size() << ", method name: powerCycle, event type: " << event;
- break;
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: powerCycle, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::nfc::V1_0::NfcStatus *result_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::nfc::V1_0::NfcStatus*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_ENUM);
- profile____android__hardware__nfc__V1_0__NfcStatus(result_0, (*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
-}
-
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/test/golden/PROFILER/Nfc.vts.h b/compilation_tools/vtsc/test/golden/PROFILER/Nfc.vts.h
deleted file mode 100644
index 70c091c..0000000
--- a/compilation_tools/vtsc/test/golden/PROFILER/Nfc.vts.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef __VTS_PROFILER_android_hardware_nfc_V1_0_INfc__
-#define __VTS_PROFILER_android_hardware_nfc_V1_0_INfc__
-
-
-#include <android-base/logging.h>
-#include <hidl/HidlSupport.h>
-#include <linux/limits.h>
-#include <test/vts/proto/ComponentSpecificationMessage.pb.h>
-#include "VtsProfilingInterface.h"
-
-// HACK: NAN is #defined by math.h which gets included by
-// ComponentSpecificationMessage.pb.h, but some HALs use
-// enums called NAN. Undefine NAN to work around it.
-#undef NAN
-
-#include <android/hardware/nfc/1.0/INfc.h>
-#include <android/hardware/nfc/1.0/INfcClientCallback.h>
-#include <android/hardware/nfc/1.0/NfcClientCallback.vts.h>
-#include <android/hardware/nfc/1.0/types.h>
-#include <android/hardware/nfc/1.0/types.vts.h>
-#include <android/hidl/base/1.0/types.h>
-
-
-using namespace android::hardware::nfc::V1_0;
-using namespace android::hardware;
-
-namespace android {
-namespace vts {
-extern "C" {
-
- void HIDL_INSTRUMENTATION_FUNCTION_android_hardware_nfc_V1_0_INfc(
- details::HidlInstrumentor::InstrumentationEvent event,
- const char* package,
- const char* version,
- const char* interface,
- const char* method,
- std::vector<void *> *args);
-}
-
-} // namespace vts
-} // namespace android
-#endif
diff --git a/compilation_tools/vtsc/test/golden/PROFILER/NfcClientCallback.profiler.cpp b/compilation_tools/vtsc/test/golden/PROFILER/NfcClientCallback.profiler.cpp
deleted file mode 100644
index eb8153f..0000000
--- a/compilation_tools/vtsc/test/golden/PROFILER/NfcClientCallback.profiler.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-#include "android/hardware/nfc/1.0/NfcClientCallback.vts.h"
-#include <cutils/properties.h>
-
-using namespace android::hardware::nfc::V1_0;
-using namespace android::hardware;
-
-#define TRACEFILEPREFIX "/data/local/tmp/"
-
-namespace android {
-namespace vts {
-
-void HIDL_INSTRUMENTATION_FUNCTION_android_hardware_nfc_V1_0_INfcClientCallback(
- details::HidlInstrumentor::InstrumentationEvent event __attribute__((__unused__)),
- const char* package,
- const char* version,
- const char* interface,
- const char* method __attribute__((__unused__)),
- std::vector<void *> *args __attribute__((__unused__))) {
- if (strcmp(package, "android.hardware.nfc") != 0) {
- LOG(WARNING) << "incorrect package. Expect: android.hardware.nfc actual: " << package;
- }
- std::string version_str = std::string(version);
- int major_version = stoi(version_str.substr(0, version_str.find('.')));
- int minor_version = stoi(version_str.substr(version_str.find('.') + 1));
- if (major_version != 1 || minor_version > 0) {
- LOG(WARNING) << "incorrect version. Expect: 1.0 or lower (if version != x.0), actual: " << version;
- }
- if (strcmp(interface, "INfcClientCallback") != 0) {
- LOG(WARNING) << "incorrect interface. Expect: INfcClientCallback actual: " << interface;
- }
-
- VtsProfilingInterface& profiler = VtsProfilingInterface::getInstance(TRACEFILEPREFIX);
-
- bool profiling_for_args = property_get_bool("hal.instrumentation.profile.args", true);
- if (strcmp(method, "sendEvent") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("sendEvent");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 2) {
- LOG(ERROR) << "Number of arguments does not match. expect: 2, actual: " << (*args).size() << ", method name: sendEvent, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::nfc::V1_0::NfcEvent *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::nfc::V1_0::NfcEvent*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_ENUM);
- profile____android__hardware__nfc__V1_0__NfcEvent(arg_0, (*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- auto *arg_1 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::nfc::V1_0::NfcStatus *arg_val_1 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::nfc::V1_0::NfcStatus*> ((*args)[1]);
- if (arg_val_1 != nullptr) {
- arg_1->set_type(TYPE_ENUM);
- profile____android__hardware__nfc__V1_0__NfcStatus(arg_1, (*arg_val_1));
- } else {
- LOG(WARNING) << "argument 1 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of return values does not match. expect: 0, actual: " << (*args).size() << ", method name: sendEvent, event type: " << event;
- break;
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "sendData") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("sendData");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: sendData, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::hidl_vec<uint8_t> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::hidl_vec<uint8_t>*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_VECTOR);
- arg_0->set_vector_size((*arg_val_0).size());
- for (int arg_0_index = 0; arg_0_index < (int)(*arg_val_0).size(); arg_0_index++) {
- auto *arg_0_vector_arg_0_index __attribute__((__unused__)) = arg_0->add_vector_value();
- arg_0_vector_arg_0_index->set_type(TYPE_SCALAR);
- arg_0_vector_arg_0_index->mutable_scalar_value()->set_uint8_t((*arg_val_0)[arg_0_index]);
- }
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of return values does not match. expect: 0, actual: " << (*args).size() << ", method name: sendData, event type: " << event;
- break;
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
-}
-
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/test/golden/PROFILER/NfcClientCallback.vts.h b/compilation_tools/vtsc/test/golden/PROFILER/NfcClientCallback.vts.h
deleted file mode 100644
index a1d6cf8..0000000
--- a/compilation_tools/vtsc/test/golden/PROFILER/NfcClientCallback.vts.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef __VTS_PROFILER_android_hardware_nfc_V1_0_INfcClientCallback__
-#define __VTS_PROFILER_android_hardware_nfc_V1_0_INfcClientCallback__
-
-
-#include <android-base/logging.h>
-#include <hidl/HidlSupport.h>
-#include <linux/limits.h>
-#include <test/vts/proto/ComponentSpecificationMessage.pb.h>
-#include "VtsProfilingInterface.h"
-
-// HACK: NAN is #defined by math.h which gets included by
-// ComponentSpecificationMessage.pb.h, but some HALs use
-// enums called NAN. Undefine NAN to work around it.
-#undef NAN
-
-#include <android/hardware/nfc/1.0/INfcClientCallback.h>
-#include <android/hardware/nfc/1.0/types.h>
-#include <android/hardware/nfc/1.0/types.vts.h>
-#include <android/hidl/base/1.0/types.h>
-
-
-using namespace android::hardware::nfc::V1_0;
-using namespace android::hardware;
-
-namespace android {
-namespace vts {
-extern "C" {
-
- void HIDL_INSTRUMENTATION_FUNCTION_android_hardware_nfc_V1_0_INfcClientCallback(
- details::HidlInstrumentor::InstrumentationEvent event,
- const char* package,
- const char* version,
- const char* interface,
- const char* method,
- std::vector<void *> *args);
-}
-
-} // namespace vts
-} // namespace android
-#endif
diff --git a/compilation_tools/vtsc/test/golden/PROFILER/TestMsgQ.profiler.cpp b/compilation_tools/vtsc/test/golden/PROFILER/TestMsgQ.profiler.cpp
deleted file mode 100644
index e2628f9..0000000
--- a/compilation_tools/vtsc/test/golden/PROFILER/TestMsgQ.profiler.cpp
+++ /dev/null
@@ -1,551 +0,0 @@
-#include "android/hardware/tests/msgq/1.0/TestMsgQ.vts.h"
-#include <cutils/properties.h>
-#include <fmq/MessageQueue.h>
-
-using namespace android::hardware::tests::msgq::V1_0;
-using namespace android::hardware;
-
-#define TRACEFILEPREFIX "/data/local/tmp/"
-
-namespace android {
-namespace vts {
-void profile____android__hardware__tests__msgq__V1_0__ITestMsgQ__EventFlagBits(VariableSpecificationMessage* arg_name,
-::android::hardware::tests::msgq::V1_0::ITestMsgQ::EventFlagBits arg_val_name __attribute__((__unused__))) {
- arg_name->set_type(TYPE_ENUM);
- arg_name->mutable_scalar_value()->set_uint32_t(static_cast<uint32_t>(arg_val_name));
- arg_name->set_scalar_type("uint32_t");
-}
-
-
-void HIDL_INSTRUMENTATION_FUNCTION_android_hardware_tests_msgq_V1_0_ITestMsgQ(
- details::HidlInstrumentor::InstrumentationEvent event __attribute__((__unused__)),
- const char* package,
- const char* version,
- const char* interface,
- const char* method __attribute__((__unused__)),
- std::vector<void *> *args __attribute__((__unused__))) {
- if (strcmp(package, "android.hardware.tests.msgq") != 0) {
- LOG(WARNING) << "incorrect package. Expect: android.hardware.tests.msgq actual: " << package;
- }
- std::string version_str = std::string(version);
- int major_version = stoi(version_str.substr(0, version_str.find('.')));
- int minor_version = stoi(version_str.substr(version_str.find('.') + 1));
- if (major_version != 1 || minor_version > 0) {
- LOG(WARNING) << "incorrect version. Expect: 1.0 or lower (if version != x.0), actual: " << version;
- }
- if (strcmp(interface, "ITestMsgQ") != 0) {
- LOG(WARNING) << "incorrect interface. Expect: ITestMsgQ actual: " << interface;
- }
-
- VtsProfilingInterface& profiler = VtsProfilingInterface::getInstance(TRACEFILEPREFIX);
-
- bool profiling_for_args = property_get_bool("hal.instrumentation.profile.args", true);
- if (strcmp(method, "configureFmqSyncReadWrite") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("configureFmqSyncReadWrite");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: configureFmqSyncReadWrite, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- ::android::hardware::MQDescriptorSync<int32_t> *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::MQDescriptorSync<int32_t>*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_FMQ_SYNC);
- MessageQueue<int32_t, kSynchronizedReadWrite> arg_0_q((*arg_val_0), false);
- if (arg_0_q.isValid()) {
- for (int i = 0; i < (int)arg_0_q.availableToRead(); i++) {
- auto *arg_0_item_i = arg_0->add_fmq_value();
- int32_t arg_0_result;
- arg_0_q.read(&arg_0_result);
- arg_0_q.write(&arg_0_result);
- arg_0_item_i->set_type(TYPE_SCALAR);
- arg_0_item_i->mutable_scalar_value()->set_int32_t(arg_0_result);
- }
- }
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: configureFmqSyncReadWrite, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- bool *result_val_0 __attribute__((__unused__)) = reinterpret_cast<bool*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_SCALAR);
- result_0->mutable_scalar_value()->set_bool_t((*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "getFmqUnsyncWrite") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("getFmqUnsyncWrite");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 2) {
- LOG(ERROR) << "Number of arguments does not match. expect: 2, actual: " << (*args).size() << ", method name: getFmqUnsyncWrite, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- bool *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<bool*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_SCALAR);
- arg_0->mutable_scalar_value()->set_bool_t((*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- auto *arg_1 __attribute__((__unused__)) = msg.add_arg();
- bool *arg_val_1 __attribute__((__unused__)) = reinterpret_cast<bool*> ((*args)[1]);
- if (arg_val_1 != nullptr) {
- arg_1->set_type(TYPE_SCALAR);
- arg_1->mutable_scalar_value()->set_bool_t((*arg_val_1));
- } else {
- LOG(WARNING) << "argument 1 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 2) {
- LOG(ERROR) << "Number of return values does not match. expect: 2, actual: " << (*args).size() << ", method name: getFmqUnsyncWrite, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- bool *result_val_0 __attribute__((__unused__)) = reinterpret_cast<bool*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_SCALAR);
- result_0->mutable_scalar_value()->set_bool_t((*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- auto *result_1 __attribute__((__unused__)) = msg.add_return_type_hidl();
- ::android::hardware::MQDescriptorUnsync<int32_t> *result_val_1 __attribute__((__unused__)) = reinterpret_cast<::android::hardware::MQDescriptorUnsync<int32_t>*> ((*args)[1]);
- if (result_val_1 != nullptr) {
- result_1->set_type(TYPE_FMQ_UNSYNC);
- MessageQueue<int32_t, kUnsynchronizedWrite> result_1_q((*result_val_1));
- if (result_1_q.isValid()) {
- for (int i = 0; i < (int)result_1_q.availableToRead(); i++) {
- auto *result_1_item_i = result_1->add_fmq_value();
- int32_t result_1_result;
- result_1_q.read(&result_1_result);
- result_1_item_i->set_type(TYPE_SCALAR);
- result_1_item_i->mutable_scalar_value()->set_int32_t(result_1_result);
- }
- }
- } else {
- LOG(WARNING) << "return value 1 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "requestWriteFmqSync") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("requestWriteFmqSync");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: requestWriteFmqSync, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- int32_t *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<int32_t*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_SCALAR);
- arg_0->mutable_scalar_value()->set_int32_t((*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: requestWriteFmqSync, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- bool *result_val_0 __attribute__((__unused__)) = reinterpret_cast<bool*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_SCALAR);
- result_0->mutable_scalar_value()->set_bool_t((*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "requestReadFmqSync") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("requestReadFmqSync");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: requestReadFmqSync, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- int32_t *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<int32_t*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_SCALAR);
- arg_0->mutable_scalar_value()->set_int32_t((*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: requestReadFmqSync, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- bool *result_val_0 __attribute__((__unused__)) = reinterpret_cast<bool*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_SCALAR);
- result_0->mutable_scalar_value()->set_bool_t((*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "requestWriteFmqUnsync") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("requestWriteFmqUnsync");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: requestWriteFmqUnsync, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- int32_t *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<int32_t*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_SCALAR);
- arg_0->mutable_scalar_value()->set_int32_t((*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: requestWriteFmqUnsync, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- bool *result_val_0 __attribute__((__unused__)) = reinterpret_cast<bool*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_SCALAR);
- result_0->mutable_scalar_value()->set_bool_t((*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "requestReadFmqUnsync") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("requestReadFmqUnsync");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: requestReadFmqUnsync, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- int32_t *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<int32_t*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_SCALAR);
- arg_0->mutable_scalar_value()->set_int32_t((*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of return values does not match. expect: 1, actual: " << (*args).size() << ", method name: requestReadFmqUnsync, event type: " << event;
- break;
- }
- auto *result_0 __attribute__((__unused__)) = msg.add_return_type_hidl();
- bool *result_val_0 __attribute__((__unused__)) = reinterpret_cast<bool*> ((*args)[0]);
- if (result_val_0 != nullptr) {
- result_0->set_type(TYPE_SCALAR);
- result_0->mutable_scalar_value()->set_bool_t((*result_val_0));
- } else {
- LOG(WARNING) << "return value 0 is null.";
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "requestBlockingRead") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("requestBlockingRead");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: requestBlockingRead, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- int32_t *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<int32_t*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_SCALAR);
- arg_0->mutable_scalar_value()->set_int32_t((*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of return values does not match. expect: 0, actual: " << (*args).size() << ", method name: requestBlockingRead, event type: " << event;
- break;
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "requestBlockingReadDefaultEventFlagBits") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("requestBlockingReadDefaultEventFlagBits");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 1) {
- LOG(ERROR) << "Number of arguments does not match. expect: 1, actual: " << (*args).size() << ", method name: requestBlockingReadDefaultEventFlagBits, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- int32_t *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<int32_t*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_SCALAR);
- arg_0->mutable_scalar_value()->set_int32_t((*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of return values does not match. expect: 0, actual: " << (*args).size() << ", method name: requestBlockingReadDefaultEventFlagBits, event type: " << event;
- break;
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
- if (strcmp(method, "requestBlockingReadRepeat") == 0) {
- FunctionSpecificationMessage msg;
- msg.set_name("requestBlockingReadRepeat");
- if (profiling_for_args) {
- if (!args) {
- LOG(WARNING) << "no argument passed";
- } else {
- switch (event) {
- case details::HidlInstrumentor::CLIENT_API_ENTRY:
- case details::HidlInstrumentor::SERVER_API_ENTRY:
- case details::HidlInstrumentor::PASSTHROUGH_ENTRY:
- {
- if ((*args).size() != 2) {
- LOG(ERROR) << "Number of arguments does not match. expect: 2, actual: " << (*args).size() << ", method name: requestBlockingReadRepeat, event type: " << event;
- break;
- }
- auto *arg_0 __attribute__((__unused__)) = msg.add_arg();
- int32_t *arg_val_0 __attribute__((__unused__)) = reinterpret_cast<int32_t*> ((*args)[0]);
- if (arg_val_0 != nullptr) {
- arg_0->set_type(TYPE_SCALAR);
- arg_0->mutable_scalar_value()->set_int32_t((*arg_val_0));
- } else {
- LOG(WARNING) << "argument 0 is null.";
- }
- auto *arg_1 __attribute__((__unused__)) = msg.add_arg();
- int32_t *arg_val_1 __attribute__((__unused__)) = reinterpret_cast<int32_t*> ((*args)[1]);
- if (arg_val_1 != nullptr) {
- arg_1->set_type(TYPE_SCALAR);
- arg_1->mutable_scalar_value()->set_int32_t((*arg_val_1));
- } else {
- LOG(WARNING) << "argument 1 is null.";
- }
- break;
- }
- case details::HidlInstrumentor::CLIENT_API_EXIT:
- case details::HidlInstrumentor::SERVER_API_EXIT:
- case details::HidlInstrumentor::PASSTHROUGH_EXIT:
- {
- if ((*args).size() != 0) {
- LOG(ERROR) << "Number of return values does not match. expect: 0, actual: " << (*args).size() << ", method name: requestBlockingReadRepeat, event type: " << event;
- break;
- }
- break;
- }
- default:
- {
- LOG(WARNING) << "not supported. ";
- break;
- }
- }
- }
- }
- profiler.AddTraceEvent(event, package, version, interface, msg);
- }
-}
-
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/test/golden/PROFILER/TestMsgQ.vts.h b/compilation_tools/vtsc/test/golden/PROFILER/TestMsgQ.vts.h
deleted file mode 100644
index afa2379..0000000
--- a/compilation_tools/vtsc/test/golden/PROFILER/TestMsgQ.vts.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef __VTS_PROFILER_android_hardware_tests_msgq_V1_0_ITestMsgQ__
-#define __VTS_PROFILER_android_hardware_tests_msgq_V1_0_ITestMsgQ__
-
-
-#include <android-base/logging.h>
-#include <hidl/HidlSupport.h>
-#include <linux/limits.h>
-#include <test/vts/proto/ComponentSpecificationMessage.pb.h>
-#include "VtsProfilingInterface.h"
-
-// HACK: NAN is #defined by math.h which gets included by
-// ComponentSpecificationMessage.pb.h, but some HALs use
-// enums called NAN. Undefine NAN to work around it.
-#undef NAN
-
-#include <android/hardware/tests/msgq/1.0/ITestMsgQ.h>
-#include <android/hidl/base/1.0/types.h>
-
-
-using namespace android::hardware::tests::msgq::V1_0;
-using namespace android::hardware;
-
-namespace android {
-namespace vts {
-void profile____android__hardware__tests__msgq__V1_0__ITestMsgQ__EventFlagBits(VariableSpecificationMessage* arg_name,
-::android::hardware::tests::msgq::V1_0::ITestMsgQ::EventFlagBits arg_val_name);
-extern "C" {
-
- void HIDL_INSTRUMENTATION_FUNCTION_android_hardware_tests_msgq_V1_0_ITestMsgQ(
- details::HidlInstrumentor::InstrumentationEvent event,
- const char* package,
- const char* version,
- const char* interface,
- const char* method,
- std::vector<void *> *args);
-}
-
-} // namespace vts
-} // namespace android
-#endif
diff --git a/compilation_tools/vtsc/test/golden/PROFILER/types.profiler.cpp b/compilation_tools/vtsc/test/golden/PROFILER/types.profiler.cpp
deleted file mode 100644
index 76c885c..0000000
--- a/compilation_tools/vtsc/test/golden/PROFILER/types.profiler.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "android/hardware/nfc/1.0/types.vts.h"
-#include <cutils/properties.h>
-
-using namespace android::hardware::nfc::V1_0;
-using namespace android::hardware;
-
-#define TRACEFILEPREFIX "/data/local/tmp/"
-
-namespace android {
-namespace vts {
-void profile____android__hardware__nfc__V1_0__NfcEvent(VariableSpecificationMessage* arg_name,
-::android::hardware::nfc::V1_0::NfcEvent arg_val_name __attribute__((__unused__))) {
- arg_name->set_type(TYPE_ENUM);
- arg_name->mutable_scalar_value()->set_uint32_t(static_cast<uint32_t>(arg_val_name));
- arg_name->set_scalar_type("uint32_t");
-}
-
-void profile____android__hardware__nfc__V1_0__NfcStatus(VariableSpecificationMessage* arg_name,
-::android::hardware::nfc::V1_0::NfcStatus arg_val_name __attribute__((__unused__))) {
- arg_name->set_type(TYPE_ENUM);
- arg_name->mutable_scalar_value()->set_uint32_t(static_cast<uint32_t>(arg_val_name));
- arg_name->set_scalar_type("uint32_t");
-}
-
-} // namespace vts
-} // namespace android
diff --git a/compilation_tools/vtsc/test/golden/PROFILER/types.vts.h b/compilation_tools/vtsc/test/golden/PROFILER/types.vts.h
deleted file mode 100644
index 967316d..0000000
--- a/compilation_tools/vtsc/test/golden/PROFILER/types.vts.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef __VTS_PROFILER_android_hardware_nfc_V1_0_types__
-#define __VTS_PROFILER_android_hardware_nfc_V1_0_types__
-
-
-#include <android-base/logging.h>
-#include <hidl/HidlSupport.h>
-#include <linux/limits.h>
-#include <test/vts/proto/ComponentSpecificationMessage.pb.h>
-#include "VtsProfilingInterface.h"
-
-// HACK: NAN is #defined by math.h which gets included by
-// ComponentSpecificationMessage.pb.h, but some HALs use
-// enums called NAN. Undefine NAN to work around it.
-#undef NAN
-
-#include <android/hardware/nfc/1.0/types.h>
-
-
-using namespace android::hardware::nfc::V1_0;
-using namespace android::hardware;
-
-namespace android {
-namespace vts {
-void profile____android__hardware__nfc__V1_0__NfcEvent(VariableSpecificationMessage* arg_name,
-::android::hardware::nfc::V1_0::NfcEvent arg_val_name);
-void profile____android__hardware__nfc__V1_0__NfcStatus(VariableSpecificationMessage* arg_name,
-::android::hardware::nfc::V1_0::NfcStatus arg_val_name);
-} // namespace vts
-} // namespace android
-#endif
diff --git a/compilation_tools/vtsc/test/test_vtsc.py b/compilation_tools/vtsc/test/test_vtsc.py
deleted file mode 100755
index a43d517..0000000
--- a/compilation_tools/vtsc/test/test_vtsc.py
+++ /dev/null
@@ -1,306 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 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.
-
-import difflib
-import filecmp
-import getopt
-import logging
-import os
-import shutil
-import subprocess
-import sys
-import unittest
-
-from vts.utils.python.common import cmd_utils
-
-
-class VtscTester(unittest.TestCase):
- """Integration test runner for vtsc in generating the driver/profiler code.
-
- Runs vtsc with specified mode on a bunch of files and compares the output
- results with canonical ones. Exit code is 0 iff all tests pass.
- Note: need to run the script from the source root to preserve the correct
- path.
-
- Usage:
- python test_vtsc.py path_to_vtsc canonical_dir output_dir
-
- example:
- python test/vts/compilation_tools/vtsc/test/test_vtsc.py vtsc
- test/vts/compilation_tools/vtsc/test/golden/ temp_output
-
- Attributes:
- _hidl_gen_path: the path to run hidl-gen
- _vtsc_path: the path to run vtsc.
- _canonical_dir: root directory contains canonical files for comparison.
- _output_dir: root directory that stores all output files.
- _errors: number of errors generates during the test.
- _temp_dir: temp dir to store the .vts file generated by hidl-gen.
- """
-
- def __init__(self, testName, hidl_gen_path, vtsc_path, canonical_dir,
- output_dir, temp_dir):
- super(VtscTester, self).__init__(testName)
- self._hidl_gen_path = hidl_gen_path
- self._vtsc_path = vtsc_path
- self._canonical_dir = canonical_dir
- self._output_dir = output_dir
- self._errors = 0
- self._temp_dir = temp_dir
-
- def setUp(self):
- """Removes output dir to prevent interference from previous runs."""
- self.RemoveOutputDir()
-
- def tearDown(self):
- """If successful, removes the output dir for clean-up."""
- if self._errors == 0:
- self.RemoveOutputDir()
-
- def testAll(self):
- """Run all tests. """
- self.TestDriver()
- self.TestProfiler()
- self.TestFuzzer()
- self.assertEqual(self._errors, 0)
-
- def TestDriver(self):
- """Run tests for DRIVER mode. """
- logging.info("Running TestDriver test case.")
- # Tests for Hidl Hals.
- for package_path, component_names in zip(
- ["android.hardware.nfc@1.0",
- "android.hardware.tests.bar@1.0",
- "android.hardware.tests.msgq@1.0",
- "android.hardware.tests.memory@1.0"],
- [["Nfc", "NfcClientCallback", "types"],
- ["Bar"], ["TestMsgQ"], ["MemoryTest"]]):
- self.GenerateVtsFile(package_path)
- for component_name in component_names:
- self.RunTest(
- "DRIVER",
- os.path.join(self._temp_dir, component_name + ".vts"),
- "%s.vts.h" % component_name,
- header_file_name="%s.vts.h" % component_name,
- file_type="HEADER")
- self.RunTest(
- "DRIVER",
- os.path.join(self._temp_dir, component_name + ".vts"),
- "%s.driver.cpp" % component_name,
- file_type="SOURCE")
- # Tests for shared libraries.
- for component_name in ["libcV1"]:
- self.RunTest("DRIVER",
- "test/vts/specification/lib/ndk/bionic/1.0/%s.vts" %
- component_name, "%s.driver.cpp" % component_name)
-
- def TestProfiler(self):
- """Run tests for PROFILER mode. """
- logging.info("Running TestProfiler test case.")
- #self.GenerateVtsFile("android.hardware.nfc@1.0")
- for package_path, component_names in zip(
- ["android.hardware.nfc@1.0",
- "android.hardware.tests.bar@1.0",
- "android.hardware.tests.msgq@1.0",
- "android.hardware.tests.memory@1.0"],
- [["Nfc", "NfcClientCallback", "types"],
- ["Bar"], ["TestMsgQ"], ["MemoryTest"]]):
- self.GenerateVtsFile(package_path)
- for component_name in component_names:
- self.RunTest(
- "PROFILER",
- os.path.join(self._temp_dir, component_name + ".vts"),
- "%s.vts.h" % component_name,
- header_file_name="%s.vts.h" % component_name,
- file_type="HEADER")
- self.RunTest(
- "PROFILER",
- os.path.join(self._temp_dir, component_name + ".vts"),
- "%s.profiler.cpp" % component_name,
- file_type="SOURCE")
-
- def TestFuzzer(self):
- """Run tests for Fuzzer mode. """
- logging.info("Running TestProfiler test case.")
- self.GenerateVtsFile("android.hardware.renderscript@1.0")
- for component_name in ["Context", "Device", "types"]:
- self.RunTest(
- "FUZZER",
- os.path.join(self._temp_dir, component_name + ".vts"),
- "%s.fuzzer.cpp" % component_name,
- file_type="SOURCE")
-
- def RunFuzzerTest(self, mode, vts_file_path, source_file_name):
- vtsc_cmd = [
- self._vtsc_path, "-m" + mode, vts_file_path,
- os.path.join(self._output_dir, mode),
- os.path.join(self._output_dir, mode, "")
- ]
- return_code = cmd_utils.RunCommand(vtsc_cmd)
-
- canonical_source_file = os.path.join(self._canonical_dir, mode,
- source_file_name)
- output_source_file = os.path.join(self._output_dir, mode,
- source_file_name)
- self.CompareOutputFile(output_source_file, canonical_source_file)
-
- def GenerateVtsFile(self, hal_package_name):
- """Run hidl-gen to generate the .vts files for the give hal package.
-
- Args:
- hal_package_name: name of hal package e.g. android.hardware.nfc@1.0
- """
- hidl_gen_cmd = [
- self._hidl_gen_path, "-o" + self._temp_dir, "-Lvts",
- "-randroid.hardware:hardware/interfaces",
- "-randroid.hidl:system/libhidl/transport", hal_package_name
- ]
- return_code = cmd_utils.RunCommand(hidl_gen_cmd)
- if (return_code != 0):
- self.Error("Fail to execute command: %s" % hidl_gen_cmd)
- [hal_name, hal_version] = hal_package_name.split("@")
- output_dir = os.path.join(self._temp_dir,
- hal_name.replace(".", "/"), hal_version)
- for file in os.listdir(output_dir):
- if file.endswith(".vts"):
- os.rename(
- os.path.join(output_dir, file),
- os.path.join(self._temp_dir, file))
-
- def RunTest(self,
- mode,
- vts_file_path,
- output_file_name,
- header_file_name="",
- file_type="BOTH"):
- """Run vtsc with given mode for the give vts file and compare the
- output results.
-
- Args:
- mode: the vtsc mode for generated code. e.g. DRIVER / PROFILER.
- vts_file_path: path of the input vts file.
- source_file_name: name of the generated source file.
- file_type: type of file e.g. HEADER / SOURCE / BOTH.
- """
- if (file_type == "BOTH"):
- vtsc_cmd = [
- self._vtsc_path, "-m" + mode, vts_file_path,
- os.path.join(self._output_dir, mode),
- os.path.join(self._output_dir, mode, output_file_name)
- ]
- else:
- vtsc_cmd = [
- self._vtsc_path, "-m" + mode, "-t" + file_type, vts_file_path,
- os.path.join(self._output_dir, mode, output_file_name)
- ]
- return_code = cmd_utils.RunCommand(vtsc_cmd)
- if (return_code != 0):
- self.Error("Fail to execute command: %s" % vtsc_cmd)
-
- if (file_type == "HEADER" or file_type == "BOTH"):
- if not header_file_name:
- header_file_name = vts_file_path + ".h"
- canonical_header_file = os.path.join(self._canonical_dir, mode,
- header_file_name)
- output_header_file = os.path.join(self._output_dir, mode,
- header_file_name)
- self.CompareOutputFile(output_header_file, canonical_header_file)
- elif (file_type == "SOURCE" or file_type == "BOTH"):
- canonical_source_file = os.path.join(self._canonical_dir, mode,
- output_file_name)
- output_source_file = os.path.join(self._output_dir, mode,
- output_file_name)
- self.CompareOutputFile(output_source_file, canonical_source_file)
- else:
- self.Error("No such file_type: %s" % file_type)
-
- def CompareOutputFile(self, output_file, canonical_file):
- """Compares a given file and the corresponding one under canonical_dir.
-
- Args:
- canonical_file: name of the canonical file.
- output_file: name of the output file.
- """
- if not os.path.isfile(canonical_file):
- self.Error("Generated unexpected file: %s (for %s)" %
- (output_file, canonical_file))
- else:
- if not filecmp.cmp(output_file, canonical_file):
- self.Error(
- "output file: %s does not match the canonical_file: "
- "%s" % (output_file, canonical_file))
- self.PrintDiffFiles(output_file, canonical_file)
-
- def PrintDiffFiles(self, output_file, canonical_file):
- with open(output_file, 'r') as file1:
- with open(canonical_file, 'r') as file2:
- diff = difflib.unified_diff(
- file1.readlines(),
- file2.readlines(),
- fromfile=output_file,
- tofile=canonical_file)
- for line in diff:
- logging.error(line)
-
- def Error(self, string):
- """Prints an error message and increments error count."""
- logging.error(string)
- self._errors += 1
-
- def RemoveOutputDir(self):
- """Remove the output_dir if it exists."""
- if os.path.exists(self._output_dir):
- logging.info("rm -rf %s", self._output_dir)
- shutil.rmtree(self._output_dir)
- if os.path.exists(self._temp_dir):
- shutil.rmtree(self._temp_dir)
-
-
-if __name__ == "__main__":
- # Default values of the input parameter, could be overridden by command.
- vtsc_path = "vtsc"
- canonical_dir = "test/vts/compilation_tools/vtsc/test/golden/"
- output_dir = "test/vts/compilation_tools/vtsc/test/temp_coutput/"
- # Parse the arguments and set the provided value for
- # hidl-gen/vtsc_path/canonical_dar/output_dir.
- try:
- opts, _ = getopt.getopt(sys.argv[1:], "h:p:c:o:t:")
- except getopt.GetoptError, err:
- print "Usage: python test_vtsc.py [-h hidl_gen_path] [-p vtsc_path] " \
- "[-c canonical_dir] [-o output_dir] [-t temp_dir]"
- sys.exit(1)
- for opt, val in opts:
- if opt == "-h":
- hidl_gen_path = val
- elif opt == "-p":
- vtsc_path = val
- elif opt == "-c":
- canonical_dir = val
- elif opt == "-o":
- output_dir = val
- elif opt == "-t":
- temp_dir = val
- else:
- print "unhandled option %s" % (opt, )
- sys.exit(1)
-
- suite = unittest.TestSuite()
- suite.addTest(
- VtscTester('testAll', hidl_gen_path, vtsc_path, canonical_dir,
- output_dir, temp_dir))
- result = unittest.TextTestRunner(verbosity=2).run(suite)
- if not result.wasSuccessful():
- sys.exit(-1)
diff --git a/drivers/hal/common/Android.bp b/drivers/hal/common/Android.bp
deleted file mode 100644
index f14a8f5..0000000
--- a/drivers/hal/common/Android.bp
+++ /dev/null
@@ -1,85 +0,0 @@
-//
-// 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 {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-cc_library_shared {
-
- name: "libvts_common",
- host_supported: true,
- // TODO(b/153609531): remove when no longer needed.
- native_bridge_supported: true,
-
- cflags: [
- "-Wall",
- "-Werror",
- ],
-
- srcs: [
- "utils/InterfaceSpecUtil.cpp",
- "utils/StringUtil.cpp",
- ],
-
- include_dirs: [
- "frameworks/native/include",
- "system/core/include",
- "system/extras",
- ],
-
- local_include_dirs: ["include"],
-
- shared_libs: [
- "libbase",
- "libprotobuf-cpp-full",
- "libvts_multidevice_proto",
- ],
-
- header_libs: [
- "libhardware_headers",
- ],
-
- export_header_lib_headers: [
- "libhardware_headers",
- ],
-
- export_include_dirs: ["include"],
-
- target: {
- android: {
- srcs: [
- "binder/VtsFuzzerBinderService.cpp",
- "component_loader/DllLoader.cpp",
- "component_loader/HalDriverLoader.cpp",
- "driver_base/DriverBase.cpp",
- "driver_base/DriverCallbackBase.cpp",
- "driver_manager/VtsHalDriverManager.cpp",
- ],
- shared_libs: [
- "libbinder",
- "libcutils",
- "libdl",
- "liblog",
- "libutils",
- "libvts_codecoverage",
- "libvts_drivercomm",
- "libvts_multidevice_proto",
- "libvts_resource_manager",
- ],
- },
- },
-}
diff --git a/drivers/hal/common/binder/VtsFuzzerBinderService.cpp b/drivers/hal/common/binder/VtsFuzzerBinderService.cpp
deleted file mode 100644
index 2a7960e..0000000
--- a/drivers/hal/common/binder/VtsFuzzerBinderService.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include <stdlib.h>
-
-#include <iostream>
-#include <string>
-
-#define LOG_TAG "VtsFuzzerBinderService"
-#include <log/log.h>
-#include <utils/RefBase.h>
-
-#include <binder/IBinder.h>
-#include <binder/IInterface.h>
-#include <binder/IPCThreadState.h>
-#include <binder/IServiceManager.h>
-#include <binder/ProcessState.h>
-#include <binder/TextOutput.h>
-
-#include "binder/VtsFuzzerBinderService.h"
-#include "utils/InterfaceSpecUtil.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-IMPLEMENT_META_INTERFACE(VtsFuzzer, VTS_FUZZER_BINDER_SERVICE_NAME);
-
-void BpVtsFuzzer::Exit() {
- Parcel data;
- Parcel reply;
- data.writeInterfaceToken(IVtsFuzzer::getInterfaceDescriptor());
- data.writeString16(String16("Exit code"));
- remote()->transact(EXIT, data, &reply, IBinder::FLAG_ONEWAY);
-}
-
-int32_t BpVtsFuzzer::LoadHal(const string& path, int target_class,
- int target_type, int target_version_major,
- int target_version_minor,
- const string& module_name) {
- Parcel data;
- Parcel reply;
-
- printf("agent->driver: LoadHal(%s, %d, %d, %s, %s)\n", path.c_str(),
- target_class, target_type,
- GetVersionString(target_version_major, target_version_minor).c_str(),
- module_name.c_str());
- data.writeInterfaceToken(IVtsFuzzer::getInterfaceDescriptor());
- data.writeCString(path.c_str());
- data.writeInt32(target_class);
- data.writeInt32(target_type);
- data.writeInt32(target_version_major);
- data.writeInt32(target_version_minor);
- data.writeCString(module_name.c_str());
-
-#ifdef VTS_FUZZER_BINDER_DEBUG
- alog << "BpVtsFuzzer::Status request parcel:\n"
- << data
- << endl;
-#endif
-
- remote()->transact(LOAD_HAL, data, &reply);
-
-#ifdef VTS_FUZZER_BINDER_DEBUG
- alog << "BpVtsFuzzer::Status response parcel:\n"
- << reply
- << endl;
-#endif
-
- int32_t res;
- status_t status = reply.readInt32(&res);
-
- printf("driver->agent: LoadHal returns %d\n", status);
- return res;
-}
-
-int32_t BpVtsFuzzer::Status(int32_t type) {
- Parcel data;
- Parcel reply;
-
- data.writeInterfaceToken(IVtsFuzzer::getInterfaceDescriptor());
- data.writeInt32(type);
-
-#ifdef VTS_FUZZER_BINDER_DEBUG
- alog << "BpVtsFuzzer::Status request parcel:\n"
- << data
- << endl;
-#endif
-
- remote()->transact(STATUS, data, &reply);
-
-#ifdef VTS_FUZZER_BINDER_DEBUG
- alog << "BpVtsFuzzer::Status response parcel:\n"
- << reply
- << endl;
-#endif
-
- int32_t res;
- /* status_t */ reply.readInt32(&res);
- return res;
-}
-
-string BpVtsFuzzer::Call(const string& call_payload) {
- Parcel data, reply;
- data.writeInterfaceToken(IVtsFuzzer::getInterfaceDescriptor());
- data.writeCString(call_payload.c_str());
-#ifdef VTS_FUZZER_BINDER_DEBUG
- alog << data << endl;
-#endif
-
- remote()->transact(CALL, data, &reply);
-#ifdef VTS_FUZZER_BINDER_DEBUG
- alog << reply << endl;
-#endif
-
- const char* res = reply.readCString();
- if (res == NULL) {
- printf("reply == NULL\n");
- return res;
- }
-
- printf("len(reply) = %zu\n", strlen(res));
- return {res};
-}
-
-const char* BpVtsFuzzer::GetFunctions() {
- Parcel data, reply;
- data.writeInterfaceToken(IVtsFuzzer::getInterfaceDescriptor());
-#ifdef VTS_FUZZER_BINDER_DEBUG
- alog << data << endl;
-#endif
-
- remote()->transact(GET_FUNCTIONS, data, &reply);
-#ifdef VTS_FUZZER_BINDER_DEBUG
- alog << reply << endl;
-#endif
-
- const char* res = reply.readCString();
- if (res == NULL) {
- printf("reply == NULL\n");
- return res;
- }
-
- printf("len(reply) = %zu\n", strlen(res));
- return res;
-}
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/hal/common/component_loader/DllLoader.cpp b/drivers/hal/common/component_loader/DllLoader.cpp
deleted file mode 100644
index 04cab45..0000000
--- a/drivers/hal/common/component_loader/DllLoader.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * 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.
- */
-
-#include "component_loader/DllLoader.h"
-
-#include <android-base/logging.h>
-#include <dlfcn.h>
-
-namespace android {
-namespace vts {
-
-DllLoader::DllLoader() : handle_(NULL) {}
-
-DllLoader::~DllLoader() {
- if (!handle_) {
- dlclose(handle_);
- handle_ = NULL;
- }
-}
-
-void* DllLoader::Load(const char* file_path) {
- if (!file_path) {
- LOG(ERROR) << "file_path is NULL";
- return NULL;
- }
-
- // consider using the load mechanism in hardware/libhardware/hardware.c
- handle_ = dlopen(file_path, RTLD_LAZY);
- if (!handle_) {
- LOG(ERROR) << "Can't load a shared library, " << file_path
- << ", error: " << dlerror();
- return NULL;
- }
- LOG(DEBUG) << "DLL loaded " << file_path;
- return handle_;
-}
-
-loader_function DllLoader::GetLoaderFunction(const char* function_name) const {
- return (loader_function)LoadSymbol(function_name);
-}
-
-loader_function_with_arg DllLoader::GetLoaderFunctionWithArg(
- const char* function_name) const {
- return (loader_function_with_arg)LoadSymbol(function_name);
-}
-
-bool DllLoader::SancovResetCoverage() {
- void (*func)() = (void (*)())LoadSymbol("__sanitizer_reset_coverage");
- if (func == NULL) {
- return false;
- }
- func();
- return true;
-}
-
-bool DllLoader::GcovInit(writeout_fn wfn, flush_fn ffn) {
- void (*func)(writeout_fn, flush_fn) =
- (void (*)(writeout_fn, flush_fn))LoadSymbol("llvm_gcov_init");
- if (func == NULL) {
- return false;
- }
- func(wfn, ffn);
- return true;
-}
-
-bool DllLoader::GcovFlush() {
- void (*func)() = (void (*)()) LoadSymbol("__gcov_flush");
- if (func == NULL) {
- return false;
- }
- func();
- return true;
-}
-
-void* DllLoader::LoadSymbol(const char* symbol_name) const {
- const char* error = dlerror();
- if (error != NULL) {
- LOG(ERROR) << "Existing error message " << error << "before loading "
- << symbol_name;
- }
- void* sym = dlsym(handle_, symbol_name);
- if ((error = dlerror()) != NULL) {
- LOG(ERROR) << "Can't find " << symbol_name << " error: " << error;
- return NULL;
- }
- return sym;
-}
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/hal/common/component_loader/HalDriverLoader.cpp b/drivers/hal/common/component_loader/HalDriverLoader.cpp
deleted file mode 100644
index 5414447..0000000
--- a/drivers/hal/common/component_loader/HalDriverLoader.cpp
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * 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.
- */
-#define LOG_TAG "VtsHalDriverLoader"
-
-#include "component_loader/HalDriverLoader.h"
-
-#include <dirent.h>
-
-#include <android-base/logging.h>
-#include <cutils/properties.h>
-#include <google/protobuf/text_format.h>
-
-#include "utils/InterfaceSpecUtil.h"
-#include "utils/StringUtil.h"
-
-static constexpr const char* kSpecFileExt = ".vts";
-static constexpr const char* kDefaultHwbinderServiceName = "default";
-
-namespace android {
-namespace vts {
-
-HalDriverLoader::HalDriverLoader(const string dir_path, int epoch_count,
- const string& callback_socket_name)
- : dir_path_(dir_path),
- epoch_count_(epoch_count),
- callback_socket_name_(callback_socket_name) {}
-
-bool HalDriverLoader::FindComponentSpecification(
- const int component_class, const string& package_name,
- const int version_major, const int version_minor,
- const string& component_name, const int component_type,
- ComponentSpecificationMessage* spec_msg) {
- DIR* dir;
- struct dirent* ent;
-
- // Derive the package-specific dir which contains .vts files
- string driver_lib_dir = dir_path_;
- if (!endsWith(driver_lib_dir, "/")) {
- driver_lib_dir += "/";
- }
- string package_path = package_name;
- ReplaceSubString(package_path, ".", "/");
- driver_lib_dir += package_path + "/";
- driver_lib_dir += GetVersionString(version_major, version_minor);
-
- if (!(dir = opendir(driver_lib_dir.c_str()))) {
- LOG(ERROR) << "Can't open dir " << driver_lib_dir;
- return false;
- }
-
- while ((ent = readdir(dir))) {
- if (ent->d_type == DT_REG &&
- string(ent->d_name).find(kSpecFileExt) != std::string::npos) {
- LOG(DEBUG) << "Checking a file " << ent->d_name;
- const string file_path = driver_lib_dir + "/" + string(ent->d_name);
- if (ParseInterfaceSpec(file_path.c_str(), spec_msg)) {
- if (spec_msg->component_class() != component_class) {
- continue;
- }
- if (spec_msg->component_class() != HAL_HIDL) {
- if (spec_msg->component_type() != component_type ||
- spec_msg->component_type_version_major() != version_major ||
- spec_msg->component_type_version_minor() != version_minor) {
- continue;
- }
- closedir(dir);
- return true;
- } else {
- if (spec_msg->package() != package_name ||
- spec_msg->component_type_version_major() != version_major ||
- spec_msg->component_type_version_minor() != version_minor) {
- continue;
- }
- if (!component_name.empty()) {
- if (spec_msg->component_name() != component_name) {
- continue;
- }
- }
- closedir(dir);
- return true;
- }
- }
- }
- }
- closedir(dir);
- return false;
-}
-
-DriverBase* HalDriverLoader::GetDriver(
- const string& driver_lib_path,
- const ComponentSpecificationMessage& spec_msg,
- const string& hw_binder_service_name, const uint64_t interface_pt,
- bool with_interface_pointer, const string& dll_file_name) {
- DriverBase* driver = nullptr;
- if (spec_msg.component_class() == HAL_HIDL) {
- driver = GetHidlHalDriver(driver_lib_path, spec_msg, hw_binder_service_name,
- interface_pt, with_interface_pointer);
- } else {
- driver = GetLibDriver(driver_lib_path, spec_msg, dll_file_name);
- }
- LOG(DEBUG) << "Loaded target comp";
-
- return driver;
-}
-
-DriverBase* HalDriverLoader::GetLibDriver(
- const string& driver_lib_path,
- const ComponentSpecificationMessage& spec_msg,
- const string& dll_file_name) {
- DriverBase* driver = LoadDriver(driver_lib_path, spec_msg);
- if (!driver) {
- LOG(ERROR) << "Couldn't get a driver base class";
- return nullptr;
- }
- if (!driver->LoadTargetComponent(dll_file_name.c_str())) {
- LOG(ERROR) << "Couldn't load target component file, " << dll_file_name;
- return nullptr;
- }
- return driver;
-}
-
-DriverBase* HalDriverLoader::GetFuzzerBaseAndAddAllFunctionsToQueue(
- const char* driver_lib_path,
- const ComponentSpecificationMessage& iface_spec_msg,
- const char* dll_file_name, const char* hw_service_name) {
- DriverBase* driver = GetDriver(driver_lib_path, iface_spec_msg,
- hw_service_name, 0, false, dll_file_name);
- if (!driver) {
- LOG(ERROR) << "Couldn't get a driver base class";
- return NULL;
- }
-
- for (const FunctionSpecificationMessage& func_msg :
- iface_spec_msg.interface().api()) {
- LOG(DEBUG) << "Add a job " << func_msg.name();
- FunctionSpecificationMessage* func_msg_copy = func_msg.New();
- func_msg_copy->CopyFrom(func_msg);
- job_queue_.push(make_pair(func_msg_copy, driver));
- }
- return driver;
-}
-
-DriverBase* HalDriverLoader::GetHidlHalDriver(
- const string& driver_lib_path,
- const ComponentSpecificationMessage& spec_msg,
- const string& hal_service_name, const uint64_t interface_pt,
- bool with_interface_pt) {
- string package_name = spec_msg.package();
-
- DriverBase* driver = nullptr;
- if (with_interface_pt) {
- driver =
- LoadDriverWithInterfacePointer(driver_lib_path, spec_msg, interface_pt);
- } else {
- driver = LoadDriver(driver_lib_path, spec_msg);
- }
- if (!driver) {
- LOG(ERROR) << "Couldn't get a driver base class";
- return nullptr;
- }
- LOG(DEBUG) << "Got Hidl Hal driver";
-
- if (!with_interface_pt) {
- string service_name;
- if (!hal_service_name.empty()) {
- service_name = hal_service_name;
- } else {
- service_name = kDefaultHwbinderServiceName;
- }
-
- char get_sub_property[PROPERTY_VALUE_MAX];
- bool get_stub = false; /* default is binderized */
- if (property_get("vts.hidl.get_stub", get_sub_property, "") > 0) {
- if (!strcmp(get_sub_property, "true") ||
- !strcmp(get_sub_property, "True") || !strcmp(get_sub_property, "1")) {
- get_stub = true;
- }
- }
- if (!driver->GetService(get_stub, service_name.c_str())) {
- LOG(ERROR) << "Couldn't get hal service";
- return nullptr;
- }
- } else {
- LOG(INFO) << "Created DriverBase with interface pointer:" << interface_pt;
- }
- LOG(DEBUG) << "Loaded target comp";
- return driver;
-}
-
-DriverBase* HalDriverLoader::LoadDriver(
- const string& driver_lib_path,
- const ComponentSpecificationMessage& spec_msg) {
- if (!dll_loader_.Load(driver_lib_path.c_str())) {
- LOG(ERROR) << "Failed to load " << driver_lib_path;
- return nullptr;
- }
- LOG(DEBUG) << "DLL loaded " << driver_lib_path;
- string function_name_prefix = GetFunctionNamePrefix(spec_msg);
- loader_function func =
- dll_loader_.GetLoaderFunction(function_name_prefix.c_str());
- if (!func) {
- LOG(ERROR) << "Function not found.";
- return nullptr;
- }
- LOG(DEBUG) << "Function found; trying to call.";
- DriverBase* driver = func();
- return driver;
-}
-
-DriverBase* HalDriverLoader::LoadDriverWithInterfacePointer(
- const string& driver_lib_path,
- const ComponentSpecificationMessage& spec_msg,
- const uint64_t interface_pt) {
- // Assumption: no shared library lookup is needed because that is handled
- // the by the driver's linking dependency.
- // Example: name (android::hardware::gnss::V1_0::IAGnssRil) converted to
- // function name (vts_func_4_android_hardware_tests_bar_V1_0_IBar_with_arg)
- if (!dll_loader_.Load(driver_lib_path.c_str())) {
- LOG(ERROR) << "Failed to load " << driver_lib_path;
- return nullptr;
- }
- LOG(DEBUG) << "DLL loaded " << driver_lib_path;
- string function_name_prefix = GetFunctionNamePrefix(spec_msg);
- function_name_prefix += "with_arg";
- loader_function_with_arg func =
- dll_loader_.GetLoaderFunctionWithArg(function_name_prefix.c_str());
- if (!func) {
- LOG(ERROR) << "Function not found.";
- return nullptr;
- }
- return func(interface_pt);
-}
-
-bool HalDriverLoader::Process(const char* dll_file_name,
- const char* spec_lib_file_path, int target_class,
- int target_type, int target_version_major,
- int target_version_minor,
- const char* target_package,
- const char* target_component_name,
- const char* hal_service_name) {
- ComponentSpecificationMessage interface_specification_message;
- if (!FindComponentSpecification(target_class, target_package,
- target_version_major, target_version_minor,
- target_component_name, target_type,
- &interface_specification_message)) {
- LOG(ERROR) << "No interface specification file found for class "
- << target_class << " type " << target_type << " version "
- << GetVersionString(target_version_major, target_version_minor);
- return false;
- }
-
- if (!GetFuzzerBaseAndAddAllFunctionsToQueue(
- spec_lib_file_path, interface_specification_message, dll_file_name,
- hal_service_name)) {
- return false;
- }
-
- for (int i = 0; i < epoch_count_; i++) {
- // by default, breath-first-searching is used.
- if (job_queue_.empty()) {
- LOG(ERROR) << "No more job to process; stopping after epoch " << i;
- break;
- }
-
- pair<vts::FunctionSpecificationMessage*, DriverBase*> curr_job =
- job_queue_.front();
- job_queue_.pop();
-
- vts::FunctionSpecificationMessage* func_msg = curr_job.first;
- DriverBase* func_fuzzer = curr_job.second;
-
- void* result;
- FunctionSpecificationMessage result_msg;
- LOG(INFO) << "Iteration " << (i + 1) << " Function " << func_msg->name();
- // For Hidl HAL, use CallFunction method.
- if (interface_specification_message.component_class() == HAL_HIDL) {
- func_fuzzer->CallFunction(*func_msg, callback_socket_name_, &result_msg);
- } else {
- func_fuzzer->Fuzz(func_msg, &result, callback_socket_name_);
- }
- }
-
- return true;
-}
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/hal/common/driver_base/DriverBase.cpp b/drivers/hal/common/driver_base/DriverBase.cpp
deleted file mode 100644
index 9392ee9..0000000
--- a/drivers/hal/common/driver_base/DriverBase.cpp
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * Copyright 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.
- */
-#define LOG_TAG "VtsHalDriverBase"
-
-#include "driver_base/DriverBase.h"
-
-#include <dirent.h>
-#include <sys/stat.h>
-#include <string>
-#include <vector>
-
-#include <android-base/logging.h>
-
-#include "GcdaParser.h"
-#include "component_loader/DllLoader.h"
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-#include "utils/InterfaceSpecUtil.h"
-
-using namespace std;
-using namespace android;
-
-#define USE_GCOV 1
-
-namespace android {
-namespace vts {
-
-const string default_gcov_output_basepath = "/data/misc/gcov";
-
-static void RemoveDir(char* path) {
- struct dirent* entry = NULL;
- DIR* dir = opendir(path);
-
- while ((entry = readdir(dir)) != NULL) {
- DIR* sub_dir = NULL;
- FILE* file = NULL;
- char abs_path[4096] = {0};
-
- if (*(entry->d_name) != '.') {
- sprintf(abs_path, "%s/%s", path, entry->d_name);
- if ((sub_dir = opendir(abs_path)) != NULL) {
- closedir(sub_dir);
- RemoveDir(abs_path);
- } else if ((file = fopen(abs_path, "r")) != NULL) {
- fclose(file);
- remove(abs_path);
- }
- }
- }
- remove(path);
-}
-
-DriverBase::DriverBase(int target_class)
- : device_(NULL),
- hmi_(NULL),
- target_dll_path_(NULL),
- target_class_(target_class),
- component_filename_(NULL),
- gcov_output_basepath_(NULL) {}
-
-DriverBase::~DriverBase() { free(component_filename_); }
-
-void wfn() { LOG(DEBUG) << "debug"; }
-
-void ffn() { LOG(DEBUG) << "debug"; }
-
-bool DriverBase::LoadTargetComponent(const char* target_dll_path) {
- if (target_dll_path && target_dll_path_ &&
- !strcmp(target_dll_path, target_dll_path_)) {
- LOG(DEBUG) << "Skip loading " << target_dll_path;
- return true;
- }
-
- if (!target_loader_.Load(target_dll_path)) return false;
- target_dll_path_ = (char*)malloc(strlen(target_dll_path) + 1);
- strcpy(target_dll_path_, target_dll_path);
- LOG(DEBUG) << "Loaded the target";
- if (target_class_ == HAL_LEGACY) return true;
- LOG(DEBUG) << "Loaded a non-legacy HAL file.";
-
- if (target_dll_path_) {
- LOG(DEBUG) << "Target DLL path " << target_dll_path_;
- string target_path(target_dll_path_);
-
- size_t offset = target_path.rfind("/", target_path.length());
- if (offset != string::npos) {
- string filename =
- target_path.substr(offset + 1, target_path.length() - offset);
- filename = filename.substr(0, filename.length() - 3 /* for .so */);
- component_filename_ = (char*)malloc(filename.length() + 1);
- strcpy(component_filename_, filename.c_str());
- LOG(DEBUG) << "Module file name: " << component_filename_;
- }
- LOG(DEBUG) << "Target_dll_path " << target_dll_path_;
- }
-
-#if USE_GCOV
- LOG(DEBUG) << "gcov init " << target_loader_.GcovInit(wfn, ffn);
-#endif
- return true;
-}
-
-bool DriverBase::Fuzz(vts::ComponentSpecificationMessage* message,
- void** result) {
- LOG(DEBUG) << "Fuzzing target component: "
- << "class " << message->component_class() << " type "
- << message->component_type() << " version "
- << GetVersionString(message->component_type_version_major(),
- message->component_type_version_minor());
-
- string function_name_prefix = GetFunctionNamePrefix(*message);
- function_name_prefix_ = function_name_prefix.c_str();
- for (vts::FunctionSpecificationMessage func_msg :
- *message->mutable_interface()->mutable_api()) {
- Fuzz(&func_msg, result, "");
- }
- return true;
-}
-
-void DriverBase::FunctionCallBegin() {
- char product_path[4096];
- char product[128];
- char module_basepath[4096];
-
- snprintf(product_path, 4096, "%s/%s", default_gcov_output_basepath.c_str(),
- "proc/self/cwd/out/target/product");
- DIR* srcdir = opendir(product_path);
- if (!srcdir) {
- LOG(WARNING) << "Couldn't open " << product_path;
- return;
- }
-
- int dir_count = 0;
- struct dirent* dent;
- while ((dent = readdir(srcdir)) != NULL) {
- struct stat st;
- if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) {
- continue;
- }
- if (fstatat(dirfd(srcdir), dent->d_name, &st, 0) < 0) {
- LOG(ERROR) << "Error " << dent->d_name;
- continue;
- }
- if (S_ISDIR(st.st_mode)) {
- LOG(DEBUG) << "dir " << dent->d_name;
- strcpy(product, dent->d_name);
- dir_count++;
- }
- }
- closedir(srcdir);
- if (dir_count != 1) {
- LOG(ERROR) << "More than one product dir found.";
- return;
- }
-
- int n = snprintf(module_basepath, 4096, "%s/%s/obj/SHARED_LIBRARIES",
- product_path, product);
- if (n <= 0 || n >= 4096) {
- LOG(ERROR) << "Couln't get module_basepath";
- return;
- }
- srcdir = opendir(module_basepath);
- if (!srcdir) {
- LOG(ERROR) << "Couln't open " << module_basepath;
- return;
- }
-
- if (component_filename_ != NULL) {
- dir_count = 0;
- string target = string(component_filename_) + "_intermediates";
- bool hit = false;
- while ((dent = readdir(srcdir)) != NULL) {
- struct stat st;
- if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) {
- continue;
- }
- if (fstatat(dirfd(srcdir), dent->d_name, &st, 0) < 0) {
- LOG(ERROR) << "Error " << dent->d_name;
- continue;
- }
- if (S_ISDIR(st.st_mode)) {
- LOG(DEBUG) << "module_basepath " << string(dent->d_name);
- if (string(dent->d_name) == target) {
- LOG(DEBUG) << "hit";
- hit = true;
- }
- dir_count++;
- }
- }
- if (hit) {
- free(gcov_output_basepath_);
- gcov_output_basepath_ =
- (char*)malloc(strlen(module_basepath) + target.length() + 2);
- if (!gcov_output_basepath_) {
- LOG(ERROR) << "Couldn't alloc memory";
- return;
- }
- sprintf(gcov_output_basepath_, "%s/%s", module_basepath, target.c_str());
- RemoveDir(gcov_output_basepath_);
- }
- } else {
- LOG(ERROR) << "component_filename_ is NULL";
- }
- // TODO: check how it works when there already is a file.
- closedir(srcdir);
-}
-
-bool DriverBase::ReadGcdaFile(const string& basepath, const string& filename,
- FunctionSpecificationMessage* msg) {
-#if VTS_GCOV_DEBUG
- LOG(DEBUG) << "file = " << dent->d_name;
-#endif
- if (string(filename).rfind(".gcda") != string::npos) {
- string buffer = basepath + "/" + filename;
- vector<unsigned> processed_data =
- android::vts::GcdaRawCoverageParser(buffer.c_str()).Parse();
- for (const auto& data : processed_data) {
- msg->mutable_processed_coverage_data()->Add(data);
- }
-
- FILE* gcda_file = fopen(buffer.c_str(), "rb");
- if (!gcda_file) {
- LOG(ERROR) << "Unable to open a gcda file. " << buffer;
- } else {
- LOG(DEBUG) << "Opened a gcda file. " << buffer;
- fseek(gcda_file, 0, SEEK_END);
- long gcda_file_size = ftell(gcda_file);
-#if VTS_GCOV_DEBUG
- LOG(DEBUG) << "File size " << gcda_file_size << " bytes";
-#endif
- fseek(gcda_file, 0, SEEK_SET);
-
- char* gcda_file_buffer = (char*)malloc(gcda_file_size + 1);
- if (!gcda_file_buffer) {
- LOG(ERROR) << "Unable to allocate memory to read a gcda file.";
- } else {
- if (fread(gcda_file_buffer, gcda_file_size, 1, gcda_file) != 1) {
- LOG(ERROR) << "File read error";
- } else {
-#if VTS_GCOV_DEBUG
- LOG(DEBUG) << "GCDA field populated.";
-#endif
- gcda_file_buffer[gcda_file_size] = '\0';
- NativeCodeCoverageRawDataMessage* raw_msg =
- msg->mutable_raw_coverage_data()->Add();
- raw_msg->set_file_path(filename.c_str());
- string gcda_file_buffer_string(gcda_file_buffer, gcda_file_size);
- raw_msg->set_gcda(gcda_file_buffer_string);
- free(gcda_file_buffer);
- }
- }
- fclose(gcda_file);
- }
-#if USE_GCOV_DEBUG
- if (result) {
- for (unsigned int index = 0; index < result->size(); index++) {
- LOG(DEBUG) << result->at(index);
- }
- }
-#endif
- return true;
- }
- return false;
-}
-
-bool DriverBase::ScanAllGcdaFiles(const string& basepath,
- FunctionSpecificationMessage* msg) {
- DIR* srcdir = opendir(basepath.c_str());
- if (!srcdir) {
- LOG(ERROR) << "Couln't open " << basepath;
- return false;
- }
-
- struct dirent* dent;
- while ((dent = readdir(srcdir)) != NULL) {
-#if VTS_GCOV_DEBUG
- LOG(DEBUG) << "readdir(" << basepath << ") for " << dent->d_name;
-#endif
- struct stat st;
- if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) {
- continue;
- }
- if (fstatat(dirfd(srcdir), dent->d_name, &st, 0) < 0) {
- LOG(ERROR) << "error " << dent->d_name;
- continue;
- }
- if (S_ISDIR(st.st_mode)) {
- ScanAllGcdaFiles(basepath + "/" + dent->d_name, msg);
- } else {
- ReadGcdaFile(basepath, dent->d_name, msg);
- }
- }
-#if VTS_GCOV_DEBUG
- LOG(DEBUG) << "closedir(" << srcdir << ")";
-#endif
- closedir(srcdir);
- return true;
-}
-
-bool DriverBase::FunctionCallEnd(FunctionSpecificationMessage* msg) {
-#if USE_GCOV
- target_loader_.GcovFlush();
- // find the file.
- if (!gcov_output_basepath_) {
- LOG(WARNING) << "No gcov basepath set";
- return ScanAllGcdaFiles(default_gcov_output_basepath, msg);
- }
- DIR* srcdir = opendir(gcov_output_basepath_);
- if (!srcdir) {
- LOG(WARNING) << "Couln't open " << gcov_output_basepath_;
- return false;
- }
-
- struct dirent* dent;
- while ((dent = readdir(srcdir)) != NULL) {
- LOG(DEBUG) << "readdir(" << srcdir << ") for " << dent->d_name;
-
- struct stat st;
- if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) {
- continue;
- }
- if (fstatat(dirfd(srcdir), dent->d_name, &st, 0) < 0) {
- LOG(ERROR) << "error " << dent->d_name;
- continue;
- }
- if (!S_ISDIR(st.st_mode) &&
- ReadGcdaFile(gcov_output_basepath_, dent->d_name, msg)) {
- break;
- }
- }
- LOG(DEBUG) << "closedir(" << srcdir << ")";
- closedir(srcdir);
-#endif
- return true;
-}
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/hal/common/driver_base/DriverCallbackBase.cpp b/drivers/hal/common/driver_base/DriverCallbackBase.cpp
deleted file mode 100644
index ebb4b6b..0000000
--- a/drivers/hal/common/driver_base/DriverCallbackBase.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 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.
- */
-#define LOG_TAG "VtsHalDriverCallbackBase"
-
-#include "driver_base/DriverCallbackBase.h"
-
-#include <VtsDriverCommUtil.h>
-#include <android-base/logging.h>
-
-#include "component_loader/DllLoader.h"
-#include "test/vts/proto/AndroidSystemControlMessage.pb.h"
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-#include "utils/InterfaceSpecUtil.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-static std::map<string, string> id_map_;
-
-DriverCallbackBase::DriverCallbackBase() {}
-
-DriverCallbackBase::~DriverCallbackBase() {}
-
-bool DriverCallbackBase::Register(const VariableSpecificationMessage& message) {
- LOG(DEBUG) << "type = " << message.type();
- if (!message.is_callback()) {
- LOG(ERROR) << "ERROR: argument is not a callback.";
- return false;
- }
-
- if (!message.has_type() || message.type() != TYPE_FUNCTION_POINTER) {
- LOG(ERROR) << "ERROR: inconsistent message.";
- return false;
- }
-
- for (const auto& func_pt : message.function_pointer()) {
- LOG(DEBUG) << "map[" << func_pt.function_name() << "] = " << func_pt.id();
- id_map_[func_pt.function_name()] = func_pt.id();
- }
- return true;
-}
-
-const char* DriverCallbackBase::GetCallbackID(const string& name) {
- // TODO: handle when not found.
- LOG(DEBUG) << "GetCallbackID for " << name << "returns '"
- << id_map_[name].c_str() << "'";
- return id_map_[name].c_str();
-}
-
-void DriverCallbackBase::RpcCallToAgent(
- const AndroidSystemCallbackRequestMessage& message,
- const string& callback_socket_name) {
- LOG(DEBUG) << " id = '" << message.id() << "'";
- if (message.id().empty() || callback_socket_name.empty()) {
- LOG(DEBUG) << "Abort callback forwarding.";
- return;
- }
- VtsDriverCommUtil util;
- if (!util.Connect(callback_socket_name)) exit(-1);
- util.VtsSocketSendMessage(message);
- util.Close();
-}
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/hal/common/driver_manager/VtsHalDriverManager.cpp b/drivers/hal/common/driver_manager/VtsHalDriverManager.cpp
deleted file mode 100644
index 2255f05..0000000
--- a/drivers/hal/common/driver_manager/VtsHalDriverManager.cpp
+++ /dev/null
@@ -1,695 +0,0 @@
-/*
- * 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.
- */
-#define LOG_TAG "VtsHalDriverManager"
-
-#include "driver_manager/VtsHalDriverManager.h"
-
-#include <iostream>
-#include <string>
-
-#include <android-base/logging.h>
-#include <google/protobuf/text_format.h>
-
-#include "utils/InterfaceSpecUtil.h"
-#include "utils/StringUtil.h"
-
-static constexpr const char* kErrorString = "error";
-static constexpr const char* kVoidString = "void";
-static constexpr const int kInvalidDriverId = -1;
-
-namespace android {
-namespace vts {
-
-VtsHalDriverManager::VtsHalDriverManager(const string& spec_dir,
- const int epoch_count,
- const string& callback_socket_name,
- VtsResourceManager* resource_manager)
- : callback_socket_name_(callback_socket_name),
- hal_driver_loader_(
- HalDriverLoader(spec_dir, epoch_count, callback_socket_name)),
- resource_manager_(resource_manager) {}
-
-DriverId VtsHalDriverManager::LoadTargetComponent(
- const string& dll_file_name, const string& spec_lib_file_path,
- const int component_class, const int component_type,
- const int version_major, const int version_minor,
- const string& package_name, const string& component_name,
- const string& hw_binder_service_name) {
- LOG(DEBUG) << "dll_file_name = " << dll_file_name;
- ComponentSpecificationMessage spec_message;
- if (!hal_driver_loader_.FindComponentSpecification(
- component_class, package_name, version_major, version_minor,
- component_name, component_type, &spec_message)) {
- LOG(ERROR) << "Failed to load specification for component: "
- << GetComponentDebugMsg(
- component_class, component_type,
- GetVersionString(version_major, version_minor),
- package_name, component_name);
- return kInvalidDriverId;
- }
- LOG(INFO) << "Loaded specification for component: "
- << GetComponentDebugMsg(
- component_class, component_type,
- GetVersionString(version_major, version_minor), package_name,
- component_name);
-
- string driver_lib_path = "";
- if (component_class == HAL_HIDL) {
- driver_lib_path =
- GetHidlHalDriverLibName(package_name, version_major, version_minor);
- } else {
- driver_lib_path = spec_lib_file_path;
- }
-
- LOG(DEBUG) << "driver lib path " << driver_lib_path;
-
- std::unique_ptr<DriverBase> hal_driver = nullptr;
- hal_driver.reset(hal_driver_loader_.GetDriver(driver_lib_path, spec_message,
- hw_binder_service_name, 0,
- false, dll_file_name));
- if (!hal_driver) {
- LOG(ERROR) << "Can't load driver for component: "
- << GetComponentDebugMsg(
- component_class, component_type,
- GetVersionString(version_major, version_minor),
- package_name, component_name);
- return kInvalidDriverId;
- } else {
- LOG(INFO) << "Loaded driver for component: "
- << GetComponentDebugMsg(
- component_class, component_type,
- GetVersionString(version_major, version_minor),
- package_name, component_name);
- }
- // TODO (zhuoyao): get hidl_proxy_pointer for loaded hidl hal dirver.
- uint64_t interface_pt = 0;
- return RegisterDriver(std::move(hal_driver), spec_message, interface_pt);
-}
-
-string VtsHalDriverManager::CallFunction(FunctionCallMessage* call_msg) {
- string output = "";
- DriverBase* driver = GetDriverWithCallMsg(*call_msg);
- if (!driver) {
- LOG(ERROR) << "can't find driver for component: "
- << GetComponentDebugMsg(
- call_msg->component_class(), call_msg->component_type(),
- GetVersionString(
- call_msg->component_type_version_major(),
- call_msg->component_type_version_minor()),
- call_msg->package_name(), call_msg->component_name());
- return kErrorString;
- }
-
- FunctionSpecificationMessage* api = call_msg->mutable_api();
- void* result;
- FunctionSpecificationMessage result_msg;
- driver->FunctionCallBegin();
- LOG(DEBUG) << "Call Function " << api->name();
- if (call_msg->component_class() == HAL_HIDL) {
- // Pre-processing if we want to call an API with an interface as argument.
- for (int index = 0; index < api->arg_size(); index++) {
- auto* arg = api->mutable_arg(index);
- bool process_success = PreprocessHidlHalFunctionCallArgs(arg);
- if (!process_success) {
- LOG(ERROR) << "Error in preprocess argument index " << index;
- return kErrorString;
- }
- }
- // For Hidl HAL, use CallFunction method.
- if (!driver->CallFunction(*api, callback_socket_name_, &result_msg)) {
- LOG(ERROR) << "Failed to call function: " << api->DebugString();
- return kErrorString;
- }
- } else {
- if (!driver->Fuzz(api, &result, callback_socket_name_)) {
- LOG(ERROR) << "Failed to call function: " << api->DebugString();
- return kErrorString;
- }
- }
- LOG(DEBUG) << "Called function " << api->name();
-
- // set coverage data.
- driver->FunctionCallEnd(api);
-
- if (call_msg->component_class() == HAL_HIDL) {
- for (int index = 0; index < result_msg.return_type_hidl_size(); index++) {
- auto* return_val = result_msg.mutable_return_type_hidl(index);
- bool set_success = SetHidlHalFunctionCallResults(return_val);
- if (!set_success) {
- LOG(ERROR) << "Error in setting return value index " << index;
- return kErrorString;
- }
- }
- google::protobuf::TextFormat::PrintToString(result_msg, &output);
- return output;
- } else if (call_msg->component_class() == LIB_SHARED) {
- return ProcessFuncResultsForLibrary(api, result);
- }
- return kVoidString;
-}
-
-bool VtsHalDriverManager::VerifyResults(
- DriverId id, const FunctionSpecificationMessage& expected_result,
- const FunctionSpecificationMessage& actual_result) {
- DriverBase* driver = GetDriverById(id);
- if (!driver) {
- LOG(ERROR) << "Can't find driver with id: " << id;
- return false;
- }
- return driver->VerifyResults(expected_result, actual_result);
-}
-
-string VtsHalDriverManager::GetAttribute(FunctionCallMessage* call_msg) {
- string output = "";
- DriverBase* driver = GetDriverWithCallMsg(*call_msg);
- if (!driver) {
- LOG(ERROR) << "Can't find driver for component: "
- << GetComponentDebugMsg(
- call_msg->component_class(), call_msg->component_type(),
- GetVersionString(
- call_msg->component_type_version_major(),
- call_msg->component_type_version_minor()),
- call_msg->package_name(), call_msg->component_name());
- return kErrorString;
- }
-
- void* result;
- FunctionSpecificationMessage* api = call_msg->mutable_api();
- LOG(DEBUG) << "Get Atrribute " << api->name() << " parent_path("
- << api->parent_path() << ")";
- if (!driver->GetAttribute(api, &result)) {
- LOG(ERROR) << "attribute not found - todo handle more explicitly";
- return kErrorString;
- }
-
- if (call_msg->component_class() == HAL_HIDL) {
- api->mutable_return_type()->set_type(TYPE_STRING);
- api->mutable_return_type()->mutable_string_value()->set_message(
- *(string*)result);
- api->mutable_return_type()->mutable_string_value()->set_length(
- ((string*)result)->size());
- free(result);
- string* output = new string();
- google::protobuf::TextFormat::PrintToString(*api, output);
- return *output;
- } else if (call_msg->component_class() == LIB_SHARED) {
- return ProcessFuncResultsForLibrary(api, result);
- }
- return kVoidString;
-}
-
-DriverId VtsHalDriverManager::RegisterDriver(
- std::unique_ptr<DriverBase> driver,
- const ComponentSpecificationMessage& spec_msg,
- const uint64_t interface_pt) {
- DriverId driver_id = FindDriverIdInternal(spec_msg, interface_pt, true);
- if (driver_id == kInvalidDriverId) {
- driver_id = hal_driver_map_.size();
- hal_driver_map_.insert(make_pair(
- driver_id, HalDriverInfo(spec_msg, interface_pt, std::move(driver))));
- } else {
- LOG(WARNING) << "Driver already exists. ";
- }
-
- return driver_id;
-}
-
-DriverBase* VtsHalDriverManager::GetDriverById(const DriverId id) {
- auto res = hal_driver_map_.find(id);
- if (res == hal_driver_map_.end()) {
- LOG(ERROR) << "Failed to find driver info with id: " << id;
- return nullptr;
- }
- LOG(DEBUG) << "Found driver info with id: " << id;
- return res->second.driver.get();
-}
-
-uint64_t VtsHalDriverManager::GetDriverPointerById(const DriverId id) {
- auto res = hal_driver_map_.find(id);
- if (res == hal_driver_map_.end()) {
- LOG(ERROR) << "Failed to find driver info with id: " << id;
- return 0;
- }
- LOG(DEBUG) << "Found driver info with id: " << id;
- return res->second.hidl_hal_proxy_pt;
-}
-
-DriverId VtsHalDriverManager::GetDriverIdForHidlHalInterface(
- const string& package_name, const int version_major,
- const int version_minor, const string& interface_name,
- const string& hal_service_name) {
- ComponentSpecificationMessage spec_msg;
- spec_msg.set_component_class(HAL_HIDL);
- spec_msg.set_package(package_name);
- spec_msg.set_component_type_version_major(version_major);
- spec_msg.set_component_type_version_minor(version_minor);
- spec_msg.set_component_name(interface_name);
- DriverId driver_id = FindDriverIdInternal(spec_msg);
- if (driver_id == kInvalidDriverId) {
- string driver_lib_path =
- GetHidlHalDriverLibName(package_name, version_major, version_minor);
- driver_id = LoadTargetComponent("", driver_lib_path, HAL_HIDL, 0,
- version_major, version_minor, package_name,
- interface_name, hal_service_name);
- }
- return driver_id;
-}
-
-bool VtsHalDriverManager::FindComponentSpecification(
- const int component_class, const int component_type,
- const int version_major, const int version_minor,
- const string& package_name, const string& component_name,
- ComponentSpecificationMessage* spec_msg) {
- return hal_driver_loader_.FindComponentSpecification(
- component_class, package_name, version_major, version_minor,
- component_name, component_type, spec_msg);
-}
-
-ComponentSpecificationMessage*
-VtsHalDriverManager::GetComponentSpecification() {
- if (hal_driver_map_.empty()) {
- return nullptr;
- } else {
- return &(hal_driver_map_.find(0)->second.spec_msg);
- }
-}
-
-DriverId VtsHalDriverManager::FindDriverIdInternal(
- const ComponentSpecificationMessage& spec_msg, const uint64_t interface_pt,
- bool with_interface_pointer) {
- if (!spec_msg.has_component_class()) {
- LOG(ERROR) << "Component class not specified. ";
- return kInvalidDriverId;
- }
- if (spec_msg.component_class() == HAL_HIDL) {
- if (!spec_msg.has_package() || spec_msg.package().empty()) {
- LOG(ERROR) << "Package name is required but not specified.";
- return kInvalidDriverId;
- }
- if (!spec_msg.has_component_type_version_major() ||
- !spec_msg.has_component_type_version_minor()) {
- LOG(ERROR) << "Package version is required but not specified.";
- return kInvalidDriverId;
- }
- if (!spec_msg.has_component_name() || spec_msg.component_name().empty()) {
- LOG(ERROR) << "Component name is required but not specified.";
- return kInvalidDriverId;
- }
- }
- for (auto it = hal_driver_map_.begin(); it != hal_driver_map_.end(); ++it) {
- ComponentSpecificationMessage cur_spec_msg = it->second.spec_msg;
- if (cur_spec_msg.component_class() != spec_msg.component_class()) {
- continue;
- }
- // If package name is specified, match package name.
- if (spec_msg.has_package()) {
- if (!cur_spec_msg.has_package() ||
- cur_spec_msg.package() != spec_msg.package()) {
- continue;
- }
- }
- // If version is specified, match version.
- if (spec_msg.has_component_type_version_major() &&
- spec_msg.has_component_type_version_minor()) {
- if (!cur_spec_msg.has_component_type_version_major() ||
- !cur_spec_msg.has_component_type_version_minor() ||
- cur_spec_msg.component_type_version_major() !=
- spec_msg.component_type_version_major() ||
- cur_spec_msg.component_type_version_minor() !=
- spec_msg.component_type_version_minor()) {
- continue;
- }
- }
- if (spec_msg.component_class() == HAL_HIDL) {
- if (cur_spec_msg.component_name() != spec_msg.component_name()) {
- continue;
- }
- if (with_interface_pointer &&
- it->second.hidl_hal_proxy_pt != interface_pt) {
- continue;
- }
- LOG(DEBUG) << "Found hidl hal driver with id: " << it->first;
- return it->first;
- } else if (spec_msg.component_class() == LIB_SHARED) {
- if (spec_msg.has_component_type() &&
- cur_spec_msg.component_type() == spec_msg.component_type()) {
- LOG(DEBUG) << "Found shared lib driver with id: " << it->first;
- return it->first;
- }
- }
- }
- return kInvalidDriverId;
-}
-
-DriverBase* VtsHalDriverManager::GetDriverWithCallMsg(
- const FunctionCallMessage& call_msg) {
- DriverId driver_id = kInvalidDriverId;
- // If call_mag contains driver_id, use that given driver id.
- if (call_msg.has_hal_driver_id() &&
- call_msg.hal_driver_id() != kInvalidDriverId) {
- driver_id = call_msg.hal_driver_id();
- } else {
- // Otherwise, try to find a registed driver matches the given info. e.g.,
- // package_name, version etc.
- ComponentSpecificationMessage spec_msg;
- spec_msg.set_component_class(call_msg.component_class());
- spec_msg.set_package(call_msg.package_name());
- spec_msg.set_component_type_version_major(
- call_msg.component_type_version_major());
- spec_msg.set_component_type_version_minor(
- call_msg.component_type_version_minor());
- spec_msg.set_component_name(call_msg.component_name());
- driver_id = FindDriverIdInternal(spec_msg);
- }
-
- if (driver_id == kInvalidDriverId) {
- LOG(ERROR) << "Can't find driver ID for package: "
- << call_msg.package_name() << " version: "
- << GetVersionString(call_msg.component_type_version_major(),
- call_msg.component_type_version_minor());
- return nullptr;
- } else {
- return GetDriverById(driver_id);
- }
-}
-
-string VtsHalDriverManager::ProcessFuncResultsForLibrary(
- FunctionSpecificationMessage* func_msg, void* result) {
- string output = "";
- if (func_msg->return_type().type() == TYPE_PREDEFINED) {
- // TODO: actually handle this case.
- if (result != NULL) {
- // loads that interface spec and enqueues all functions.
- LOG(DEBUG) << "Return type: " << func_msg->return_type().type();
- } else {
- LOG(ERROR) << "Return value = NULL";
- }
- LOG(ERROR) << "Todo: support aggregate";
- google::protobuf::TextFormat::PrintToString(*func_msg, &output);
- return output;
- } else if (func_msg->return_type().type() == TYPE_SCALAR) {
- // TODO handle when the size > 1.
- // todo handle more types;
- if (!strcmp(func_msg->return_type().scalar_type().c_str(), "int32_t")) {
- func_msg->mutable_return_type()->mutable_scalar_value()->set_int32_t(
- *((int*)(&result)));
- google::protobuf::TextFormat::PrintToString(*func_msg, &output);
- return output;
- } else if (!strcmp(func_msg->return_type().scalar_type().c_str(),
- "uint32_t")) {
- func_msg->mutable_return_type()->mutable_scalar_value()->set_uint32_t(
- *((int*)(&result)));
- google::protobuf::TextFormat::PrintToString(*func_msg, &output);
- return output;
- } else if (!strcmp(func_msg->return_type().scalar_type().c_str(),
- "int16_t")) {
- func_msg->mutable_return_type()->mutable_scalar_value()->set_int16_t(
- *((int*)(&result)));
- google::protobuf::TextFormat::PrintToString(*func_msg, &output);
- return output;
- } else if (!strcmp(func_msg->return_type().scalar_type().c_str(),
- "uint16_t")) {
- google::protobuf::TextFormat::PrintToString(*func_msg, &output);
- return output;
- }
- }
- return kVoidString;
-}
-
-string VtsHalDriverManager::GetComponentDebugMsg(const int component_class,
- const int component_type,
- const string& version,
- const string& package_name,
- const string& component_name) {
- if (component_class == HAL_HIDL) {
- return "HIDL_HAL: " + package_name + "@" + version + "::" + component_name;
- } else {
- return "component_type: " + std::to_string(component_type) +
- " version: " + version + " component_name: " + component_name;
- }
-}
-
-bool VtsHalDriverManager::PreprocessHidlHalFunctionCallArgs(
- VariableSpecificationMessage* arg) {
- switch (arg->type()) {
- case TYPE_ARRAY:
- case TYPE_VECTOR: {
- // Recursively parse each element in the vector/array.
- for (int i = 0; i < arg->vector_size(); i++) {
- if (!PreprocessHidlHalFunctionCallArgs(arg->mutable_vector_value(i))) {
- // Bad argument, preprocess failure.
- LOG(ERROR) << "Failed to preprocess vector value " << i << ".";
- return false;
- }
- }
- break;
- }
- case TYPE_UNION: {
- // Recursively parse each union value.
- for (int i = 0; i < arg->union_value_size(); i++) {
- auto* union_field = arg->mutable_union_value(i);
- if (!PreprocessHidlHalFunctionCallArgs(union_field)) {
- // Bad argument, preprocess failure.
- LOG(ERROR) << "Failed to preprocess union field \""
- << union_field->name() << "\" in union \"" << arg->name()
- << "\".";
- return false;
- }
- }
- break;
- }
- case TYPE_STRUCT: {
- // Recursively parse each struct value.
- for (int i = 0; i < arg->struct_value_size(); i++) {
- auto* struct_field = arg->mutable_struct_value(i);
- if (!PreprocessHidlHalFunctionCallArgs(struct_field)) {
- // Bad argument, preprocess failure.
- LOG(ERROR) << "Failed to preprocess struct field \""
- << struct_field->name() << "\" in struct \"" << arg->name()
- << "\".";
- return false;
- }
- }
- break;
- }
- case TYPE_REF: {
- if (!PreprocessHidlHalFunctionCallArgs(arg->mutable_ref_value())) {
- // Bad argument, preprocess failure.
- LOG(ERROR) << "Failed to preprocess reference value with name \""
- << arg->name() << "\".";
- return false;
- }
- break;
- }
- case TYPE_HIDL_INTERFACE: {
- string type_name = arg->predefined_type();
- ComponentSpecificationMessage spec_msg;
- string version_str = GetVersion(type_name);
- int version_major = GetVersionMajor(version_str, true);
- int version_minor = GetVersionMinor(version_str, true);
- spec_msg.set_package(GetPackageName(type_name));
- spec_msg.set_component_type_version_major(version_major);
- spec_msg.set_component_type_version_minor(version_minor);
- spec_msg.set_component_name(GetComponentName(type_name));
- DriverId driver_id = FindDriverIdInternal(spec_msg);
- // If found a registered driver for the interface, set the pointer in
- // the arg proto.
- if (driver_id != kInvalidDriverId) {
- uint64_t interface_pt = GetDriverPointerById(driver_id);
- arg->set_hidl_interface_pointer(interface_pt);
- }
- break;
- }
- case TYPE_FMQ_SYNC:
- case TYPE_FMQ_UNSYNC: {
- if (arg->fmq_value_size() == 0) {
- LOG(ERROR) << "Driver manager: host side didn't specify queue "
- << "information in fmq_value field.";
- return false;
- }
- if (arg->fmq_value(0).fmq_id() != -1) {
- // Preprocess an argument that wants to use an existing FMQ.
- // resource_manager returns address of hidl_memory pointer and
- // driver_manager fills the address in the proto field,
- // which can be read by HAL driver.
- size_t descriptor_addr;
- bool success =
- resource_manager_->GetQueueDescAddress(*arg, &descriptor_addr);
- if (!success) {
- LOG(ERROR) << "Unable to find queue descriptor for queue with id "
- << arg->fmq_value(0).fmq_id();
- return false;
- }
- arg->mutable_fmq_value(0)->set_fmq_desc_address(descriptor_addr);
- }
- break;
- }
- case TYPE_HIDL_MEMORY: {
- if (arg->hidl_memory_value().mem_id() != -1) {
- // Preprocess an argument that wants to use an existing hidl_memory.
- // resource_manager returns the address of the hidl_memory pointer,
- // and driver_manager fills the address in the proto field,
- // which can be read by vtsc.
- size_t hidl_mem_address;
- bool success =
- resource_manager_->GetHidlMemoryAddress(*arg, &hidl_mem_address);
- if (!success) {
- LOG(ERROR) << "Unable to find hidl_memory with id "
- << arg->hidl_memory_value().mem_id();
- return false;
- }
- arg->mutable_hidl_memory_value()->set_hidl_mem_address(
- hidl_mem_address);
- }
- break;
- }
- case TYPE_HANDLE: {
- if (arg->handle_value().handle_id() != -1) {
- // Preprocess an argument that wants to use an existing hidl_handle.
- // resource_manager returns the address of the hidl_memory pointer,
- // and driver_manager fills the address in the proto field,
- // which can be read by vtsc.
- size_t hidl_handle_address;
- bool success =
- resource_manager_->GetHidlHandleAddress(*arg, &hidl_handle_address);
- if (!success) {
- LOG(ERROR) << "Unable to find hidl_handle with id "
- << arg->handle_value().handle_id();
- return false;
- }
- arg->mutable_handle_value()->set_hidl_handle_address(
- hidl_handle_address);
- }
- break;
- }
- default:
- break;
- }
- return true;
-}
-
-bool VtsHalDriverManager::SetHidlHalFunctionCallResults(
- VariableSpecificationMessage* return_val) {
- switch (return_val->type()) {
- case TYPE_ARRAY:
- case TYPE_VECTOR: {
- // Recursively set each element in the vector/array.
- for (int i = 0; i < return_val->vector_size(); i++) {
- if (!SetHidlHalFunctionCallResults(
- return_val->mutable_vector_value(i))) {
- // Failed to set recursive return value.
- LOG(ERROR) << "Failed to set vector value " << i << ".";
- return false;
- }
- }
- break;
- }
- case TYPE_UNION: {
- // Recursively set each field.
- for (int i = 0; i < return_val->union_value_size(); i++) {
- auto* union_field = return_val->mutable_union_value(i);
- if (!SetHidlHalFunctionCallResults(union_field)) {
- // Failed to set recursive return value.
- LOG(ERROR) << "Failed to set union field \"" << union_field->name()
- << "\" in union \"" << return_val->name() << "\".";
- return false;
- }
- }
- break;
- }
- case TYPE_STRUCT: {
- // Recursively set each field.
- for (int i = 0; i < return_val->struct_value_size(); i++) {
- auto* struct_field = return_val->mutable_struct_value(i);
- if (!SetHidlHalFunctionCallResults(struct_field)) {
- // Failed to set recursive return value.
- LOG(ERROR) << "Failed to set struct field \"" << struct_field->name()
- << "\" in struct \"" << return_val->name() << "\".";
- return false;
- }
- }
- break;
- }
- case TYPE_REF: {
- if (!SetHidlHalFunctionCallResults(return_val->mutable_ref_value())) {
- // Failed to set recursive return value.
- LOG(ERROR) << "Failed to set reference value for \""
- << return_val->name() << "\".";
- return false;
- }
- break;
- }
- case TYPE_HIDL_INTERFACE: {
- if (return_val->hidl_interface_pointer() != 0) {
- string type_name = return_val->predefined_type();
- uint64_t interface_pt = return_val->hidl_interface_pointer();
- std::unique_ptr<DriverBase> driver;
- ComponentSpecificationMessage spec_msg;
- string version_str = GetVersion(type_name);
- int version_major = GetVersionMajor(version_str, true);
- int version_minor = GetVersionMinor(version_str, true);
- string package_name = GetPackageName(type_name);
- string component_name = GetComponentName(type_name);
- if (!hal_driver_loader_.FindComponentSpecification(
- HAL_HIDL, package_name, version_major, version_minor,
- component_name, 0, &spec_msg)) {
- LOG(ERROR) << "Failed to load specification for generated interface :"
- << type_name;
- return false;
- }
- string driver_lib_path =
- GetHidlHalDriverLibName(package_name, version_major, version_minor);
- // TODO(zhuoyao): figure out a way to get the service_name.
- string hw_binder_service_name = "default";
- driver.reset(hal_driver_loader_.GetDriver(driver_lib_path, spec_msg,
- hw_binder_service_name,
- interface_pt, true, ""));
- int32_t driver_id =
- RegisterDriver(std::move(driver), spec_msg, interface_pt);
- return_val->set_hidl_interface_id(driver_id);
- } else {
- // in case of generated nullptr, set the driver_id to -1.
- return_val->set_hidl_interface_id(-1);
- }
- break;
- }
- case TYPE_FMQ_SYNC:
- case TYPE_FMQ_UNSYNC: {
- // Tell resource_manager to register a new FMQ.
- int new_queue_id = resource_manager_->RegisterFmq(*return_val);
- return_val->mutable_fmq_value(0)->set_fmq_id(new_queue_id);
- break;
- }
- case TYPE_HIDL_MEMORY: {
- // Tell resource_manager to register the new memory object.
- int new_mem_id = resource_manager_->RegisterHidlMemory(*return_val);
- return_val->mutable_hidl_memory_value()->set_mem_id(new_mem_id);
- break;
- }
- case TYPE_HANDLE: {
- // Tell resource_manager to register the new handle object.
- int new_handle_id = resource_manager_->RegisterHidlHandle(*return_val);
- return_val->mutable_handle_value()->set_handle_id(new_handle_id);
- break;
- }
- default:
- break;
- }
- return true;
-}
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/hal/common/include/binder/VtsFuzzerBinderService.h b/drivers/hal/common/include/binder/VtsFuzzerBinderService.h
deleted file mode 100644
index af5f3e1..0000000
--- a/drivers/hal/common/include/binder/VtsFuzzerBinderService.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef __VTS_FUZZER_BINDER_SERVICE_H__
-#define __VTS_FUZZER_BINDER_SERVICE_H__
-
-#include <string>
-
-#include <utils/RefBase.h>
-#include <utils/String8.h>
-
-#include <binder/IBinder.h>
-#include <binder/IInterface.h>
-#include <binder/ProcessState.h>
-
-// #ifdef VTS_FUZZER_BINDER_DEBUG
-
-#define VTS_FUZZER_BINDER_SERVICE_NAME "VtsFuzzer"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-// VTS Fuzzer Binder Interface
-class IVtsFuzzer : public IInterface {
- public:
- enum {
- EXIT = IBinder::FIRST_CALL_TRANSACTION,
- LOAD_HAL,
- STATUS,
- CALL,
- GET_FUNCTIONS
- };
-
- // Sends an exit command.
- virtual void Exit() = 0;
-
- // Requests to load a HAL.
- // Notes on args:
- // target_version_major:
- // int, the target component major HAL version
- // target_version_minor:
- // int, the target component minor HAL version
- virtual int32_t LoadHal(const string& path, int target_class, int target_type,
- int target_version_major, int target_version_minor,
- const string& module_name) = 0;
-
- // Requests to return the specified status.
- virtual int32_t Status(int32_t type) = 0;
-
- // Requests to call the specified function using the provided arguments.
- virtual string Call(const string& call_payload) = 0;
-
- virtual const char* GetFunctions() = 0;
-
- DECLARE_META_INTERFACE(VtsFuzzer);
-};
-
-// For client
-class BpVtsFuzzer : public BpInterface<IVtsFuzzer> {
- public:
- explicit BpVtsFuzzer(const sp<IBinder>& impl)
- : BpInterface<IVtsFuzzer>(impl) {}
-
- void Exit();
-
- // Notes on args:
- // target_version_major:
- // int, the target component major HAL version
- // target_version_minor:
- // int, the target component minor HAL version
- int32_t LoadHal(const string& path, int target_class, int target_type,
- int target_version_major, int target_version_minor,
- const string& module_name);
- int32_t Status(int32_t type);
- string Call(const string& call_payload);
- const char* GetFunctions();
-};
-
-} // namespace vts
-} // namespace android
-
-#endif
diff --git a/drivers/hal/common/include/component_loader/DllLoader.h b/drivers/hal/common/include/component_loader/DllLoader.h
deleted file mode 100644
index 1138ecb..0000000
--- a/drivers/hal/common/include/component_loader/DllLoader.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef __VTS_SYSFUZZER_COMMON_COMPONENTLOADER_DLLLOADER_H__
-#define __VTS_SYSFUZZER_COMMON_COMPONENTLOADER_DLLLOADER_H__
-
-#include "hardware/hardware.h"
-
-namespace android {
-namespace vts {
-
-class DriverBase;
-
-// Pointer type for a function in a loaded component.
-typedef DriverBase* (*loader_function)();
-typedef DriverBase* (*loader_function_with_arg)(uint64_t arg);
-typedef void (*writeout_fn)();
-typedef void (*flush_fn)();
-
-// Component loader implementation for a DLL file.
-class DllLoader {
- public:
- DllLoader();
- virtual ~DllLoader();
-
- // Loads a DLL file.
- // Returns a handle (void *) if successful; NULL otherwise.
- void* Load(const char* file_path);
-
- // Finds and returns a requested function defined in the loaded file.
- // Returns NULL if not found.
- loader_function GetLoaderFunction(const char* function_name) const;
- loader_function_with_arg GetLoaderFunctionWithArg(
- const char* function_name) const;
-
- // (for sancov) Reset coverage data.
- bool SancovResetCoverage();
-
- // (for gcov) initialize.
- bool GcovInit(writeout_fn wfn, flush_fn ffn);
-
- // (for gcov) flush to file(s).
- bool GcovFlush();
-
- private:
- // pointer to a handle of the loaded DLL file.
- void* handle_;
-
- // Loads a symbol and prints error message.
- // Returns the symbol value if successful; NULL otherwise.
- void* LoadSymbol(const char* symbol_name) const;
-};
-
-} // namespace vts
-} // namespace android
-
-#endif // __VTS_SYSFUZZER_COMMON_COMPONENTLOADER_DLLLOADER_H__
diff --git a/drivers/hal/common/include/component_loader/HalDriverLoader.h b/drivers/hal/common/include/component_loader/HalDriverLoader.h
deleted file mode 100644
index 6d68775..0000000
--- a/drivers/hal/common/include/component_loader/HalDriverLoader.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef __VTS_SYSFUZZER_COMMON_SPECPARSER_SPECBUILDER_H__
-#define __VTS_SYSFUZZER_COMMON_SPECPARSER_SPECBUILDER_H__
-
-#include <queue>
-#include <string>
-
-#include "component_loader/DllLoader.h"
-#include "driver_base/DriverBase.h"
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-// Builder of an interface specification.
-class HalDriverLoader {
- public:
- // Constructor where the first argument is the path of a dir which contains
- // all available interface specification files.
- HalDriverLoader(const string dir_path, int epoch_count,
- const string& callback_socket_name);
-
- // Scans the dir and returns an component specification for a requested
- // component.
- // Args:
- // version_major: int, hal major version, e.g. 1.0 -> 1
- // version_minor: int, hal minor version, e.g. 1.0 -> 0
- bool FindComponentSpecification(const int component_class,
- const string& package_name,
- const int version_major,
- const int version_minor,
- const string& component_name,
- const int component_type,
- ComponentSpecificationMessage* spec_msg);
-
- // Create driver for given component.
- DriverBase* GetDriver(const string& driver_lib_path,
- const ComponentSpecificationMessage& spec_msg,
- const string& hw_binder_service_name,
- const uint64_t interface_pt,
- bool with_interface_pointer,
- const string& dll_file_name);
-
- // Returns FuzzBase for a given interface specification, and adds all the
- // found functions to the fuzzing job queue.
- // TODO (zhuoyao): consider to deprecate this method.
- DriverBase* GetFuzzerBaseAndAddAllFunctionsToQueue(
- const char* driver_lib_path,
- const ComponentSpecificationMessage& iface_spec_msg,
- const char* dll_file_name, const char* hw_service_name);
-
- // Main function for the VTS system fuzzer where dll_file_name is the path of
- // a target component, spec_lib_file_path is the path of a specification
- // library file, and the rest three arguments are the basic information of
- // the target component.
- // Args:
- // target_version_major: hal major version, e.g. 1.0 -> 1.
- // target_version_minor: hal minor version, e.g. 1.0 -> 0.
- // TODO (zhuoyao): consider to deprecate this method.
- bool Process(const char* dll_file_name, const char* spec_lib_file_path,
- int target_class, int target_type, int target_version_major,
- int target_version_minor, const char* target_package,
- const char* target_component_name, const char* hal_service_name);
-
- private:
- // Internal method to create driver for library.
- DriverBase* GetLibDriver(const string& driver_lib_path,
- const ComponentSpecificationMessage& spec_msg,
- const string& dll_file_name);
-
- // Internal method to create driver for HIDL HAL.
- DriverBase* GetHidlHalDriver(const string& driver_lib_path,
- const ComponentSpecificationMessage& spec_msg,
- const string& hal_service_name,
- const uint64_t interface_pt,
- bool with_interface_pt);
-
- // Internal method to create driver for HIDL HAL with interface pointer.
- DriverBase* LoadDriverWithInterfacePointer(
- const string& driver_lib_path,
- const ComponentSpecificationMessage& spec_msg,
- const uint64_t interface_pt);
-
- // Helper method to load a driver library with the given path.
- DriverBase* LoadDriver(const string& driver_lib_path,
- const ComponentSpecificationMessage& spec_msg);
-
- // A DLL Loader instance used to load the driver library.
- DllLoader dll_loader_;
- // the path of a dir which contains interface specification ASCII proto files.
- const string dir_path_;
- // the total number of epochs
- const int epoch_count_;
- // the server socket port # of the agent.
- const string callback_socket_name_;
- // fuzzing job queue. Used by Process method.
- queue<pair<FunctionSpecificationMessage*, DriverBase*>> job_queue_;
-};
-
-} // namespace vts
-} // namespace android
-
-#endif // __VTS_SYSFUZZER_COMMON_SPECPARSER_SPECBUILDER_H__
diff --git a/drivers/hal/common/include/driver_base/DriverBase.h b/drivers/hal/common/include/driver_base/DriverBase.h
deleted file mode 100644
index 45f0e15..0000000
--- a/drivers/hal/common/include/driver_base/DriverBase.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef __VTS_SYSFUZZER_COMMON_FUZZER_BASE_H__
-#define __VTS_SYSFUZZER_COMMON_FUZZER_BASE_H__
-
-#include "component_loader/DllLoader.h"
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-// HACK: NAN is #defined by math.h which gets included by
-// ComponentSpecificationMessage.pb.h, but some HALs use
-// enums called NAN. Undefine NAN to work around it.
-#undef NAN
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-class DriverBase {
- public:
- explicit DriverBase(int target_class);
- virtual ~DriverBase();
-
- // Loads a target component where the argument is the file path.
- // Returns true iff successful.
- bool LoadTargetComponent(const char* target_dll_path);
-
- // Gets the HIDL service.
- // Returns true iff successful.
- virtual bool GetService(bool /*get_stub*/, const char* /*service_name*/) {
- return false;
- };
-
- // Fuzz tests the loaded component using the provided interface specification.
- // Returns true iff the testing is conducted completely.
- bool Fuzz(vts::ComponentSpecificationMessage* message, void** result);
-
- // Actual implementation of routines to test a specific function using the
- // provided function interface specification message.
- // Returns true iff the testing is conducted completely.
- virtual bool Fuzz(vts::FunctionSpecificationMessage* /*func_msg*/,
- void** /*result*/, const string& /*callback_socket_name*/) {
- return false;
- };
-
- virtual bool CallFunction(
- const vts::FunctionSpecificationMessage& /*func_msg*/,
- const string& /*callback_socket_name*/,
- vts::FunctionSpecificationMessage* /*result_msg*/) {
- return false;
- };
-
- virtual bool VerifyResults(
- const vts::FunctionSpecificationMessage& /*expected_result_msg*/,
- const vts::FunctionSpecificationMessage& /*actual_result_msg*/) {
- return false;
- };
-
- virtual bool GetAttribute(vts::FunctionSpecificationMessage* /*func_msg*/,
- void** /*result*/) {
- return false;
- }
-
- // Called before calling a target function.
- void FunctionCallBegin();
-
- // Called after calling a target function. Fills in the code coverage info.
- bool FunctionCallEnd(FunctionSpecificationMessage* msg);
-
- // Scans all GCDA files under a given dir and adds to the message.
- bool ScanAllGcdaFiles(const string& basepath,
- FunctionSpecificationMessage* msg);
-
- protected:
- bool ReadGcdaFile(const string& basepath, const string& filename,
- FunctionSpecificationMessage* msg);
-
- // a pointer to a HAL data structure of the loaded component.
- struct hw_device_t* device_;
-
- // DLL Loader class.
- DllLoader target_loader_;
-
- // a pointer to the HAL_MODULE_INFO_SYM data structure of the loaded
- // component.
- struct hw_module_t* hmi_;
-
- private:
- // a pointer to the string which contains the loaded component.
- char* target_dll_path_;
-
- // function name prefix.
- const char* function_name_prefix_;
-
- // target class
- const int target_class_;
-
- // target component file name (without extension)
- char* component_filename_;
-
- // path to store the gcov output files.
- char* gcov_output_basepath_;
-};
-
-} // namespace vts
-} // namespace android
-
-#endif // __VTS_SYSFUZZER_COMMON_FUZZER_BASE_H__
diff --git a/drivers/hal/common/include/driver_base/DriverCallbackBase.h b/drivers/hal/common/include/driver_base/DriverCallbackBase.h
deleted file mode 100644
index d5a4a75..0000000
--- a/drivers/hal/common/include/driver_base/DriverCallbackBase.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef __VTS_SYSFUZZER_COMMON_FUZZER_CALLBACK_BASE_H__
-#define __VTS_SYSFUZZER_COMMON_FUZZER_CALLBACK_BASE_H__
-
-#include <string>
-
-#include "component_loader/DllLoader.h"
-#include "test/vts/proto/AndroidSystemControlMessage.pb.h"
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-class DriverCallbackBase {
- public:
- DriverCallbackBase();
- virtual ~DriverCallbackBase();
-
- static bool Register(const VariableSpecificationMessage& message);
-
- protected:
- static const char* GetCallbackID(const string& name);
-
- static void RpcCallToAgent(const AndroidSystemCallbackRequestMessage& message,
- const string& callback_socket_name);
-};
-
-} // namespace vts
-} // namespace android
-
-#endif // __VTS_SYSFUZZER_COMMON_FUZZER_CALLBACK_BASE_H__
diff --git a/drivers/hal/common/include/driver_manager/VtsHalDriverManager.h b/drivers/hal/common/include/driver_manager/VtsHalDriverManager.h
deleted file mode 100644
index e09ea30..0000000
--- a/drivers/hal/common/include/driver_manager/VtsHalDriverManager.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef __VTS_DRIVER_HAL_VTSHALDRIVERMANAGER_H
-#define __VTS_DRIVER_HAL_VTSHALDRIVERMANAGER_H
-
-#include <map>
-#include <string>
-
-#include <resource_manager/VtsResourceManager.h>
-#include "component_loader/HalDriverLoader.h"
-#include "driver_base/DriverBase.h"
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-using namespace std;
-using DriverId = int32_t;
-
-namespace android {
-namespace vts {
-
-class VtsHalDriverManager {
- public:
- // Constructor where the first argument is the path of a dir which contains
- // all available interface specification files.
- VtsHalDriverManager(const string& spec_dir, const int epoch_count,
- const string& callback_socket_name,
- VtsResourceManager* resource_manager);
-
- // Loads the driver library for the target HAL, creates the corresponding
- // driver instance, assign it a driver id and registers the created driver
- // instance in hal_driver_map_.
- // Returns the generated driver id.
- // Args:
- // version_major: int, hal major version, e.g. 1.0 -> 1.
- // version_minor: int, hal minor version, e.g. 1.0 -> 0.
- //
- DriverId LoadTargetComponent(const string& dll_file_name,
- const string& spec_lib_file_path,
- const int component_class,
- const int component_type,
- const int version_major, const int version_minor,
- const string& package_name,
- const string& component_name,
- const string& hw_binder_service_name);
-
- // Call the API specified in func_msg with the provided parameter using the
- // the corresonding driver instance. If func_msg specified the driver_id,
- // use the driver instance corresponds to driver_id, otherwise, use the
- // default driver instance (with driver_id = 0).
- // Returns a string which contians the return results (a text format of the
- // returned protobuf).
- // For error cases, returns string "error";
- // TODO (zhuoyao): use FunctionCallMessage instead of
- // FunctionSpecificationMessage which contains info such as component name and
- // driver id.
- string CallFunction(FunctionCallMessage* func_msg);
-
- // Searches hal_driver_map_ for Hidl HAL driver instance with the given
- // package name, version and component (interface) name. If found, returns
- // the correponding driver instance, otherwise, creates a new driver instance
- // with the given info, registers it in hal_driver_map_ and returns the
- // generated driver instance. This is used by VTS replay test.
- // Args:
- // version_major: int, hal major version, e.g. 1.0 -> 1.
- // version_minor: int, hal minor version, e.g. 1.0 -> 0.
- //
- DriverId GetDriverIdForHidlHalInterface(const string& package_name,
- const int version_major,
- const int version_minor,
- const string& interface_name,
- const string& hal_service_name);
-
- // Verify the return result of a function call matches the expected result.
- // This is used by VTS replay test.
- bool VerifyResults(DriverId id,
- const FunctionSpecificationMessage& expected_result,
- const FunctionSpecificationMessage& actual_result);
-
- // Loads the specification message for component with given component info
- // such as component_class etc. Used to server the ReadSpecification request
- // from host.
- // Returns true if load successfully, false otherwise.
- // Args:
- // version_major: int, hal major version, e.g. 1.0 -> 1.
- // version_minor: int, hal minor version, e.g. 1.0 -> 0.
- //
- bool FindComponentSpecification(const int component_class,
- const int component_type,
- const int version_major,
- const int version_minor,
- const string& package_name,
- const string& component_name,
- ComponentSpecificationMessage* spec_msg);
-
- // Returns the specification message for default driver. Used to serve the
- // ListFunctions request from host.
- // TODO (zhuoyao): needs to revisit this after supporting multi-hal testing.
- ComponentSpecificationMessage* GetComponentSpecification();
-
- // Used to serve the GetAttribute request from host. Only supported by
- // conventional HAL.
- // TODO (zhuoyao): consider deprecate this method.
- string GetAttribute(FunctionCallMessage* func_msg);
-
- private:
- // Internal method to register a HAL driver in hal_driver_map_.
- // Returns the driver id of registed driver.
- DriverId RegisterDriver(std::unique_ptr<DriverBase> driver,
- const ComponentSpecificationMessage& spec_msg,
- const uint64_t interface_pt);
-
- // Internal method to get the HAL driver based on the driver id. Returns
- // nullptr if no driver instance existes with given id.
- DriverBase* GetDriverById(const DriverId id);
-
- // Internal method to get the registered driver pointer based on driver id.
- // Returns -1 if no driver instance existes with given id.
- uint64_t GetDriverPointerById(const DriverId id);
-
- // Internal method to get the HAL driver based on FunctionCallMessage.
- DriverBase* GetDriverWithCallMsg(const FunctionCallMessage& call_msg);
-
- // Internal method to find the driver id based on component spec and
- // (for Hidl HAL) address to the hidl proxy.
- DriverId FindDriverIdInternal(const ComponentSpecificationMessage& spec_msg,
- const uint64_t interface_pt = 0,
- bool with_interface_pointer = false);
-
- // Internal method to process function return results for library.
- string ProcessFuncResultsForLibrary(FunctionSpecificationMessage* func_msg,
- void* result);
-
- // Util method to generate debug message with component info.
- string GetComponentDebugMsg(const int component_class,
- const int component_type, const string& version,
- const string& package_name,
- const string& component_name);
-
- // Recursively preprocess HAL function call arguments that have special types
- // such as TYPE_HIDL_INTERFACE, TYPE_FMQ_SYNC, TYPE_FMQ_UNSYNC,
- // TYPE_HIDL_MEMORY, TYPE_HANDLE.
- //
- // @param arg argument for a HAL function call.
- //
- // @return true if preprocessing succeeds, false otherwise.
- bool PreprocessHidlHalFunctionCallArgs(VariableSpecificationMessage* arg);
-
- // Recursively set HAL function call return values that have special types
- // such as TYPE_HIDL_INTERFACE, TYPE_FMQ_SYNC, TYPE_FMQ_UNSYNC,
- // TYPE_HIDL_MEMORY, TYPE_HANDLE.
- //
- // @param return_val return value for a HAL function call.
- //
- // @return true if setting results succeeds, false otherwise.
- bool SetHidlHalFunctionCallResults(VariableSpecificationMessage* return_val);
-
- // ============== attributes ===================
-
- // The server socket port # of the agent.
- const string callback_socket_name_;
- // A HalDriverLoader instance.
- HalDriverLoader hal_driver_loader_;
-
- // struct that store the driver instance and its corresponding meta info.
- struct HalDriverInfo {
- // Spcification for the HAL.
- ComponentSpecificationMessage spec_msg;
- // Pointer to the HAL client proxy, used for HIDL HAL only.
- uint64_t hidl_hal_proxy_pt;
- // A HAL driver instance.
- std::unique_ptr<DriverBase> driver;
-
- // Constructor for halDriverInfo
- HalDriverInfo(const ComponentSpecificationMessage& spec_msg,
- const uint64_t interface_pt,
- std::unique_ptr<DriverBase> driver)
- : spec_msg(spec_msg),
- hidl_hal_proxy_pt(interface_pt),
- driver(std::move(driver)) {}
- };
- // map to keep all the active HAL driver instances and their corresponding
- // meta info.
- // TODO(zhuoyao): consider to use unordered_map for performance optimization.
- map<DriverId, HalDriverInfo> hal_driver_map_;
- // TODO(zhuoyao): use mutex to protect hal_driver_map_;
-
- // Hold onto a resource_manager because some function calls need to reference
- // resources allocated on the target side.
- // driver_manager doesn't own resource_manager because driver_manager and
- // resource_manager are both started by the agent. driver_manager only holds
- // this pointer because it is easy to call functions in resource_manager.
- VtsResourceManager* resource_manager_;
-};
-
-} // namespace vts
-} // namespace android
-#endif //__VTS_DRIVER_HAL_VTSHALDRIVERMANAGER_H
diff --git a/drivers/hal/common/include/utils/InterfaceSpecUtil.h b/drivers/hal/common/include/utils/InterfaceSpecUtil.h
deleted file mode 100644
index c039480..0000000
--- a/drivers/hal/common/include/utils/InterfaceSpecUtil.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef __VTS_SYSFUZZER_COMMON_UTILS_IFSPECUTIL_H__
-#define __VTS_SYSFUZZER_COMMON_UTILS_IFSPECUTIL_H__
-
-#include <string>
-
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-#define VTS_INTERFACE_SPECIFICATION_FUNCTION_NAME_PREFIX "vts_func_"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-// Reads the given file and parse the file contents into a
-// ComponentSpecificationMessage.
-bool ParseInterfaceSpec(const char* file_path,
- ComponentSpecificationMessage* message);
-
-// Returns the function name prefix of a given interface specification.
-string GetFunctionNamePrefix(const ComponentSpecificationMessage& message);
-
-// Get HAL version (represented by two integers) string to be used to
-// build a relevant dir path.
-//
-// Args:
-// version_major: int, HAL major version, e.g. 1.10 -> 1.
-// version_minor: int, HAL minor version, e.g. 1.10 -> 10.
-// for_macro: bool, if true, it returns version 1.10 as V1_10
-//
-// Returns:
-// string, for version 1.10, if for_macro is true, it returns V1_10,
-// otherwise, it returns 1.10.
-string GetVersionString(int version_major, int version_minor,
- bool for_macro = false);
-
-// deprecated
-// Get HAL version string to be used to build a relevant dir path.
-//
-// Args:
-// version: float, HAL version, e.g. 1.10.
-// for_macro: bool, if true, it returns version 1.10 as V1_10.
-//
-// Returns:
-// string, for version 1.10, if for_macro is true, it returns V1_10,
-// otherwise, it returns 1.10.
-string GetVersionString(float version, bool for_macro=false);
-
-// Get the driver library name for a given HIDL HAL.
-//
-// Args:
-// package_name: string, name of target package.
-// version_major: int, hal major version, e.g. 1.10 -> 1.
-// version_minor: int, hal minor version, e.g. 1.10 -> 10.
-//
-// Returns:
-// string, the driver lib name built from the arguments.
-string GetHidlHalDriverLibName(const string& package_name,
- const int version_major,
- const int version_minor);
-
-// Get the FQName for a given HIDL HAL.
-//
-// Args:
-// package_name: string, name of target package.
-// version_major: int, hal major version, e.g. 1.10 -> 1.
-// version_minor: int, hal minor version, e.g. 1.10 -> 10.
-// interface_name: string, name of target interface.
-//
-// Returns:
-// string, the interface FQ name built from the arguments.
-string GetInterfaceFQName(const string& package_name, const int version_major,
- const int version_minor,
- const string& interface_name);
-
-// Extract package name from full hidl type name
-// e.g. ::android::hardware::nfc::V1_0::INfc -> android.hardware.nfc
-string GetPackageName(const string& type_name);
-
-// Extract version from full hidl type name
-// e.g. ::android::hardware::nfc::V1_0::INfc -> "1_0"
-string GetVersion(const string& type_name);
-
-// Extract major version from version string
-// for_macro is true if the input version string has "_"
-// e.g. "1_10" -> 1 if for_macro is true
-// "1.10" -> 1 if for_macro is false
-int GetVersionMajor(const string& version, bool for_macro = false);
-
-// Extract minor version from version string
-// for_macro is true if the input version string has "_"
-// e.g. "1_10" -> 10 if for_macro is true
-// "1.10" -> 10 if for_macro is false
-int GetVersionMinor(const string& version, bool for_macro = false);
-
-// Extract component name from full hidl type name
-// e.g. ::android::hardware::nfc::V1_0::INfc -> INfc
-string GetComponentName(const string& type_name);
-
-} // namespace vts
-} // namespace android
-
-#endif // __VTS_SYSFUZZER_COMMON_UTILS_IFSPECUTIL_H__
diff --git a/drivers/hal/common/include/utils/StringUtil.h b/drivers/hal/common/include/utils/StringUtil.h
deleted file mode 100644
index 645c9fb..0000000
--- a/drivers/hal/common/include/utils/StringUtil.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef __VTS_SYSFUZZER_COMMON_UTILS_STRINGUTIL_H__
-#define __VTS_SYSFUZZER_COMMON_UTILS_STRINGUTIL_H__
-
-#include <string>
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-// returns true if s ends with suffix.
-bool endsWith(const string& s, const string& suffix);
-
-
-// custom util function to replace all occurrences of a substring.
-extern void ReplaceSubString(
- string& original, const string& from, const string& to);
-
-
-} // namespace vts
-} // namespace android
-
-#endif // __VTS_SYSFUZZER_COMMON_UTILS_STRINGUTIL_H__
diff --git a/drivers/hal/common/utils/InterfaceSpecUtil.cpp b/drivers/hal/common/utils/InterfaceSpecUtil.cpp
deleted file mode 100644
index 56da304..0000000
--- a/drivers/hal/common/utils/InterfaceSpecUtil.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * 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.
- */
-
-#include "utils/InterfaceSpecUtil.h"
-
-#include <fstream>
-#include <sstream>
-#include <string>
-
-#include <android-base/logging.h>
-#include <assert.h>
-#include <google/protobuf/message.h>
-#include <google/protobuf/text_format.h>
-
-#include "utils/StringUtil.h"
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-bool ParseInterfaceSpec(const char* file_path,
- ComponentSpecificationMessage* message) {
- ifstream in_file(file_path);
- stringstream str_stream;
- if (!in_file.is_open()) {
- LOG(ERROR) << "Unable to open file. " << file_path;
- return false;
- }
- str_stream << in_file.rdbuf();
- in_file.close();
- const string data = str_stream.str();
-
- message->Clear();
- if (!google::protobuf::TextFormat::MergeFromString(data, message)) {
- LOG(ERROR) << "Can't parse a given proto file " << file_path;
- return false;
- }
- return true;
-}
-
-string GetFunctionNamePrefix(const ComponentSpecificationMessage& message) {
- stringstream prefix_ss;
- if (message.component_class() != HAL_HIDL) {
- prefix_ss << VTS_INTERFACE_SPECIFICATION_FUNCTION_NAME_PREFIX
- << message.component_class() << "_" << message.component_type()
- << "_"
- << GetVersionString(message.component_type_version_major(),
- message.component_type_version_minor(),
- true) // set flag to true, use macro version,
- // e.g. V1_10.
- << "_";
- } else {
- string package_as_function_name(message.package());
- ReplaceSubString(package_as_function_name, ".", "_");
- prefix_ss << VTS_INTERFACE_SPECIFICATION_FUNCTION_NAME_PREFIX
- << message.component_class() << "_" << package_as_function_name
- << "_"
- << GetVersionString(message.component_type_version_major(),
- message.component_type_version_minor(),
- true) // set flag to true, use macro version,
- // e.g. V1_10.
- << "_" << message.component_name() << "_";
- }
- return prefix_ss.str();
-}
-
-#define DEFAULT_FACTOR 10000
-
-// deprecated
-string GetVersionString(float version, bool for_macro) {
- std::ostringstream out;
- if (for_macro) {
- out << "V";
- }
- long version_long = version * DEFAULT_FACTOR;
- out << (version_long / DEFAULT_FACTOR);
- if (!for_macro) {
- out << ".";
- } else {
- out << "_";
- }
- version_long -= (version_long / DEFAULT_FACTOR) * DEFAULT_FACTOR;
- bool first = true;
- long factor = DEFAULT_FACTOR / 10;
- while (first || (version_long > 0 && factor > 1)) {
- out << (version_long / factor);
- version_long -= (version_long / factor) * factor;
- factor /= 10;
- first = false;
- }
- return out.str();
-}
-
-string GetVersionString(int version_major, int version_minor, bool for_macro) {
- std::ostringstream out;
-
- if (for_macro) out << "V";
-
- out << version_major;
- out << (for_macro ? "_" : ".");
- out << version_minor;
- return out.str();
-}
-
-string GetHidlHalDriverLibName(const string& package_name,
- const int version_major,
- const int version_minor) {
- return package_name + "@" + GetVersionString(version_major, version_minor) +
- "-vts.driver.so";
-}
-
-string GetInterfaceFQName(const string& package_name, const int version_major,
- const int version_minor,
- const string& interface_name) {
- return package_name + "@" + GetVersionString(version_major, version_minor) +
- "::" + interface_name;
-}
-
-string GetPackageName(const string& type_name) {
- string str = type_name.substr(0, type_name.find('V') - strlen("::"));
- if (str.find("::") == 0) {
- str = str.substr(strlen("::"));
- }
- ReplaceSubString(str, "::", ".");
- return str;
-}
-
-string GetVersion(const string& type_name) {
- string str = type_name.substr(type_name.find('V') + 1);
- string version_str = str.substr(0, str.find("::"));
- return version_str;
-}
-
-int GetVersionMajor(const string& version, bool for_macro) {
- if (for_macro) return std::stoi(version.substr(0, version.find("_")));
- return std::stoi(version.substr(0, version.find(".")));
-}
-
-int GetVersionMinor(const string& version, bool for_macro) {
- if (for_macro) return std::stoi(version.substr(version.find("_") + 1));
- return std::stoi(version.substr(version.find(".") + 1));
-}
-
-string GetComponentName(const string& type_name) {
- string str = type_name.substr(type_name.find('V'));
- return str.substr(str.find("::") + strlen("::"));
-}
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/hal/common/utils/StringUtil.cpp b/drivers/hal/common/utils/StringUtil.cpp
deleted file mode 100644
index f93ec42..0000000
--- a/drivers/hal/common/utils/StringUtil.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.
- */
-
-#include "utils/StringUtil.h"
-
-#include <string>
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-bool endsWith(const string& s, const string& suffix) {
- return s.size() >= suffix.size() && s.rfind(suffix) == (s.size() - suffix.size());
-}
-
-void ReplaceSubString(string& original, const string& from, const string& to) {
- size_t index = 0;
- int from_len = from.length();
- while (true) {
- index = original.find(from, index);
- if (index == std::string::npos) break;
- original.replace(index, from_len, to);
- index += from_len;
- }
-}
-
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/hal/libcodecoverage/Android.bp b/drivers/hal/libcodecoverage/Android.bp
deleted file mode 100644
index 04cfa38..0000000
--- a/drivers/hal/libcodecoverage/Android.bp
+++ /dev/null
@@ -1,36 +0,0 @@
-//
-// 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 {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-cc_library_shared {
-
- name: "libvts_codecoverage",
-
- // TODO(b/153609531): remove when no longer needed.
- native_bridge_supported: true,
-
- srcs: [
- "GcdaParser.cpp",
- "GcdaFile.cpp",
- ],
-
- cflags: ["-Wall", "-Werror"],
-
- export_include_dirs: ["."],
-}
diff --git a/drivers/hal/libcodecoverage/GcdaFile.cpp b/drivers/hal/libcodecoverage/GcdaFile.cpp
deleted file mode 100644
index 7beca35..0000000
--- a/drivers/hal/libcodecoverage/GcdaFile.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "GcdaFile.h"
-
-#include <inttypes.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-namespace android {
-namespace vts {
-
-bool GcdaFile::Open() {
- if (filename_.length() < 1) return false;
- if (gcov_var_.file) return false;
-
- memset(&gcov_var_, 0, sizeof(gcov_var_));
- gcov_var_.overread = -1u;
-
- gcov_var_.file = fopen(filename_.c_str(), "rb");
- if (!gcov_var_.file) return false;
- gcov_var_.mode = 0;
- setbuf(gcov_var_.file, (char*)0);
- return true;
-}
-
-int GcdaFile::Close() {
- if (gcov_var_.file) {
- fclose(gcov_var_.file);
- gcov_var_.file = 0;
- gcov_var_.length = 0;
- }
- free(gcov_var_.buffer);
- gcov_var_.alloc = 0;
- gcov_var_.buffer = 0;
- gcov_var_.mode = 0;
- return gcov_var_.error;
-}
-
-void GcdaFile::Sync(unsigned base, unsigned length) {
- if (!gcov_var_.file) return;
-
- base += length;
- if (base - gcov_var_.start <= gcov_var_.length) {
- gcov_var_.offset = base - gcov_var_.start;
- } else {
- gcov_var_.offset = gcov_var_.length = 0;
- fseek(gcov_var_.file, base << 2, SEEK_SET);
- gcov_var_.start = ftell(gcov_var_.file) >> 2;
- }
-}
-unsigned GcdaFile::ReadStringArray(char** string_array, unsigned num_strings) {
- unsigned i;
- unsigned j;
- unsigned len = 0;
-
- for (j = 0; j < num_strings; j++) {
- unsigned string_len = ReadUnsigned();
- string_array[j] = (char*)malloc(string_len * sizeof(unsigned)); // xmalloc
- for (i = 0; i < string_len; i++) {
- ((unsigned*)string_array[j])[i] = ReadUnsigned();
- }
- len += (string_len + 1);
- }
- return len;
-}
-
-unsigned GcdaFile::ReadUnsigned() {
- const unsigned* buffer = ReadWords(1);
-
- if (!buffer) return 0;
- return FromFile(buffer[0]);
-}
-
-void GcdaFile::Allocate(unsigned length) {
- size_t new_size = gcov_var_.alloc;
-
- if (!new_size) new_size = GCOV_BLOCK_SIZE;
- new_size += length;
- new_size *= 2;
- gcov_var_.alloc = new_size;
- gcov_var_.buffer = (unsigned*)realloc(gcov_var_.buffer, new_size << 2);
-}
-
-const unsigned* GcdaFile::ReadWords(unsigned words) {
- const unsigned* result;
- unsigned excess = gcov_var_.length - gcov_var_.offset;
-
- if (!gcov_var_.file) return 0;
-
- if (excess < words) {
- gcov_var_.start += gcov_var_.offset;
- memmove(gcov_var_.buffer, gcov_var_.buffer + gcov_var_.offset, excess * 4);
- gcov_var_.offset = 0;
- gcov_var_.length = excess;
- if (gcov_var_.length + words > gcov_var_.alloc) {
- Allocate(gcov_var_.length + words);
- }
- excess = gcov_var_.alloc - gcov_var_.length;
- excess = fread(gcov_var_.buffer + gcov_var_.length, 1, excess << 2,
- gcov_var_.file) >> 2;
- gcov_var_.length += excess;
- if (gcov_var_.length < words) {
- gcov_var_.overread += words - gcov_var_.length;
- gcov_var_.length = 0;
- return 0;
- }
- }
- result = &gcov_var_.buffer[gcov_var_.offset];
- gcov_var_.offset += words;
- return result;
-}
-
-int GcdaFile::Magic(unsigned magic, unsigned expected) {
- if (magic == expected) return 1;
- magic = (magic >> 16) | (magic << 16);
- magic = ((magic & 0xff00ff) << 8) | ((magic >> 8) & 0xff00ff);
- if (magic == expected) {
- gcov_var_.endian = 1;
- return -1;
- }
- return 0;
-}
-
-gcov_type GcdaFile::ReadCounter() {
- gcov_type value;
- const unsigned* buffer = ReadWords(2);
- if (!buffer) return 0;
- value = FromFile(buffer[0]);
- if (sizeof(value) > sizeof(unsigned)) {
- value |= ((gcov_type)FromFile(buffer[1])) << 32;
- } else if (buffer[1]) {
- gcov_var_.error = -1;
- }
- return value;
-}
-
-void GcdaFile::WriteBlock(unsigned size) {
- int num_words = fwrite(gcov_var_.buffer, size << 2, 1, gcov_var_.file);
- if (num_words != 1) {
- gcov_var_.error = 1;
- }
- gcov_var_.start += size;
- gcov_var_.offset -= size;
-}
-
-const char* GcdaFile::ReadString() {
- unsigned length = ReadUnsigned();
- if (!length) return 0;
- return (const char*)ReadWords(length);
-}
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/hal/libcodecoverage/GcdaFile.h b/drivers/hal/libcodecoverage/GcdaFile.h
deleted file mode 100644
index 2f55fa2..0000000
--- a/drivers/hal/libcodecoverage/GcdaFile.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef __VTS_SYSFUZZER_LIBMEASUREMENT_GCDA_FILE_H__
-#define __VTS_SYSFUZZER_LIBMEASUREMENT_GCDA_FILE_H__
-
-#include <string>
-
-#include "gcov_basic_io.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-// Basic I/O methods for a GCOV file.
-class GcdaFile {
- public:
- explicit GcdaFile(const string& filename) : filename_(filename) {}
- virtual ~GcdaFile() {};
-
- // Opens a file.
- bool Open();
-
- // Closes a file and returns any existing error code.
- int Close();
-
- // Synchronizes to the given base and length.
- void Sync(unsigned base, unsigned length);
-
- // Reads a string array where the maximum number of strings is also specified.
- unsigned ReadStringArray(char** string_array, unsigned num_strings);
-
- // Reads a string.
- const char* ReadString();
-
- // Reads an unsigned integer.
- unsigned ReadUnsigned();
-
- // Reads 'words' number of words.
- const unsigned* ReadWords(unsigned words);
-
- // Reads a counter.
- gcov_type ReadCounter();
-
- // Write a block using 'size'.
- void WriteBlock(unsigned size);
-
- // Allocates memory for length.
- void Allocate(unsigned length);
-
- // Processes the magic tag.
- int Magic(unsigned magic, unsigned expected);
-
- // Returns the current position in the file.
- inline unsigned Position() const {
- return gcov_var_.start + gcov_var_.offset;
- }
-
- // Returns non-zero error code if there's an error.
- inline int IsError() const {
- return gcov_var_.file ? gcov_var_.error : 1;
- }
-
- protected:
- inline unsigned FromFile(unsigned value) {
- if (gcov_var_.endian) {
- value = (value >> 16) | (value << 16);
- value = ((value & 0xff00ff) << 8) | ((value >> 8) & 0xff00ff);
- }
- return value;
- }
-
- private:
- // The GCOV var data structure for an opened file.
- struct gcov_var_t gcov_var_;
- const string& filename_;
-};
-
-} // namespace vts
-} // namespace android
-
-#endif
diff --git a/drivers/hal/libcodecoverage/GcdaParser.cpp b/drivers/hal/libcodecoverage/GcdaParser.cpp
deleted file mode 100644
index b12394f..0000000
--- a/drivers/hal/libcodecoverage/GcdaParser.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "GcdaParser.h"
-
-#include <iostream>
-#include <vector>
-
-#include "GcdaFile.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-bool GcdaRawCoverageParser::ParseMagic() {
- unsigned magic = gcda_file_->ReadUnsigned();
- unsigned version;
- const char* type = NULL;
- int endianness = 0;
- char m[4], v[4];
-
- if ((endianness = gcda_file_->Magic(magic, GCOV_DATA_MAGIC))) {
- type = "data";
- } else {
- cout << __func__ << ": not a GCOV file, " << filename_ << endl;
- gcda_file_->Close();
- return false;
- }
- version = gcda_file_->ReadUnsigned();
- GCOV_UNSIGNED2STRING(v, version);
- GCOV_UNSIGNED2STRING(m, magic);
- if (version != GCOV_VERSION) {
- char e[4];
- GCOV_UNSIGNED2STRING(e, GCOV_VERSION);
- }
- return true;
-}
-
-void GcdaRawCoverageParser::ParseBody() {
- unsigned tags[4];
- unsigned depth = 0;
- bool found;
- unsigned base;
- unsigned position;
- unsigned tag;
- unsigned length;
- unsigned tag_depth;
- int error;
- unsigned mask;
-
- gcda_file_->ReadUnsigned(); // stamp
- while (1) {
- position = gcda_file_->Position();
-
- tag = gcda_file_->ReadUnsigned();
- if (!tag) break;
-
- length = gcda_file_->ReadUnsigned();
- base = gcda_file_->Position();
- mask = GCOV_TAG_MASK(tag) >> 1;
- for (tag_depth = 4; mask; mask >>= 8) {
- if ((mask & 0xff) != 0xff) {
- cerr << __func__ << ": invalid tag, " << tag << endl;
- break;
- }
- tag_depth--;
- }
- found = false;
-
- if (tag) {
- if (depth && depth < tag_depth &&
- !GCOV_TAG_IS_SUBTAG(tags[depth - 1], tag)) {
- cerr << __func__ << ": incorrectly nested tag, " << tag << endl;
- }
- depth = tag_depth;
- tags[depth - 1] = tag;
- }
-
- switch(tag) {
- case GCOV_TAG_FUNCTION:
- TagFunction(tag, length);
- break;
- case GCOV_TAG_BLOCKS:
- TagBlocks(tag, length);
- break;
- case GCOV_TAG_ARCS:
- TagArcs(tag, length);
- break;
- case GCOV_TAG_LINES:
- TagLines(tag, length);
- break;
- }
- gcda_file_->Sync(base, length);
-
- if ((error = gcda_file_->IsError())) {
- cerr << __func__ << ": I/O error at "
- << gcda_file_->Position() << endl;
- break;
- }
- }
-}
-
-vector<unsigned> GcdaRawCoverageParser::Parse() {
- result.clear();
- if (!gcda_file_->Open()) {
- cerr << __func__ << " Cannot open a file, " << filename_ << endl;
- return result;
- }
-
- if (!ParseMagic()) return result;
- ParseBody();
- gcda_file_->Close();
- return result;
-}
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/hal/libcodecoverage/GcdaParser.h b/drivers/hal/libcodecoverage/GcdaParser.h
deleted file mode 100644
index 170761f..0000000
--- a/drivers/hal/libcodecoverage/GcdaParser.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef __VTS_SYSFUZZER_LIBMEASUREMENT_GCDA_PARSER_H__
-#define __VTS_SYSFUZZER_LIBMEASUREMENT_GCDA_PARSER_H__
-
-#include <iostream>
-#include <string>
-#include <vector>
-
-#include "GcdaFile.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-// Parses a GCDA file and extracts raw coverage info.
-class GcdaRawCoverageParser {
- public:
- explicit GcdaRawCoverageParser(const char* filename)
- : filename_(filename), gcda_file_(new GcdaFile(filename_)) {}
-
- virtual ~GcdaRawCoverageParser() {}
-
- // Parses a given file and returns a vector which contains IDs of raw
- // coverage measurement units (e.g., basic blocks).
- vector<unsigned> Parse();
-
- protected:
- // Parses the GCOV magic number.
- bool ParseMagic();
-
- // Parses the GCOV file body.
- void ParseBody();
-
- // Processes tag for functions.
- void TagFunction(unsigned /*tag*/, unsigned length) {
- /* unsigned long pos = */ gcda_file_->Position();
-
- if (length) {
- gcda_file_->ReadUnsigned(); // ident %u
- unsigned lineno_checksum = gcda_file_->ReadUnsigned();
- result.push_back(lineno_checksum);
- gcda_file_->ReadUnsigned(); // cfg_checksum 0x%08x
- }
- }
-
- // Processes tag for blocks.
- void TagBlocks(unsigned /*tag*/, unsigned length) {
- unsigned n_blocks = GCOV_TAG_BLOCKS_NUM(length);
- cout << __func__ << ": " << n_blocks << " blocks" << endl;
- }
-
- // Processes tag for arcs.
- void TagArcs(unsigned /*tag*/, unsigned length) {
- unsigned n_arcs = GCOV_TAG_ARCS_NUM(length);
- cout << __func__ << ": " << n_arcs << " arcs" << endl;
- }
-
- // Processes tag for lines.
- void TagLines(unsigned /*tag*/, unsigned /*length*/) {
- cout << __func__ << endl;
- }
-
- private:
- // the name of a target file.
- const string filename_;
-
- // global GcovFile data structure.
- GcdaFile* gcda_file_;
-
- // vector containing the parsed, raw coverage data.
- vector<unsigned> result;
-};
-
-} // namespace vts
-} // namespace android
-
-#endif
diff --git a/drivers/hal/libcodecoverage/gcda_parser_test.cpp b/drivers/hal/libcodecoverage/gcda_parser_test.cpp
deleted file mode 100644
index 5548ab4..0000000
--- a/drivers/hal/libcodecoverage/gcda_parser_test.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "gcov_basic_io.h"
-
-#include <iostream>
-#include <vector>
-#include "GcdaParser.h"
-
-/*
- * To test locally:
- * $ rm a.out; gcc GcdaParser.cpp gcda_parser_test.cpp GcdaFile.cpp -lstdc++; ./a.out
- */
-
-using namespace std;
-
-int main() {
- std::vector<unsigned> result =
- android::vts::GcdaRawCoverageParser("testdata/lights.gcda").Parse();
- for (unsigned int index = 0; index < result.size(); index++) {
- cout << result.at(index) << endl;
- }
- return 0;
-}
diff --git a/drivers/hal/libcodecoverage/gcov_basic_io.h b/drivers/hal/libcodecoverage/gcov_basic_io.h
deleted file mode 100644
index dcf180f..0000000
--- a/drivers/hal/libcodecoverage/gcov_basic_io.h
+++ /dev/null
@@ -1,134 +0,0 @@
-#ifndef __VTS_SYSFUZZER_LIBMEASUREMENT_GCOV_BASIC_IO_H__
-#define __VTS_SYSFUZZER_LIBMEASUREMENT_GCOV_BASIC_IO_H__
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-namespace android {
-namespace vts {
-
-struct block_info;
-struct source_info;
-
-#define GCOV_DATA_MAGIC ((unsigned)0x67636461) /* "gcda" */
-
-#define GCOV_TAG_FUNCTION ((unsigned int)0x01000000)
-#define GCOV_TAG_FUNCTION_LENGTH (3) /* or 2 */
-#define GCOV_COUNTER_ARCS 0
-#define GCOV_TAG_ARCS ((unsigned)0x01430000)
-#define GCOV_TAG_ARCS_LENGTH(NUM) (1 + (NUM)*2)
-#define GCOV_TAG_ARCS_NUM(LENGTH) (((LENGTH)-1) / 2)
-#define GCOV_TAG_LINES ((unsigned)0x01450000)
-#define GCOV_TAG_BLOCKS ((unsigned)0x01410000)
-#define GCOV_TAG_BLOCKS_LENGTH(NUM) (NUM)
-#define GCOV_TAG_BLOCKS_NUM(LENGTH) (LENGTH)
-#define GCOV_TAG_OBJECT_SUMMARY ((unsigned)0xa1000000)
-#define GCOV_TAG_COUNTER_NUM(LENGTH) ((LENGTH) / 2)
-
-#define GCOV_HISTOGRAM_SIZE 252
-#define GCOV_HISTOGRAM_BITVECTOR_SIZE (GCOV_HISTOGRAM_SIZE + 31) / 32
-#define GCOV_COUNTERS_SUMMABLE (GCOV_COUNTER_ARCS + 1)
-
-#define GCOV_TAG_IS_COUNTER(TAG) \
- (!((TAG)&0xFFFF) && GCOV_COUNTER_FOR_TAG(TAG) < GCOV_COUNTERS)
-
-#define GCOV_TAG_MASK(TAG) (((TAG)-1) ^ (TAG))
-
-/* Return nonzero if SUB is an immediate subtag of TAG. */
-#define GCOV_TAG_IS_SUBTAG(TAG, SUB) \
- (GCOV_TAG_MASK(TAG) >> 8 == GCOV_TAG_MASK(SUB) && \
- !(((SUB) ^ (TAG)) & ~GCOV_TAG_MASK(TAG)))
-
-/* Return nonzero if SUB is at a sublevel to TAG. */
-#define GCOV_TAG_IS_SUBLEVEL(TAG, SUB) (GCOV_TAG_MASK(TAG) > GCOV_TAG_MASK(SUB))
-
-typedef long long gcov_type;
-
-enum { GCOV_COUNTERS };
-
-#define GCOV_VERSION ((unsigned)0x34303670) /* 406p */
-
-#define GCOV_TAG_BUILD_INFO ((unsigned)0xa7000000)
-#define GCOV_TAG_PROGRAM_SUMMARY ((unsigned)0xa3000000)
-
-#define XCNEWVEC(T, N) ((T *)calloc((N), sizeof(T)))
-
-#define GCOV_TAG_COUNTER_BASE ((unsigned)0x01a10000)
-#define GCOV_TAG_COUNTER_LENGTH(NUM) ((NUM)*2)
-
-/* Convert a counter index to a tag. */
-#define GCOV_TAG_FOR_COUNTER(COUNT) \
- (GCOV_TAG_COUNTER_BASE + ((unsigned)(COUNT) << 17))
-
-/* Convert a tag to a counter. */
-#define GCOV_COUNTER_FOR_TAG(TAG) \
- ((unsigned)(((TAG)-GCOV_TAG_COUNTER_BASE) >> 17))
-
-/* Check whether a tag is a counter tag. */
-#define GCOV_TAG_IS_COUNTER(TAG) \
- (!((TAG)&0xFFFF) && GCOV_COUNTER_FOR_TAG(TAG) < GCOV_COUNTERS)
-
-#define GCOV_UNSIGNED2STRING(ARRAY, VALUE) \
- ((ARRAY)[0] = (char)((VALUE) >> 24), (ARRAY)[1] = (char)((VALUE) >> 16), \
- (ARRAY)[2] = (char)((VALUE) >> 8), (ARRAY)[3] = (char)((VALUE) >> 0))
-
-#define GCOV_BLOCK_SIZE (1 << 10)
-
-typedef struct arc_info {
- /* source and destination blocks. */
- struct block_info *src;
- struct block_info *dst;
-
- /* transition counts. */
- gcov_type count;
- /* used in cycle search, so that we do not clobber original counts. */
- gcov_type cs_count;
-
- unsigned int count_valid : 1;
- unsigned int on_tree : 1;
- unsigned int fake : 1;
- unsigned int fall_through : 1;
-
- /* Arc to a catch handler. */
- unsigned int is_throw : 1;
-
- /* Arc is for a function that abnormally returns. */
- unsigned int is_call_non_return : 1;
-
- /* Arc is for catch/setjmp. */
- unsigned int is_nonlocal_return : 1;
-
- /* Is an unconditional branch. */
- unsigned int is_unconditional : 1;
-
- /* Loop making arc. */
- unsigned int cycle : 1;
-
- /* Next branch on line. */
- struct arc_info *line_next;
-
- /* Links to next arc on src and dst lists. */
- struct arc_info *succ_next;
- struct arc_info *pred_next;
-} arc_t;
-
-struct gcov_var_t {
- FILE* file;
- unsigned start; /* Position of first byte of block */
- unsigned offset; /* Read/write position within the block. */
- unsigned length; /* Read limit in the block. */
- unsigned overread; /* Number of words overread. */
- int error; /* < 0 overflow, > 0 disk error. */
- int mode; /* < 0 writing, > 0 reading */
- int endian; /* Swap endianness. */
- /* Holds a variable length block, as the compiler can write
- strings and needs to backtrack. */
- size_t alloc;
- unsigned* buffer;
-};
-
-} // namespace vts
-} // namespace android
-
-#endif
diff --git a/drivers/hal/libcodecoverage/testdata/lights.gcda b/drivers/hal/libcodecoverage/testdata/lights.gcda
deleted file mode 100644
index d200289..0000000
--- a/drivers/hal/libcodecoverage/testdata/lights.gcda
+++ /dev/null
Binary files differ
diff --git a/drivers/hal/libcodecoverage/testdata/lights.gcno b/drivers/hal/libcodecoverage/testdata/lights.gcno
deleted file mode 100644
index 608d0fb..0000000
--- a/drivers/hal/libcodecoverage/testdata/lights.gcno
+++ /dev/null
Binary files differ
diff --git a/drivers/hal/libdatatype/Android.bp b/drivers/hal/libdatatype/Android.bp
deleted file mode 100644
index 5bf2a37..0000000
--- a/drivers/hal/libdatatype/Android.bp
+++ /dev/null
@@ -1,50 +0,0 @@
-//
-// 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 {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-cc_library_shared {
- name: "libvts_datatype",
- // TODO(b/153609531): remove when no longer needed.
- native_bridge_supported: true,
- srcs: [
- "vts_datatype.cpp",
- "hal_light.cpp",
- "hal_gps.cpp",
- "hal_camera.cpp",
- ],
- cflags: [
- "-Wall",
- "-Werror",
- ],
- shared_libs: [
- "libcutils",
- "libcamera_metadata",
- "libprotobuf-cpp-full",
- "libvts_multidevice_proto",
- ],
- header_libs: [
- "libhardware_headers",
- ],
- export_shared_lib_headers: [
- "libcamera_metadata",
- ],
- export_include_dirs: [
- "include",
- ],
-}
diff --git a/drivers/hal/libdatatype/hal_camera.cpp b/drivers/hal/libdatatype/hal_camera.cpp
deleted file mode 100644
index de98d87..0000000
--- a/drivers/hal/libdatatype/hal_camera.cpp
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "hal_camera.h"
-
-#include <pthread.h>
-#include <stdlib.h>
-
-#include <iostream>
-
-#include <hardware/camera.h>
-#include <hardware/camera_common.h>
-#include <hardware/hardware.h>
-
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-#include "vts_datatype.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-// Callbacks {
-static void vts_camera_device_status_change(
- const struct camera_module_callbacks*, int /*camera_id*/,
- int /*new_status*/) {}
-
-static void vts_torch_mode_status_change(
- const struct camera_module_callbacks*, const char* /*camera_id*/,
- int /*new_status*/) {}
-
-static void vts_camera_notify_callback(
- int32_t /*msg_type*/, int32_t /*ext1*/, int32_t /*ext2*/,
- void* /*user*/) {}
-
-static void vts_camera_data_callback(
- int32_t /*msg_type*/, const camera_memory_t* /*data*/,
- unsigned int /*index*/, camera_frame_metadata_t* /*metadata*/,
- void* /*user*/) {}
-
-static void vts_camera_data_timestamp_callback(
- int64_t /*timestamp*/, int32_t /*msg_type*/,
- const camera_memory_t* /*data*/, unsigned int /*index*/, void* /*user*/) {
-}
-
-static camera_memory_t* vts_camera_request_memory(
- int /*fd*/, size_t /*buf_size*/, unsigned int /*num_bufs*/,
- void* /*user*/) {
- cout << __func__ << endl;
- return NULL;
-}
-// } Callbacks
-
-camera_module_callbacks_t* GenerateCameraModuleCallbacks() {
- cout << __func__ << endl;
- if (RandomBool()) {
- return NULL;
- } else {
- camera_module_callbacks_t* callbacks =
- (camera_module_callbacks_t*)malloc(sizeof(camera_module_callbacks_t));
- callbacks->camera_device_status_change = vts_camera_device_status_change;
- callbacks->torch_mode_status_change = vts_torch_mode_status_change;
- return callbacks;
- }
-}
-
-camera_notify_callback GenerateCameraNotifyCallback() {
- return vts_camera_notify_callback;
-}
-
-camera_data_callback GenerateCameraDataCallback() {
- return vts_camera_data_callback;
-}
-
-camera_data_timestamp_callback GenerateCameraDataTimestampCallback() {
- return vts_camera_data_timestamp_callback;
-}
-
-camera_request_memory GenerateCameraRequestMemory() {
- return vts_camera_request_memory;
-}
-
-camera_info_t* GenerateCameraInfo() {
- cout << __func__ << endl;
- if (RandomBool()) {
- return NULL;
- } else {
- camera_info_t* caminfo = (camera_info_t*)malloc(sizeof(camera_info_t));
- caminfo->facing = RandomBool() ? CAMERA_FACING_BACK : CAMERA_FACING_FRONT;
- // support CAMERA_FACING_EXTERNAL if CAMERA_MODULE_API_VERSION_2_4 or above
- caminfo->orientation =
- RandomBool() ? (RandomBool() ? 0 : 90) : (RandomBool() ? 180 : 270);
- caminfo->device_version = CAMERA_MODULE_API_VERSION_2_1;
- caminfo->static_camera_characteristics = NULL;
- caminfo->resource_cost = 50; // between 50 and 100.
- caminfo->conflicting_devices = NULL;
- caminfo->conflicting_devices_length = 0;
-
- return caminfo;
- }
- /**
- * The camera's fixed characteristics, which include all static camera
- metadata
- * specified in system/media/camera/docs/docs.html. This should be a sorted
- metadata
- * buffer, and may not be modified or freed by the caller. The pointer should
- remain
- * valid for the lifetime of the camera module, and values in it may not
- * change after it is returned by get_camera_info().
- *
- * Version information (based on camera_module_t.common.module_api_version):
- *
- * CAMERA_MODULE_API_VERSION_1_0:
- *
- * Not valid. Extra characteristics are not available. Do not read this
- * field.
- *
- * CAMERA_MODULE_API_VERSION_2_0 or higher:
- *
- * Valid if device_version >= CAMERA_DEVICE_API_VERSION_2_0. Do not read
- * otherwise.
- *
- const camera_metadata_t *static_camera_characteristics;
- */
-
- /**
- * An array of camera device IDs represented as NULL-terminated strings
- * indicating other devices that cannot be simultaneously opened while this
- * camera device is in use.
- *
- * This field is intended to be used to indicate that this camera device
- * is a composite of several other camera devices, or otherwise has
- * hardware dependencies that prohibit simultaneous usage. If there are no
- * dependencies, a NULL may be returned in this field to indicate this.
- *
- * The camera service will never simultaneously open any of the devices
- * in this list while this camera device is open.
- *
- * The strings pointed to in this field will not be cleaned up by the camera
- * service, and must remain while this device is plugged in.
- *
- * Version information (based on camera_module_t.common.module_api_version):
- *
- * CAMERA_MODULE_API_VERSION_2_3 or lower:
- *
- * Not valid. Can be assumed to be NULL. Do not read this field.
- *
- * CAMERA_MODULE_API_VERSION_2_4 or higher:
- *
- * Always valid.
- char** conflicting_devices;
- */
-
- /**
- * The length of the array given in the conflicting_devices field.
- *
- * Version information (based on camera_module_t.common.module_api_version):
- *
- * CAMERA_MODULE_API_VERSION_2_3 or lower:
- *
- * Not valid. Can be assumed to be 0. Do not read this field.
- *
- * CAMERA_MODULE_API_VERSION_2_4 or higher:
- *
- * Always valid.
- size_t conflicting_devices_length;
- */
-}
-
-camera_info_t* GenerateCameraInfoUsingMessage(
- const VariableSpecificationMessage& /*msg*/) {
- cout << __func__ << endl;
- // TODO: acutally use msg.
- camera_info_t* caminfo = (camera_info_t*)malloc(sizeof(camera_info_t));
- caminfo->facing = RandomBool() ? CAMERA_FACING_BACK : CAMERA_FACING_FRONT;
- // support CAMERA_FACING_EXTERNAL if CAMERA_MODULE_API_VERSION_2_4 or above
- caminfo->orientation =
- RandomBool() ? (RandomBool() ? 0 : 90) : (RandomBool() ? 180 : 270);
- caminfo->device_version = CAMERA_MODULE_API_VERSION_2_1;
- caminfo->static_camera_characteristics = NULL;
- caminfo->resource_cost = 50; // between 50 and 100.
- caminfo->conflicting_devices = NULL;
- caminfo->conflicting_devices_length = 0;
-
- return caminfo;
-}
-
-bool ConvertCameraInfoToProtobuf(camera_info_t* raw,
- VariableSpecificationMessage* msg) {
- cout << __func__ << ":" << __LINE__ << endl;
-
- if (msg->struct_value_size() > 0) msg->clear_struct_value();
-
- if (!raw) return false;
-
- cout << __func__ << ":" << __LINE__ << endl;
- // TODO: use primitive_name and put in the expected order.
- msg->set_type(TYPE_STRUCT);
-
- VariableSpecificationMessage* sub_msg;
-
- sub_msg = msg->add_struct_value();
- sub_msg->set_type(TYPE_SCALAR);
- sub_msg->set_scalar_type("int32_t");
- sub_msg->mutable_scalar_value()->set_int32_t(raw->facing);
-
- sub_msg = msg->add_struct_value();
- sub_msg->set_type(TYPE_SCALAR);
- sub_msg->set_scalar_type("int32_t");
- sub_msg->mutable_scalar_value()->set_int32_t(raw->orientation);
-
- sub_msg = msg->add_struct_value();
- sub_msg->set_type(TYPE_SCALAR);
- sub_msg->set_scalar_type("uint32_t");
- sub_msg->mutable_scalar_value()->set_uint32_t(raw->device_version);
-
- // TODO: update for static_camera_characteristics and others
- // msg.add_primitive_value()->set_int32_t(raw->static_camera_characteristics);
- sub_msg = msg->add_struct_value();
- sub_msg->set_type(TYPE_SCALAR);
- sub_msg->set_scalar_type("int32_t");
- sub_msg->mutable_scalar_value()->set_int32_t(raw->resource_cost);
-
- // TODO: support pointer. conflicting_devices is pointer pointer.
- // msg.add_primitive_value()->set_pointer(raw->conflicting_devices);
- // msg.add_primitive_value()->set_int32_t(raw->conflicting_devices_length);
- sub_msg = msg->add_struct_value();
- sub_msg->set_type(TYPE_SCALAR);
- sub_msg->set_scalar_type("int32_t");
- sub_msg->mutable_scalar_value()->set_int32_t(0);
- return true;
-}
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/hal/libdatatype/hal_gps.cpp b/drivers/hal/libdatatype/hal_gps.cpp
deleted file mode 100644
index f633bf3..0000000
--- a/drivers/hal/libdatatype/hal_gps.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "hal_gps.h"
-
-#include <pthread.h>
-#include <stdlib.h>
-
-#include <hardware/gps.h>
-
-#include "vts_datatype.h"
-
-namespace android {
-namespace vts {
-
-// Callbacks {
-static void vts_gps_location_callback(GpsLocation* /*location*/) {}
-static void vts_gps_status_callback(GpsStatus* /*status*/) {}
-static void vts_gps_sv_status_callback(GpsSvStatus* /*sv_info*/) {}
-static void vts_gps_nmea_callback(
- GpsUtcTime /*timestamp*/, const char* /*nmea*/, int /*length*/) {}
-static void vts_gps_set_capabilities(uint32_t /*capabilities*/) {}
-static void vts_gps_acquire_wakelock() {}
-static void vts_gps_release_wakelock() {}
-static void vts_gps_request_utc_time() {}
-
-static pthread_t vts_gps_create_thread(
- const char* /*name*/, void (*/*start*/)(void*), void* /*arg*/) {
- return (pthread_t)NULL;
-}
-// } Callbacks
-
-GpsCallbacks* GenerateGpsCallbacks() {
- if (RandomBool()) {
- return NULL;
- } else {
- GpsCallbacks* cbs = (GpsCallbacks*)malloc(sizeof(GpsCallbacks));
- cbs->size = sizeof(GpsCallbacks);
- cbs->location_cb = vts_gps_location_callback;
- cbs->status_cb = vts_gps_status_callback;
- cbs->sv_status_cb = vts_gps_sv_status_callback;
- cbs->nmea_cb = vts_gps_nmea_callback;
- cbs->set_capabilities_cb = vts_gps_set_capabilities;
- cbs->acquire_wakelock_cb = vts_gps_acquire_wakelock;
- cbs->release_wakelock_cb = vts_gps_release_wakelock;
- cbs->create_thread_cb = vts_gps_create_thread;
- cbs->request_utc_time_cb = vts_gps_request_utc_time;
-
- return cbs;
- }
-}
-
-GpsUtcTime /*int64_t*/ GenerateGpsUtcTime() {
- // TOOD: consider returning the current time + a random number.
- return RandomInt64();
-}
-
-double GenerateLatitude() { return 10.0; }
-
-double GenerateLongitude() { return 20.0; }
-
-float GenerateGpsAccuracy() { return 5.0; }
-
-uint16_t GenerateGpsFlagsUint16() { return 1; }
-
-GpsPositionMode /*uint32_t*/ GenerateGpsPositionMode() {
- if (RandomBool()) {
- return RandomUint32();
- } else {
- if (RandomBool()) {
- return GPS_POSITION_MODE_STANDALONE;
- } else if (RandomBool()) {
- return GPS_POSITION_MODE_MS_BASED;
- } else {
- return GPS_POSITION_MODE_MS_ASSISTED;
- }
- }
- return RandomUint32();
-}
-
-GpsPositionRecurrence /*uint32_t*/ GenerateGpsPositionRecurrence() {
- if (RandomBool()) {
- return RandomUint32();
- } else {
- if (RandomBool()) {
- return GPS_POSITION_RECURRENCE_PERIODIC;
- } else {
- return GPS_POSITION_RECURRENCE_SINGLE;
- }
- }
-}
-
-// TODO: add generators for min_interval, preferred_accuracy, and preferred_time
-// all uint32_t.
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/hal/libdatatype/hal_light.cpp b/drivers/hal/libdatatype/hal_light.cpp
deleted file mode 100644
index 5b25c37..0000000
--- a/drivers/hal/libdatatype/hal_light.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "hal_light.h"
-
-#include <stdlib.h>
-
-#include <iostream>
-
-#include <hardware/lights.h>
-
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-#include "vts_datatype.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-light_state_t* GenerateLightState() {
- if (RandomBool()) {
- return NULL;
- } else {
- light_state_t* state = (light_state_t*)malloc(sizeof(light_state_t));
-
- state->color = RandomUint32();
- state->flashMode = RandomInt32();
- state->flashOnMS = RandomInt32();
- state->flashOffMS = RandomInt32();
- if (RandomBool()) { // normal values
- if (RandomBool()) {
- state->brightnessMode = BRIGHTNESS_MODE_USER;
- } else {
- state->brightnessMode = BRIGHTNESS_MODE_SENSOR;
- }
- } else { // abnormal values
- state->brightnessMode = RandomInt32();
- }
-
- return state;
- }
-}
-
-light_state_t* GenerateLightStateUsingMessage(
- const VariableSpecificationMessage& msg) {
- cout << __func__ << " entry" << endl;
- light_state_t* state = (light_state_t*)malloc(sizeof(light_state_t));
-
- // TODO: use a dict in the proto and handle when the key is missing (i.e.,
- // randomly generate that).
- state->color = msg.struct_value(0).scalar_value().uint32_t();
- cout << __func__ << " color " << state->color << endl;
- state->flashMode = msg.struct_value(1).scalar_value().int32_t();
- cout << __func__ << " flashMode " << state->flashMode << endl;
- state->flashOnMS = msg.struct_value(2).scalar_value().int32_t();
- cout << __func__ << " flashOnMS " << state->flashOnMS << endl;
- state->flashOffMS = msg.struct_value(3).scalar_value().int32_t();
- cout << __func__ << " flashOffMS " << state->flashOffMS << endl;
- state->brightnessMode = msg.struct_value(4).scalar_value().int32_t();
- cout << __func__ << " brightnessMode " << state->brightnessMode << endl;
-
- return state;
-}
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/hal/libdatatype/include/hal_camera.h b/drivers/hal/libdatatype/include/hal_camera.h
deleted file mode 100644
index 110b344..0000000
--- a/drivers/hal/libdatatype/include/hal_camera.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef __vts_libdatatype_hal_camera_h__
-#define __vts_libdatatype_hal_camera_h__
-
-#include <hardware/camera.h>
-#include <hardware/camera_common.h>
-#include <hardware/hardware.h>
-
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-namespace android {
-namespace vts {
-
-// Generates a camera_module_callbacks data structure.
-extern camera_module_callbacks_t* GenerateCameraModuleCallbacks();
-
-// Return the pointer to a camera_notify_callback function.
-extern camera_notify_callback GenerateCameraNotifyCallback();
-
-// Return the pointer to a camera_data_callback function.
-extern camera_data_callback GenerateCameraDataCallback();
-
-// Return the pointer to a camera_data_timestamp_callback function.
-extern camera_data_timestamp_callback GenerateCameraDataTimestampCallback();
-
-// Return the pointer to a camera_request_memory function.
-extern camera_request_memory GenerateCameraRequestMemory();
-
-// Generates a camera_info data structure.
-extern camera_info_t* GenerateCameraInfo();
-
-// Generates a camera_info data structure using a given protobuf msg's values.
-extern camera_info_t* GenerateCameraInfoUsingMessage(
- const VariableSpecificationMessage& msg);
-
-// Converts camera_info to a protobuf message.
-extern bool ConvertCameraInfoToProtobuf(camera_info_t* raw,
- VariableSpecificationMessage* msg);
-
-} // namespace vts
-} // namespace android
-
-#endif
diff --git a/drivers/hal/libdatatype/include/hal_gps.h b/drivers/hal/libdatatype/include/hal_gps.h
deleted file mode 100644
index a65dada..0000000
--- a/drivers/hal/libdatatype/include/hal_gps.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef __vts_libdatatype_hal_gps_h__
-#define __vts_libdatatype_hal_gps_h__
-
-#include <hardware/gps.h>
-
-namespace android {
-namespace vts {
-
-typedef double vts_gps_longitude;
-typedef double vts_gps_latitude;
-typedef float vts_gps_accuracy;
-typedef uint16_t vts_gps_flags_uint16;
-
-typedef uint32_t min_interval;
-typedef uint32_t preferred_accuracy;
-typedef uint32_t preferred_time;
-
-// Generates a GpsCallback instance used for GPS HAL v1 init().
-extern GpsCallbacks* GenerateGpsCallbacks();
-
-// Generates a GpsUtcTime value which is int64_t.
-extern GpsUtcTime GenerateGpsUtcTime();
-
-// Generates a GPS latitude value.
-extern double GenerateLatitude();
-
-// Generates a GPS longitude value.
-extern double GenerateLongitude();
-
-// Generates a GPS accuracy value.
-extern float GenerateGpsAccuracy();
-
-// Generates a uint16_t flag value.
-extern uint16_t GenerateGpsFlagsUint16();
-
-// Generates a GpsPositionMode value which is uint32_t.
-extern GpsPositionMode GenerateGpsPositionMode();
-
-// Generates a GpsPositionRecurrence value which is uint32_t.
-extern GpsPositionRecurrence GenerateGpsPositionRecurrence();
-
-} // namespace vts
-} // namespace android
-
-#endif
diff --git a/drivers/hal/libdatatype/include/hal_light.h b/drivers/hal/libdatatype/include/hal_light.h
deleted file mode 100644
index f3f7805..0000000
--- a/drivers/hal/libdatatype/include/hal_light.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef __vts_libdatatype_hal_light_h__
-#define __vts_libdatatype_hal_light_h__
-
-#include <hardware/lights.h>
-
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-namespace android {
-namespace vts {
-
-// Generates light_state_t instance.
-light_state_t* GenerateLightState();
-
-light_state_t* GenerateLightStateUsingMessage(
- const VariableSpecificationMessage& msg);
-
-} // namespace vts
-} // namespace android
-
-#endif
diff --git a/drivers/hal/libdatatype/include/vts_datatype.h b/drivers/hal/libdatatype/include/vts_datatype.h
deleted file mode 100644
index 4b0d55c..0000000
--- a/drivers/hal/libdatatype/include/vts_datatype.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef __VTS_DATATYPE_H__
-#define __VTS_DATATYPE_H__
-
-#include "hal_camera.h"
-#include "hal_gps.h"
-#include "hal_light.h"
-
-#define MAX_CHAR_POINTER_LENGTH 100
-
-namespace android {
-namespace vts {
-
-extern void RandomNumberGeneratorReset();
-extern uint32_t RandomUint32();
-extern int32_t RandomInt32();
-extern uint64_t RandomUint64();
-extern int64_t RandomInt64();
-extern float RandomFloat();
-extern double RandomDouble();
-extern bool RandomBool();
-extern char* RandomCharPointer();
-extern void* RandomVoidPointer();
-
-} // namespace vts
-} // namespace android
-
-#endif
diff --git a/drivers/hal/libdatatype/vts_datatype.cpp b/drivers/hal/libdatatype/vts_datatype.cpp
deleted file mode 100644
index ee93a21..0000000
--- a/drivers/hal/libdatatype/vts_datatype.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "vts_datatype.h"
-
-#include <stdlib.h>
-#include <time.h>
-
-namespace android {
-namespace vts {
-
-void RandomNumberGeneratorReset() { srand(time(NULL)); }
-
-uint32_t RandomUint32() { return (unsigned int)rand(); }
-
-int32_t RandomInt32() { return rand(); }
-
-uint64_t RandomUint64() {
- uint64_t num = (unsigned int)rand();
- return (num << 32) | (unsigned int)rand();
-}
-
-int64_t RandomInt64() {
- int64_t num = rand();
- return (num << 32) | rand();
-}
-
-float RandomFloat() { return (float)rand() / (float)(RAND_MAX / 1000000000.0); }
-
-double RandomDouble() {
- return (double)rand() / (double)(RAND_MAX / 1000000000.0);
-}
-
-bool RandomBool() { return (abs(rand()) % 2) == 1; }
-
-char* RandomCharPointer() {
- int len = RandomUint32() % MAX_CHAR_POINTER_LENGTH;
- char* buf = (char*)malloc(len);
- buf[len - 1] = '\0';
- return buf;
-}
-
-void* RandomVoidPointer() {
- int len = RandomUint32() % MAX_CHAR_POINTER_LENGTH;
- void* buf = malloc(len);
- return buf;
-}
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/hal/libmeasurement/Android.bp b/drivers/hal/libmeasurement/Android.bp
deleted file mode 100644
index a18a12d..0000000
--- a/drivers/hal/libmeasurement/Android.bp
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// 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 {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-cc_library_shared {
- name: "libvts_measurement",
- // TODO(b/153609531): remove when no longer needed.
- native_bridge_supported: true,
- srcs: [
- "vts_measurement.cpp",
- ],
- cflags: [
- "-Wall",
- "-Werror",
- ],
- shared_libs: [
- "libcutils",
- "libvts_common",
- ],
- export_include_dirs: [
- "include",
- ],
-}
diff --git a/drivers/hal/libmeasurement/include/vts_measurement.h b/drivers/hal/libmeasurement/include/vts_measurement.h
deleted file mode 100644
index 1c1e8ed..0000000
--- a/drivers/hal/libmeasurement/include/vts_measurement.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef __VTS_MEASUREMENT_H__
-#define __VTS_MEASUREMENT_H__
-
-#if USE_CTIME
-#include <time.h>
-#else
-#include <sys/time.h>
-#endif
-
-#include <vector>
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-// Class to do measurements before and after calling a target function.
-class VtsMeasurement {
- public:
- VtsMeasurement() {}
-
- // Starts the measurement
- void Start();
-
- // Stops the measurement and returns the measured values.
- vector<float>* Stop();
-
- private:
-// data structure to keep the start time.
-#if USE_CTIME
- struct timeval tv_;
-#else
- timespec ts_;
-#endif
-};
-
-} // namespace vts
-} // namespace android
-
-#endif
diff --git a/drivers/hal/libmeasurement/vts_measurement.cpp b/drivers/hal/libmeasurement/vts_measurement.cpp
deleted file mode 100644
index 5299a4b..0000000
--- a/drivers/hal/libmeasurement/vts_measurement.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "vts_measurement.h"
-
-#if USE_CTIME
-#include <time.h>
-#else
-#include <sys/time.h>
-#endif
-#include <stdlib.h>
-
-#include <iostream>
-
-#define COVERAGE_SANCOV 0
-
-#if COVERAGE_SANCOV
-#include <sanitizer/coverage_interface.h>
-#endif
-
-#include <vector>
-
-using namespace std;
-
-#if COVERAGE_SANCOV
-
-extern "C" {
-// Re-declare some of the sanitizer functions as "weak" so that
-// libFuzzer can be linked w/o the sanitizers and sanitizer-coverage
-// (in which case it will complain at start-up time).
-__attribute__((weak)) void __sanitizer_print_stack_trace();
-__attribute__((weak)) void __sanitizer_reset_coverage();
-__attribute__((weak)) size_t __sanitizer_get_total_unique_caller_callee_pairs();
-__attribute__((weak)) size_t __sanitizer_get_total_unique_coverage();
-__attribute__((weak)) void __sanitizer_set_death_callback(
- void (*callback)(void));
-__attribute__((weak)) size_t __sanitizer_get_number_of_counters();
-__attribute__((weak)) uintptr_t
-__sanitizer_update_counter_bitset_and_clear_counters(uint8_t* bitset);
-}
-
-#define CHECK_WEAK_API_FUNCTION(fn) \
- do { \
- if (!fn) MissingWeakApiFunction(#fn); \
- } while (false)
-
-static void MissingWeakApiFunction(const char* FnName) {
- cerr << "ERROR: " << FnName << " is not defined. Exiting.\n"
- << "Did you use -fsanitize-coverage=... to build your code?" << endl;
- exit(1);
-}
-#endif
-
-namespace android {
-namespace vts {
-
-void VtsMeasurement::Start() {
-#if COVERAGE_SANCOV
- cout << "reset coverage";
- CHECK_WEAK_API_FUNCTION(__sanitizer_reset_coverage);
- __sanitizer_reset_coverage();
- cout << endl;
-#endif
-
-#if USE_CTIME
- gettimeofday(&tv_, NULL);
-#else
- clock_gettime(CLOCK_REALTIME, &ts_);
-#endif
-}
-
-vector<float>* VtsMeasurement::Stop() {
-#if USE_CTIME
- struct timeval curr_tv;
- gettimeofday(&curr_tv, NULL);
-#else
- timespec ts_now;
- clock_gettime(CLOCK_REALTIME, &ts_now);
-#endif
-
- vector<float>* result = new vector<float>;
-
-#if USE_CTIME
- float stop_time_usecs;
- float start_time_usecs;
- stop_time_usecs = curr_tv.tv_sec + curr_tv.tv_usec / 1000000.0;
- start_time_usecs = tv_.tv_sec + tv_.tv_usec / 1000000.0;
- result->push_back(stop_time_usecs - start_time_usecs);
-#else
- float stop_time_usecs;
- float start_time_usecs;
- stop_time_usecs = ts_now.tv_sec + ts_now.tv_nsec / 1000000000.0;
- start_time_usecs = ts_.tv_sec + ts_.tv_nsec / 1000000000.0;
- result->push_back(stop_time_usecs - start_time_usecs);
-#endif
-
-#if COVERAGE_SANCOV
- cout << "coverage: ";
- cout << __sanitizer_get_total_unique_caller_callee_pairs() << endl;
-#endif
-
- return result;
-}
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/libdrivercomm/Android.bp b/drivers/libdrivercomm/Android.bp
deleted file mode 100644
index 9b487ac..0000000
--- a/drivers/libdrivercomm/Android.bp
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-// 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 {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-cc_library_shared {
-
- name: "libvts_drivercomm",
-
- // TODO(b/153609531): remove when no longer needed.
- native_bridge_supported: true,
-
- srcs: [
- "VtsDriverCommUtil.cpp",
- "VtsDriverFileUtil.cpp",
- ],
-
- cflags: ["-Wall", "-Werror"],
-
- shared_libs: [
- "libbase",
- "libcutils",
- "libprotobuf-cpp-full",
- "libvts_multidevice_proto",
- ],
-
- export_include_dirs: ["."],
-}
diff --git a/drivers/libdrivercomm/VtsDriverCommUtil.cpp b/drivers/libdrivercomm/VtsDriverCommUtil.cpp
deleted file mode 100644
index cf9ed7d..0000000
--- a/drivers/libdrivercomm/VtsDriverCommUtil.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#define LOG_TAG "VtsDriverCommUtil"
-
-#include "VtsDriverCommUtil.h"
-
-#include <errno.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sstream>
-
-#include <android-base/logging.h>
-
-#include "test/vts/proto/VtsDriverControlMessage.pb.h"
-
-using namespace std;
-
-#define MAX_HEADER_BUFFER_SIZE 128
-
-namespace android {
-namespace vts {
-
-bool VtsDriverCommUtil::Connect(const string& socket_name) {
- struct sockaddr_un serv_addr;
- struct hostent* server;
-
- LOG(DEBUG) << "Connect socket: " << socket_name;
- sockfd_ = socket(PF_UNIX, SOCK_STREAM, 0);
- if (sockfd_ < 0) {
- LOG(ERROR) << "ERROR opening socket.";
- return false;
- }
-
- server = gethostbyname("127.0.0.1");
- if (server == NULL) {
- LOG(ERROR) << "ERROR can't resolve the host name, 127.0.0.1";
- return false;
- }
-
- bzero((char*)&serv_addr, sizeof(serv_addr));
- serv_addr.sun_family = AF_UNIX;
- strcpy(serv_addr.sun_path, socket_name.c_str());
-
- if (connect(sockfd_, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
- LOG(ERROR) << "ERROR connecting to " << socket_name << " errno = " << errno
- << " " << strerror(errno);
- sockfd_ = -1;
- return false;
- }
- return true;
-}
-
-int VtsDriverCommUtil::Close() {
- int result = 0;
- if (sockfd_ != -1) {
- result = close(sockfd_);
- if (result != 0) {
- LOG(ERROR) << "ERROR closing socket (errno = " << errno << ")";
- }
-
- sockfd_ = -1;
- }
-
- return result;
-}
-
-bool VtsDriverCommUtil::VtsSocketSendBytes(const string& message) {
- if (sockfd_ == -1) {
- LOG(ERROR) << "ERROR sockfd not set.";
- return false;
- }
- stringstream header;
- header << message.length() << "\n";
- LOG(DEBUG) << "[agent->driver] len = " << message.length();
- int n = write(sockfd_, header.str().c_str(), header.str().length());
- if (n < 0) {
- LOG(ERROR) << " ERROR writing to socket.";
- return false;
- }
-
- int bytes_sent = 0;
- int msg_len = message.length();
- while (bytes_sent < msg_len) {
- n = write(sockfd_, &message.c_str()[bytes_sent], msg_len - bytes_sent);
- if (n <= 0) {
- LOG(ERROR) << "ERROR writing to socket.";
- return false;
- }
- bytes_sent += n;
- }
- return true;
-}
-
-string VtsDriverCommUtil::VtsSocketRecvBytes() {
- if (sockfd_ == -1) {
- LOG(ERROR) << "ERROR sockfd not set.";
- return string();
- }
-
- int header_index = 0;
- char header_buffer[MAX_HEADER_BUFFER_SIZE];
-
- for (header_index = 0; header_index < MAX_HEADER_BUFFER_SIZE;
- header_index++) {
- int ret = read(sockfd_, &header_buffer[header_index], 1);
- if (ret != 1) {
- int errno_save = errno;
- LOG(DEBUG) << "ERROR reading the length ret = " << ret
- << " sockfd = " << sockfd_ << " "
- << " errno = " << errno_save << " " << strerror(errno_save);
- return string();
- }
- if (header_buffer[header_index] == '\n' ||
- header_buffer[header_index] == '\r') {
- header_buffer[header_index] = '\0';
- break;
- }
- }
-
- int msg_len = atoi(header_buffer);
- char* msg = (char*)malloc(msg_len + 1);
- if (!msg) {
- LOG(ERROR) << "ERROR malloc failed.";
- return string();
- }
-
- int bytes_read = 0;
- while (bytes_read < msg_len) {
- int result = read(sockfd_, &msg[bytes_read], msg_len - bytes_read);
- if (result <= 0) {
- LOG(ERROR) << "ERROR read failed.";
- return string();
- }
- bytes_read += result;
- }
- msg[msg_len] = '\0';
- return string(msg, msg_len);
-}
-
-bool VtsDriverCommUtil::VtsSocketSendMessage(
- const google::protobuf::Message& message) {
- if (sockfd_ == -1) {
- LOG(ERROR) << "ERROR sockfd not set.";
- return false;
- }
-
- string message_string;
- if (!message.SerializeToString(&message_string)) {
- LOG(ERROR) << "ERROR can't serialize the message to a string.";
- return false;
- }
- return VtsSocketSendBytes(message_string);
-}
-
-bool VtsDriverCommUtil::VtsSocketRecvMessage(
- google::protobuf::Message* message) {
- if (sockfd_ == -1) {
- LOG(ERROR) << "ERROR sockfd not set.";
- return false;
- }
-
- string message_string = VtsSocketRecvBytes();
- if (message_string.length() == 0) {
- LOG(DEBUG) << "ERROR message string zero length.";
- return false;
- }
-
- return message->ParseFromString(message_string);
-}
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/libdrivercomm/VtsDriverCommUtil.h b/drivers/libdrivercomm/VtsDriverCommUtil.h
deleted file mode 100644
index 9a49d7b..0000000
--- a/drivers/libdrivercomm/VtsDriverCommUtil.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef __VTS_DRIVER_COMM_UTIL_H_
-#define __VTS_DRIVER_COMM_UTIL_H_
-
-#include <string>
-
-#include "test/vts/proto/VtsDriverControlMessage.pb.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-class VtsDriverCommUtil {
- public:
- VtsDriverCommUtil() : sockfd_(-1) {}
-
- explicit VtsDriverCommUtil(int sockfd) : sockfd_(sockfd) {}
-
- ~VtsDriverCommUtil() {
- // if (sockfd_ != -1) Close();
- }
-
- // returns true if connection to the server is successful, false otherwise.
- bool Connect(const string& socket_name);
-
- // sets sockfd_
- void SetSockfd(int sockfd) {
- sockfd_ = sockfd;
- }
-
- // closes the channel. returns 0 if success or socket already closed
- int Close();
-
- // Sends a message using the VTS's protocol for socket communication.
- bool VtsSocketSendBytes(const string& message);
-
- // Receives a message using the VTS's protocol for socket communication.
- string VtsSocketRecvBytes();
-
- // Sends a protobuf message.
- bool VtsSocketSendMessage(const google::protobuf::Message& message);
-
- // Receives a protobuf message.
- bool VtsSocketRecvMessage(google::protobuf::Message* message);
-
- private:
- // sockfd
- int sockfd_;
-};
-
-} // namespace vts
-} // namespace android
-
-#endif // __VTS_DRIVER_COMM_UTIL_H_
diff --git a/drivers/libdrivercomm/VtsDriverFileUtil.cpp b/drivers/libdrivercomm/VtsDriverFileUtil.cpp
deleted file mode 100644
index 4e88990..0000000
--- a/drivers/libdrivercomm/VtsDriverFileUtil.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#include "VtsDriverFileUtil.h"
-
-#include <fstream>
-#include <iostream>
-#include <sstream>
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-string ReadFile(const string& file_path) {
- ifstream ifs(file_path);
- string content((istreambuf_iterator<char>(ifs)),
- (istreambuf_iterator<char>()));
- return content;
-}
-
-string GetDirFromFilePath(const string& str) {
- size_t found = str.find_last_of("/\\");
- if (found == string::npos) {
- return ".";
- }
-
- return str.substr(0, found);
-}
-
-} // namespace vts
-} //
diff --git a/drivers/libdrivercomm/VtsDriverFileUtil.h b/drivers/libdrivercomm/VtsDriverFileUtil.h
deleted file mode 100644
index d861b06..0000000
--- a/drivers/libdrivercomm/VtsDriverFileUtil.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef __VTS_DRIVER_FILE_UTIL_H_
-#define __VTS_DRIVER_FILE_UTIL_H_
-
-#include <string>
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-/*
- * Read file content into a string
- */
-extern string ReadFile(const string& file_path);
-
-/*
- * Get the directory path out from file path.
- * This method does not check for error at this time.
- */
-extern string GetDirFromFilePath(const string& file_path_absolute);
-
-} // namespace vts
-} // namespace android
-
-#endif // __VTS_DRIVER_FILE_UTIL_H_
diff --git a/drivers/resource/Android.bp b/drivers/resource/Android.bp
deleted file mode 100644
index da1dce6..0000000
--- a/drivers/resource/Android.bp
+++ /dev/null
@@ -1,133 +0,0 @@
-//
-// Copyright (C) 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.
-//
-
-package {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-cc_defaults {
-
- name: "libvts_resource-defaults",
-
- cflags: [
- "-Wall",
- "-Werror",
- ],
-
- local_include_dirs: ["include"],
-
- static_libs: [
- "android.hardware.audio@4.0",
- "android.hardware.audio.effect@2.0",
- "android.hardware.audio.effect@4.0",
- ],
-
- shared_libs: [
- "android.hidl.allocator@1.0",
- "android.hidl.memory@1.0",
- "libbase",
- "libcutils",
- "libfmq",
- "libhidlbase",
- "libhidlmemory",
- "liblog",
- "libprotobuf-cpp-full",
- "libutils",
- ],
-
- export_include_dirs: ["include"],
-
- export_static_lib_headers: [
- "android.hardware.audio@4.0",
- "android.hardware.audio.effect@2.0",
- "android.hardware.audio.effect@4.0",
- ],
-
- export_shared_lib_headers: [
- "android.hidl.allocator@1.0",
- "android.hidl.memory@1.0",
- "libcutils",
- "libfmq",
- "libhidlbase",
- "libutils",
- ],
-}
-
-cc_library_shared {
- name: "libvts_resource_driver",
-
- defaults: ["libvts_resource-defaults"],
-
- // TODO(b/153609531): remove when no longer needed.
- native_bridge_supported: true,
-
- srcs: [
- "hidl_handle_driver/VtsHidlHandleDriver.cpp",
- "hidl_memory_driver/VtsHidlMemoryDriver.cpp",
- ],
-}
-
-cc_library_shared {
- name: "libvts_resource_manager",
-
- defaults: ["libvts_resource-defaults"],
-
- // TODO(b/153609531): remove when no longer needed.
- native_bridge_supported: true,
-
- srcs: [
- "resource_manager/VtsResourceManager.cpp",
- ],
-
- shared_libs: [
- "libvts_multidevice_proto",
- "libvts_resource_driver",
- ],
-}
-
-cc_test {
- name: "vts_resource_fmq_test",
-
- defaults: ["libvts_resource-defaults"],
-
- rtti: true,
-
- srcs: [
- "fmq_driver/VtsFmqDriverTest.cpp"
- ],
-}
-
-cc_test {
- name: "vts_resource_hidl_memory_test",
-
- defaults: ["libvts_resource-defaults"],
-
- srcs: [
- "hidl_memory_driver/VtsHidlMemoryDriver.cpp",
- "hidl_memory_driver/VtsHidlMemoryDriverTest.cpp",
- ]
-}
-
-cc_test {
- name: "vts_resource_hidl_handle_test",
-
- defaults: ["libvts_resource-defaults"],
-
- srcs: [
- "hidl_handle_driver/VtsHidlHandleDriver.cpp",
- "hidl_handle_driver/VtsHidlHandleDriverTest.cpp",
- ]
-}
diff --git a/drivers/resource/fmq_driver/VtsFmqDriverTest.cpp b/drivers/resource/fmq_driver/VtsFmqDriverTest.cpp
deleted file mode 100644
index 002fc66..0000000
--- a/drivers/resource/fmq_driver/VtsFmqDriverTest.cpp
+++ /dev/null
@@ -1,363 +0,0 @@
-//
-// 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.
-//
-
-#include "fmq_driver/VtsFmqDriver.h"
-
-#include <errno.h>
-#include <limits.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/wait.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <fmq/MessageQueue.h>
-#include <gtest/gtest.h>
-
-using android::hardware::kSynchronizedReadWrite;
-using android::hardware::kUnsynchronizedWrite;
-using namespace std;
-
-namespace android {
-namespace vts {
-
-// A test that initializes a single writer and a single reader.
-class SyncReadWrites : public ::testing::Test {
- protected:
- virtual void SetUp() {
- static constexpr size_t NUM_ELEMS = 2048;
-
- // initialize a writer
- writer_id_ = manager_.CreateFmq<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", NUM_ELEMS, false);
- ASSERT_NE(writer_id_, -1);
-
- // initialize a reader
- reader_id_ = manager_.CreateFmq<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", writer_id_);
- ASSERT_NE(reader_id_, -1);
- }
-
- virtual void TearDown() {}
-
- VtsFmqDriver manager_;
- QueueId writer_id_;
- QueueId reader_id_;
-};
-
-// A test that initializes a single writer and a single reader.
-// TODO: add tests for blocking between multiple queues later when there is more
-// use case.
-class BlockingReadWrites : public ::testing::Test {
- protected:
- virtual void SetUp() {
- static constexpr size_t NUM_ELEMS = 2048;
-
- // initialize a writer
- writer_id_ = manager_.CreateFmq<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", NUM_ELEMS, true);
- ASSERT_NE(writer_id_, -1);
-
- // initialize a reader
- reader_id_ = manager_.CreateFmq<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", writer_id_);
- ASSERT_NE(reader_id_, -1);
- }
-
- virtual void TearDown() {}
-
- VtsFmqDriver manager_;
- QueueId writer_id_;
- QueueId reader_id_;
-};
-
-// A test that initializes a single writer and two readers.
-class UnsynchronizedWrites : public ::testing::Test {
- protected:
- virtual void SetUp() {
- static constexpr size_t NUM_ELEMS = 2048;
-
- // initialize a writer
- writer_id_ = manager_.CreateFmq<uint16_t, kUnsynchronizedWrite>(
- "uint16_t", NUM_ELEMS, false);
- ASSERT_NE(writer_id_, -1);
-
- // initialize two readers
- reader_id1_ = manager_.CreateFmq<uint16_t, kUnsynchronizedWrite>(
- "uint16_t", writer_id_);
- reader_id2_ = manager_.CreateFmq<uint16_t, kUnsynchronizedWrite>(
- "uint16_t", writer_id_);
- ASSERT_NE(reader_id1_, -1);
- ASSERT_NE(reader_id2_, -1);
- }
-
- virtual void TearDown() {}
-
- VtsFmqDriver manager_;
- QueueId writer_id_;
- QueueId reader_id1_;
- QueueId reader_id2_;
-};
-
-// Tests the reader and writer are set up correctly.
-TEST_F(SyncReadWrites, SetupBasicTest) {
- static constexpr size_t NUM_ELEMS = 2048;
-
- // check if the writer has a valid queue
- ASSERT_TRUE((manager_.IsValid<uint16_t, kSynchronizedReadWrite>("uint16_t",
- writer_id_)));
-
- // check queue size on writer side
- size_t writer_queue_size;
- ASSERT_TRUE((manager_.GetQuantumCount<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", writer_id_, &writer_queue_size)));
- ASSERT_EQ(NUM_ELEMS, writer_queue_size);
-
- // check queue element size on writer side
- size_t writer_elem_size;
- ASSERT_TRUE((manager_.GetQuantumSize<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", writer_id_, &writer_elem_size)));
- ASSERT_EQ(sizeof(uint16_t), writer_elem_size);
-
- // check space available for writer
- size_t writer_available_writes;
- ASSERT_TRUE((manager_.AvailableToWrite<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", writer_id_, &writer_available_writes)));
- ASSERT_EQ(NUM_ELEMS, writer_available_writes);
-
- // check if the reader has a valid queue
- ASSERT_TRUE((manager_.IsValid<uint16_t, kSynchronizedReadWrite>("uint16_t",
- reader_id_)));
-
- // check queue size on reader side
- size_t reader_queue_size;
- ASSERT_TRUE((manager_.GetQuantumCount<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", reader_id_, &reader_queue_size)));
- ASSERT_EQ(NUM_ELEMS, reader_queue_size);
-
- // check queue element size on reader side
- size_t reader_elem_size;
- ASSERT_TRUE((manager_.GetQuantumSize<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", reader_id_, &reader_elem_size)));
- ASSERT_EQ(sizeof(uint16_t), reader_elem_size);
-
- // check items available for reader
- size_t reader_available_reads;
- ASSERT_TRUE((manager_.AvailableToRead<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", reader_id_, &reader_available_reads)));
- ASSERT_EQ(0, reader_available_reads);
-}
-
-// util method to initialize data
-void InitData(uint16_t* data, size_t len) {
- for (size_t i = 0; i < len; i++) {
- data[i] = rand() % 100 + 1; // a random value between 1 and 100
- }
-}
-
-// Tests a basic writer and reader interaction.
-// Reader reads back data written by the writer correctly.
-TEST_F(SyncReadWrites, ReadWriteSuccessTest) {
- static constexpr size_t DATA_SIZE = 64;
- uint16_t write_data[DATA_SIZE];
- uint16_t read_data[DATA_SIZE];
-
- // initialize the data to transfer
- InitData(write_data, DATA_SIZE);
-
- // writer should succeed
- ASSERT_TRUE((manager_.WriteFmq<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", writer_id_, write_data, DATA_SIZE)));
-
- // reader should succeed
- ASSERT_TRUE((manager_.ReadFmq<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", reader_id_, read_data, DATA_SIZE)));
-
- // check if the data is read back correctly
- ASSERT_EQ(0, memcmp(write_data, read_data, DATA_SIZE * sizeof(uint16_t)));
-}
-
-// Tests reading from an empty queue.
-TEST_F(SyncReadWrites, ReadEmpty) {
- static constexpr size_t DATA_SIZE = 64;
- uint16_t read_data[DATA_SIZE];
-
- // attempt to read from an empty queue
- ASSERT_FALSE((manager_.ReadFmq<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", reader_id_, read_data, DATA_SIZE)));
-}
-
-// Tests writing to a full queue.
-TEST_F(SyncReadWrites, WriteFull) {
- static constexpr size_t DATA_SIZE = 2048;
- uint16_t write_data[DATA_SIZE];
- uint16_t read_data[DATA_SIZE];
-
- // initialize the data to transfer
- InitData(write_data, DATA_SIZE);
-
- // This write succeeds, filling up the queue
- ASSERT_TRUE((manager_.WriteFmq<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", writer_id_, write_data, DATA_SIZE)));
-
- // This write fails, queue is full
- ASSERT_FALSE((manager_.WriteFmq<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", writer_id_, write_data, DATA_SIZE)));
-
- // checks space available is 0
- size_t writer_available_writes;
- ASSERT_TRUE((manager_.AvailableToWrite<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", writer_id_, &writer_available_writes)));
- ASSERT_EQ(0, writer_available_writes);
-
- // reader succeeds, reads the entire queue back correctly
- ASSERT_TRUE((manager_.ReadFmq<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", reader_id_, read_data, DATA_SIZE)));
-
- ASSERT_EQ(0, memcmp(write_data, read_data, DATA_SIZE * sizeof(uint16_t)));
-}
-
-// Attempt to write more than the size of the queue.
-TEST_F(SyncReadWrites, WriteTooLarge) {
- static constexpr size_t LARGE_DATA_SIZE = 2049;
- uint16_t write_data[LARGE_DATA_SIZE];
-
- // initialize data to transfer
- InitData(write_data, LARGE_DATA_SIZE);
-
- // write more than the queue size
- ASSERT_FALSE((manager_.WriteFmq<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", writer_id_, write_data, LARGE_DATA_SIZE)));
-}
-
-// Pass the wrong type.
-TEST_F(SyncReadWrites, WrongType) {
- static constexpr size_t DATA_SIZE = 2;
- uint16_t write_data[DATA_SIZE];
-
- // initialize data to transfer
- InitData(write_data, DATA_SIZE);
-
- // attempt to write uint32_t type
- ASSERT_FALSE((manager_.WriteFmq<uint16_t, kSynchronizedReadWrite>(
- "uint32_t", writer_id_, write_data, DATA_SIZE)));
-}
-
-// Tests consecutive interaction between writer and reader.
-// Reader immediately reads back what writer writes.
-TEST_F(SyncReadWrites, ConsecutiveReadWrite) {
- static constexpr size_t DATA_SIZE = 64;
- static constexpr size_t BATCH_SIZE = 10;
- uint16_t read_data[DATA_SIZE];
- uint16_t write_data[DATA_SIZE];
-
- // 10 consecutive writes and reads
- for (size_t i = 0; i < BATCH_SIZE; i++) {
- InitData(write_data, DATA_SIZE);
- ASSERT_TRUE((manager_.WriteFmq<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", writer_id_, write_data, DATA_SIZE)));
-
- ASSERT_TRUE((manager_.ReadFmq<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", reader_id_, read_data, DATA_SIZE)));
- ASSERT_EQ(0, memcmp(write_data, read_data, DATA_SIZE * sizeof(uint16_t)));
- }
-
- // no more available to read
- size_t reader_available_reads;
- ASSERT_TRUE((manager_.AvailableToRead<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", reader_id_, &reader_available_reads)));
- ASSERT_EQ(0, reader_available_reads);
-}
-
-// Tests reader waiting for data to be available.
-// Writer waits for 0.05s and writes the data.
-// Reader blocks for at most 0.1s and reads the data if it is available.
-TEST_F(BlockingReadWrites, ReadWriteSuccess) {
- static constexpr size_t DATA_SIZE = 64;
-
- uint16_t read_data[DATA_SIZE];
- uint16_t write_data[DATA_SIZE];
-
- // initialize data to transfer
- InitData(write_data, DATA_SIZE);
-
- pid_t pid = fork();
- if (pid == 0) { // child process is a reader, blocking for at most 0.1s.
- ASSERT_TRUE((manager_.ReadFmqBlocking<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", reader_id_, read_data, DATA_SIZE, 100 * 1000000)));
- ASSERT_EQ(0, memcmp(write_data, read_data, DATA_SIZE * sizeof(uint16_t)));
- exit(0);
- } else if (pid > 0) {
- // parent process is a writer, waits for 0.05s and writes.
- struct timespec writer_wait_time = {0, 50 * 1000000};
- nanosleep(&writer_wait_time, NULL);
- ASSERT_TRUE((manager_.WriteFmqBlocking<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", writer_id_, write_data, DATA_SIZE, 1000000)));
- }
-}
-
-// Tests reader blocking times out.
-TEST_F(BlockingReadWrites, BlockingTimeOut) {
- static constexpr size_t DATA_SIZE = 64;
- uint16_t read_data[DATA_SIZE];
-
- // block for 0.05s, timeout
- ASSERT_FALSE((manager_.ReadFmqBlocking<uint16_t, kSynchronizedReadWrite>(
- "uint16_t", reader_id_, read_data, DATA_SIZE, 50 * 1000000)));
-}
-
-// Tests two readers can both read back what writer writes correctly.
-TEST_F(UnsynchronizedWrites, ReadWriteSuccess) {
- static constexpr size_t DATA_SIZE = 64;
- uint16_t write_data[DATA_SIZE];
- uint16_t read_data1[DATA_SIZE];
- uint16_t read_data2[DATA_SIZE];
-
- // initialize data to transfer
- InitData(write_data, DATA_SIZE);
-
- // writer writes 64 items
- ASSERT_TRUE((manager_.WriteFmq<uint16_t, kUnsynchronizedWrite>(
- "uint16_t", writer_id_, write_data, DATA_SIZE)));
-
- // reader 1 reads back data correctly
- ASSERT_TRUE((manager_.ReadFmq<uint16_t, kUnsynchronizedWrite>(
- "uint16_t", reader_id1_, read_data1, DATA_SIZE)));
- ASSERT_EQ(0, memcmp(write_data, read_data1, DATA_SIZE * sizeof(uint16_t)));
-
- // reader 2 reads back data correctly
- ASSERT_TRUE((manager_.ReadFmq<uint16_t, kUnsynchronizedWrite>(
- "uint16_t", reader_id2_, read_data2, DATA_SIZE)));
- ASSERT_EQ(0, memcmp(write_data, read_data2, DATA_SIZE * sizeof(uint16_t)));
-}
-
-// Tests that blocking is not allowed on unsynchronized queue.
-TEST_F(UnsynchronizedWrites, IllegalBlocking) {
- static constexpr size_t DATA_SIZE = 64;
- uint16_t write_data[DATA_SIZE];
-
- // initialize data to transfer
- InitData(write_data, DATA_SIZE);
-
- // should fail immediately, instead of blocking
- ASSERT_FALSE((manager_.WriteFmqBlocking<uint16_t, kUnsynchronizedWrite>(
- "uint16_t", writer_id_, write_data, DATA_SIZE, 1000000)));
-}
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/resource/hidl_handle_driver/VtsHidlHandleDriver.cpp b/drivers/resource/hidl_handle_driver/VtsHidlHandleDriver.cpp
deleted file mode 100644
index 570b752..0000000
--- a/drivers/resource/hidl_handle_driver/VtsHidlHandleDriver.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-//
-// 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.
-//
-#define LOG_TAG "VtsHidlHandleDriver"
-
-#include "hidl_handle_driver/VtsHidlHandleDriver.h"
-
-#include <fcntl.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <vector>
-
-#include <android-base/logging.h>
-
-using android::hardware::hidl_handle;
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-VtsHidlHandleDriver::VtsHidlHandleDriver() {}
-
-VtsHidlHandleDriver::~VtsHidlHandleDriver() {
- // clears objects in the map.
- hidl_handle_map_.clear();
-}
-
-HandleId VtsHidlHandleDriver::CreateFileHandle(string filepath, int flag,
- int mode, vector<int> data) {
- int num_fds = 1;
- int num_ints = data.size();
- native_handle_t* native_handle = native_handle_create(num_fds, num_ints);
- if (native_handle == nullptr) {
- LOG(ERROR) << "native_handle create failure.";
- return -1;
- }
-
- for (int i = 0; i < num_fds + num_ints; i++) {
- if (i < num_fds) {
- int curr_fd = open(filepath.c_str(), flag, mode);
- if (curr_fd == -1) {
- LOG(ERROR) << "Failed to create file descriptor for file with path "
- << filepath;
- // Need to close already opened files because creating handle fails.
- for (int j = 0; j < i; j++) {
- close(native_handle->data[j]);
- }
- native_handle_delete(native_handle);
- return -1;
- }
- native_handle->data[i] = curr_fd;
- } else {
- native_handle->data[i] = data[i - num_fds];
- }
- }
-
- // This class owns native_handle object, responsible for deleting it
- // in the destructor.
- unique_ptr<hidl_handle> hidl_handle_ptr(new hidl_handle());
- hidl_handle_ptr->setTo(native_handle, true);
- // Insert the handle object into the map.
- map_mutex_.lock();
- size_t new_handle_id = hidl_handle_map_.size();
- hidl_handle_map_.emplace(new_handle_id, move(hidl_handle_ptr));
- map_mutex_.unlock();
- return new_handle_id;
-}
-
-bool VtsHidlHandleDriver::UnregisterHidlHandle(HandleId handle_id) {
- // true flag to indicate we want smart pointer to release ownership.
- hidl_handle* handle_obj = FindHandle(handle_id, true);
- if (handle_obj == nullptr) return false; // unable to find handle object.
- delete handle_obj; // This closes open file descriptors in the handle object.
- return true;
-}
-
-ssize_t VtsHidlHandleDriver::ReadFile(HandleId handle_id, void* read_data,
- size_t num_bytes) {
- hidl_handle* handle_obj = FindHandle(handle_id);
- if (handle_obj == nullptr) return -1;
-
- const native_handle_t* native_handle = handle_obj->getNativeHandle();
- // Check if a file descriptor exists.
- if (native_handle->numFds == 0) {
- LOG(ERROR) << "Read from file failure: handle object with id " << handle_id
- << " has no file descriptor.";
- return -1;
- }
- int fd = native_handle->data[0];
- ssize_t read_result = read(fd, read_data, num_bytes);
- if (read_result == -1) {
- LOG(ERROR) << "Read from file failure: read from file with descriptor "
- << fd << " failure: " << strerror(errno);
- }
- return read_result;
-}
-
-ssize_t VtsHidlHandleDriver::WriteFile(HandleId handle_id,
- const void* write_data,
- size_t num_bytes) {
- hidl_handle* handle_obj = FindHandle(handle_id);
- if (handle_obj == nullptr) return -1;
-
- const native_handle_t* native_handle = handle_obj->getNativeHandle();
- // Check if a file descriptor exists.
- if (native_handle->numFds == 0) {
- LOG(ERROR) << "Write to file failure: handle object with id " << handle_id
- << " has no file descriptor.";
- return -1;
- }
- int fd = native_handle->data[0];
- ssize_t write_result = write(fd, write_data, num_bytes);
- if (write_result == -1) {
- LOG(ERROR) << "Write to file failure: write to file with descriptor " << fd
- << " failure: " << strerror(errno);
- }
- return write_result;
-}
-
-HandleId VtsHidlHandleDriver::RegisterHidlHandle(size_t hidl_handle_address) {
- unique_ptr<hidl_handle> hidl_handle_ptr(
- reinterpret_cast<hidl_handle*>(hidl_handle_address));
-
- map_mutex_.lock();
- size_t new_handle_id = hidl_handle_map_.size();
- hidl_handle_map_.emplace(new_handle_id, move(hidl_handle_ptr));
- map_mutex_.unlock();
- return new_handle_id;
-}
-
-bool VtsHidlHandleDriver::GetHidlHandleAddress(HandleId handle_id,
- size_t* result) {
- hidl_handle* handle = FindHandle(handle_id);
- if (handle == nullptr) return false; // unable to find handle object.
- *result = reinterpret_cast<size_t>(handle);
- return true;
-}
-
-hidl_handle* VtsHidlHandleDriver::FindHandle(HandleId handle_id, bool release) {
- hidl_handle* handle;
- map_mutex_.lock();
- auto iterator = hidl_handle_map_.find(handle_id);
- if (iterator == hidl_handle_map_.end()) {
- LOG(ERROR) << "Unable to find hidl_handle associated with handle_id "
- << handle_id;
- map_mutex_.unlock();
- return nullptr;
- }
- // During unregistering a handle, unique_ptr releases ownership.
- if (release)
- handle = (iterator->second).release();
- else
- handle = (iterator->second).get();
- map_mutex_.unlock();
- return handle;
-}
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/resource/hidl_handle_driver/VtsHidlHandleDriverTest.cpp b/drivers/resource/hidl_handle_driver/VtsHidlHandleDriverTest.cpp
deleted file mode 100644
index 810b8df..0000000
--- a/drivers/resource/hidl_handle_driver/VtsHidlHandleDriverTest.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-//
-// 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.
-//
-
-#include "hidl_handle_driver/VtsHidlHandleDriver.h"
-
-#include <errno.h>
-#include <fcntl.h>
-#include <gtest/gtest.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-using namespace std;
-
-static constexpr const char* kTestFilePath = "/data/local/tmp/test.txt";
-
-namespace android {
-namespace vts {
-
-// Unit test to test operations on hidl_memory_driver.
-class HidlHandleDriverUnitTest : public ::testing::Test {
- protected:
- virtual void SetUp() {
- // Register handle objects.
- client1_id_ = handle_driver_.CreateFileHandle(string(kTestFilePath),
- O_RDWR | O_CREAT | O_TRUNC,
- S_IRWXG, vector<int>());
- client2_id_ = handle_driver_.CreateFileHandle(string(kTestFilePath),
- O_RDONLY, 0, vector<int>());
- ASSERT_NE(client1_id_, -1);
- ASSERT_NE(client2_id_, -1);
- }
-
- virtual void TearDown() {
- ASSERT_TRUE(handle_driver_.UnregisterHidlHandle(client1_id_));
- ASSERT_TRUE(handle_driver_.UnregisterHidlHandle(client2_id_));
- // Delete files for testing.
- remove(kTestFilePath);
- }
-
- VtsHidlHandleDriver handle_driver_;
- int client1_id_;
- int client2_id_;
-};
-
-// Tests trying to write to an invalid handle object.
-TEST_F(HidlHandleDriverUnitTest, InvalidHandleId) {
- // Invalid ID: 42, tries to read 10 bytes.
- ASSERT_EQ(handle_driver_.WriteFile(42, nullptr, 10), -1);
-}
-
-// Tests reader doesn't have the permission to edit test.txt.
-TEST_F(HidlHandleDriverUnitTest, ReaderInvalidWrite) {
- char write_data[10];
- ASSERT_EQ(handle_driver_.WriteFile(client2_id_, write_data, 10), -1);
-}
-
-// Tests unregistering a handle and using that handle after returns error.
-TEST_F(HidlHandleDriverUnitTest, UnregisterHandle) {
- int new_id = handle_driver_.CreateFileHandle(string(kTestFilePath), O_RDONLY,
- 0, vector<int>());
- // Reading 0 bytes should work, because handle object is found.
- ASSERT_EQ(handle_driver_.ReadFile(new_id, nullptr, 0), 0);
-
- // Now unregister the handle.
- ASSERT_TRUE(handle_driver_.UnregisterHidlHandle(new_id));
- // Read 0 bytes again, this time should fail because handle object is deleted.
- ASSERT_EQ(handle_driver_.ReadFile(new_id, nullptr, 0), -1);
-}
-
-// Tests simple read/write operations on the same file from two clients.
-TEST_F(HidlHandleDriverUnitTest, SimpleReadWrite) {
- string write_data = "Hello World!";
-
- // Writer writes to test.txt.
- ASSERT_EQ(handle_driver_.WriteFile(
- client1_id_, static_cast<const void*>(write_data.c_str()),
- write_data.length()),
- write_data.length());
-
- // Reader reads from test.txt.
- char read_data[write_data.length()];
- ASSERT_EQ(handle_driver_.ReadFile(client2_id_, static_cast<void*>(read_data),
- write_data.length()),
- write_data.length());
-
- ASSERT_TRUE(write_data == string(read_data, write_data.length()));
-}
-
-// Tests large read/write interaction between reader and writer.
-// Writer keeps adding "abcd" at the end of the file.
-// After every iteration, reader should read back one extra repeated "abcd".
-TEST_F(HidlHandleDriverUnitTest, LargeReadWrite) {
- static constexpr size_t NUM_ITERS = 10;
- const string write_data = "abcd";
- string curr_correct_data = "";
- char read_data[write_data.length() * NUM_ITERS];
- char* curr_read_data_ptr = read_data;
-
- for (int i = 0; i < NUM_ITERS; i++) {
- // Writer writes to test1.txt.
- ASSERT_EQ(handle_driver_.WriteFile(
- client1_id_, static_cast<const void*>(write_data.c_str()),
- write_data.length()),
- write_data.length());
-
- // Reader reads from test1.txt.
- ASSERT_EQ(handle_driver_.ReadFile(client2_id_,
- static_cast<void*>(curr_read_data_ptr),
- write_data.length()),
- write_data.length());
-
- string curr_read_data = string(read_data, write_data.length() * (i + 1));
- curr_correct_data += write_data;
- curr_read_data_ptr += write_data.length();
- ASSERT_TRUE(curr_read_data == curr_correct_data);
- }
-}
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/resource/hidl_memory_driver/VtsHidlMemoryDriver.cpp b/drivers/resource/hidl_memory_driver/VtsHidlMemoryDriver.cpp
deleted file mode 100644
index 0bfde0b..0000000
--- a/drivers/resource/hidl_memory_driver/VtsHidlMemoryDriver.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-//
-// 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.
-//
-#define LOG_TAG "VtsHidlMemoryDriver"
-
-#include "hidl_memory_driver/VtsHidlMemoryDriver.h"
-
-#include <android-base/logging.h>
-#include <android/hidl/allocator/1.0/IAllocator.h>
-#include <hidlmemory/mapping.h>
-
-using android::sp;
-using android::hardware::hidl_memory;
-using android::hidl::allocator::V1_0::IAllocator;
-using android::hidl::memory::V1_0::IMemory;
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-VtsHidlMemoryDriver::VtsHidlMemoryDriver() {}
-
-VtsHidlMemoryDriver::~VtsHidlMemoryDriver() {
- // clears objects in the map.
- hidl_memory_map_.clear();
-}
-
-MemoryId VtsHidlMemoryDriver::Allocate(size_t mem_size) {
- sp<IAllocator> ashmem_allocator = IAllocator::getService("ashmem");
- unique_ptr<MemoryInfo> mem_info = nullptr;
- ashmem_allocator->allocate(
- mem_size, [&](bool success, const hidl_memory& mem) {
- if (!success) { // error
- LOG(ERROR) << "Allocate memory failure.";
- } else {
- unique_ptr<hidl_memory> hidl_mem_ptr(new hidl_memory(mem));
- sp<IMemory> mem_ptr = mapMemory(mem);
- mem_info.reset(new MemoryInfo{move(hidl_mem_ptr), mem_ptr});
- }
- });
- if (mem_info == nullptr) return -1;
- map_mutex_.lock();
- size_t new_mem_id = hidl_memory_map_.size();
- hidl_memory_map_.emplace(new_mem_id, move(mem_info));
- map_mutex_.unlock();
- return new_mem_id;
-}
-
-MemoryId VtsHidlMemoryDriver::RegisterHidlMemory(size_t hidl_mem_address) {
- unique_ptr<hidl_memory> hidl_mem_ptr(
- reinterpret_cast<hidl_memory*>(hidl_mem_address));
- sp<IMemory> mem_ptr = mapMemory(*hidl_mem_ptr.get());
- if (mem_ptr == nullptr) {
- LOG(ERROR) << "Register memory failure. "
- << "Unable to map hidl_memory to IMemory object.";
- return -1;
- }
- unique_ptr<MemoryInfo> mem_info(new MemoryInfo{move(hidl_mem_ptr), mem_ptr});
- map_mutex_.lock();
- size_t new_mem_id = hidl_memory_map_.size();
- hidl_memory_map_.emplace(new_mem_id, move(mem_info));
- map_mutex_.unlock();
- return new_mem_id;
-}
-
-bool VtsHidlMemoryDriver::Update(MemoryId mem_id) {
- MemoryInfo* mem_info = FindMemory(mem_id);
- if (mem_info == nullptr) return false;
- (mem_info->memory)->update();
- return true;
-}
-
-bool VtsHidlMemoryDriver::UpdateRange(MemoryId mem_id, uint64_t start,
- uint64_t length) {
- MemoryInfo* mem_info = FindMemory(mem_id);
- if (mem_info == nullptr) return false;
- (mem_info->memory)->updateRange(start, length);
- return true;
-}
-
-bool VtsHidlMemoryDriver::Read(MemoryId mem_id) {
- MemoryInfo* mem_info = FindMemory(mem_id);
- if (mem_info == nullptr) return false;
- (mem_info->memory)->read();
- return true;
-}
-
-bool VtsHidlMemoryDriver::ReadRange(MemoryId mem_id, uint64_t start,
- uint64_t length) {
- MemoryInfo* mem_info = FindMemory(mem_id);
- if (mem_info == nullptr) return false;
- (mem_info->memory)->readRange(start, length);
- return true;
-}
-
-bool VtsHidlMemoryDriver::UpdateBytes(MemoryId mem_id, const char* write_data,
- uint64_t length, uint64_t start) {
- MemoryInfo* mem_info = FindMemory(mem_id);
- if (mem_info == nullptr) return false;
- void* memory_ptr = (mem_info->memory)->getPointer();
- char* memory_char_ptr = static_cast<char*>(memory_ptr);
- memcpy(memory_char_ptr + start, write_data, length);
- return true;
-}
-
-bool VtsHidlMemoryDriver::ReadBytes(MemoryId mem_id, char* read_data,
- uint64_t length, uint64_t start) {
- MemoryInfo* mem_info = FindMemory(mem_id);
- if (mem_info == nullptr) return false;
- void* memory_ptr = (mem_info->memory)->getPointer();
- char* memory_char_ptr = static_cast<char*>(memory_ptr);
- memcpy(read_data, memory_char_ptr + start, length);
- return true;
-}
-
-bool VtsHidlMemoryDriver::Commit(MemoryId mem_id) {
- MemoryInfo* mem_info = FindMemory(mem_id);
- if (mem_info == nullptr) return false;
- (mem_info->memory)->commit();
- return true;
-}
-
-bool VtsHidlMemoryDriver::GetSize(MemoryId mem_id, size_t* result) {
- MemoryInfo* mem_info = FindMemory(mem_id);
- if (mem_info == nullptr) return false;
- *result = (mem_info->memory)->getSize();
- return true;
-}
-
-bool VtsHidlMemoryDriver::GetHidlMemoryAddress(MemoryId mem_id,
- size_t* result) {
- MemoryInfo* mem_info = FindMemory(mem_id);
- if (mem_info == nullptr) return false; // unable to find memory object.
- hidl_memory* hidl_mem_ptr = (mem_info->hidl_mem_ptr).get();
- *result = reinterpret_cast<size_t>(hidl_mem_ptr);
- return true;
-}
-
-MemoryInfo* VtsHidlMemoryDriver::FindMemory(MemoryId mem_id) {
- MemoryInfo* mem_info;
- map_mutex_.lock();
- auto iterator = hidl_memory_map_.find(mem_id);
- if (iterator == hidl_memory_map_.end()) {
- LOG(ERROR) << "Unable to find memory region associated with mem_id "
- << mem_id;
- map_mutex_.unlock();
- return nullptr;
- }
- mem_info = (iterator->second).get();
- map_mutex_.unlock();
- return mem_info;
-}
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/resource/hidl_memory_driver/VtsHidlMemoryDriverTest.cpp b/drivers/resource/hidl_memory_driver/VtsHidlMemoryDriverTest.cpp
deleted file mode 100644
index d15f8ce..0000000
--- a/drivers/resource/hidl_memory_driver/VtsHidlMemoryDriverTest.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-//
-// 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.
-//
-
-#include "hidl_memory_driver/VtsHidlMemoryDriver.h"
-
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <gtest/gtest.h>
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-// Unit test to test operations on hidl_memory_driver.
-class HidlMemoryDriverUnitTest : public ::testing::Test {
- protected:
- virtual void SetUp() {
- mem_id_ = mem_driver_.Allocate(100);
- ASSERT_NE(mem_id_, -1);
- }
-
- virtual void TearDown() {}
-
- VtsHidlMemoryDriver mem_driver_;
- int mem_id_;
-};
-
-// Helper method to initialize an array of random integers.
-void InitData(int* data, size_t len) {
- for (size_t i = 0; i < len; i++) {
- data[i] = rand() % 100 + 1;
- }
-}
-
-// Tests trying to read from an invalid memory object.
-TEST_F(HidlMemoryDriverUnitTest, InvalidMemId) {
- ASSERT_FALSE(mem_driver_.Read(42));
-}
-
-// Tests GetSize() method.
-TEST_F(HidlMemoryDriverUnitTest, GetSizeTest) {
- size_t mem_size;
- ASSERT_TRUE(mem_driver_.GetSize(mem_id_, &mem_size));
- ASSERT_EQ(100, mem_size);
-}
-
-// Tests writing to the memory and reading the same data back.
-TEST_F(HidlMemoryDriverUnitTest, SimpleWriteRead) {
- string write_data = "abcdef";
- // Write into the memory.
- ASSERT_TRUE(mem_driver_.Update(mem_id_));
- ASSERT_TRUE(mem_driver_.UpdateBytes(mem_id_, write_data.c_str(),
- write_data.length()));
- ASSERT_TRUE(mem_driver_.Commit(mem_id_));
-
- // Read from the memory.
- char read_data[write_data.length()];
- ASSERT_TRUE(mem_driver_.Read(mem_id_));
- ASSERT_TRUE(mem_driver_.ReadBytes(mem_id_, read_data, write_data.length()));
- ASSERT_TRUE(mem_driver_.Commit(mem_id_));
-
- // Check read data.
- ASSERT_EQ(0, strncmp(write_data.c_str(), read_data, write_data.length()));
-}
-
-// Tests consecutive writes and reads using integers.
-// For each of the 5 iterations, write 5 integers into
-// different chunks of memory, and read them back.
-TEST_F(HidlMemoryDriverUnitTest, LargeWriteRead) {
- int write_data[5];
- int read_data[5];
-
- // Every write shifts 5 * sizeof(int) bytes of region.
- // Every iteration writes 5 integers.
- for (int i = 0; i < 100; i += 5 * sizeof(int)) {
- InitData(write_data, 5);
- // Write 5 integers, which is equivalent to writing 5 * sizeof(int) bytes.
- ASSERT_TRUE(mem_driver_.UpdateRange(mem_id_, i, 5 * sizeof(int)));
- ASSERT_TRUE(mem_driver_.UpdateBytes(
- mem_id_, reinterpret_cast<char*>(write_data), 5 * sizeof(int), i));
- ASSERT_TRUE(mem_driver_.Commit(mem_id_));
-
- // Read the integers back.
- ASSERT_TRUE(mem_driver_.ReadRange(mem_id_, i, 5 * sizeof(int)));
- ASSERT_TRUE(mem_driver_.ReadBytes(
- mem_id_, reinterpret_cast<char*>(read_data), 5 * sizeof(int), i));
- ASSERT_TRUE(mem_driver_.Commit(mem_id_));
-
- ASSERT_EQ(0, memcmp(write_data, read_data, 5 * sizeof(int)));
- }
-}
-
-// Tests writing into different regions in the memory buffer.
-// Writer requests the beginning of the first half and
-// the beginning of the second half of the buffer.
-// It writes to the second half, commits, and reads the data back.
-// Then it writes to the first half, commits, and reads the data back.
-TEST_F(HidlMemoryDriverUnitTest, WriteTwoRegionsInOneBuffer) {
- string write_data1 = "abcdef";
- string write_data2 = "ghijklmno";
- char read_data1[write_data1.length()];
- char read_data2[write_data2.length()];
-
- // Request writes to two separate regions in the same buffer.
- // One from the start, the second from offset 50.
- ASSERT_TRUE(mem_driver_.UpdateRange(mem_id_, 0, write_data1.length()));
- ASSERT_TRUE(mem_driver_.UpdateRange(mem_id_, 50, write_data2.length()));
- // Update the second region.
- ASSERT_TRUE(mem_driver_.UpdateBytes(mem_id_, write_data2.c_str(),
- write_data2.length(), 50));
- ASSERT_TRUE(mem_driver_.Commit(mem_id_));
-
- // Read from the second region.
- ASSERT_TRUE(mem_driver_.Read(mem_id_));
- ASSERT_TRUE(
- mem_driver_.ReadBytes(mem_id_, read_data2, write_data2.length(), 50));
- ASSERT_TRUE(mem_driver_.Commit(mem_id_));
- ASSERT_EQ(0, strncmp(read_data2, write_data2.c_str(), write_data2.length()));
-
- // Update the first region.
- ASSERT_TRUE(mem_driver_.UpdateBytes(mem_id_, write_data1.c_str(),
- write_data1.length()));
- ASSERT_TRUE(mem_driver_.Commit(mem_id_));
-
- // Read from the first region.
- ASSERT_TRUE(mem_driver_.Read(mem_id_));
- ASSERT_TRUE(mem_driver_.ReadBytes(mem_id_, read_data1, write_data1.length()));
- ASSERT_TRUE(mem_driver_.Commit(mem_id_));
- ASSERT_EQ(0, strncmp(read_data1, write_data1.c_str(), write_data1.length()));
-}
-
-} // namespace vts
-} // namespace android
diff --git a/drivers/resource/include/fmq_driver/VtsFmqDriver.h b/drivers/resource/include/fmq_driver/VtsFmqDriver.h
deleted file mode 100644
index 3340322..0000000
--- a/drivers/resource/include/fmq_driver/VtsFmqDriver.h
+++ /dev/null
@@ -1,641 +0,0 @@
-//
-// 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.
-//
-
-#ifndef __VTS_RESOURCE_VTSFMQDRIVER_H
-#define __VTS_RESOURCE_VTSFMQDRIVER_H
-
-#include <mutex>
-#include <string>
-#include <unordered_map>
-
-#include <android-base/logging.h>
-#include <fmq/MessageQueue.h>
-
-using android::hardware::kSynchronizedReadWrite;
-using android::hardware::kUnsynchronizedWrite;
-using android::hardware::MessageQueue;
-using android::hardware::MQDescriptorSync;
-using android::hardware::MQDescriptorUnsync;
-
-using namespace std;
-using QueueId = int;
-
-static constexpr const int kInvalidQueueId = -1;
-
-namespace android {
-namespace vts {
-
-// struct to store queue information.
-struct QueueInfo {
- // type of data in the queue.
- string queue_data_type;
- // flavor of the queue (sync or unsync).
- hardware::MQFlavor queue_flavor;
- // pointer to the actual queue object.
- shared_ptr<void> queue_object;
-};
-
-// A fast message queue class that manages all fast message queues created
-// on the target side. Reader and writer use their id to read from and write
-// into the queue.
-// Example:
-// VtsFmqDriver manager;
-// // creates one reader and one writer.
-// QueueId writer_id =
-// manager.CreateFmq<uint16_t, kSynchronizedReadWrite>(2048, false);
-// QueueId reader_id =
-// manager.CreateFmq<uint16_t, kSynchronizedReadWrite>(writer_id);
-// // write some data
-// uint16_t write_data[5] {1, 2, 3, 4, 5};
-// manager.WriteFmq<uint16_t, kSynchronizedReadWrite>(
-// writer_id, write_data, 5);
-// // read the same data back
-// uint16_t read_data[5];
-// manager.ReadFmq<uint16_t, kSynchronizedReadWrite>(
-// reader_id, read_data, 5);
-class VtsFmqDriver {
- public:
- // Constructor to initialize a Fast Message Queue (FMQ) manager.
- VtsFmqDriver() {}
-
- // Destructor to clean up the class.
- ~VtsFmqDriver() {
- // Clears objects in the map.
- fmq_map_.clear();
- }
-
- // Creates a brand new FMQ, i.e. the "first message queue object".
- //
- // @param data_type type of data in the queue. This information is stored
- // in the driver to verify type later.
- // @param queue_size number of elements in the queue.
- // @param blocking whether to enable blocking within the queue.
- //
- // @return message queue object id associated with the caller on success,
- // kInvalidQueueId on failure.
- template <typename T, hardware::MQFlavor flavor>
- QueueId CreateFmq(const string& data_type, size_t queue_size, bool blocking);
-
- // Creates a new FMQ object based on an existing message queue
- // (Using queue_id assigned by fmq_driver.).
- //
- // @param data_type type of data in the queue. This information is stored
- // in the driver to verify type later.
- // @param queue_id identifies the message queue object.
- // @param reset_pointers whether to reset read and write pointers.
- //
- // @return message queue object id associated with the caller on success,
- // kInvalidQueueId on failure.
- template <typename T, hardware::MQFlavor flavor>
- QueueId CreateFmq(const string& data_type, QueueId queue_id,
- bool reset_pointers = true);
-
- // Creates a new FMQ object based on an existing message queue
- // (Using queue descriptor.).
- // This method will reset read/write pointers in the new queue object.
- //
- // @param data_type type of data in the queue. This information is
- // stored in the driver to verify type later.
- // @param queue_descriptor pointer to descriptor of an existing queue.
- //
- // @return message queue object id associated with the caller on success,
- // kInvalidQueueId on failure.
- template <typename T, hardware::MQFlavor flavor>
- QueueId CreateFmq(const string& data_type, size_t queue_descriptor);
-
- // Reads data_size items from FMQ (no blocking at all).
- //
- // @param data_type type of data in the queue. This information is verified
- // by the driver before calling the API on FMQ.
- // @param queue_id identifies the message queue object.
- // @param data pointer to the start of data to be filled.
- // @param data_size number of items to read.
- //
- // @return true if no error happens when reading from FMQ,
- // false otherwise.
- template <typename T, hardware::MQFlavor flavor>
- bool ReadFmq(const string& data_type, QueueId queue_id, T* data,
- size_t data_size);
-
- // Reads data_size items from FMQ, block if there is not enough data to
- // read.
- // This method can only be called if blocking=true on creation of the "first
- // message queue object" of the FMQ.
- //
- // @param data_type type of data in the queue. This information is
- // verified by the driver before calling the API on FMQ.
- // @param queue_id identifies the message queue object.
- // @param data pointer to the start of data to be filled.
- // @param data_size number of items to read.
- // @param time_out_nanos wait time when blocking.
- //
- // Returns: true if no error happens when reading from FMQ,
- // false otherwise.
- template <typename T, hardware::MQFlavor flavor>
- bool ReadFmqBlocking(const string& data_type, QueueId queue_id, T* data,
- size_t data_size, int64_t time_out_nanos);
-
- // Reads data_size items from FMQ, possibly block on other queues.
- //
- // @param data_type type of data in the queue. This information is
- // verified by the driver before calling the API
- // on FMQ.
- // @param queue_id identifies the message queue object.
- // @param data pointer to the start of data to be filled.
- // @param data_size number of items to read.
- // @param read_notification notification bits to set when finish reading.
- // @param write_notification notification bits to wait on when blocking.
- // Read will fail if this argument is 0.
- // @param time_out_nanos wait time when blocking.
- // @param event_flag_word event flag word shared by multiple queues.
- //
- // @return true if no error happens when reading from FMQ,
- // false otherwise.
- template <typename T, hardware::MQFlavor flavor>
- bool ReadFmqBlocking(const string& data_type, QueueId queue_id, T* data,
- size_t data_size, uint32_t read_notification,
- uint32_t write_notification, int64_t time_out_nanos,
- atomic<uint32_t>* event_flag_word);
-
- // Writes data_size items to FMQ (no blocking at all).
- //
- // @param data_type type of data in the queue. This information is verified
- // by the driver before calling the API on FMQ.
- // @param queue_id identifies the message queue object.
- // @param data pointer to the start of data to be written.
- // @param data_size number of items to write.
- //
- // @return true if no error happens when writing to FMQ,
- // false otherwise.
- template <typename T, hardware::MQFlavor flavor>
- bool WriteFmq(const string& data_type, QueueId queue_id, T* data,
- size_t data_size);
-
- // Writes data_size items to FMQ, block if there is not enough space in
- // the queue.
- // This method can only be called if blocking=true on creation of the "first
- // message queue object" of the FMQ.
- //
- // @param data_type type of data in the queue. This information is
- // verified
- // by the driver before calling the API on FMQ.
- // @param queue_id identifies the message queue object.
- // @param data pointer to the start of data to be written.
- // @param data_size number of items to write.
- // @param time_out_nanos wait time when blocking.
- //
- // @returns true if no error happens when writing to FMQ,
- // false otherwise
- template <typename T, hardware::MQFlavor flavor>
- bool WriteFmqBlocking(const string& data_type, QueueId queue_id, T* data,
- size_t data_size, int64_t time_out_nanos);
-
- // Writes data_size items to FMQ, possibly block on other queues.
- //
- // @param data_type type of data in the queue. This information is
- // verified by the driver before calling the API
- // on FMQ.
- // @param queue_id identifies the message queue object.
- // @param data pointer to the start of data to be written.
- // @param data_size number of items to write.
- // @param read_notification notification bits to wait on when blocking.
- // Write will fail if this argument is 0.
- // @param write_notification notification bits to set when finish writing.
- // @param time_out_nanos wait time when blocking.
- // @param event_flag_word event flag word shared by multiple queues.
- //
- // @return true if no error happens when writing to FMQ,
- // false otherwise.
- template <typename T, hardware::MQFlavor flavor>
- bool WriteFmqBlocking(const string& data_type, QueueId queue_id, T* data,
- size_t data_size, uint32_t read_notification,
- uint32_t write_notification, int64_t time_out_nanos,
- atomic<uint32_t>* event_flag_word);
-
- // Gets space available to write in the queue.
- //
- // @param data_type type of data in the queue. This information is
- // verified by the driver before calling the API on FMQ.
- // @param queue_id identifies the message queue object.
- // @param result pointer to the result. Use pointer to store result because
- // the return value signals if the queue is found correctly.
- //
- // @return true if queue is found and type matches, and puts actual result in
- // result pointer,
- // false otherwise.
- template <typename T, hardware::MQFlavor flavor>
- bool AvailableToWrite(const string& data_type, QueueId queue_id,
- size_t* result);
-
- // Gets number of items available to read in the queue.
- //
- // @param data_type type of data in the queue. This information is
- // verified by the driver before calling the API on FMQ.
- // @param queue_id identifies the message queue object.
- // @param result pointer to the result. Use pointer to store result because
- // the return value signals if the queue is found correctly.
- //
- // @return true if queue is found and type matches, and puts actual result in
- // result pointer,
- // false otherwise.
- template <typename T, hardware::MQFlavor flavor>
- bool AvailableToRead(const string& data_type, QueueId queue_id,
- size_t* result);
-
- // Gets size of item in the queue.
- //
- // @param data_type type of data in the queue. This information is
- // verified by the driver before calling the API on FMQ.
- // @param queue_id identifies the message queue object.
- // @param result pointer to the result. Use pointer to store result because
- // the return value signals if the queue is found correctly.
- //
- // @return true if queue is found and type matches, and puts actual result in
- // result pointer,
- // false otherwise.
- template <typename T, hardware::MQFlavor flavor>
- bool GetQuantumSize(const string& data_type, QueueId queue_id,
- size_t* result);
-
- // Gets number of items that fit in the queue.
- //
- // @param data_type type of data in the queue. This information is
- // verified by the driver before calling the API on FMQ.
- // @param queue_id identifies the message queue object.
- // @param result pointer to the result. Use pointer to store result because
- // the return value signals if the queue is found correctly.
- //
- // @return true if queue is found and type matches, and puts actual result in
- // result pointer,
- // false otherwise.
- template <typename T, hardware::MQFlavor flavor>
- bool GetQuantumCount(const string& data_type, QueueId queue_id,
- size_t* result);
-
- // Checks if the queue associated with queue_id is valid.
- //
- // @param data_type type of data in the queue. This information is
- // verified by the driver before calling the API on FMQ.
- // @param queue_id identifies the message queue object.
- //
- // @return true if the queue object is valid, false otherwise.
- template <typename T, hardware::MQFlavor flavor>
- bool IsValid(const string& data_type, QueueId queue_id);
-
- // Gets event flag word of the queue, which allows multiple queues
- // to communicate (i.e. blocking).
- // The returned event flag word can be passed into readBlocking() and
- // writeBlocking() to achieve blocking among multiple queues.
- //
- // @param data_type type of data in the queue. This information is
- // verified by the driver before calling the API on FMQ.
- // @param queue_id identifies the message queue object.
- // @param result pointer to the result. Use pointer to store result because
- // the return value signals if the queue is found correctly.
- //
- // @return true if queue is found and type matches, and puts actual result in
- // result pointer,
- // false otherwise.
- template <typename T, hardware::MQFlavor flavor>
- bool GetEventFlagWord(const string& data_type, QueueId queue_id,
- atomic<uint32_t>** result);
-
- // Gets the address of queue descriptor in memory. This function is called by
- // driver_manager to preprocess arguments that are FMQs.
- //
- // @param data_type type of data in the queue. This information is
- // verified by the driver before calling the API on FMQ.
- // @param queue_id identifies the message queue object.
- // @param result pointer to store result.
- //
- // @return true if queue is found, and type matches, and puts actual result in
- // result pointer,
- // false otherwise.
- template <typename T, hardware::MQFlavor flavor>
- bool GetQueueDescAddress(const string& data_type, QueueId queue_id,
- size_t* result);
-
- private:
- // Finds the queue in the map based on the input queue ID.
- //
- // @param data_type type of data in the queue. This function verifies this
- // information.
- // @param queue_id identifies the message queue object.
- //
- // @return the pointer to message queue object,
- // nullptr if queue ID is invalid or queue type is misspecified.
- template <typename T, hardware::MQFlavor flavor>
- MessageQueue<T, flavor>* FindQueue(const string& data_type, QueueId queue_id);
-
- // Inserts a FMQ object into the map, along with its type of data and queue
- // flavor. This function ensures only one thread is inserting queue into the
- // map at once.
- //
- // @param data_type type of data in the queue. This information is stored
- // in the driver.
- // @param queue_object a shared pointer to MessageQueue.
- //
- // @return id associated with the queue.
- template <typename T, hardware::MQFlavor flavor>
- QueueId InsertQueue(const string& data_type,
- shared_ptr<MessageQueue<T, flavor>> queue_object);
-
- // a hashtable to keep track of all ongoing FMQ's.
- // The key of the hashtable is the queue ID.
- // The value of the hashtable is a smart pointer to message queue object
- // information struct associated with the queue ID.
- unordered_map<QueueId, unique_ptr<QueueInfo>> fmq_map_;
-
- // a mutex to ensure mutual exclusion of operations on fmq_map_
- mutex map_mutex_;
-};
-
-// Implementations follow, because all the methods are template methods.
-template <typename T, hardware::MQFlavor flavor>
-QueueId VtsFmqDriver::CreateFmq(const string& data_type, size_t queue_size,
- bool blocking) {
- shared_ptr<MessageQueue<T, flavor>> new_queue(
- new (std::nothrow) MessageQueue<T, flavor>(queue_size, blocking));
- return InsertQueue<T, flavor>(data_type, new_queue);
-}
-
-template <typename T, hardware::MQFlavor flavor>
-QueueId VtsFmqDriver::CreateFmq(const string& data_type, QueueId queue_id,
- bool reset_pointers) {
- MessageQueue<T, flavor>* queue_object =
- FindQueue<T, flavor>(data_type, queue_id);
- const hardware::MQDescriptor<T, flavor>* descriptor = queue_object->getDesc();
- if (descriptor == nullptr) {
- LOG(ERROR) << "FMQ Driver: cannot find descriptor for the specified "
- << "Fast Message Queue with ID " << queue_id << ".";
- return kInvalidQueueId;
- }
-
- shared_ptr<MessageQueue<T, flavor>> new_queue(
- new (std::nothrow) MessageQueue<T, flavor>(*descriptor, reset_pointers));
- return InsertQueue<T, flavor>(data_type, new_queue);
-}
-
-template <typename T, hardware::MQFlavor flavor>
-QueueId VtsFmqDriver::CreateFmq(const string& data_type,
- size_t queue_desc_addr) {
- // Cast the address back to a descriptor object.
- hardware::MQDescriptor<T, flavor>* descriptor_addr =
- reinterpret_cast<hardware::MQDescriptor<T, flavor>*>(queue_desc_addr);
- shared_ptr<MessageQueue<T, flavor>> new_queue(
- new (std::nothrow) MessageQueue<T, flavor>(*descriptor_addr));
- // Need to manually delete this pointer because HAL driver allocates it.
- delete descriptor_addr;
-
- return InsertQueue<T, flavor>(data_type, new_queue);
-}
-
-template <typename T, hardware::MQFlavor flavor>
-bool VtsFmqDriver::ReadFmq(const string& data_type, QueueId queue_id, T* data,
- size_t data_size) {
- MessageQueue<T, flavor>* queue_object =
- FindQueue<T, flavor>(data_type, queue_id);
- if (queue_object == nullptr) return false;
- return queue_object->read(data, data_size);
-}
-
-template <typename T, hardware::MQFlavor flavor>
-bool VtsFmqDriver::ReadFmqBlocking(const string& data_type, QueueId queue_id,
- T* data, size_t data_size,
- int64_t time_out_nanos) {
- if (flavor == kUnsynchronizedWrite) {
- LOG(ERROR) << "FMQ Driver: blocking read is not allowed in "
- << "unsynchronized queue.";
- return false;
- }
-
- MessageQueue<T, kSynchronizedReadWrite>* queue_object =
- FindQueue<T, kSynchronizedReadWrite>(data_type, queue_id);
- if (queue_object == nullptr) return false;
- return queue_object->readBlocking(data, data_size, time_out_nanos);
-}
-
-template <typename T, hardware::MQFlavor flavor>
-bool VtsFmqDriver::ReadFmqBlocking(const string& data_type, QueueId queue_id,
- T* data, size_t data_size,
- uint32_t read_notification,
- uint32_t write_notification,
- int64_t time_out_nanos,
- atomic<uint32_t>* event_flag_word) {
- if (flavor == kUnsynchronizedWrite) {
- LOG(ERROR) << "FMQ Driver: blocking read is not allowed in "
- << "unsynchronized queue.";
- return false;
- }
-
- hardware::EventFlag* ef_group = nullptr;
- status_t status;
- // create an event flag out of the event flag word
- status = hardware::EventFlag::createEventFlag(event_flag_word, &ef_group);
- if (status != NO_ERROR) { // check status
- LOG(ERROR) << "FMQ Driver: cannot create event flag with the specified "
- << "event flag word.";
- return false;
- }
-
- MessageQueue<T, kSynchronizedReadWrite>* queue_object =
- FindQueue<T, kSynchronizedReadWrite>(data_type, queue_id);
- if (queue_object == nullptr) return false;
- return queue_object->readBlocking(data, data_size, read_notification,
- write_notification, time_out_nanos,
- ef_group);
-}
-
-template <typename T, hardware::MQFlavor flavor>
-bool VtsFmqDriver::WriteFmq(const string& data_type, QueueId queue_id, T* data,
- size_t data_size) {
- MessageQueue<T, flavor>* queue_object =
- FindQueue<T, flavor>(data_type, queue_id);
- if (queue_object == nullptr) return false;
- return queue_object->write(data, data_size);
-}
-
-template <typename T, hardware::MQFlavor flavor>
-bool VtsFmqDriver::WriteFmqBlocking(const string& data_type, QueueId queue_id,
- T* data, size_t data_size,
- int64_t time_out_nanos) {
- if (flavor == kUnsynchronizedWrite) {
- LOG(ERROR) << "FMQ Driver: blocking write is not allowed in "
- << "unsynchronized queue.";
- return false;
- }
-
- MessageQueue<T, kSynchronizedReadWrite>* queue_object =
- FindQueue<T, kSynchronizedReadWrite>(data_type, queue_id);
- if (queue_object == nullptr) return false;
- return queue_object->writeBlocking(data, data_size, time_out_nanos);
-}
-
-template <typename T, hardware::MQFlavor flavor>
-bool VtsFmqDriver::WriteFmqBlocking(const string& data_type, QueueId queue_id,
- T* data, size_t data_size,
- uint32_t read_notification,
- uint32_t write_notification,
- int64_t time_out_nanos,
- atomic<uint32_t>* event_flag_word) {
- if (flavor == kUnsynchronizedWrite) {
- LOG(ERROR) << "FMQ Driver: blocking write is not allowed in "
- << "unsynchronized queue.";
- return false;
- }
-
- hardware::EventFlag* ef_group = nullptr;
- status_t status;
- // create an event flag out of the event flag word
- status = hardware::EventFlag::createEventFlag(event_flag_word, &ef_group);
- if (status != NO_ERROR) { // check status
- LOG(ERROR) << "FMQ Driver: cannot create event flag with the specified "
- << "event flag word.";
- return false;
- }
-
- MessageQueue<T, kSynchronizedReadWrite>* queue_object =
- FindQueue<T, kSynchronizedReadWrite>(data_type, queue_id);
- if (queue_object == nullptr) return false;
- return queue_object->writeBlocking(data, data_size, read_notification,
- write_notification, time_out_nanos,
- ef_group);
-}
-
-template <typename T, hardware::MQFlavor flavor>
-bool VtsFmqDriver::AvailableToWrite(const string& data_type, QueueId queue_id,
- size_t* result) {
- MessageQueue<T, flavor>* queue_object =
- FindQueue<T, flavor>(data_type, queue_id);
- if (queue_object == nullptr) return false;
- *result = queue_object->availableToWrite();
- return true;
-}
-
-template <typename T, hardware::MQFlavor flavor>
-bool VtsFmqDriver::AvailableToRead(const string& data_type, QueueId queue_id,
- size_t* result) {
- MessageQueue<T, flavor>* queue_object =
- FindQueue<T, flavor>(data_type, queue_id);
- if (queue_object == nullptr) return false;
- *result = queue_object->availableToRead();
- return true;
-}
-
-template <typename T, hardware::MQFlavor flavor>
-bool VtsFmqDriver::GetQuantumSize(const string& data_type, QueueId queue_id,
- size_t* result) {
- MessageQueue<T, flavor>* queue_object =
- FindQueue<T, flavor>(data_type, queue_id);
- if (queue_object == nullptr) return false;
- *result = queue_object->getQuantumSize();
- return true;
-}
-
-template <typename T, hardware::MQFlavor flavor>
-bool VtsFmqDriver::GetQuantumCount(const string& data_type, QueueId queue_id,
- size_t* result) {
- MessageQueue<T, flavor>* queue_object =
- FindQueue<T, flavor>(data_type, queue_id);
- if (queue_object == nullptr) return false;
- *result = queue_object->getQuantumCount();
- return true;
-}
-
-template <typename T, hardware::MQFlavor flavor>
-bool VtsFmqDriver::IsValid(const string& data_type, QueueId queue_id) {
- MessageQueue<T, flavor>* queue_object =
- FindQueue<T, flavor>(data_type, queue_id);
- if (queue_object == nullptr) return false;
- return queue_object->isValid();
-}
-
-template <typename T, hardware::MQFlavor flavor>
-bool VtsFmqDriver::GetEventFlagWord(const string& data_type, QueueId queue_id,
- atomic<uint32_t>** result) {
- MessageQueue<T, flavor>* queue_object =
- FindQueue<T, flavor>(data_type, queue_id);
- if (queue_object == nullptr) return false;
- *result = queue_object->getEventFlagWord();
- return true;
-}
-
-template <typename T, hardware::MQFlavor flavor>
-bool VtsFmqDriver::GetQueueDescAddress(const string& data_type,
- QueueId queue_id, size_t* result) {
- MessageQueue<T, flavor>* queue_object =
- FindQueue<T, flavor>(data_type, queue_id);
- if (queue_object == nullptr) return false;
- *result = reinterpret_cast<size_t>(queue_object->getDesc());
- return true;
-}
-
-template <typename T, hardware::MQFlavor flavor>
-MessageQueue<T, flavor>* VtsFmqDriver::FindQueue(const string& data_type,
- QueueId queue_id) {
- map_mutex_.lock(); // Ensure mutual exclusion.
- auto iterator = fmq_map_.find(queue_id);
- if (iterator == fmq_map_.end()) { // queue not found
- LOG(ERROR) << "FMQ Driver: cannot find Fast Message Queue with ID "
- << queue_id;
- return nullptr;
- }
-
- QueueInfo* queue_info = (iterator->second).get();
- if (queue_info->queue_data_type != data_type) { // queue data type incorrect
- LOG(ERROR) << "FMQ Driver: caller specified data type " << data_type
- << " doesn't match with the data type "
- << queue_info->queue_data_type << " stored in driver.";
- return nullptr;
- }
-
- if (queue_info->queue_flavor != flavor) { // queue flavor incorrect
- LOG(ERROR) << "FMQ Driver: caller specified flavor " << flavor
- << "doesn't match with the stored queue flavor "
- << queue_info->queue_flavor << ".";
- return nullptr;
- }
-
- // type check passes, extract queue from the struct
- shared_ptr<MessageQueue<T, flavor>> queue_object =
- static_pointer_cast<MessageQueue<T, flavor>>(queue_info->queue_object);
- MessageQueue<T, flavor>* result = queue_object.get();
- map_mutex_.unlock();
- return result;
-}
-
-template <typename T, hardware::MQFlavor flavor>
-QueueId VtsFmqDriver::InsertQueue(
- const string& data_type, shared_ptr<MessageQueue<T, flavor>> queue_object) {
- if (queue_object == nullptr) {
- LOG(ERROR) << "FMQ Driver Error: Failed to create a FMQ "
- << "using FMQ constructor.";
- return kInvalidQueueId;
- }
- // Create a struct to store queue object, type of data, and
- // queue flavor.
- unique_ptr<QueueInfo> new_queue_info(new QueueInfo{
- string(data_type), flavor, static_pointer_cast<void>(queue_object)});
- map_mutex_.lock();
- size_t new_queue_id = fmq_map_.size();
- fmq_map_.emplace(new_queue_id, move(new_queue_info));
- map_mutex_.unlock();
- return new_queue_id;
-}
-
-} // namespace vts
-} // namespace android
-#endif //__VTS_RESOURCE_VTSFMQDRIVER_H
diff --git a/drivers/resource/include/hidl_handle_driver/VtsHidlHandleDriver.h b/drivers/resource/include/hidl_handle_driver/VtsHidlHandleDriver.h
deleted file mode 100644
index 3205bc9..0000000
--- a/drivers/resource/include/hidl_handle_driver/VtsHidlHandleDriver.h
+++ /dev/null
@@ -1,147 +0,0 @@
-//
-// 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.
-//
-
-#ifndef __VTS_RESOURCE_VTSHIDLHANDLEDRIVER_H
-#define __VTS_RESOURCE_VTSHIDLHANDLEDRIVER_H
-
-#include <mutex>
-#include <unordered_map>
-
-#include <android-base/logging.h>
-#include <cutils/native_handle.h>
-#include <hidl/HidlSupport.h>
-
-using android::hardware::hidl_handle;
-
-using namespace std;
-using HandleId = int;
-
-namespace android {
-namespace vts {
-
-// A hidl_handle driver that manages all hidl_handle objects created
-// on the target side. Users can create handle objects to manage their
-// File I/O.
-// TODO: Currently, this class only supports opening a single file in
-// one handle object. In the future, we need to support opening
-// a list of various file types, such as socket, pipe.
-//
-// Example:
-// VtsHidlHandleDriver handle_driver;
-//
-// // Create a new file handler.
-// int writer_id = handle_driver.CreateFileHandle(
-// "test.txt", O_RDWR | O_CREAT | O_TRUNC, S_IRWXG, vector<int>());
-//
-// string write_data = "Hello World!";
-// // Writer writes to test.txt.
-// handle_driver.WriteFile(writer_id,
-// static_cast<const void*>(write_data.c_str())),
-// write_data.length());
-class VtsHidlHandleDriver {
- public:
- // Constructor to initialize a hidl_handle manager.
- VtsHidlHandleDriver();
-
- // Destructor to clean up the class.
- ~VtsHidlHandleDriver();
-
- // Creates a hidl_handle object by providing a single file path to the file
- // to be opened with the flag and mode, and a list of integers needed in
- // native_handle_t struct.
- //
- // @param filepath path to the file to be opened.
- // @param flag file status flag, details in Linux man page.
- // @param mode file access mode, details in Linux man page.
- // @param data vector of integers useful in native_handle_t struct.
- //
- // @return new handle ID registered on the target side.
- HandleId CreateFileHandle(string filepath, int flag, int mode,
- vector<int> data);
-
- // Closes all file descriptors in the handle object associated with input ID.
- //
- // @param handle_id identifies the handle object.
- //
- // @return true if the handle object is found, false otherwise.
- bool UnregisterHidlHandle(HandleId handle_id);
-
- // Reads a file in the handle object.
- // Caller specifies the handle_id and number of bytes to read.
- // This function assumes caller only wants to read from a single file,
- // so it will access the first file descriptor in the native_handle_t struct,
- // and the first descriptor must be a file.
- //
- // @param handle_id identifies the handle object.
- // @param read_data data read back from file.
- // @param num_bytes number of bytes to read.
- //
- // @return number of bytes read, -1 to signal failure.
- ssize_t ReadFile(HandleId handle_id, void* read_data, size_t num_bytes);
-
- // Writes to a file in the handle object.
- // Caller specifies the handle_id and number of bytes to write.
- // This function assumes caller only wants to write to a single file,
- // so it will access the first file descriptor in the native_handle_t struct,
- // and the first descriptor must be a file.
- //
- // @param handle_id identifies the handle object.
- // @param write_data data to be written into to file.
- // @param num_bytes number of bytes to write.
- //
- // @return number of bytes written, -1 to signal failure.
- ssize_t WriteFile(HandleId handle_id, const void* write_data,
- size_t num_bytes);
-
- // Registers a handle object in the driver using an existing
- // hidl_handle address created by vtsc.
- //
- // @param handle_address address of hidl_handle pointer.
- //
- // @return id to be used to hidl_handle later.
- // -1 if registration fails.
- HandleId RegisterHidlHandle(size_t hidl_handle_address);
-
- // Get hidl_handle address of handle object with handle_id.
- //
- // @param handle_id identifies the handle object.
- // @param result stores the hidl_handle address.
- //
- // @return true if handle object is found, false otherwise.
- bool GetHidlHandleAddress(HandleId handle_id, size_t* result);
-
- private:
- // Finds the handle object with ID handle_id.
- // Logs error if handle_id is not found.
- //
- // @param handle_id identifies the handle object.
- // @param release whether to release the handle object managed unique_ptr.
- // This parameter is only true if UnregisterHidlHandle() is called.
- //
- // @return hidl_handle pointer.
- hidl_handle* FindHandle(HandleId handle_id, bool release = false);
-
- // A map to keep track of each hidl_handle information.
- // Store hidl_handle smart pointers.
- unordered_map<HandleId, unique_ptr<hidl_handle>> hidl_handle_map_;
-
- // A mutex to ensure insert and lookup on hidl_handle_map_ are thread-safe.
- mutex map_mutex_;
-};
-
-} // namespace vts
-} // namespace android
-#endif //__VTS_RESOURCE_VTSHIDLHANDLEDRIVER_H
\ No newline at end of file
diff --git a/drivers/resource/include/hidl_memory_driver/VtsHidlMemoryDriver.h b/drivers/resource/include/hidl_memory_driver/VtsHidlMemoryDriver.h
deleted file mode 100644
index 7159744..0000000
--- a/drivers/resource/include/hidl_memory_driver/VtsHidlMemoryDriver.h
+++ /dev/null
@@ -1,195 +0,0 @@
-//
-// 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.
-//
-
-#ifndef __VTS_RESOURCE_VTSHIDLMEMORYDRIVER_H
-#define __VTS_RESOURCE_VTSHIDLMEMORYDRIVER_H
-
-#include <mutex>
-#include <unordered_map>
-
-#include <android-base/logging.h>
-#include <android/hidl/memory/1.0/IMemory.h>
-#include <hidl/HidlSupport.h>
-
-using android::sp;
-using android::hardware::hidl_memory;
-using android::hidl::memory::V1_0::IMemory;
-
-using namespace std;
-using MemoryId = int;
-
-namespace android {
-namespace vts {
-
-// Need to store both hidl_memory pointer and IMemory pointer.
-// Conversion from hidl_memory to IMemory is slow, and we can send hidl_memory
-// pointer in hidl, and operate on the memory object using IMemory pointer.
-struct MemoryInfo {
- // Pointer to hidl_memory, which can be passed around in hidl.
- // Need to manually manage hidl_memory as a pointer, because the returned
- // hidl_memory reference from hidl API goes out of scope.
- unique_ptr<hidl_memory> hidl_mem_ptr;
- // Pointer to IMemory that allows actual memory operation.
- sp<IMemory> memory;
-};
-
-// A hidl_memory driver that manages all hidl_memory objects created
-// on the target side. Reader and writer use their id to read from and write
-// into the memory.
-// Example:
-// VtsHidlMemoryDriver mem_driver;
-// // Allcate memory.
-// int mem_id = mem_driver.Allocate(100);
-//
-// string write_data = "abcdef";
-// // Write into the memory.
-// mem_driver.Update(mem_id);
-// mem_driver.UpdateBytes(mem_id, write_data.c_str(),
-// write_data.length());
-// mem_driver.Commit(mem_id);
-// // Read from the memory.
-// char read_data[write_data.length()];
-// mem_driver.Read(mem_id);
-// mem_driver.ReadBytes(mem_id, read_data, write_data.length());
-// mem_driver.Commit(mem_id);
-class VtsHidlMemoryDriver {
- public:
- // Constructor to initialize a hidl_memory manager.
- VtsHidlMemoryDriver();
-
- // Destructor to clean up the class.
- ~VtsHidlMemoryDriver();
-
- // Allocate a memory region with size mem_size.
- //
- // @param mem_size size of the memory.
- //
- // @return int, id to be used to reference the memory object later.
- // -1 if allocation fails.
- MemoryId Allocate(size_t mem_size);
-
- // Registers a memory object in the driver.
- //
- // @param hidl_mem_address address of hidl_memory pointer.
- //
- // @return id to be used to reference the memory region later.
- // -1 if registration fails.
- MemoryId RegisterHidlMemory(size_t hidl_mem_address);
-
- // Notify that caller will possibly write to all memory region with id mem_id.
- //
- // @param mem_id identifies the memory object.
- //
- // @return true if memory object is found, false otherwise.
- bool Update(MemoryId mem_id);
-
- // Notify that caller will possibly write to memory region with mem_id
- // starting at start and ending at start + length.
- // start + length must be < size.
- //
- // @param mem_id identifies the memory object.
- // @param start offset from the start of memory region to be modified.
- // @param length number of bytes to be modified.
- //
- // @return true if memory object is found, false otherwise.
- bool UpdateRange(MemoryId mem_id, uint64_t start, uint64_t length);
-
- // Notify that caller will read the entire memory.
- //
- // @param mem_id identifies the memory object.
- //
- // @return true if memory object is found, false otherwise.
- bool Read(MemoryId mem_id);
-
- // Notify that caller will read memory region with mem_id starting at start
- // and end at start + length.
- //
- // @param mem_id identifies the memory object.
- // @param start offset from the start of memory region to be modified.
- // @param length number of bytes to be modified.
- //
- // @return true if memory object is found, false otherwise.
- bool ReadRange(MemoryId mem_id, uint64_t start, uint64_t length);
-
- // Add this method to perform actual write operation in memory,
- // because host side won't be able to cast c++ pointers.
- //
- // @param mem_id identifies the memory object.
- // @param write_data pointer to the start of buffer to be written into memory.
- // @param length number of bytes to write.
- // @param start offset from the start of memory region to be modified.
- //
- // @return true if memory object is found, false otherwise.
- bool UpdateBytes(MemoryId mem_id, const char* write_data, uint64_t length,
- uint64_t start = 0);
-
- // Add this method to perform actual read operation in memory,
- // because host side won't be able to cast c++ pointers.
- //
- // @param mem_id identifies the memory object.
- // @param read_data pointer to the start of buffer to be filled with
- // memory content.
- // @param length number of bytes to be read.
- // @param start offset from the start of the memory region to be modified.
- //
- // @return true if memory object is found, false otherwise.
- bool ReadBytes(MemoryId mem_id, char* read_data, uint64_t length,
- uint64_t start = 0);
-
- // Caller signals done with reading from or writing to memory.
- //
- // @param mem_id identifies the memory object.
- //
- // @return true if memory object is found, false otherwise.
- bool Commit(MemoryId mem_id);
-
- // Get the size of the memory.
- //
- // @param mem_id identifies the memory object.
- //
- // @return true if memory object is found, false otherwise.
- bool GetSize(MemoryId mem_id, size_t* result);
-
- // Get hidl_memory pointer address of memory object with mem_id.
- //
- // @param mem_id identifies the memory object.
- // @param result stores the hidl_memory pointer address.
- //
- // @return true if memory object is found, false otherwise.
- bool GetHidlMemoryAddress(MemoryId mem_id, size_t* result);
-
- private:
- // Finds the memory object with ID mem_id.
- // Logs error if mem_id is not found.
- //
- // @param mem_id identifies the memory object.
- //
- // @return MemoryInfo pointer, which contains both hidl_memory pointer and
- // IMemory pointer.
- MemoryInfo* FindMemory(MemoryId mem_id);
-
- // A map to keep track of each hidl_memory information.
- // Store MemoryInfo smart pointer, which contains both hidl_memory,
- // and actual memory pointer.
- unordered_map<MemoryId, unique_ptr<MemoryInfo>> hidl_memory_map_;
-
- // A mutex to ensure insert and lookup on hidl_memory_map_ are thread-safe.
- mutex map_mutex_;
-};
-
-} // namespace vts
-} // namespace android
-#endif //__VTS_RESOURCE_VTSHIDLMEMORYDRIVER_H
diff --git a/drivers/resource/include/resource_manager/VtsResourceManager.h b/drivers/resource/include/resource_manager/VtsResourceManager.h
deleted file mode 100644
index aba77a4..0000000
--- a/drivers/resource/include/resource_manager/VtsResourceManager.h
+++ /dev/null
@@ -1,311 +0,0 @@
-//
-// 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.
-//
-
-#ifndef __VTS_RESOURCE_VTSRESOURCEMANAGER_H
-#define __VTS_RESOURCE_VTSRESOURCEMANAGER_H
-
-#include <android-base/logging.h>
-#include <android/hardware/audio/4.0/IStreamIn.h>
-#include <android/hardware/audio/4.0/IStreamOut.h>
-#include <android/hardware/audio/effect/2.0/types.h>
-#include <android/hardware/audio/effect/4.0/types.h>
-#include <google/protobuf/repeated_field.h>
-#include <google/protobuf/text_format.h>
-
-#include "fmq_driver/VtsFmqDriver.h"
-#include "hidl_handle_driver/VtsHidlHandleDriver.h"
-#include "hidl_memory_driver/VtsHidlMemoryDriver.h"
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-#include "test/vts/proto/VtsResourceControllerMessage.pb.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-typedef ::android::hardware::audio::V4_0::IStreamIn::ReadParameters
- ReadParameters;
-typedef ::android::hardware::audio::V4_0::IStreamIn::ReadStatus ReadStatus;
-typedef ::android::hardware::audio::V4_0::IStreamOut::WriteCommand WriteCommand;
-typedef ::android::hardware::audio::V4_0::IStreamOut::WriteStatus WriteStatus;
-typedef ::android::hardware::audio::effect::V4_0::Result ResultV4_0;
-typedef ::android::hardware::audio::effect::V2_0::Result ResultV2_0;
-
-// A class that manages all resources allocated on the target side.
-// Resources include fast message queue, hidl_memory, hidl_handle.
-//
-// Example (Process FMQ Command):
-// // Initialize a manager.
-// VtsResourceManager manager;
-//
-// // Generate some FMQ request (e.g. creating a queue.).
-// FmqRequestMessage fmq_request;
-// fmq_request.set_operation(FMQ_CREATE);
-// fmq_request.set_data_type("uint16_t");
-// fmq_request.set_sync(true);
-// fmq_request.set_queue_size(2048);
-// fmq_request.set_blocking(false);
-//
-// // receive response.
-// FmqRequestResponse fmq_response;
-// // This will ask FMQ driver to process request and send response.
-// ProcessFmqCommand(fmq_request, &fmq_response);
-class VtsResourceManager {
- public:
- // Constructor to set up the resource manager.
- VtsResourceManager();
-
- // Destructor to clean up the resource manager.
- ~VtsResourceManager();
-
- // Processes command for operations on hidl_handle.
- //
- // @param hidl_handle_request contains arguments for the operation.
- // @param hidl_handle_response to be filled by the function.
- void ProcessHidlHandleCommand(
- const HidlHandleRequestMessage& hidl_handle_request,
- HidlHandleResponseMessage* hidl_handle_response);
-
- // Registers the handle object in hidl_handle_driver_ given the hidl_handle
- // address provided in hidl_handle_msg.
- //
- // @param hidl_handle_msg stores hidl_handle address, used to find actual
- // handle object.
- //
- // @return handle_id assigned to the new handle object.
- int RegisterHidlHandle(const VariableSpecificationMessage& hidl_handle_msg);
-
- // Gets hidl_handle address in hidl_handle_driver_.
- // If caller wants to use a handle object in the driver, it specifies
- // handle_id in HandleDataValueMessage. This method calls hidl_handle_driver_
- // to locate the handle object with handle_id, and stores the address
- // in result pointer.
- //
- // @param hidl_handle_msg contains handle_id of the handle object.
- // @param result stores hidl_handle address.
- //
- // @return true if the handle object with handle_id is found, and stores
- // address in result,
- // false otherwise.
- bool GetHidlHandleAddress(const VariableSpecificationMessage& hidl_handle_msg,
- size_t* result);
-
- // Processes command for operations on hidl_memory.
- //
- // @param hidl_memory_request contains arguments for the operation.
- // @param hidl_memory_response to be filled by the function.
- void ProcessHidlMemoryCommand(
- const HidlMemoryRequestMessage& hidl_memory_request,
- HidlMemoryResponseMessage* hidl_memory_response);
-
- // Registers the memory object in hidl_memory_driver_ given the hidl_memory
- // pointer address provided in hidl_memory_msg.
- //
- // @param hidl_memory_msg stores hidl_memory pointer, used to find actual
- // memory pointer.
- //
- // @return mem_id assigned to the new memory object.
- int RegisterHidlMemory(const VariableSpecificationMessage& hidl_memory_msg);
-
- // Gets hidl_memory pointer address in hidl_memory_driver_.
- // If caller wants to use a memory object in the driver, it specifies mem_id
- // in MemoryDataValueMessage. This method calls hidl_memory_driver to locate
- // the memory object with mem_id, and stores the address in result pointer.
- //
- // @param hidl_memory_msg contains memory object mem_id.
- // @param result stores hidl_memory pointer.
- //
- // @return true if the memory object with mem_id is found, and stores pointer
- // address in result,
- // false otherwise.
- bool GetHidlMemoryAddress(const VariableSpecificationMessage& hidl_memory_msg,
- size_t* result);
-
- // Processes command for operations on Fast Message Queue.
- // The arguments are specified in fmq_request, and this function stores result
- // in fmq_response.
- //
- // @param fmq_request contains arguments for the operation.
- // @param fmq_response to be filled by the function.
- void ProcessFmqCommand(const FmqRequestMessage& fmq_request,
- FmqResponseMessage* fmq_response);
-
- // Registers a fmq in fmq_driver_ given the information provided in
- // queue_msg.
- // This message stores queue data_type, sync option, and existing
- // descriptor address. This method recasts the address into a pointer
- // and passes it to fmq_driver_.
- //
- // @param queue_msg stores queue information, data_type, sync option,
- // and queue descriptor address.
- //
- // @return queue_id assigned to the new queue object.
- int RegisterFmq(const VariableSpecificationMessage& queue_msg);
-
- // Gets queue descriptor address specified in VariableSpecificationMessage.
- // The message contains type of data in the queue, queue flavor,
- // and queue id. The method calls fmq_driver to locate the address of the
- // descriptor using these information, then stores the address in
- // result pointer.
- //
- // @param queue_msg contains queue information.
- // @param result to store queue descriptor pointer address.
- //
- // @return true if queue is found and type matches, and stores the descriptor
- // address in result.
- // false otherwise.
- bool GetQueueDescAddress(const VariableSpecificationMessage& queue_msg,
- size_t* result);
-
- private:
- // Function template used in our map that maps type name to function
- // with template.
- typedef void (VtsResourceManager::*ProcessFmqCommandFn)(
- const FmqRequestMessage&, FmqResponseMessage*);
-
- // This method infers the queue flavor from the sync field in fmq_request
- // proto message, and calls ProcessFmqCommandInternal() with template T
- // and queue flavor.
- // Notice we create another method called
- // ProcessFmqCommandWithPredefinedType() with the same interface.
- // This prevents compiler error during conversion between protobuf message
- // and C++.
- //
- // @param fmq_request contains arguments for FMQ operation.
- // @param fmq_response FMQ response to be filled by this function.
- template <typename T>
- void ProcessFmqCommandWithType(const FmqRequestMessage& fmq_request,
- FmqResponseMessage* fmq_response);
-
- // A helper method to call methods on fmq_driver.
- // This method already has the template type and flavor of FMQ.
- //
- // @param fmq_request contains arguments for FMQ operation.
- // @param fmq_response FMQ response to be filled by this function.
- template <typename T, hardware::MQFlavor flavor>
- void ProcessFmqCommandInternal(const FmqRequestMessage& fmq_request,
- FmqResponseMessage* fmq_response);
-
- // Converts write_data field in fmq_request to a C++ buffer.
- // For user-defined type, dynamically load the HAL shared library
- // to parse protobuf message to C++ type.
- //
- // @param fmq_request contains the write_data, represented as a repeated
- // proto field.
- // @param write_data converted data that will be written into FMQ.
- // @param write_data_size number of items in write_data.
- //
- // @return true if parsing is successful, false otherwise.
- // This function can fail if loading shared library or locating
- // function symbols fails in user-defined type.
- template <typename T>
- bool FmqProto2Cpp(const FmqRequestMessage& fmq_request, T* write_data,
- size_t write_data_size);
-
- // Converts a C++ buffer into read_data field in fmq_response.
- // For user-defined type, dynamically load the HAL shared library
- // to parse C++ type to protobuf message.
- //
- // @param fmq_response to be filled by the function. The function fills the
- // read_data field, which is represented as a repeated
- // proto field.
- // @param data_type type of data in FMQ, this information will be
- // written into protobuf message.
- // @param read_data contains data read from FMQ read operation.
- // @param read_data_size number of items in read_data.
- //
- // @return true if parsing is successful, false otherwise.
- // This function can fail if loading shared library or locating
- // function symbols fails in user-defined type.
- template <typename T>
- bool FmqCpp2Proto(FmqResponseMessage* fmq_response, const string& data_type,
- T* read_data, size_t read_data_size);
-
- // Loads the corresponding HAL driver shared library from the type name.
- // This function parses the shared library path from a type name, and
- // loads the shared library object from the path.
- //
- // Example:
- // For type ::android::hardware::audio::V4_0::IStreamIn::ReadParameters,
- // the path that is parsed from the type name is
- // /data/local/tmp/android.hardware.audio@4.0-vts.driver.so.
- // Then the function loads the shared library object from this path.
- //
- // TODO: Consider determining the path and bitness by passing a field
- // in the protobuf message.
- //
- // @param data_type type name.
- //
- // @return shared library object.
- void* LoadSharedLibFromTypeName(const string& data_type);
-
- // Load the translation function between C++ and protobuf.
- // This method parses the function name that can translate C++ to protobuf
- // or translate protobuf to C++ from data_type.
- // Then it loads the function symbol from shared_lib_obj, which is an opened
- // HAL shared library.
- //
- // Example: type name is
- // ::android::hardware::audio::V4_0::IStreamIn::ReadParameters,
- // and we have the shared library pointer shared_lib_obj.
- // To translate from protobuf to C++, we need to call
- // GetTranslationFuncPtr(shared_lib_obj, data_type, true);
- // To translate from C++ to protobuf, we need to call
- // GetTranslationFuncPtr(shared_lib_obj, data_type, false);
- //
- // @param shared_lib_obj opened HAL shared library object.
- // @param data_type type name.
- // @param is_proto_to_cpp whether the function is to convert proto to C++.
- //
- // @return name of the translation function.
- void* GetTranslationFuncPtr(void* shared_lib_obj, const string& data_type,
- bool is_proto_to_cpp);
-
- // Manages Fast Message Queue (FMQ) driver.
- VtsFmqDriver fmq_driver_;
- // Manages hidl_memory driver.
- VtsHidlMemoryDriver hidl_memory_driver_;
- // Manages hidl_handle driver.
- VtsHidlHandleDriver hidl_handle_driver_;
- // A map that maps each FMQ user-defined type into a process
- // function with template.
- const unordered_map<string, ProcessFmqCommandFn> func_map_ = {
- {"int8_t", &VtsResourceManager::ProcessFmqCommandWithType<int8_t>},
- {"uint8_t", &VtsResourceManager::ProcessFmqCommandWithType<uint8_t>},
- {"int16_t", &VtsResourceManager::ProcessFmqCommandWithType<int16_t>},
- {"uint16_t", &VtsResourceManager::ProcessFmqCommandWithType<uint16_t>},
- {"int32_t", &VtsResourceManager::ProcessFmqCommandWithType<int32_t>},
- {"uint32_t", &VtsResourceManager::ProcessFmqCommandWithType<uint32_t>},
- {"int64_t", &VtsResourceManager::ProcessFmqCommandWithType<int64_t>},
- {"uint64_t", &VtsResourceManager::ProcessFmqCommandWithType<uint64_t>},
- {"float_t", &VtsResourceManager::ProcessFmqCommandWithType<float>},
- {"double_t", &VtsResourceManager::ProcessFmqCommandWithType<double>},
- {"bool_t", &VtsResourceManager::ProcessFmqCommandWithType<bool>},
- {"::android::hardware::audio::V4_0::IStreamIn::ReadParameters",
- &VtsResourceManager::ProcessFmqCommandWithType<ReadParameters>},
- {"::android::hardware::audio::V4_0::IStreamIn::ReadStatus",
- &VtsResourceManager::ProcessFmqCommandWithType<ReadStatus>},
- {"::android::hardware::audio::V4_0::IStreamOut::WriteCommand",
- &VtsResourceManager::ProcessFmqCommandWithType<WriteCommand>},
- {"::android::hardware::audio::effect::V4_0::Result",
- &VtsResourceManager::ProcessFmqCommandWithType<ResultV4_0>},
- {"::android::hardware::audio::effect::V2_0::Result",
- &VtsResourceManager::ProcessFmqCommandWithType<ResultV2_0>}};
-};
-
-} // namespace vts
-} // namespace android
-#endif //__VTS_RESOURCE_VTSRESOURCEMANAGER_H
diff --git a/drivers/resource/resource_manager/VtsResourceManager.cpp b/drivers/resource/resource_manager/VtsResourceManager.cpp
deleted file mode 100644
index a78f307..0000000
--- a/drivers/resource/resource_manager/VtsResourceManager.cpp
+++ /dev/null
@@ -1,760 +0,0 @@
-//
-// 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.
-//
-#define LOG_TAG "VtsResourceManager"
-
-#include "resource_manager/VtsResourceManager.h"
-
-#include <dlfcn.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <regex>
-
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-#include "test/vts/proto/VtsResourceControllerMessage.pb.h"
-
-using android::hardware::kSynchronizedReadWrite;
-using android::hardware::kUnsynchronizedWrite;
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-VtsResourceManager::VtsResourceManager() {}
-
-VtsResourceManager::~VtsResourceManager() {}
-
-void VtsResourceManager::ProcessHidlHandleCommand(
- const HidlHandleRequestMessage& hidl_handle_request,
- HidlHandleResponseMessage* hidl_handle_response) {
- HidlHandleOp operation = hidl_handle_request.operation();
- HandleId handle_id = hidl_handle_request.handle_id();
- HandleDataValueMessage handle_info = hidl_handle_request.handle_info();
- size_t read_data_size = hidl_handle_request.read_data_size();
- const void* write_data =
- static_cast<const void*>(hidl_handle_request.write_data().c_str());
- size_t write_data_size = hidl_handle_request.write_data().length();
- bool success = false;
-
- switch (operation) {
- case HANDLE_PROTO_CREATE_FILE: {
- if (handle_info.fd_val().size() == 0) {
- LOG(ERROR) << "No files to open.";
- break;
- }
-
- // TODO: currently only support opening a single file.
- // Support any file descriptor type in the future.
- FdMessage file_desc_info = handle_info.fd_val(0);
- if (file_desc_info.type() != FILE_TYPE) {
- LOG(ERROR) << "Currently only support file type.";
- break;
- }
-
- string filepath = file_desc_info.file_name();
- int flag;
- int mode = 0;
- // Translate the mode into C++ flags and modes.
- if (file_desc_info.file_mode_str() == "r" ||
- file_desc_info.file_mode_str() == "rb") {
- flag = O_RDONLY;
- } else if (file_desc_info.file_mode_str() == "w" ||
- file_desc_info.file_mode_str() == "wb") {
- flag = O_WRONLY | O_CREAT | O_TRUNC;
- mode = S_IRWXU; // User has the right to read/write/execute.
- } else if (file_desc_info.file_mode_str() == "a" ||
- file_desc_info.file_mode_str() == "ab") {
- flag = O_WRONLY | O_CREAT | O_APPEND;
- mode = S_IRWXU;
- } else if (file_desc_info.file_mode_str() == "r+" ||
- file_desc_info.file_mode_str() == "rb+" ||
- file_desc_info.file_mode_str() == "r+b") {
- flag = O_RDWR;
- } else if (file_desc_info.file_mode_str() == "w+" ||
- file_desc_info.file_mode_str() == "wb+" ||
- file_desc_info.file_mode_str() == "w+b") {
- flag = O_RDWR | O_CREAT | O_TRUNC;
- mode = S_IRWXU;
- } else if (file_desc_info.file_mode_str() == "a+" ||
- file_desc_info.file_mode_str() == "ab+" ||
- file_desc_info.file_mode_str() == "a+b") {
- flag = O_RDWR | O_CREAT | O_APPEND;
- mode = S_IRWXU;
- } else if (file_desc_info.file_mode_str() == "x" ||
- file_desc_info.file_mode_str() == "x+") {
- struct stat buffer;
- if (stat(filepath.c_str(), &buffer) == 0) {
- LOG(ERROR) << "Host side creates a file with mode x, "
- << "but file already exists";
- break;
- }
- flag = O_CREAT;
- mode = S_IRWXU;
- if (file_desc_info.file_mode_str() == "x+") {
- flag |= O_RDWR;
- } else {
- flag |= O_WRONLY;
- }
- } else {
- LOG(ERROR) << "Unknown file mode.";
- break;
- }
-
- // Convert repeated int field into vector.
- vector<int> int_data(write_data_size);
- transform(handle_info.int_val().cbegin(), handle_info.int_val().cend(),
- int_data.begin(), [](const int& item) { return item; });
- // Call API on hidl_handle driver to create a file handle.
- int new_handle_id =
- hidl_handle_driver_.CreateFileHandle(filepath, flag, mode, int_data);
- hidl_handle_response->set_new_handle_id(new_handle_id);
- success = new_handle_id != -1;
- break;
- }
- case HANDLE_PROTO_READ_FILE: {
- char read_data[read_data_size];
- // Call API on hidl_handle driver to read the file.
- ssize_t read_success_bytes = hidl_handle_driver_.ReadFile(
- handle_id, static_cast<void*>(read_data), read_data_size);
- success = read_success_bytes != -1;
- hidl_handle_response->set_read_data(
- string(read_data, read_success_bytes));
- break;
- }
- case HANDLE_PROTO_WRITE_FILE: {
- // Call API on hidl_handle driver to write to the file.
- ssize_t write_success_bytes =
- hidl_handle_driver_.WriteFile(handle_id, write_data, write_data_size);
- success = write_success_bytes != -1;
- hidl_handle_response->set_write_data_size(write_success_bytes);
- break;
- }
- case HANDLE_PROTO_DELETE: {
- // Call API on hidl_handle driver to unregister the handle object.
- success = hidl_handle_driver_.UnregisterHidlHandle(handle_id);
- break;
- }
- default:
- LOG(ERROR) << "Unknown operation.";
- break;
- }
- hidl_handle_response->set_success(success);
-}
-
-int VtsResourceManager::RegisterHidlHandle(
- const VariableSpecificationMessage& hidl_handle_msg) {
- size_t hidl_handle_address =
- hidl_handle_msg.handle_value().hidl_handle_address();
- if (hidl_handle_address == 0) {
- LOG(ERROR) << "Invalid hidl_handle address."
- << "HAL driver either didn't set the address or "
- << "set a null pointer.";
- return -1; // check for null pointer
- }
- return hidl_handle_driver_.RegisterHidlHandle(hidl_handle_address);
-}
-
-bool VtsResourceManager::GetHidlHandleAddress(
- const VariableSpecificationMessage& hidl_handle_msg, size_t* result) {
- int handle_id = hidl_handle_msg.handle_value().handle_id();
- bool success = hidl_handle_driver_.GetHidlHandleAddress(handle_id, result);
- return success;
-}
-
-void VtsResourceManager::ProcessHidlMemoryCommand(
- const HidlMemoryRequestMessage& hidl_memory_request,
- HidlMemoryResponseMessage* hidl_memory_response) {
- size_t mem_size = hidl_memory_request.mem_size();
- int mem_id = hidl_memory_request.mem_id();
- uint64_t start = hidl_memory_request.start();
- uint64_t length = hidl_memory_request.length();
- const string& write_data = hidl_memory_request.write_data();
- bool success = false;
-
- switch (hidl_memory_request.operation()) {
- case MEM_PROTO_ALLOCATE: {
- int new_mem_id = hidl_memory_driver_.Allocate(mem_size);
- hidl_memory_response->set_new_mem_id(new_mem_id);
- success = new_mem_id != -1;
- break;
- }
- case MEM_PROTO_START_READ: {
- success = hidl_memory_driver_.Read(mem_id);
- break;
- }
- case MEM_PROTO_START_READ_RANGE: {
- success = hidl_memory_driver_.ReadRange(mem_id, start, length);
- break;
- }
- case MEM_PROTO_START_UPDATE: {
- success = hidl_memory_driver_.Update(mem_id);
- break;
- }
- case MEM_PROTO_START_UPDATE_RANGE: {
- success = hidl_memory_driver_.UpdateRange(mem_id, start, length);
- break;
- }
- case MEM_PROTO_UPDATE_BYTES: {
- success = hidl_memory_driver_.UpdateBytes(mem_id, write_data.c_str(),
- length, start);
- break;
- }
- case MEM_PROTO_READ_BYTES: {
- char read_data[length];
- success = hidl_memory_driver_.ReadBytes(mem_id, read_data, length, start);
- hidl_memory_response->set_read_data(string(read_data, length));
- break;
- }
- case MEM_PROTO_COMMIT: {
- success = hidl_memory_driver_.Commit(mem_id);
- break;
- }
- case MEM_PROTO_GET_SIZE: {
- size_t result_mem_size;
- success = hidl_memory_driver_.GetSize(mem_id, &result_mem_size);
- hidl_memory_response->set_mem_size(result_mem_size);
- break;
- }
- default:
- LOG(ERROR) << "unknown operation in hidl_memory_driver.";
- break;
- }
- hidl_memory_response->set_success(success);
-}
-
-int VtsResourceManager::RegisterHidlMemory(
- const VariableSpecificationMessage& hidl_memory_msg) {
- size_t hidl_mem_address =
- hidl_memory_msg.hidl_memory_value().hidl_mem_address();
- if (hidl_mem_address == 0) {
- LOG(ERROR) << "Resource manager: invalid hidl_memory address."
- << "HAL driver either didn't set the address or "
- << "set a null pointer.";
- return -1; // check for null pointer
- }
- return hidl_memory_driver_.RegisterHidlMemory(hidl_mem_address);
-}
-
-bool VtsResourceManager::GetHidlMemoryAddress(
- const VariableSpecificationMessage& hidl_memory_msg, size_t* result) {
- int mem_id = hidl_memory_msg.hidl_memory_value().mem_id();
- bool success = hidl_memory_driver_.GetHidlMemoryAddress(mem_id, result);
- return success;
-}
-
-void VtsResourceManager::ProcessFmqCommand(const FmqRequestMessage& fmq_request,
- FmqResponseMessage* fmq_response) {
- const string& data_type = fmq_request.data_type();
- // Find the correct function with template to process FMQ operation.
- auto iterator = func_map_.find(data_type);
- if (iterator == func_map_.end()) { // queue not found
- LOG(ERROR) << "Resource manager: current FMQ driver doesn't support type "
- << data_type;
- fmq_response->set_success(false);
- } else {
- (this->*(iterator->second))(fmq_request, fmq_response);
- }
-}
-
-int VtsResourceManager::RegisterFmq(
- const VariableSpecificationMessage& queue_msg) {
- size_t queue_desc_addr = queue_msg.fmq_value(0).fmq_desc_address();
- if (queue_desc_addr == 0) {
- LOG(ERROR)
- << "Resource manager: invalid queue descriptor address."
- << "HAL driver either didn't set the address or set a null pointer.";
- return -1; // check for null pointer
- }
-
- FmqRequestMessage fmq_request;
- FmqResponseMessage fmq_response;
- fmq_request.set_operation(FMQ_CREATE);
- fmq_request.set_sync(queue_msg.type() == TYPE_FMQ_SYNC);
- // TODO: support user-defined types in the future, only support scalar types
- // for now.
- fmq_request.set_data_type(queue_msg.fmq_value(0).scalar_type());
- fmq_request.set_queue_desc_addr(queue_desc_addr);
- ProcessFmqCommand(fmq_request, &fmq_response);
- return fmq_response.queue_id();
-}
-
-bool VtsResourceManager::GetQueueDescAddress(
- const VariableSpecificationMessage& queue_msg, size_t* result) {
- FmqRequestMessage fmq_request;
- FmqResponseMessage fmq_response;
- fmq_request.set_operation(FMQ_GET_DESC_ADDR);
- fmq_request.set_sync(queue_msg.type() == TYPE_FMQ_SYNC);
- // TODO: support user-defined types in the future, only support scalar types
- // for now.
- fmq_request.set_data_type(queue_msg.fmq_value(0).scalar_type());
- fmq_request.set_queue_id(queue_msg.fmq_value(0).fmq_id());
- ProcessFmqCommand(fmq_request, &fmq_response);
- bool success = fmq_response.success();
- *result = fmq_response.sizet_return_val();
- return success;
-}
-
-template <typename T>
-void VtsResourceManager::ProcessFmqCommandWithType(
- const FmqRequestMessage& fmq_request, FmqResponseMessage* fmq_response) {
- // Infers queue flavor and calls the internal method.
- if (fmq_request.sync()) {
- ProcessFmqCommandInternal<T, kSynchronizedReadWrite>(fmq_request,
- fmq_response);
- } else {
- ProcessFmqCommandInternal<T, kUnsynchronizedWrite>(fmq_request,
- fmq_response);
- }
-}
-
-template <typename T, hardware::MQFlavor flavor>
-void VtsResourceManager::ProcessFmqCommandInternal(
- const FmqRequestMessage& fmq_request, FmqResponseMessage* fmq_response) {
- const string& data_type = fmq_request.data_type();
- int queue_id = fmq_request.queue_id();
- size_t queue_size = fmq_request.queue_size();
- bool blocking = fmq_request.blocking();
- bool reset_pointers = fmq_request.reset_pointers();
- size_t write_data_size = fmq_request.write_data_size();
- T write_data[write_data_size];
- size_t read_data_size = fmq_request.read_data_size();
- T read_data[read_data_size];
- size_t queue_desc_addr = fmq_request.queue_desc_addr();
- int64_t time_out_nanos = fmq_request.time_out_nanos();
- // TODO: The three variables below are manually created.
- // In the future, get these from host side when we support long-form
- // blocking from host side.
- uint32_t read_notification = 0;
- uint32_t write_notification = 0;
- atomic<uint32_t> event_flag_word;
- bool success = false;
- size_t sizet_result;
-
- switch (fmq_request.operation()) {
- case FMQ_CREATE: {
- int new_queue_id = -1;
- if (queue_id == -1) {
- if (queue_desc_addr == 0) {
- new_queue_id =
- fmq_driver_.CreateFmq<T, flavor>(data_type, queue_size, blocking);
- } else {
- new_queue_id =
- fmq_driver_.CreateFmq<T, flavor>(data_type, queue_desc_addr);
- }
- } else {
- new_queue_id = fmq_driver_.CreateFmq<T, flavor>(data_type, queue_id,
- reset_pointers);
- }
- fmq_response->set_queue_id(new_queue_id);
- success = new_queue_id != -1;
- break;
- }
- case FMQ_READ: {
- success = fmq_driver_.ReadFmq<T, flavor>(data_type, queue_id, read_data,
- read_data_size);
- if (!FmqCpp2Proto<T>(fmq_response, data_type, read_data,
- read_data_size)) {
- LOG(ERROR) << "Resource manager: failed to convert C++ type into "
- << "protobuf message for type " << data_type;
- break;
- }
- break;
- }
- case FMQ_READ_BLOCKING: {
- success = fmq_driver_.ReadFmqBlocking<T, flavor>(
- data_type, queue_id, read_data, read_data_size, time_out_nanos);
- if (!FmqCpp2Proto<T>(fmq_response, data_type, read_data,
- read_data_size)) {
- LOG(ERROR) << "Resource manager: failed to convert C++ type into "
- << "protobuf message for type " << data_type;
- break;
- }
- break;
- }
- case FMQ_READ_BLOCKING_LONG: {
- // TODO: implement a meaningful long-form blocking mechanism
- // Currently passing a test event flag word.
- success = fmq_driver_.ReadFmqBlocking<T, flavor>(
- data_type, queue_id, read_data, read_data_size, read_notification,
- write_notification, time_out_nanos, &event_flag_word);
- if (!FmqCpp2Proto<T>(fmq_response, data_type, read_data,
- read_data_size)) {
- LOG(ERROR) << "Resource manager: failed to convert C++ type into "
- << "protobuf message for type " << data_type;
- break;
- }
- break;
- }
- case FMQ_WRITE: {
- if (!FmqProto2Cpp<T>(fmq_request, write_data, write_data_size)) {
- LOG(ERROR) << "Resource manager: failed to convert protobuf message "
- << "into C++ types for type " << data_type;
- break;
- }
- success = fmq_driver_.WriteFmq<T, flavor>(data_type, queue_id, write_data,
- write_data_size);
- break;
- }
- case FMQ_WRITE_BLOCKING: {
- if (!FmqProto2Cpp<T>(fmq_request, write_data, write_data_size)) {
- LOG(ERROR) << "Resource manager: failed to convert protobuf message "
- << "into C++ types for type " << data_type;
- break;
- }
- success = fmq_driver_.WriteFmqBlocking<T, flavor>(
- data_type, queue_id, write_data, write_data_size, time_out_nanos);
- break;
- }
- case FMQ_WRITE_BLOCKING_LONG: {
- // TODO: implement a meaningful long-form blocking mechanism
- // Currently passing a test event flag word.
- if (!FmqProto2Cpp<T>(fmq_request, write_data, write_data_size)) {
- LOG(ERROR) << "Resource manager: failed to convert protobuf message "
- << "into C++ types for type " << data_type;
- break;
- }
- success = fmq_driver_.WriteFmqBlocking<T, flavor>(
- data_type, queue_id, write_data, write_data_size, read_notification,
- write_notification, time_out_nanos, &event_flag_word);
- break;
- }
- case FMQ_AVAILABLE_WRITE: {
- success = fmq_driver_.AvailableToWrite<T, flavor>(data_type, queue_id,
- &sizet_result);
- fmq_response->set_sizet_return_val(sizet_result);
- break;
- }
- case FMQ_AVAILABLE_READ: {
- success = fmq_driver_.AvailableToRead<T, flavor>(data_type, queue_id,
- &sizet_result);
- fmq_response->set_sizet_return_val(sizet_result);
- break;
- }
- case FMQ_GET_QUANTUM_SIZE: {
- success = fmq_driver_.GetQuantumSize<T, flavor>(data_type, queue_id,
- &sizet_result);
- fmq_response->set_sizet_return_val(sizet_result);
- break;
- }
- case FMQ_GET_QUANTUM_COUNT: {
- success = fmq_driver_.GetQuantumCount<T, flavor>(data_type, queue_id,
- &sizet_result);
- fmq_response->set_sizet_return_val(sizet_result);
- break;
- }
- case FMQ_IS_VALID: {
- success = fmq_driver_.IsValid<T, flavor>(data_type, queue_id);
- break;
- }
- case FMQ_GET_DESC_ADDR: {
- success = fmq_driver_.GetQueueDescAddress<T, flavor>(data_type, queue_id,
- &sizet_result);
- fmq_response->set_sizet_return_val(sizet_result);
- break;
- }
- default:
- LOG(ERROR) << "Resource manager: Unsupported FMQ operation.";
- }
- fmq_response->set_success(success);
-}
-
-template <typename T>
-bool VtsResourceManager::FmqProto2Cpp(const FmqRequestMessage& fmq_request,
- T* write_data, size_t write_data_size) {
- const string& data_type = fmq_request.data_type();
- // Read from different proto fields based on type.
- if (data_type == "int8_t") {
- int8_t* convert_data = reinterpret_cast<int8_t*>(write_data);
- for (int i = 0; i < write_data_size; i++) {
- convert_data[i] = (fmq_request.write_data(i).scalar_value().int8_t());
- }
- } else if (data_type == "uint8_t") {
- uint8_t* convert_data = reinterpret_cast<uint8_t*>(write_data);
- for (int i = 0; i < write_data_size; i++) {
- convert_data[i] = fmq_request.write_data(i).scalar_value().uint8_t();
- }
- } else if (data_type == "int16_t") {
- int16_t* convert_data = reinterpret_cast<int16_t*>(write_data);
- for (int i = 0; i < write_data_size; i++) {
- convert_data[i] = fmq_request.write_data(i).scalar_value().int16_t();
- }
- } else if (data_type == "uint16_t") {
- uint16_t* convert_data = reinterpret_cast<uint16_t*>(write_data);
- for (int i = 0; i < write_data_size; i++) {
- convert_data[i] = fmq_request.write_data(i).scalar_value().uint16_t();
- }
- } else if (data_type == "int32_t") {
- int32_t* convert_data = reinterpret_cast<int32_t*>(write_data);
- for (int i = 0; i < write_data_size; i++) {
- convert_data[i] = fmq_request.write_data(i).scalar_value().int32_t();
- }
- } else if (data_type == "uint32_t") {
- uint32_t* convert_data = reinterpret_cast<uint32_t*>(write_data);
- for (int i = 0; i < write_data_size; i++) {
- convert_data[i] = fmq_request.write_data(i).scalar_value().uint32_t();
- }
- } else if (data_type == "int64_t") {
- int64_t* convert_data = reinterpret_cast<int64_t*>(write_data);
- for (int i = 0; i < write_data_size; i++) {
- convert_data[i] = fmq_request.write_data(i).scalar_value().int64_t();
- }
- } else if (data_type == "uint64_t") {
- uint64_t* convert_data = reinterpret_cast<uint64_t*>(write_data);
- for (int i = 0; i < write_data_size; i++) {
- convert_data[i] = fmq_request.write_data(i).scalar_value().uint64_t();
- }
- } else if (data_type == "float_t") {
- float* convert_data = reinterpret_cast<float*>(write_data);
- for (int i = 0; i < write_data_size; i++) {
- convert_data[i] = fmq_request.write_data(i).scalar_value().float_t();
- }
- } else if (data_type == "double_t") {
- double* convert_data = reinterpret_cast<double*>(write_data);
- for (int i = 0; i < write_data_size; i++) {
- convert_data[i] = fmq_request.write_data(i).scalar_value().double_t();
- }
- } else if (data_type == "bool_t") {
- bool* convert_data = reinterpret_cast<bool*>(write_data);
- for (int i = 0; i < write_data_size; i++) {
- convert_data[i] = fmq_request.write_data(i).scalar_value().bool_t();
- }
- } else {
- // Encounter a predefined type in HAL service.
- LOG(INFO) << "Resource manager: detected host side specifies a "
- << "predefined type.";
- void* shared_lib_obj = LoadSharedLibFromTypeName(data_type);
-
- // Locate the symbol for the translation function.
- typedef void (*parse_fn)(const VariableSpecificationMessage&, T*,
- const string&);
- parse_fn parser =
- (parse_fn)(GetTranslationFuncPtr(shared_lib_obj, data_type, true));
- if (!parser) return false; // Error logged in helper function.
-
- // Parse the data from protobuf to C++.
- for (int i = 0; i < write_data_size; i++) {
- (*parser)(fmq_request.write_data(i), &write_data[i], "");
- }
- dlclose(shared_lib_obj);
- }
- return true;
-}
-
-// TODO: support user-defined types, only support primitive types now.
-template <typename T>
-bool VtsResourceManager::FmqCpp2Proto(FmqResponseMessage* fmq_response,
- const string& data_type, T* read_data,
- size_t read_data_size) {
- fmq_response->clear_read_data();
- // Write to different proto fields based on type.
- if (data_type == "int8_t") {
- int8_t* convert_data = reinterpret_cast<int8_t*>(read_data);
- for (size_t i = 0; i < read_data_size; i++) {
- VariableSpecificationMessage* item = fmq_response->add_read_data();
- item->set_type(TYPE_SCALAR);
- item->set_scalar_type(data_type);
- (item->mutable_scalar_value())->set_int8_t(convert_data[i]);
- }
- } else if (data_type == "uint8_t") {
- uint8_t* convert_data = reinterpret_cast<uint8_t*>(read_data);
- for (size_t i = 0; i < read_data_size; i++) {
- VariableSpecificationMessage* item = fmq_response->add_read_data();
- item->set_type(TYPE_SCALAR);
- item->set_scalar_type(data_type);
- (item->mutable_scalar_value())->set_uint8_t(convert_data[i]);
- }
- } else if (data_type == "int16_t") {
- int16_t* convert_data = reinterpret_cast<int16_t*>(read_data);
- for (size_t i = 0; i < read_data_size; i++) {
- VariableSpecificationMessage* item = fmq_response->add_read_data();
- item->set_type(TYPE_SCALAR);
- item->set_scalar_type(data_type);
- (item->mutable_scalar_value())->set_int16_t(convert_data[i]);
- }
- } else if (data_type == "uint16_t") {
- uint16_t* convert_data = reinterpret_cast<uint16_t*>(read_data);
- for (size_t i = 0; i < read_data_size; i++) {
- VariableSpecificationMessage* item = fmq_response->add_read_data();
- item->set_type(TYPE_SCALAR);
- item->set_scalar_type(data_type);
- (item->mutable_scalar_value())->set_uint16_t(convert_data[i]);
- }
- } else if (data_type == "int32_t") {
- int32_t* convert_data = reinterpret_cast<int32_t*>(read_data);
- for (size_t i = 0; i < read_data_size; i++) {
- VariableSpecificationMessage* item = fmq_response->add_read_data();
- item->set_type(TYPE_SCALAR);
- item->set_scalar_type(data_type);
- (item->mutable_scalar_value())->set_int32_t(convert_data[i]);
- }
- } else if (data_type == "uint32_t") {
- uint32_t* convert_data = reinterpret_cast<uint32_t*>(read_data);
- for (size_t i = 0; i < read_data_size; i++) {
- VariableSpecificationMessage* item = fmq_response->add_read_data();
- item->set_type(TYPE_SCALAR);
- item->set_scalar_type(data_type);
- (item->mutable_scalar_value())->set_uint32_t(convert_data[i]);
- }
- } else if (data_type == "int64_t") {
- int64_t* convert_data = reinterpret_cast<int64_t*>(read_data);
- for (size_t i = 0; i < read_data_size; i++) {
- VariableSpecificationMessage* item = fmq_response->add_read_data();
- item->set_type(TYPE_SCALAR);
- item->set_scalar_type(data_type);
- (item->mutable_scalar_value())->set_int64_t(convert_data[i]);
- }
- } else if (data_type == "uint64_t") {
- uint64_t* convert_data = reinterpret_cast<uint64_t*>(read_data);
- for (size_t i = 0; i < read_data_size; i++) {
- VariableSpecificationMessage* item = fmq_response->add_read_data();
- item->set_type(TYPE_SCALAR);
- item->set_scalar_type(data_type);
- (item->mutable_scalar_value())->set_uint64_t(convert_data[i]);
- }
- } else if (data_type == "float_t") {
- float* convert_data = reinterpret_cast<float*>(read_data);
- for (size_t i = 0; i < read_data_size; i++) {
- VariableSpecificationMessage* item = fmq_response->add_read_data();
- item->set_type(TYPE_SCALAR);
- item->set_scalar_type(data_type);
- (item->mutable_scalar_value())->set_float_t(convert_data[i]);
- }
- } else if (data_type == "double_t") {
- double* convert_data = reinterpret_cast<double*>(read_data);
- for (size_t i = 0; i < read_data_size; i++) {
- VariableSpecificationMessage* item = fmq_response->add_read_data();
- item->set_type(TYPE_SCALAR);
- item->set_scalar_type(data_type);
- (item->mutable_scalar_value())->set_double_t(convert_data[i]);
- }
- } else if (data_type == "bool_t") {
- bool* convert_data = reinterpret_cast<bool*>(read_data);
- for (size_t i = 0; i < read_data_size; i++) {
- VariableSpecificationMessage* item = fmq_response->add_read_data();
- item->set_type(TYPE_SCALAR);
- item->set_scalar_type(data_type);
- (item->mutable_scalar_value())->set_bool_t(convert_data[i]);
- }
- } else {
- // Encounter a predefined type in HAL service.
- LOG(INFO) << "Resource manager: detected host side specifies a "
- << "predefined type.";
- void* shared_lib_obj = LoadSharedLibFromTypeName(data_type);
- if (!shared_lib_obj) return false;
-
- // Locate the symbol for the translation function.
- typedef void (*set_result_fn)(VariableSpecificationMessage*, T);
- set_result_fn parser =
- (set_result_fn)(GetTranslationFuncPtr(shared_lib_obj, data_type, 0));
- if (!parser) return false; // Error logged in helper function.
-
- // Parse the data from C++ to protobuf.
- for (int i = 0; i < read_data_size; i++) {
- VariableSpecificationMessage* item = fmq_response->add_read_data();
- (*parser)(item, read_data[i]);
- }
- dlclose(shared_lib_obj);
- }
- return true;
-}
-
-void* VtsResourceManager::LoadSharedLibFromTypeName(const string& data_type) {
- // Base path.
- // TODO: Consider determining the path and bitness by passing a field
- // in the protobuf message.
- string shared_lib_path = "/data/local/tmp/64/";
- // Start searching after the first ::
- size_t curr_index = 0;
- size_t next_index;
- bool success = false;
- regex version_regex("V[0-9]+_[0-9]+");
- const string split_str = "::";
-
- while ((next_index = data_type.find(split_str, curr_index)) != string::npos) {
- if (curr_index == next_index) {
- // No character between the current :: and the next ::
- // Likely it is the first :: in the type name.
- curr_index = next_index + split_str.length();
- continue;
- }
- string curr_string = data_type.substr(curr_index, next_index - curr_index);
- // Check if it is a version, e.g. V4_0.
- if (regex_match(curr_string, version_regex)) {
- size_t length = shared_lib_path.length();
- // Change _ into ., e.g. V4_0 to V4.0.
- size_t separator = curr_string.find("_");
- curr_string.replace(separator, 1, ".");
- // Use @ before version.
- shared_lib_path.replace(length - 1, 1, "@");
- // Exclude V in the front.
- shared_lib_path += curr_string.substr(1);
- success = true;
- break;
- } else {
- shared_lib_path += curr_string + ".";
- }
- // Start searching from the next ::
- curr_index = next_index + split_str.length();
- }
- // Failed to parse the shared library name from type name.
- if (!success) return nullptr;
-
- shared_lib_path += "-vts.driver.so";
- // Load the shared library that contains translation functions.
- void* shared_lib_obj = dlopen(shared_lib_path.c_str(), RTLD_LAZY);
- if (!shared_lib_obj) {
- LOG(ERROR) << "Resource manager: failed to load shared lib "
- << shared_lib_path << " for type " << data_type;
- return nullptr;
- }
- LOG(INFO) << "Resource manager: successfully loaded shared library "
- << shared_lib_path;
- return shared_lib_obj;
-}
-
-void* VtsResourceManager::GetTranslationFuncPtr(void* shared_lib_obj,
- const string& data_type,
- bool is_proto_to_cpp) {
- string translation_func_name = data_type;
- // Replace all :: with __.
- // TODO: there might be a special case where part of the type name involves
- // a single :. Consider fixing this in the future.
- replace(translation_func_name.begin(), translation_func_name.end(), ':', '_');
-
- void* func_ptr = nullptr;
- if (is_proto_to_cpp) {
- func_ptr =
- dlsym(shared_lib_obj, ("MessageTo" + translation_func_name).c_str());
- if (!func_ptr) {
- LOG(ERROR) << "Resource manager: failed to load function name "
- << "MessageTo" << translation_func_name << " or "
- << "EnumValue" << translation_func_name
- << " to parse protobuf message into C++ type.";
- }
- } else {
- func_ptr =
- dlsym(shared_lib_obj, ("SetResult" + translation_func_name).c_str());
- if (!func_ptr) {
- LOG(ERROR) << "Resource manager: failed to load the function name "
- << "SetResult" << translation_func_name
- << " to parse C++ type into protobuf message.";
- }
- }
- return func_ptr;
-}
-
-} // namespace vts
-} // namespace android
diff --git a/hals/README.md b/hals/README.md
deleted file mode 100644
index a6afb70..0000000
--- a/hals/README.md
+++ /dev/null
@@ -1 +0,0 @@
-The files and sub dirs under this dir contain test HAL modules that are functionally similar to the ones in the corresponding nexus device's HAL dirs but are compiled in a different way (e.g., with a post-compile-time instrumentation or direct source code instrumentation). Those instrumentations are mostly for the VTS's fuzzing and tracing-and-logging when such can't be done in a non-intrusive way.
diff --git a/hals/light/bullhead/Android.bp b/hals/light/bullhead/Android.bp
deleted file mode 100644
index 29c4787..0000000
--- a/hals/light/bullhead/Android.bp
+++ /dev/null
@@ -1,55 +0,0 @@
-//
-// Copyright 2015 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.
-//
-
-// This contains the module build definitions for the hardware-specific
-// components for this device.
-//
-// As much as possible, those components should be built unconditionally,
-// with device-specific names to avoid collisions, to avoid device-specific
-// bitrot and build breakages. Building a component unconditionally does
-// *not* include it on all devices, so it is safe even with hardware-specific
-// components.
-
-package {
- default_applicable_licenses: ["test_vts_hals_light_bullhead_license"],
-}
-
-// Added automatically by a large-scale-change
-// See: http://go/android-license-faq
-license {
- name: "test_vts_hals_light_bullhead_license",
- visibility: [":__subpackages__"],
- license_kinds: [
- "SPDX-license-identifier-Apache-2.0",
- ],
- license_text: [
- "NOTICE",
- ],
-}
-
-cc_library_shared {
- name: "lights.vts",
-
- cflags: [
- "-Wall",
- "-Werror",
- ],
- srcs: ["lights.c"],
- relative_install_path: "hw",
- shared_libs: ["liblog"],
-
- compile_multilib: "both",
-}
diff --git a/hals/light/bullhead/NOTICE b/hals/light/bullhead/NOTICE
deleted file mode 100644
index 1a5b8e4..0000000
--- a/hals/light/bullhead/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (C) 2015 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.
-
- 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.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/hals/light/bullhead/lights.c b/hals/light/bullhead/lights.c
deleted file mode 100644
index dde468b..0000000
--- a/hals/light/bullhead/lights.c
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-#define LOG_TAG "lights"
-#define DEBUG 1
-
-#include <log/log.h>
-
-#include <malloc.h>
-#include <stdint.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <pthread.h>
-
-#include <sys/ioctl.h>
-#include <sys/types.h>
-
-#include <hardware/lights.h>
-
-/******************************************************************************/
-
-static pthread_once_t g_init = PTHREAD_ONCE_INIT;
-static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
-
-char const *const LCD_FILE = "/sys/class/leds/lcd-backlight/brightness";
-char const *const RED_LED_FILE = "/sys/class/leds/red/brightness";
-char const *const GREEN_LED_FILE = "/sys/class/leds/green/brightness";
-char const *const BLUE_LED_FILE = "/sys/class/leds/blue/brightness";
-char const *const RED_TIMEOUT_FILE = "/sys/class/leds/red/on_off_ms";
-char const *const GREEN_TIMEOUT_FILE = "/sys/class/leds/green/on_off_ms";
-char const *const BLUE_TIMEOUT_FILE = "/sys/class/leds/blue/on_off_ms";
-char const *const RGB_LOCKED_FILE = "/sys/class/leds/red/rgb_start";
-
-/**
- * device methods
- */
-
-void init_globals(void)
-{
- // init the mutex
- pthread_mutex_init(&g_lock, NULL);
-}
-
-static int write_int(char const* path, int value)
-{
- int fd;
- static int already_warned = 0;
-
- fd = open(path, O_RDWR);
- if (fd >= 0) {
- char buffer[32] = {0,};
- int bytes = snprintf(buffer, sizeof(buffer), "%d\n", value);
- int amt = write(fd, buffer, bytes);
- close(fd);
- return amt == -1 ? -errno : 0;
- } else {
- if (already_warned == 0) {
- ALOGE("write_int failed to open %s\n", path);
- already_warned = 1;
- }
- return -errno;
- }
-}
-
-static int write_on_off(char const* path, int on, int off)
-{
- int fd;
- static int already_warned = 0;
-
- fd = open(path, O_RDWR);
- if (fd >= 0) {
- char buffer[32] = {0,};
- int bytes = snprintf(buffer, sizeof(buffer), "%d %d\n", on, off);
- int amt = write(fd, buffer, bytes);
- close(fd);
- return amt == -1 ? -errno : 0;
- } else {
- if (already_warned == 0) {
- ALOGE("write_int failed to open %s\n", path);
- already_warned = 1;
- }
- return -errno;
- }
-}
-
-static int rgb_to_brightness(struct light_state_t const* state)
-{
- int color = state->color & 0x00ffffff;
-
- return ((77 * ((color >> 16) & 0x00ff))
- + (150 * ((color >> 8) & 0x00ff)) + (29 * (color & 0x00ff))) >> 8;
-}
-
-#if TEST_COMPLEX_CFG
-void simple_recursion(int recursion) {
- if (recursion == 0) return;
- ALOGE("simple_recursion %d", recursion);
- simple_recursion(recursion - 1);
-}
-#endif
-
-static int set_light_backlight(struct light_device_t* dev __unused,
- struct light_state_t const* state)
-{
- int err = 0;
- int brightness = rgb_to_brightness(state);
-
- pthread_mutex_lock(&g_lock);
- err = write_int(LCD_FILE, brightness);
- pthread_mutex_unlock(&g_lock);
-#if TEST_COMPLEX_CFG
- simple_recursion(10);
-#endif
-
- return err;
-}
-
-static int set_light_locked(struct light_state_t const* state, int type __unused)
-{
- int red, green, blue;
- int onMS, offMS;
- unsigned int colorRGB;
-
- switch (state->flashMode) {
- case LIGHT_FLASH_TIMED:
- case LIGHT_FLASH_HARDWARE:
- onMS = state->flashOnMS;
- offMS = state->flashOffMS;
- break;
- case LIGHT_FLASH_NONE:
- default:
- onMS = 0;
- offMS = 0;
- break;
- }
-
- colorRGB = state->color;
-
-#if DEBUG
- ALOGD("set_light_locked mode %d, colorRGB=%08X, onMS=%d, offMS=%d\n",
- state->flashMode, colorRGB, onMS, offMS);
-#endif
-
- red = (colorRGB >> 16) & 0xFF;
- green = (colorRGB >> 8) & 0xFF;
- blue = colorRGB & 0xFF;
-
- // due to limitation of driver
- if (onMS == 0) {
- red = 0;
- green = 0;
- blue = 0;
- }
-
- write_int(RGB_LOCKED_FILE, 0);
-
- write_int(RED_LED_FILE, red);
- write_int(GREEN_LED_FILE, green);
- write_int(BLUE_LED_FILE, blue);
-
- write_on_off(RED_TIMEOUT_FILE, onMS, offMS);
- write_on_off(GREEN_TIMEOUT_FILE, onMS, offMS);
- write_on_off(BLUE_TIMEOUT_FILE, onMS, offMS);
-
- write_int(RGB_LOCKED_FILE, 1);
-
- return 0;
-}
-
-static int set_light_notifications(struct light_device_t* dev __unused,
- struct light_state_t const* state)
-{
- pthread_mutex_lock(&g_lock);
- set_light_locked(state, 0);
- pthread_mutex_unlock(&g_lock);
-
- return 0;
-}
-
-static int set_light_attention(struct light_device_t* dev __unused,
- struct light_state_t const* state)
-{
- pthread_mutex_lock(&g_lock);
- set_light_locked(state, 1);
- pthread_mutex_unlock(&g_lock);
-
- return 0;
-}
-
-
-/** Close the lights device */
-static int close_lights(struct light_device_t *dev)
-{
- if (dev)
- free(dev);
-
- return 0;
-}
-
-/******************************************************************************/
-
-/**
- * module methods
- */
-
-/** Open a new instance of a lights device using name */
-static int open_lights(const struct hw_module_t* module, char const* name,
- struct hw_device_t** device)
-{
- int (*set_light)(struct light_device_t* dev,
- struct light_state_t const* state);
-
- if (!strcmp(LIGHT_ID_BACKLIGHT, name))
- set_light = set_light_backlight;
- else if (!strcmp(LIGHT_ID_NOTIFICATIONS, name))
- set_light = set_light_notifications;
- else if (!strcmp(LIGHT_ID_ATTENTION, name))
- set_light = set_light_attention;
- else
- return -EINVAL;
-
- pthread_once(&g_init, init_globals);
-
- struct light_device_t *dev = malloc(sizeof(struct light_device_t));
-
- if(!dev)
- return -ENOMEM;
-
- memset(dev, 0, sizeof(*dev));
-
- dev->common.tag = HARDWARE_DEVICE_TAG;
- dev->common.version = 0;
- dev->common.module = (struct hw_module_t*)module;
- dev->common.close = (int (*)(struct hw_device_t*))close_lights;
- dev->set_light = set_light;
-
- *device = (struct hw_device_t*)dev;
-
- return 0;
-}
-
-static struct hw_module_methods_t lights_module_methods = {
- .open = open_lights,
-};
-
-/*
- * The lights Module
- */
-struct hw_module_t HAL_MODULE_INFO_SYM = {
- .tag = HARDWARE_MODULE_TAG,
- .version_major = 1,
- .version_minor = 0,
- .id = LIGHTS_HARDWARE_MODULE_ID,
- .name = "lights Module (VTS instrumented)",
- .author = "Google, Inc.",
- .methods = &lights_module_methods,
-};
diff --git a/prebuilts/Android.bp b/libvtswidevine/Android.bp
similarity index 84%
rename from prebuilts/Android.bp
rename to libvtswidevine/Android.bp
index 6b2fa36..9edbd09 100644
--- a/prebuilts/Android.bp
+++ b/libvtswidevine/Android.bp
@@ -18,20 +18,20 @@
filegroup {
name: "libvtswidevine-arm-prebuilts",
- srcs: ["libvtswidevine/arm/*.so"],
+ srcs: ["arm/*.so"],
}
filegroup {
name: "libvtswidevine-arm64-prebuilts",
- srcs: ["libvtswidevine/arm64/*.so"],
+ srcs: ["arm64/*.so"],
}
filegroup {
name: "libvtswidevine-x86-prebuilts",
- srcs: ["libvtswidevine/x86/*.so"],
+ srcs: ["x86/*.so"],
}
filegroup {
name: "libvtswidevine-x86_64-prebuilts",
- srcs: ["libvtswidevine/x86_64/*.so"],
+ srcs: ["x86_64/*.so"],
}
diff --git a/prebuilts/libvtswidevine/README b/libvtswidevine/README
similarity index 100%
rename from prebuilts/libvtswidevine/README
rename to libvtswidevine/README
diff --git a/prebuilts/libvtswidevine/arm/libvtswidevine32.so b/libvtswidevine/arm/libvtswidevine32.so
similarity index 100%
rename from prebuilts/libvtswidevine/arm/libvtswidevine32.so
rename to libvtswidevine/arm/libvtswidevine32.so
Binary files differ
diff --git a/prebuilts/libvtswidevine/arm64/libvtswidevine64.so b/libvtswidevine/arm64/libvtswidevine64.so
similarity index 100%
rename from prebuilts/libvtswidevine/arm64/libvtswidevine64.so
rename to libvtswidevine/arm64/libvtswidevine64.so
Binary files differ
diff --git a/prebuilts/libvtswidevine/x86/libvtswidevine32.so b/libvtswidevine/x86/libvtswidevine32.so
similarity index 100%
rename from prebuilts/libvtswidevine/x86/libvtswidevine32.so
rename to libvtswidevine/x86/libvtswidevine32.so
Binary files differ
diff --git a/prebuilts/libvtswidevine/x86_64/libvtswidevine64.so b/libvtswidevine/x86_64/libvtswidevine64.so
similarity index 100%
rename from prebuilts/libvtswidevine/x86_64/libvtswidevine64.so
rename to libvtswidevine/x86_64/libvtswidevine64.so
Binary files differ
diff --git a/proto/Android.bp b/proto/Android.bp
deleted file mode 100644
index dba8a24..0000000
--- a/proto/Android.bp
+++ /dev/null
@@ -1,85 +0,0 @@
-//
-// 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 {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-cc_library_shared {
-
- name: "libvts_multidevice_proto",
- host_supported: true,
- // TODO(b/153609531): remove when no longer needed.
- native_bridge_supported: true,
-
- srcs: [
- "AndroidSystemControlMessage.proto",
- "ComponentSpecificationMessage.proto",
- "VtsProfilingMessage.proto",
- "VtsReportMessage.proto",
- "VtsResourceControllerMessage.proto",
- ],
-
- cflags: [
- "-Wall",
- "-Werror",
- ],
-
- proto: {
- export_proto_headers: true,
- type: "full",
- },
-
- target: {
- android: {
- srcs: ["VtsDriverControlMessage.proto"],
- },
- host: {
- cflags: [
- "-Wno-unused-parameter",
- "-Werror",
- ],
- },
- },
-}
-
-cc_library_shared {
- name: "libvts_proto_fuzzer_proto",
- proto: {
- export_proto_headers: true,
- type: "full",
- },
- srcs: [
- "ExecutionSpecificationMessage.proto",
- ],
- shared_libs: [
- "libprotobuf-cpp-full",
- "libvts_multidevice_proto",
- ],
- cflags: [
- "-Wall",
- "-Werror",
- "-Wno-unused-parameter",
- ],
-}
-
-java_library_host {
- name: "libvts_protos_host",
- srcs: ["**/*.proto"],
- proto: {
- type: "full",
- },
-}
diff --git a/proto/AndroidSystemControlMessage.proto b/proto/AndroidSystemControlMessage.proto
deleted file mode 100644
index f40125e..0000000
--- a/proto/AndroidSystemControlMessage.proto
+++ /dev/null
@@ -1,209 +0,0 @@
-// Copyright 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.
-
-syntax = "proto2";
-
-package android.vts;
-
-import "test/vts/proto/ComponentSpecificationMessage.proto";
-import "test/vts/proto/VtsResourceControllerMessage.proto";
-
-
-// Type of a command.
-enum CommandType {
- UNKNOWN_COMMAND_TYPE = 0;
- // To get a list of available HAL modules.
- LIST_HALS = 1;
- // To set the host information (e.g., callback server port).
- SET_HOST_INFO = 2;
- // To check the health of an agent.
- PING = 3;
-
- // To check whether fuzzer's binder service is available.
- CHECK_DRIVER_SERVICE = 101;
- // To start a fuzzer binary service and select a HAL module.
- LAUNCH_DRIVER_SERVICE = 102;
- // To read the VTS spec of a target component.
- VTS_AGENT_COMMAND_READ_SPECIFICATION = 103;
-
- // To get a list of available functions.
- LIST_APIS = 201;
- // To call a function.
- CALL_API = 202;
- // To get the value of an attribute.
- VTS_AGENT_COMMAND_GET_ATTRIBUTE = 203;
-
- // To execute a shell command;
- VTS_AGENT_COMMAND_EXECUTE_SHELL_COMMAND = 301;
-
- // To request FMQ resource.
- VTS_FMQ_COMMAND = 401;
- // To request hidl_memory resource.
- VTS_HIDL_MEMORY_COMMAND = 402;
- // To request hidl_handle resource.
- VTS_HIDL_HANDLE_COMMAND = 403;
-}
-
-
-// Type of a response.
-enum ResponseCode {
- UNKNOWN_RESPONSE_CODE = 0;
- // successful
- SUCCESS = 1;
- // failed
- FAIL = 2;
-}
-
-
-// VTS driver type.
-enum VtsDriverType {
- UKNOWN_VTS_DRIVER_TYPE = 0;
- // for various HALs.
- VTS_DRIVER_TYPE_HAL_CONVENTIONAL = 1;
- VTS_DRIVER_TYPE_HAL_LEGACY = 2;
- VTS_DRIVER_TYPE_HAL_HIDL = 3;
- VTS_DRIVER_TYPE_HAL_HIDL_WRAPPED_CONVENTIONAL = 4;
-
- // for shared libraries.
- VTS_DRIVER_TYPE_LIB_SHARED = 11;
-
- // for shell.
- VTS_DRIVER_TYPE_SHELL = 21;
-}
-
-
-// To specify a command.
-message AndroidSystemControlCommandMessage {
- // Command type.
- optional CommandType command_type = 1;
-
- // for LIST_HALS
- repeated bytes paths = 1001;
-
- // for SET_HOST_INFO
- optional int32 callback_port = 1101;
-
- // for CHECK_DRIVER_SERVICE
- // the binder service name
- optional bytes service_name = 2001;
-
- // for LAUNCH_DRIVER_SERVICE
- optional VtsDriverType driver_type = 3001;
-
- // The name of a target.
- optional bytes file_path = 3002;
-
- // Whether a target driver binary is 64-bits or 32-bits.
- optional int32 bits = 3003;
-
- // target class
- optional int32 target_class = 3004;
- // target type
- optional int32 target_type = 3005;
- // target version (should be divided by 100) - float has a compatibility issue
- // between C/C++ and python protoc.
- // Deprecated, use target_version_major and target_version_minor instead.
- optional int32 target_version = 3006 [deprecated = true];
-
- // the name of a HAL module to open.
- optional bytes module_name = 3007;
-
- // the package name of a HIDL HAL.
- optional bytes target_package = 3008;
-
- // the name of a target component (currently used for HIDL HALs only).
- optional bytes target_component_name = 3009;
-
- // use two ints to represent major and minor versions separately.
- // HAL major version of the target component (e.g. 1.0 -> 1).
- optional int32 target_version_major = 3010 [default = -1];
- // HAL minor version of the target component (e.g. 1.0 -> 0).
- optional int32 target_version_minor = 3011 [default = -1];
- // Specify if a HAL service is test HAL.
- // Need to add flag TREBLE_TESTING_OVERRIDE=true in environment if it is.
- optional bool is_test_hal = 3012;
-
- // the name of a HW Binder service to use (only needed for HIDL HAL).
- optional bytes hw_binder_service_name = 3021;
-
- // for LIST_APIS
- // none
-
- // for CALL_API and VTS_AGENT_COMMAND_INVOKE_SYSCALL
- optional bytes arg = 4001;
-
- // UID of a caller on the driver-side.
- optional bytes driver_caller_uid = 4101;
-
- // for VTS_AGENT_COMMAND_EXECUTE_SHELL_COMMAND
- repeated bytes shell_command = 5001;
-
- // for specifying requests to FMQ driver
- optional FmqRequestMessage fmq_request = 6001;
- // for specifying requests to hidl_memory driver
- optional HidlMemoryRequestMessage hidl_memory_request = 6002;
- // for specifying requests to hidl_handle driver
- optional HidlHandleRequestMessage hidl_handle_request = 6003;
-}
-
-
-// To specify a response.
-message AndroidSystemControlResponseMessage {
- // Response type.
- optional ResponseCode response_code = 1;
-
- // The reason.
- optional bytes reason = 1001;
-
- // for the found component files.
- repeated bytes file_names = 1002;
-
- // for the found API specification.
- optional bytes spec = 1003;
-
- // for the API call result including result value, profiling data, and
- // coverage measurement data.
- optional bytes result = 1004;
-
- repeated bytes stdout_str = 2001;
- repeated bytes stderr_str = 2002;
- repeated int32 exit_code = 2003;
-
- // read data and return value from FMQ driver
- optional FmqResponseMessage fmq_response = 3001;
- // response from hidl_memory driver
- optional HidlMemoryResponseMessage hidl_memory_response = 3002;
- // response from hidl_handle driver
- optional HidlHandleResponseMessage hidl_handle_response = 3003;
-}
-
-
-// To specify a callback request message for the TCP server.
-message AndroidSystemCallbackRequestMessage {
- // callback id for the message sent to the TCP Server.
- optional bytes id = 1;
-
- // the name of a callback (e.g., <class name>::<method name>).
- optional bytes name = 2;
-
- // args
- repeated VariableSpecificationMessage arg = 11;
-}
-
-
-// To specify a callback response message from the TCP server.
-message AndroidSystemCallbackResponseMessage {
- // Response code in a Callback response from TCP server.
- optional ResponseCode response_code = 1;
-}
diff --git a/proto/AndroidSystemControlMessage_pb2.py b/proto/AndroidSystemControlMessage_pb2.py
deleted file mode 100644
index 8ab0f5f..0000000
--- a/proto/AndroidSystemControlMessage_pb2.py
+++ /dev/null
@@ -1,609 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: AndroidSystemControlMessage.proto
-
-import sys
-_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
-from google.protobuf.internal import enum_type_wrapper
-from google.protobuf import descriptor as _descriptor
-from google.protobuf import message as _message
-from google.protobuf import reflection as _reflection
-from google.protobuf import symbol_database as _symbol_database
-# @@protoc_insertion_point(imports)
-
-_sym_db = _symbol_database.Default()
-
-
-import ComponentSpecificationMessage_pb2 as ComponentSpecificationMessage__pb2
-import VtsResourceControllerMessage_pb2 as VtsResourceControllerMessage__pb2
-
-
-DESCRIPTOR = _descriptor.FileDescriptor(
- name='AndroidSystemControlMessage.proto',
- package='android.vts',
- syntax='proto2',
- serialized_options=None,
- serialized_pb=_b('\n!AndroidSystemControlMessage.proto\x12\x0b\x61ndroid.vts\x1a#ComponentSpecificationMessage.proto\x1a\"VtsResourceControllerMessage.proto\"\x80\x06\n\"AndroidSystemControlCommandMessage\x12.\n\x0c\x63ommand_type\x18\x01 \x01(\x0e\x32\x18.android.vts.CommandType\x12\x0e\n\x05paths\x18\xe9\x07 \x03(\x0c\x12\x16\n\rcallback_port\x18\xcd\x08 \x01(\x05\x12\x15\n\x0cservice_name\x18\xd1\x0f \x01(\x0c\x12\x30\n\x0b\x64river_type\x18\xb9\x17 \x01(\x0e\x32\x1a.android.vts.VtsDriverType\x12\x12\n\tfile_path\x18\xba\x17 \x01(\x0c\x12\r\n\x04\x62its\x18\xbb\x17 \x01(\x05\x12\x15\n\x0ctarget_class\x18\xbc\x17 \x01(\x05\x12\x14\n\x0btarget_type\x18\xbd\x17 \x01(\x05\x12\x1b\n\x0etarget_version\x18\xbe\x17 \x01(\x05\x42\x02\x18\x01\x12\x14\n\x0bmodule_name\x18\xbf\x17 \x01(\x0c\x12\x17\n\x0etarget_package\x18\xc0\x17 \x01(\x0c\x12\x1e\n\x15target_component_name\x18\xc1\x17 \x01(\x0c\x12!\n\x14target_version_major\x18\xc2\x17 \x01(\x05:\x02-1\x12!\n\x14target_version_minor\x18\xc3\x17 \x01(\x05:\x02-1\x12\x14\n\x0bis_test_hal\x18\xc4\x17 \x01(\x08\x12\x1f\n\x16hw_binder_service_name\x18\xcd\x17 \x01(\x0c\x12\x0c\n\x03\x61rg\x18\xa1\x1f \x01(\x0c\x12\x1a\n\x11\x64river_caller_uid\x18\x85 \x01(\x0c\x12\x16\n\rshell_command\x18\x89\' \x03(\x0c\x12\x34\n\x0b\x66mq_request\x18\xf1. \x01(\x0b\x32\x1e.android.vts.FmqRequestMessage\x12\x43\n\x13hidl_memory_request\x18\xf2. \x01(\x0b\x32%.android.vts.HidlMemoryRequestMessage\x12\x43\n\x13hidl_handle_request\x18\xf3. \x01(\x0b\x32%.android.vts.HidlHandleRequestMessage\"\xa1\x03\n#AndroidSystemControlResponseMessage\x12\x30\n\rresponse_code\x18\x01 \x01(\x0e\x32\x19.android.vts.ResponseCode\x12\x0f\n\x06reason\x18\xe9\x07 \x01(\x0c\x12\x13\n\nfile_names\x18\xea\x07 \x03(\x0c\x12\r\n\x04spec\x18\xeb\x07 \x01(\x0c\x12\x0f\n\x06result\x18\xec\x07 \x01(\x0c\x12\x13\n\nstdout_str\x18\xd1\x0f \x03(\x0c\x12\x13\n\nstderr_str\x18\xd2\x0f \x03(\x0c\x12\x12\n\texit_code\x18\xd3\x0f \x03(\x05\x12\x36\n\x0c\x66mq_response\x18\xb9\x17 \x01(\x0b\x32\x1f.android.vts.FmqResponseMessage\x12\x45\n\x14hidl_memory_response\x18\xba\x17 \x01(\x0b\x32&.android.vts.HidlMemoryResponseMessage\x12\x45\n\x14hidl_handle_response\x18\xbb\x17 \x01(\x0b\x32&.android.vts.HidlHandleResponseMessage\"w\n#AndroidSystemCallbackRequestMessage\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\x0c\n\x04name\x18\x02 \x01(\x0c\x12\x36\n\x03\x61rg\x18\x0b \x03(\x0b\x32).android.vts.VariableSpecificationMessage\"X\n$AndroidSystemCallbackResponseMessage\x12\x30\n\rresponse_code\x18\x01 \x01(\x0e\x32\x19.android.vts.ResponseCode*\xf7\x02\n\x0b\x43ommandType\x12\x18\n\x14UNKNOWN_COMMAND_TYPE\x10\x00\x12\r\n\tLIST_HALS\x10\x01\x12\x11\n\rSET_HOST_INFO\x10\x02\x12\x08\n\x04PING\x10\x03\x12\x18\n\x14\x43HECK_DRIVER_SERVICE\x10\x65\x12\x19\n\x15LAUNCH_DRIVER_SERVICE\x10\x66\x12(\n$VTS_AGENT_COMMAND_READ_SPECIFICATION\x10g\x12\x0e\n\tLIST_APIS\x10\xc9\x01\x12\r\n\x08\x43\x41LL_API\x10\xca\x01\x12$\n\x1fVTS_AGENT_COMMAND_GET_ATTRIBUTE\x10\xcb\x01\x12,\n\'VTS_AGENT_COMMAND_EXECUTE_SHELL_COMMAND\x10\xad\x02\x12\x14\n\x0fVTS_FMQ_COMMAND\x10\x91\x03\x12\x1c\n\x17VTS_HIDL_MEMORY_COMMAND\x10\x92\x03\x12\x1c\n\x17VTS_HIDL_HANDLE_COMMAND\x10\x93\x03*@\n\x0cResponseCode\x12\x19\n\x15UNKNOWN_RESPONSE_CODE\x10\x00\x12\x0b\n\x07SUCCESS\x10\x01\x12\x08\n\x04\x46\x41IL\x10\x02*\xfd\x01\n\rVtsDriverType\x12\x1a\n\x16UKNOWN_VTS_DRIVER_TYPE\x10\x00\x12$\n VTS_DRIVER_TYPE_HAL_CONVENTIONAL\x10\x01\x12\x1e\n\x1aVTS_DRIVER_TYPE_HAL_LEGACY\x10\x02\x12\x1c\n\x18VTS_DRIVER_TYPE_HAL_HIDL\x10\x03\x12\x31\n-VTS_DRIVER_TYPE_HAL_HIDL_WRAPPED_CONVENTIONAL\x10\x04\x12\x1e\n\x1aVTS_DRIVER_TYPE_LIB_SHARED\x10\x0b\x12\x19\n\x15VTS_DRIVER_TYPE_SHELL\x10\x15')
- ,
- dependencies=[ComponentSpecificationMessage__pb2.DESCRIPTOR,VtsResourceControllerMessage__pb2.DESCRIPTOR,])
-
-_COMMANDTYPE = _descriptor.EnumDescriptor(
- name='CommandType',
- full_name='android.vts.CommandType',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='UNKNOWN_COMMAND_TYPE', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='LIST_HALS', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='SET_HOST_INFO', index=2, number=2,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='PING', index=3, number=3,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='CHECK_DRIVER_SERVICE', index=4, number=101,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='LAUNCH_DRIVER_SERVICE', index=5, number=102,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_AGENT_COMMAND_READ_SPECIFICATION', index=6, number=103,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='LIST_APIS', index=7, number=201,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='CALL_API', index=8, number=202,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_AGENT_COMMAND_GET_ATTRIBUTE', index=9, number=203,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_AGENT_COMMAND_EXECUTE_SHELL_COMMAND', index=10, number=301,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_FMQ_COMMAND', index=11, number=401,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_HIDL_MEMORY_COMMAND', index=12, number=402,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_HIDL_HANDLE_COMMAND', index=13, number=403,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=1526,
- serialized_end=1901,
-)
-_sym_db.RegisterEnumDescriptor(_COMMANDTYPE)
-
-CommandType = enum_type_wrapper.EnumTypeWrapper(_COMMANDTYPE)
-_RESPONSECODE = _descriptor.EnumDescriptor(
- name='ResponseCode',
- full_name='android.vts.ResponseCode',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='UNKNOWN_RESPONSE_CODE', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='SUCCESS', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='FAIL', index=2, number=2,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=1903,
- serialized_end=1967,
-)
-_sym_db.RegisterEnumDescriptor(_RESPONSECODE)
-
-ResponseCode = enum_type_wrapper.EnumTypeWrapper(_RESPONSECODE)
-_VTSDRIVERTYPE = _descriptor.EnumDescriptor(
- name='VtsDriverType',
- full_name='android.vts.VtsDriverType',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='UKNOWN_VTS_DRIVER_TYPE', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_DRIVER_TYPE_HAL_CONVENTIONAL', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_DRIVER_TYPE_HAL_LEGACY', index=2, number=2,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_DRIVER_TYPE_HAL_HIDL', index=3, number=3,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_DRIVER_TYPE_HAL_HIDL_WRAPPED_CONVENTIONAL', index=4, number=4,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_DRIVER_TYPE_LIB_SHARED', index=5, number=11,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_DRIVER_TYPE_SHELL', index=6, number=21,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=1970,
- serialized_end=2223,
-)
-_sym_db.RegisterEnumDescriptor(_VTSDRIVERTYPE)
-
-VtsDriverType = enum_type_wrapper.EnumTypeWrapper(_VTSDRIVERTYPE)
-UNKNOWN_COMMAND_TYPE = 0
-LIST_HALS = 1
-SET_HOST_INFO = 2
-PING = 3
-CHECK_DRIVER_SERVICE = 101
-LAUNCH_DRIVER_SERVICE = 102
-VTS_AGENT_COMMAND_READ_SPECIFICATION = 103
-LIST_APIS = 201
-CALL_API = 202
-VTS_AGENT_COMMAND_GET_ATTRIBUTE = 203
-VTS_AGENT_COMMAND_EXECUTE_SHELL_COMMAND = 301
-VTS_FMQ_COMMAND = 401
-VTS_HIDL_MEMORY_COMMAND = 402
-VTS_HIDL_HANDLE_COMMAND = 403
-UNKNOWN_RESPONSE_CODE = 0
-SUCCESS = 1
-FAIL = 2
-UKNOWN_VTS_DRIVER_TYPE = 0
-VTS_DRIVER_TYPE_HAL_CONVENTIONAL = 1
-VTS_DRIVER_TYPE_HAL_LEGACY = 2
-VTS_DRIVER_TYPE_HAL_HIDL = 3
-VTS_DRIVER_TYPE_HAL_HIDL_WRAPPED_CONVENTIONAL = 4
-VTS_DRIVER_TYPE_LIB_SHARED = 11
-VTS_DRIVER_TYPE_SHELL = 21
-
-
-
-_ANDROIDSYSTEMCONTROLCOMMANDMESSAGE = _descriptor.Descriptor(
- name='AndroidSystemControlCommandMessage',
- full_name='android.vts.AndroidSystemControlCommandMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='command_type', full_name='android.vts.AndroidSystemControlCommandMessage.command_type', index=0,
- number=1, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='paths', full_name='android.vts.AndroidSystemControlCommandMessage.paths', index=1,
- number=1001, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='callback_port', full_name='android.vts.AndroidSystemControlCommandMessage.callback_port', index=2,
- number=1101, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='service_name', full_name='android.vts.AndroidSystemControlCommandMessage.service_name', index=3,
- number=2001, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='driver_type', full_name='android.vts.AndroidSystemControlCommandMessage.driver_type', index=4,
- number=3001, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='file_path', full_name='android.vts.AndroidSystemControlCommandMessage.file_path', index=5,
- number=3002, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='bits', full_name='android.vts.AndroidSystemControlCommandMessage.bits', index=6,
- number=3003, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='target_class', full_name='android.vts.AndroidSystemControlCommandMessage.target_class', index=7,
- number=3004, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='target_type', full_name='android.vts.AndroidSystemControlCommandMessage.target_type', index=8,
- number=3005, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='target_version', full_name='android.vts.AndroidSystemControlCommandMessage.target_version', index=9,
- number=3006, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=_b('\030\001'), file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='module_name', full_name='android.vts.AndroidSystemControlCommandMessage.module_name', index=10,
- number=3007, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='target_package', full_name='android.vts.AndroidSystemControlCommandMessage.target_package', index=11,
- number=3008, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='target_component_name', full_name='android.vts.AndroidSystemControlCommandMessage.target_component_name', index=12,
- number=3009, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='target_version_major', full_name='android.vts.AndroidSystemControlCommandMessage.target_version_major', index=13,
- number=3010, type=5, cpp_type=1, label=1,
- has_default_value=True, default_value=-1,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='target_version_minor', full_name='android.vts.AndroidSystemControlCommandMessage.target_version_minor', index=14,
- number=3011, type=5, cpp_type=1, label=1,
- has_default_value=True, default_value=-1,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='is_test_hal', full_name='android.vts.AndroidSystemControlCommandMessage.is_test_hal', index=15,
- number=3012, type=8, cpp_type=7, label=1,
- has_default_value=False, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hw_binder_service_name', full_name='android.vts.AndroidSystemControlCommandMessage.hw_binder_service_name', index=16,
- number=3021, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='arg', full_name='android.vts.AndroidSystemControlCommandMessage.arg', index=17,
- number=4001, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='driver_caller_uid', full_name='android.vts.AndroidSystemControlCommandMessage.driver_caller_uid', index=18,
- number=4101, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='shell_command', full_name='android.vts.AndroidSystemControlCommandMessage.shell_command', index=19,
- number=5001, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='fmq_request', full_name='android.vts.AndroidSystemControlCommandMessage.fmq_request', index=20,
- number=6001, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hidl_memory_request', full_name='android.vts.AndroidSystemControlCommandMessage.hidl_memory_request', index=21,
- number=6002, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hidl_handle_request', full_name='android.vts.AndroidSystemControlCommandMessage.hidl_handle_request', index=22,
- number=6003, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=124,
- serialized_end=892,
-)
-
-
-_ANDROIDSYSTEMCONTROLRESPONSEMESSAGE = _descriptor.Descriptor(
- name='AndroidSystemControlResponseMessage',
- full_name='android.vts.AndroidSystemControlResponseMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='response_code', full_name='android.vts.AndroidSystemControlResponseMessage.response_code', index=0,
- number=1, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='reason', full_name='android.vts.AndroidSystemControlResponseMessage.reason', index=1,
- number=1001, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='file_names', full_name='android.vts.AndroidSystemControlResponseMessage.file_names', index=2,
- number=1002, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='spec', full_name='android.vts.AndroidSystemControlResponseMessage.spec', index=3,
- number=1003, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='result', full_name='android.vts.AndroidSystemControlResponseMessage.result', index=4,
- number=1004, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='stdout_str', full_name='android.vts.AndroidSystemControlResponseMessage.stdout_str', index=5,
- number=2001, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='stderr_str', full_name='android.vts.AndroidSystemControlResponseMessage.stderr_str', index=6,
- number=2002, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='exit_code', full_name='android.vts.AndroidSystemControlResponseMessage.exit_code', index=7,
- number=2003, type=5, cpp_type=1, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='fmq_response', full_name='android.vts.AndroidSystemControlResponseMessage.fmq_response', index=8,
- number=3001, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hidl_memory_response', full_name='android.vts.AndroidSystemControlResponseMessage.hidl_memory_response', index=9,
- number=3002, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hidl_handle_response', full_name='android.vts.AndroidSystemControlResponseMessage.hidl_handle_response', index=10,
- number=3003, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=895,
- serialized_end=1312,
-)
-
-
-_ANDROIDSYSTEMCALLBACKREQUESTMESSAGE = _descriptor.Descriptor(
- name='AndroidSystemCallbackRequestMessage',
- full_name='android.vts.AndroidSystemCallbackRequestMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='id', full_name='android.vts.AndroidSystemCallbackRequestMessage.id', index=0,
- number=1, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='name', full_name='android.vts.AndroidSystemCallbackRequestMessage.name', index=1,
- number=2, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='arg', full_name='android.vts.AndroidSystemCallbackRequestMessage.arg', index=2,
- number=11, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=1314,
- serialized_end=1433,
-)
-
-
-_ANDROIDSYSTEMCALLBACKRESPONSEMESSAGE = _descriptor.Descriptor(
- name='AndroidSystemCallbackResponseMessage',
- full_name='android.vts.AndroidSystemCallbackResponseMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='response_code', full_name='android.vts.AndroidSystemCallbackResponseMessage.response_code', index=0,
- number=1, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=1435,
- serialized_end=1523,
-)
-
-_ANDROIDSYSTEMCONTROLCOMMANDMESSAGE.fields_by_name['command_type'].enum_type = _COMMANDTYPE
-_ANDROIDSYSTEMCONTROLCOMMANDMESSAGE.fields_by_name['driver_type'].enum_type = _VTSDRIVERTYPE
-_ANDROIDSYSTEMCONTROLCOMMANDMESSAGE.fields_by_name['fmq_request'].message_type = VtsResourceControllerMessage__pb2._FMQREQUESTMESSAGE
-_ANDROIDSYSTEMCONTROLCOMMANDMESSAGE.fields_by_name['hidl_memory_request'].message_type = VtsResourceControllerMessage__pb2._HIDLMEMORYREQUESTMESSAGE
-_ANDROIDSYSTEMCONTROLCOMMANDMESSAGE.fields_by_name['hidl_handle_request'].message_type = VtsResourceControllerMessage__pb2._HIDLHANDLEREQUESTMESSAGE
-_ANDROIDSYSTEMCONTROLRESPONSEMESSAGE.fields_by_name['response_code'].enum_type = _RESPONSECODE
-_ANDROIDSYSTEMCONTROLRESPONSEMESSAGE.fields_by_name['fmq_response'].message_type = VtsResourceControllerMessage__pb2._FMQRESPONSEMESSAGE
-_ANDROIDSYSTEMCONTROLRESPONSEMESSAGE.fields_by_name['hidl_memory_response'].message_type = VtsResourceControllerMessage__pb2._HIDLMEMORYRESPONSEMESSAGE
-_ANDROIDSYSTEMCONTROLRESPONSEMESSAGE.fields_by_name['hidl_handle_response'].message_type = VtsResourceControllerMessage__pb2._HIDLHANDLERESPONSEMESSAGE
-_ANDROIDSYSTEMCALLBACKREQUESTMESSAGE.fields_by_name['arg'].message_type = ComponentSpecificationMessage__pb2._VARIABLESPECIFICATIONMESSAGE
-_ANDROIDSYSTEMCALLBACKRESPONSEMESSAGE.fields_by_name['response_code'].enum_type = _RESPONSECODE
-DESCRIPTOR.message_types_by_name['AndroidSystemControlCommandMessage'] = _ANDROIDSYSTEMCONTROLCOMMANDMESSAGE
-DESCRIPTOR.message_types_by_name['AndroidSystemControlResponseMessage'] = _ANDROIDSYSTEMCONTROLRESPONSEMESSAGE
-DESCRIPTOR.message_types_by_name['AndroidSystemCallbackRequestMessage'] = _ANDROIDSYSTEMCALLBACKREQUESTMESSAGE
-DESCRIPTOR.message_types_by_name['AndroidSystemCallbackResponseMessage'] = _ANDROIDSYSTEMCALLBACKRESPONSEMESSAGE
-DESCRIPTOR.enum_types_by_name['CommandType'] = _COMMANDTYPE
-DESCRIPTOR.enum_types_by_name['ResponseCode'] = _RESPONSECODE
-DESCRIPTOR.enum_types_by_name['VtsDriverType'] = _VTSDRIVERTYPE
-_sym_db.RegisterFileDescriptor(DESCRIPTOR)
-
-AndroidSystemControlCommandMessage = _reflection.GeneratedProtocolMessageType('AndroidSystemControlCommandMessage', (_message.Message,), {
- 'DESCRIPTOR' : _ANDROIDSYSTEMCONTROLCOMMANDMESSAGE,
- '__module__' : 'AndroidSystemControlMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.AndroidSystemControlCommandMessage)
- })
-_sym_db.RegisterMessage(AndroidSystemControlCommandMessage)
-
-AndroidSystemControlResponseMessage = _reflection.GeneratedProtocolMessageType('AndroidSystemControlResponseMessage', (_message.Message,), {
- 'DESCRIPTOR' : _ANDROIDSYSTEMCONTROLRESPONSEMESSAGE,
- '__module__' : 'AndroidSystemControlMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.AndroidSystemControlResponseMessage)
- })
-_sym_db.RegisterMessage(AndroidSystemControlResponseMessage)
-
-AndroidSystemCallbackRequestMessage = _reflection.GeneratedProtocolMessageType('AndroidSystemCallbackRequestMessage', (_message.Message,), {
- 'DESCRIPTOR' : _ANDROIDSYSTEMCALLBACKREQUESTMESSAGE,
- '__module__' : 'AndroidSystemControlMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.AndroidSystemCallbackRequestMessage)
- })
-_sym_db.RegisterMessage(AndroidSystemCallbackRequestMessage)
-
-AndroidSystemCallbackResponseMessage = _reflection.GeneratedProtocolMessageType('AndroidSystemCallbackResponseMessage', (_message.Message,), {
- 'DESCRIPTOR' : _ANDROIDSYSTEMCALLBACKRESPONSEMESSAGE,
- '__module__' : 'AndroidSystemControlMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.AndroidSystemCallbackResponseMessage)
- })
-_sym_db.RegisterMessage(AndroidSystemCallbackResponseMessage)
-
-
-_ANDROIDSYSTEMCONTROLCOMMANDMESSAGE.fields_by_name['target_version']._options = None
-# @@protoc_insertion_point(module_scope)
diff --git a/proto/ComponentSpecificationMessage.proto b/proto/ComponentSpecificationMessage.proto
deleted file mode 100644
index 7a72c49..0000000
--- a/proto/ComponentSpecificationMessage.proto
+++ /dev/null
@@ -1,593 +0,0 @@
-// Copyright 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.
-
-syntax = "proto2";
-
-package android.vts;
-option java_package = "com.android.vts.proto";
-option java_outer_classname = "VtsComponentSpecificationMessage";
-
-// Class of a target component.
-enum ComponentClass {
- UNKNOWN_CLASS = 0;
- // For a HAL shared library. Deprecated.
- HAL_CONVENTIONAL = 1;
- // For a submodule of a shared library HAL. Deprecated.
- HAL_CONVENTIONAL_SUBMODULE = 2;
- // For a legacy HAL. Deprecated.
- HAL_LEGACY = 3;
- // For a HAL which uses HIDL (HAL Interface Definition Language).
- HAL_HIDL = 4;
- // For a HAL which uses HIDL (HAL Interface Definition Language).
- HAL_HIDL_WRAPPED_CONVENTIONAL = 5;
-
- // For a shared library which is not a HAL (e.g., standard library).
- LIB_SHARED = 11;
-
- // For an OS kernel.
- KERNEL = 21;
- // For an OS kernel module.
- KERNEL_MODULE = 22;
-}
-
-
-// Type of a target component.
-enum ComponentType {
- UNKNOWN_TYPE = 0;
- // For an audio submodule.
- AUDIO = 1;
- // For a camera submodule.
- CAMERA = 2;
- // For a GPS submodule.
- GPS = 3;
- // For a Lights sensor submodule.
- LIGHT = 4;
- // For a WiFi submodule.
- WIFI = 5;
- // For a mobile networking submodule.
- MOBILE = 6;
- // For a WiFi submodule.
- BLUETOOTH = 7;
- // For a NFC submodule.
- NFC = 8;
- // For a power HAL.
- POWER = 9;
- // For a mem track HAL.
- MEMTRACK = 10;
- // For a biometrics fingerprint HAL.
- BFP = 11;
- // For a vibrator submodule.
- VIBRATOR = 12;
- // For a thermal submodule.
- THERMAL = 13;
- // For a tv_input HAL.
- TV_INPUT = 14;
- // For a tv hdmi_cec submodule
- TV_CEC = 15;
- // For sensors submodule
- SENSORS = 16;
- // For a vehicle submodule
- VEHICLE = 17;
- // For a VR submodule.
- VR = 18;
- // For a graphics allocator submodule.
- GRAPHICS_ALLOCATOR = 19;
- // For a graphics mapper submodule.
- GRAPHICS_MAPPER = 20;
- // For a radio submodule
- RADIO = 21;
- // For the context hub HAL.
- CONTEXTHUB = 22;
- // For a graphics composer submodule.
- GRAPHICS_COMPOSER = 23;
- // For a media omx submodule.
- MEDIA_OMX = 24;
- // For msgq test HAL.
- TESTS_MSGQ = 25;
- // For memory test HAL.
- TESTS_MEMORY = 26;
- // For dumpstate HAL (a lazy HAL, for debugging).
- DUMPSTATE = 27;
-
- // for bionic's libm
- BIONIC_LIBM = 1001;
-
- // for bionic's libc
- BIONIC_LIBC = 1002;
-
- // for VNDK's libcutils
- VNDK_LIBCUTILS = 1101;
-
- // for OS kernel's system call.
- SYSCALL = 2001;
-}
-
-
-// Type of a variable.
-enum VariableType {
- UNKNOWN_VARIABLE_TYPE = 0;
- TYPE_PREDEFINED = 1;
- TYPE_SCALAR = 2;
- TYPE_STRING = 3;
- TYPE_ENUM = 4;
- TYPE_ARRAY = 5;
- TYPE_VECTOR = 6;
- TYPE_STRUCT = 7;
- // for conventional HALs, to keep a data structure with one or multiple
- // callback functions.
- TYPE_FUNCTION_POINTER = 8;
- TYPE_VOID = 9;
- TYPE_HIDL_CALLBACK = 10;
- TYPE_SUBMODULE = 11;
- TYPE_UNION = 12;
- TYPE_HIDL_INTERFACE = 13;
- TYPE_HANDLE = 14;
- // for an enum whose every enumerator value is a number which is power of 2.
- TYPE_MASK = 15;
- // for hidl_memory type
- TYPE_HIDL_MEMORY = 16;
- // for pointer type
- TYPE_POINTER = 17;
- // for FMQ types
- TYPE_FMQ_SYNC = 18;
- TYPE_FMQ_UNSYNC = 19;
- // for HIDL ref<>, a restricted native pointer type.
- TYPE_REF = 20;
- // similar to TYPE_UNION, but support runtime type check.
- TYPE_SAFE_UNION = 21;
-}
-
-
-// Type of a target processor architecture.
-enum TargetArch {
- UNKNOWN_TARGET_ARCH = 0;
- TARGET_ARCH_ARM = 1;
- TARGET_ARCH_ARM64 = 2;
-}
-
-
-// To specify a call flow event.
-message CallFlowSpecificationMessage {
- // true if for a function call event.
- optional bool entry = 1 [default = false];
- // true if for an exit event from a function.
- optional bool exit = 2 [default = false];
- // a list of functions that can be called right after this event.
- repeated bytes next = 11;
- // a list of functions that can be called right before this event.
- repeated bytes prev = 12;
-}
-
-
-// To specify the measured native code coverage raw data.
-message NativeCodeCoverageRawDataMessage {
- // gcno file path.
- optional bytes file_path = 1;
-
- // content of a gcda file.
- optional bytes gcda = 11;
-}
-
-
-// To specify an API call to an interface.
-message FunctionCallMessage {
- // Name of the interface. Not required if hal_driver_id is set.
- // Currently only used by fuzzer.
- optional bytes hidl_interface_name = 1;
-
- // HAL driver ID, if set (e.g., >0), use the given driver_id to get the
- // corresponding driver instance; otherwise, create a new driver based
- // on the component info (package, version etc.)
- optional int32 hal_driver_id = 11 [default = -1];
-
- // Component class, e.g., HIDL HAL or Conventional HAL.
- optional ComponentClass component_class = 21;
- // Component type, e.g., BLUETOOTH, used for Conventional HAL only.
- optional ComponentType component_type = 22;
- // Component version (e.g., 1.0).
- // Deprecated, use component_type_version_major and component_type_version_minor instead.
- optional bytes component_type_version = 23 [deprecated = true];
- // Component name (e.g., INfc), used for HIDL HALs only.
- optional bytes component_name = 24;
- // Component package name (e.g., android.hardware.nfc).
- optional bytes package_name = 25;
- // Component major and minor versions stored separately.
- // HAL major version of component (e.g. 1.0 -> 1).
- optional int32 component_type_version_major = 26 [default = -1];
- // HAL minor version of component (e.g. 1.0 -> 0).
- optional int32 component_type_version_minor = 27 [default = -1];
-
- // Specifies API function and inputs.
- optional FunctionSpecificationMessage api = 100;
-}
-
-// To specify a function.
-message FunctionSpecificationMessage {
- // the function name.
- optional bytes name = 1;
-
- // the submodule name.
- optional bytes submodule_name = 2;
-
- // the HIDL interface ID used to call an API of another nested interface
- // using a VTS HAL driver (for HIDL HAL). 0 for the main interface.
- optional int32 hidl_interface_id = 3;
-
- // whether the function is inherited from another class.
- optional bool is_inherited = 4;
-
- // data type of the return value (for legacy HALs and shared libraries).
- optional VariableSpecificationMessage return_type = 11;
-
- // data type of the return value (for HIDL HALs).
- repeated VariableSpecificationMessage return_type_hidl = 12;
-
- // used to pass the spec of a found HAL_CONVENTIONAL_SUBMODULE to the host.
- optional ComponentSpecificationMessage return_type_submodule_spec = 13;
-
- // a list of arguments.
- repeated VariableSpecificationMessage arg = 21;
-
- // hidl annotation fields {
-
- // a specification of the call flows of the function.
- repeated CallFlowSpecificationMessage callflow = 31;
- // if true, will not be fuzz tested.
- optional bool do_not_fuzz = 32 [default = false];
-
- // } hidl annotation fields
-
- // whether it is a callback.
- optional bool is_callback = 41 [deprecated = true];
-
- // when it is a callback.
- optional FunctionPointerSpecificationMessage function_pointer = 42;
-
- // profiling data.
- repeated float profiling_data = 101;
-
- // measured processed coverage data.
- repeated uint32 processed_coverage_data = 201;
-
- // measured raw coverage data.
- repeated NativeCodeCoverageRawDataMessage raw_coverage_data = 202;
-
- // not a user-provided variable. used by the frameworks to tell the sub
- // struct hierarchy.
- optional bytes parent_path = 301;
-
- // to specify a syscall number.
- optional uint32 syscall_number = 401;
-}
-
-
-// To keep the value of a scalar variable.
-message ScalarDataValueMessage {
- optional bool bool_t = 1;
-
- optional int32 int8_t = 11;
- optional uint32 uint8_t = 12;
-
- optional int32 char = 13;
- optional uint32 uchar = 14;
-
- optional int32 int16_t = 21;
- optional uint32 uint16_t = 22;
-
- optional int32 int32_t = 31;
- optional uint32 uint32_t = 32;
-
- optional int64 int64_t = 41;
- optional uint64 uint64_t = 42;
-
- optional float float_t = 101;
- optional double double_t = 102;
-
- optional uint32 pointer = 201;
- optional uint32 opaque = 202;
- optional uint32 void_pointer = 211;
- optional uint32 char_pointer = 212;
- optional uint32 uchar_pointer = 213;
- optional uint32 pointer_pointer = 251;
-}
-
-
-// To keep the specification and value of a function pointer.
-message FunctionPointerSpecificationMessage {
- // used for a function pointer to keep its function name.
- optional bytes function_name = 1;
-
- // actual pointer value.
- optional uint32 address = 11;
- // ID used for VTS RMI (remote method invocation).
- optional bytes id = 21;
-
- // argument(s)
- repeated VariableSpecificationMessage arg = 101;
-
- // data type of the return value (for legacy HALs and shared libraries).
- optional VariableSpecificationMessage return_type = 111;
-}
-
-
-// To keep the value of a string variable.
-message StringDataValueMessage {
- // for actual contents.
- optional bytes message = 1;
-
- // for length in bytes, and usually not required.
- optional uint32 length = 11;
-}
-
-
-// To keep the value of an enum type variable.
-message EnumDataValueMessage {
- // for the enumerator names.
- repeated bytes enumerator = 1;
-
- // for the corresponding values.
- repeated ScalarDataValueMessage scalar_value = 2;
- optional bytes scalar_type = 3;
-}
-
-// To keep the value of a memory variable.
-message MemoryDataValueMessage {
- optional int64 size = 1;
- optional bytes contents = 2;
- // To identify an existing hidl_memory object stored in resource_manager.
- optional int32 mem_id = 3 [default = -1];
- // To record the pointer address of hidl_memory object.
- // We use uint64 to represent the address of the hidl_memory pointer,
- // which allows vtsc to reinterpret the address when caller wants to use
- // an existing hidl_memory object stored in resource_manager.
- // This field is updated by driver_manager when the hidl_memory address
- // is found in memory.
- optional uint64 hidl_mem_address = 4;
-}
-
-// Type of a file descriptor.
-enum FdType {
- FILE_TYPE = 1;
- DIR_TYPE = 2;
- DEV_TYPE = 3;
- PIPE_TYPE = 4;
- SOCKET_TYPE = 5;
- LINK_TYPE = 6;
-}
-
-// To keep the value of a file-descriptor.
-message FdMessage {
- optional FdType type = 1;
- optional uint32 mode = 2;
- optional int32 flags = 3;
- optional bytes file_name = 4;
- // When opening a file in host side, user specifies file
- // access mode in string.
- optional bytes file_mode_str = 5;
- // For shared memory.
- optional MemoryDataValueMessage memory = 6;
-}
-
-// To keep the value of a handle variable.
-message HandleDataValueMessage {
- // sizeof(native_handle_t)
- optional int32 version = 1;
- // number of file-descriptors.
- optional int32 num_fds = 2;
- // number of ints.
- optional int32 num_ints = 3;
- // file-descriptor values.
- repeated FdMessage fd_val = 4;
- // ints values
- repeated int32 int_val = 5;
- // To specify an existing handle object registered in target-side driver.
- // If host side specifies this field, HIDL function calls will retrieve
- // the handle object from target-side driver, instead of creating a new one.
- optional int32 handle_id = 6 [default = -1];
- // To record the pointer address of hidl_handle object.
- // We use uint64 to represent the address of the hidl_handle pointer,
- // which allows vtsc to reinterpret the address when caller wants to use
- // an existing hidl_handle object stored in target-side driver.
- // This field is updated by driver_manager when the hidl_handle address
- // is found in memory.
- optional uint64 hidl_handle_address = 7;
-}
-
-// To specify a function argument or an attribute in general.
-message VariableSpecificationMessage {
- // the variable name. empty if for a type definition.
- optional bytes name = 1;
-
- // the variable type which is one of:
- // TYPE_SCALAR, TYPE_STRING, TYPE_ENUM, TYPE_ARRAY,
- // TYPE_VECTOR, TYPE_STRUCT, TYPE_UNION, TYPE_HIDL_CALLBACK,
- // TYPE_HIDL_INTERFACE, TYPE_HANDLE
- //
- // not yet supported:
- // "template", "typedef", "binder", "parcelable".
- optional VariableType type = 2;
-
- // the actual value(s) for an scalar data type.
- // repeated values for a vector.
- optional ScalarDataValueMessage scalar_value = 101;
- optional bytes scalar_type = 102;
-
- optional StringDataValueMessage string_value = 111;
-
- // for the definition of enum type only.
- // The value of an eunm variable is stored in scalar_value message.
- optional EnumDataValueMessage enum_value = 121;
-
- // for both TYPE_ARRAY (using size field) and TYPE_VECTOR.
- repeated VariableSpecificationMessage vector_value = 131;
- // Length of an array. Also used for TYPE_VECTOR at runtime.
- optional int32 vector_size = 132;
-
- // for sub variables when this's a struct type.
- repeated VariableSpecificationMessage struct_value = 141;
- // the type name of this struct.
- optional bytes struct_type = 142;
-
- // for nested struct type declarations (without actual definitions).
- repeated VariableSpecificationMessage sub_struct = 143;
-
- // for sub variables when this's a union type.
- repeated VariableSpecificationMessage union_value = 151;
- // the type name of this union.
- optional bytes union_type = 152;
-
- // for nested union type declarations (without actual definitions).
- repeated VariableSpecificationMessage sub_union = 153;
-
- // for sub variables when this's a safe_union type.
- repeated VariableSpecificationMessage safe_union_value = 154;
-
- // the runtime type used in the safe union.
- optional VariableType safe_union_type = 155;
-
- // for nested safe_union type declarations.
- repeated VariableSpecificationMessage sub_safe_union = 156;
-
- // for the definition/value of TYPE_FMQ_SYNC and TYPE_FMQ_UNSYNC.
- repeated VariableSpecificationMessage fmq_value = 161;
- // for queue identifier of TYPE_FMQ_SYNC and TYPE_FMQ_UNSYNC,
- // when caller wants to use an existing FMQ.
- optional int32 fmq_id = 162 [default = -1];
- // descriptor of an existing queue.
- // The descriptor can be passed in hidl and be used to create new
- // FMQ objects. We use uint64 to represent the address of the descriptor,
- // which allows vtsc to reinterpret the address when callers wants to use
- // an existing FMQ.
- // This field is updated by driver_manager when the descriptor of
- // an queue object is located in memory.
- optional uint64 fmq_desc_address = 163;
-
- // for TYPE_REF.
- optional VariableSpecificationMessage ref_value = 171;
-
- // for TYPE_HIDL_MEMROY.
- optional MemoryDataValueMessage hidl_memory_value =172;
-
- // for TYPE_HANDLE.
- optional HandleDataValueMessage handle_value =181;
-
- // for non HIDL HAL, to use a custom type defined in C/C++.
- optional bytes predefined_type = 201;
-
- // for non HIDL HAL, to set function pointer(s).
- repeated FunctionPointerSpecificationMessage function_pointer = 221;
-
- // for HIDL HAL, to use a HIDL callback instance.
- optional bytes hidl_callback_type = 231;
-
- // for HIDL HAL, to specify the HIDL_INTERFACE ID. ID is used between
- // a VTS driver and other modules (e.g., agent and host-side module).
- optional int32 hidl_interface_id = 241;
-
- // for HIDL HAL, to specify an HIDL interface's client proxy object's
- // pointer value. Passed from a DriverBase instance to the VTS HAL driver
- // framework as a return value of its CallFunction() method. Another use
- // case is when this variable is passed to a DriverBase instance from the
- // VTS HAL driver framework which can get this value from another
- // (potentially nested or main) DriverBase instance.
- optional uint64 hidl_interface_pointer = 242;
-
- // true if the argument is an input (valid only for the top-level message).
- optional bool is_input = 301 [default = true];
- // true if the argument is an output.
- optional bool is_output = 302 [default = false];
- // true if the argument is a constant variable.
- optional bool is_const = 303 [default = false];
- // true if the argument is a struct with one or multiple function pointers.
- optional bool is_callback = 304 [default = false];
-}
-
-
-// To specify a sub-structure.
-message StructSpecificationMessage {
- // the sub-structure's variable name in its parent data structure.
- optional bytes name = 1;
-
- // whether itself a pointer varaible in its parent data structure.
- optional bool is_pointer = 2 [default = false];
-
- // a list of functions contained in the struct.
- repeated FunctionSpecificationMessage api = 1001;
-
- // a list of structures contained in the component.
- repeated StructSpecificationMessage sub_struct = 2001;
-
- // The definitions of custom-defined aggregate types.
- repeated VariableSpecificationMessage attribute = 3001;
-}
-
-
-// To specify an interface of a component
-message InterfaceSpecificationMessage {
- // whether this interface is a HIDL callback.
- optional bool is_hidl_callback = 101 [default = false];
-
- // a list of functions exposed by the component.
- repeated FunctionSpecificationMessage api = 2001;
-
- // The definitions of custom-defined aggregate types.
- repeated VariableSpecificationMessage attribute = 3001;
-
- // a list of structures contained in the component.
- repeated StructSpecificationMessage sub_struct = 4001;
-}
-
-
-// To specify a module (which is logically equivalent to a .hal file in case
-// of a HIDL HAL).
-message ComponentSpecificationMessage {
- // Class, type, and version of a target component.
- optional ComponentClass component_class = 1;
- optional ComponentType component_type = 2;
- // component HAL version (e.g. 1.0).
- // Deprecated, use component_type_version_major and component_type_version_minor instead.
- optional float component_type_version = 3 [deprecated = true];
-
- // The name of a target component (used for HIDL HALs).
- optional bytes component_name = 4;
-
- // for the target processor architecture.
- optional TargetArch target_arch = 5;
-
- // use two ints to represent major and minor versions separately.
- // HAL major version of component (e.g. 1.0 -> 1).
- optional int32 component_type_version_major = 6 [default = -1];
- // HAL minor version of component (e.g. 1.0 -> 0).
- optional int32 component_type_version_minor = 7 [default = -1];
-
- // The package path of a target component (e.g., android.hardware.name).
- // name implies the component_type field.
- optional bytes package = 11;
-
- // The modules to import (e.g., package_path.component_name).
- repeated bytes import = 12;
-
- // The name of original C/C++ data structure
- // (used for conventional and legacy HALs).
- optional bytes original_data_structure_name = 1001;
-
- // a list of headers that need to be imported in order to use the component.
- repeated bytes header = 1002;
-
- // For a .hal file which actually defines an interface.
- optional InterfaceSpecificationMessage interface = 2001;
-
- // For a .hal file which does not defines an interface (e.g., types.hal).
- repeated VariableSpecificationMessage attribute = 2101;
-}
diff --git a/proto/ComponentSpecificationMessage_pb2.py b/proto/ComponentSpecificationMessage_pb2.py
deleted file mode 100644
index 69f8937..0000000
--- a/proto/ComponentSpecificationMessage_pb2.py
+++ /dev/null
@@ -1,1931 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: ComponentSpecificationMessage.proto
-
-import sys
-_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
-from google.protobuf.internal import enum_type_wrapper
-from google.protobuf import descriptor as _descriptor
-from google.protobuf import message as _message
-from google.protobuf import reflection as _reflection
-from google.protobuf import symbol_database as _symbol_database
-# @@protoc_insertion_point(imports)
-
-_sym_db = _symbol_database.Default()
-
-
-
-
-DESCRIPTOR = _descriptor.FileDescriptor(
- name='ComponentSpecificationMessage.proto',
- package='android.vts',
- syntax='proto2',
- serialized_options=_b('\n\025com.android.vts.protoB VtsComponentSpecificationMessage'),
- serialized_pb=_b('\n#ComponentSpecificationMessage.proto\x12\x0b\x61ndroid.vts\"e\n\x1c\x43\x61llFlowSpecificationMessage\x12\x14\n\x05\x65ntry\x18\x01 \x01(\x08:\x05\x66\x61lse\x12\x13\n\x04\x65xit\x18\x02 \x01(\x08:\x05\x66\x61lse\x12\x0c\n\x04next\x18\x0b \x03(\x0c\x12\x0c\n\x04prev\x18\x0c \x03(\x0c\"C\n NativeCodeCoverageRawDataMessage\x12\x11\n\tfile_path\x18\x01 \x01(\x0c\x12\x0c\n\x04gcda\x18\x0b \x01(\x0c\"\x95\x03\n\x13\x46unctionCallMessage\x12\x1b\n\x13hidl_interface_name\x18\x01 \x01(\x0c\x12\x19\n\rhal_driver_id\x18\x0b \x01(\x05:\x02-1\x12\x34\n\x0f\x63omponent_class\x18\x15 \x01(\x0e\x32\x1b.android.vts.ComponentClass\x12\x32\n\x0e\x63omponent_type\x18\x16 \x01(\x0e\x32\x1a.android.vts.ComponentType\x12\"\n\x16\x63omponent_type_version\x18\x17 \x01(\x0c\x42\x02\x18\x01\x12\x16\n\x0e\x63omponent_name\x18\x18 \x01(\x0c\x12\x14\n\x0cpackage_name\x18\x19 \x01(\x0c\x12(\n\x1c\x63omponent_type_version_major\x18\x1a \x01(\x05:\x02-1\x12(\n\x1c\x63omponent_type_version_minor\x18\x1b \x01(\x05:\x02-1\x12\x36\n\x03\x61pi\x18\x64 \x01(\x0b\x32).android.vts.FunctionSpecificationMessage\"\xf4\x05\n\x1c\x46unctionSpecificationMessage\x12\x0c\n\x04name\x18\x01 \x01(\x0c\x12\x16\n\x0esubmodule_name\x18\x02 \x01(\x0c\x12\x19\n\x11hidl_interface_id\x18\x03 \x01(\x05\x12\x14\n\x0cis_inherited\x18\x04 \x01(\x08\x12>\n\x0breturn_type\x18\x0b \x01(\x0b\x32).android.vts.VariableSpecificationMessage\x12\x43\n\x10return_type_hidl\x18\x0c \x03(\x0b\x32).android.vts.VariableSpecificationMessage\x12N\n\x1areturn_type_submodule_spec\x18\r \x01(\x0b\x32*.android.vts.ComponentSpecificationMessage\x12\x36\n\x03\x61rg\x18\x15 \x03(\x0b\x32).android.vts.VariableSpecificationMessage\x12;\n\x08\x63\x61llflow\x18\x1f \x03(\x0b\x32).android.vts.CallFlowSpecificationMessage\x12\x1a\n\x0b\x64o_not_fuzz\x18 \x01(\x08:\x05\x66\x61lse\x12\x17\n\x0bis_callback\x18) \x01(\x08\x42\x02\x18\x01\x12J\n\x10\x66unction_pointer\x18* \x01(\x0b\x32\x30.android.vts.FunctionPointerSpecificationMessage\x12\x16\n\x0eprofiling_data\x18\x65 \x03(\x02\x12 \n\x17processed_coverage_data\x18\xc9\x01 \x03(\r\x12I\n\x11raw_coverage_data\x18\xca\x01 \x03(\x0b\x32-.android.vts.NativeCodeCoverageRawDataMessage\x12\x14\n\x0bparent_path\x18\xad\x02 \x01(\x0c\x12\x17\n\x0esyscall_number\x18\x91\x03 \x01(\r\"\xf5\x02\n\x16ScalarDataValueMessage\x12\x0e\n\x06\x62ool_t\x18\x01 \x01(\x08\x12\x0e\n\x06int8_t\x18\x0b \x01(\x05\x12\x0f\n\x07uint8_t\x18\x0c \x01(\r\x12\x0c\n\x04\x63har\x18\r \x01(\x05\x12\r\n\x05uchar\x18\x0e \x01(\r\x12\x0f\n\x07int16_t\x18\x15 \x01(\x05\x12\x10\n\x08uint16_t\x18\x16 \x01(\r\x12\x0f\n\x07int32_t\x18\x1f \x01(\x05\x12\x10\n\x08uint32_t\x18 \x01(\r\x12\x0f\n\x07int64_t\x18) \x01(\x03\x12\x10\n\x08uint64_t\x18* \x01(\x04\x12\x0f\n\x07\x66loat_t\x18\x65 \x01(\x02\x12\x10\n\x08\x64ouble_t\x18\x66 \x01(\x01\x12\x10\n\x07pointer\x18\xc9\x01 \x01(\r\x12\x0f\n\x06opaque\x18\xca\x01 \x01(\r\x12\x15\n\x0cvoid_pointer\x18\xd3\x01 \x01(\r\x12\x15\n\x0c\x63har_pointer\x18\xd4\x01 \x01(\r\x12\x16\n\ruchar_pointer\x18\xd5\x01 \x01(\r\x12\x18\n\x0fpointer_pointer\x18\xfb\x01 \x01(\r\"\xd1\x01\n#FunctionPointerSpecificationMessage\x12\x15\n\rfunction_name\x18\x01 \x01(\x0c\x12\x0f\n\x07\x61\x64\x64ress\x18\x0b \x01(\r\x12\n\n\x02id\x18\x15 \x01(\x0c\x12\x36\n\x03\x61rg\x18\x65 \x03(\x0b\x32).android.vts.VariableSpecificationMessage\x12>\n\x0breturn_type\x18o \x01(\x0b\x32).android.vts.VariableSpecificationMessage\"9\n\x16StringDataValueMessage\x12\x0f\n\x07message\x18\x01 \x01(\x0c\x12\x0e\n\x06length\x18\x0b \x01(\r\"z\n\x14\x45numDataValueMessage\x12\x12\n\nenumerator\x18\x01 \x03(\x0c\x12\x39\n\x0cscalar_value\x18\x02 \x03(\x0b\x32#.android.vts.ScalarDataValueMessage\x12\x13\n\x0bscalar_type\x18\x03 \x01(\x0c\"f\n\x16MemoryDataValueMessage\x12\x0c\n\x04size\x18\x01 \x01(\x03\x12\x10\n\x08\x63ontents\x18\x02 \x01(\x0c\x12\x12\n\x06mem_id\x18\x03 \x01(\x05:\x02-1\x12\x18\n\x10hidl_mem_address\x18\x04 \x01(\x04\"\xaa\x01\n\tFdMessage\x12!\n\x04type\x18\x01 \x01(\x0e\x32\x13.android.vts.FdType\x12\x0c\n\x04mode\x18\x02 \x01(\r\x12\r\n\x05\x66lags\x18\x03 \x01(\x05\x12\x11\n\tfile_name\x18\x04 \x01(\x0c\x12\x15\n\rfile_mode_str\x18\x05 \x01(\x0c\x12\x33\n\x06memory\x18\x06 \x01(\x0b\x32#.android.vts.MemoryDataValueMessage\"\xb9\x01\n\x16HandleDataValueMessage\x12\x0f\n\x07version\x18\x01 \x01(\x05\x12\x0f\n\x07num_fds\x18\x02 \x01(\x05\x12\x10\n\x08num_ints\x18\x03 \x01(\x05\x12&\n\x06\x66\x64_val\x18\x04 \x03(\x0b\x32\x16.android.vts.FdMessage\x12\x0f\n\x07int_val\x18\x05 \x03(\x05\x12\x15\n\thandle_id\x18\x06 \x01(\x05:\x02-1\x12\x1b\n\x13hidl_handle_address\x18\x07 \x01(\x04\"\xb2\x0b\n\x1cVariableSpecificationMessage\x12\x0c\n\x04name\x18\x01 \x01(\x0c\x12\'\n\x04type\x18\x02 \x01(\x0e\x32\x19.android.vts.VariableType\x12\x39\n\x0cscalar_value\x18\x65 \x01(\x0b\x32#.android.vts.ScalarDataValueMessage\x12\x13\n\x0bscalar_type\x18\x66 \x01(\x0c\x12\x39\n\x0cstring_value\x18o \x01(\x0b\x32#.android.vts.StringDataValueMessage\x12\x35\n\nenum_value\x18y \x01(\x0b\x32!.android.vts.EnumDataValueMessage\x12@\n\x0cvector_value\x18\x83\x01 \x03(\x0b\x32).android.vts.VariableSpecificationMessage\x12\x14\n\x0bvector_size\x18\x84\x01 \x01(\x05\x12@\n\x0cstruct_value\x18\x8d\x01 \x03(\x0b\x32).android.vts.VariableSpecificationMessage\x12\x14\n\x0bstruct_type\x18\x8e\x01 \x01(\x0c\x12>\n\nsub_struct\x18\x8f\x01 \x03(\x0b\x32).android.vts.VariableSpecificationMessage\x12?\n\x0bunion_value\x18\x97\x01 \x03(\x0b\x32).android.vts.VariableSpecificationMessage\x12\x13\n\nunion_type\x18\x98\x01 \x01(\x0c\x12=\n\tsub_union\x18\x99\x01 \x03(\x0b\x32).android.vts.VariableSpecificationMessage\x12\x44\n\x10safe_union_value\x18\x9a\x01 \x03(\x0b\x32).android.vts.VariableSpecificationMessage\x12\x33\n\x0fsafe_union_type\x18\x9b\x01 \x01(\x0e\x32\x19.android.vts.VariableType\x12\x42\n\x0esub_safe_union\x18\x9c\x01 \x03(\x0b\x32).android.vts.VariableSpecificationMessage\x12=\n\tfmq_value\x18\xa1\x01 \x03(\x0b\x32).android.vts.VariableSpecificationMessage\x12\x13\n\x06\x66mq_id\x18\xa2\x01 \x01(\x05:\x02-1\x12\x19\n\x10\x66mq_desc_address\x18\xa3\x01 \x01(\x04\x12=\n\tref_value\x18\xab\x01 \x01(\x0b\x32).android.vts.VariableSpecificationMessage\x12?\n\x11hidl_memory_value\x18\xac\x01 \x01(\x0b\x32#.android.vts.MemoryDataValueMessage\x12:\n\x0chandle_value\x18\xb5\x01 \x01(\x0b\x32#.android.vts.HandleDataValueMessage\x12\x18\n\x0fpredefined_type\x18\xc9\x01 \x01(\x0c\x12K\n\x10\x66unction_pointer\x18\xdd\x01 \x03(\x0b\x32\x30.android.vts.FunctionPointerSpecificationMessage\x12\x1b\n\x12hidl_callback_type\x18\xe7\x01 \x01(\x0c\x12\x1a\n\x11hidl_interface_id\x18\xf1\x01 \x01(\x05\x12\x1f\n\x16hidl_interface_pointer\x18\xf2\x01 \x01(\x04\x12\x17\n\x08is_input\x18\xad\x02 \x01(\x08:\x04true\x12\x19\n\tis_output\x18\xae\x02 \x01(\x08:\x05\x66\x61lse\x12\x18\n\x08is_const\x18\xaf\x02 \x01(\x08:\x05\x66\x61lse\x12\x1b\n\x0bis_callback\x18\xb0\x02 \x01(\x08:\x05\x66\x61lse\"\xfb\x01\n\x1aStructSpecificationMessage\x12\x0c\n\x04name\x18\x01 \x01(\x0c\x12\x19\n\nis_pointer\x18\x02 \x01(\x08:\x05\x66\x61lse\x12\x37\n\x03\x61pi\x18\xe9\x07 \x03(\x0b\x32).android.vts.FunctionSpecificationMessage\x12<\n\nsub_struct\x18\xd1\x0f \x03(\x0b\x32\'.android.vts.StructSpecificationMessage\x12=\n\tattribute\x18\xb9\x17 \x03(\x0b\x32).android.vts.VariableSpecificationMessage\"\xf6\x01\n\x1dInterfaceSpecificationMessage\x12\x1f\n\x10is_hidl_callback\x18\x65 \x01(\x08:\x05\x66\x61lse\x12\x37\n\x03\x61pi\x18\xd1\x0f \x03(\x0b\x32).android.vts.FunctionSpecificationMessage\x12=\n\tattribute\x18\xb9\x17 \x03(\x0b\x32).android.vts.VariableSpecificationMessage\x12<\n\nsub_struct\x18\xa1\x1f \x03(\x0b\x32\'.android.vts.StructSpecificationMessage\"\x9f\x04\n\x1d\x43omponentSpecificationMessage\x12\x34\n\x0f\x63omponent_class\x18\x01 \x01(\x0e\x32\x1b.android.vts.ComponentClass\x12\x32\n\x0e\x63omponent_type\x18\x02 \x01(\x0e\x32\x1a.android.vts.ComponentType\x12\"\n\x16\x63omponent_type_version\x18\x03 \x01(\x02\x42\x02\x18\x01\x12\x16\n\x0e\x63omponent_name\x18\x04 \x01(\x0c\x12,\n\x0btarget_arch\x18\x05 \x01(\x0e\x32\x17.android.vts.TargetArch\x12(\n\x1c\x63omponent_type_version_major\x18\x06 \x01(\x05:\x02-1\x12(\n\x1c\x63omponent_type_version_minor\x18\x07 \x01(\x05:\x02-1\x12\x0f\n\x07package\x18\x0b \x01(\x0c\x12\x0e\n\x06import\x18\x0c \x03(\x0c\x12%\n\x1coriginal_data_structure_name\x18\xe9\x07 \x01(\x0c\x12\x0f\n\x06header\x18\xea\x07 \x03(\x0c\x12>\n\tinterface\x18\xd1\x0f \x01(\x0b\x32*.android.vts.InterfaceSpecificationMessage\x12=\n\tattribute\x18\xb5\x10 \x03(\x0b\x32).android.vts.VariableSpecificationMessage*\xc9\x01\n\x0e\x43omponentClass\x12\x11\n\rUNKNOWN_CLASS\x10\x00\x12\x14\n\x10HAL_CONVENTIONAL\x10\x01\x12\x1e\n\x1aHAL_CONVENTIONAL_SUBMODULE\x10\x02\x12\x0e\n\nHAL_LEGACY\x10\x03\x12\x0c\n\x08HAL_HIDL\x10\x04\x12!\n\x1dHAL_HIDL_WRAPPED_CONVENTIONAL\x10\x05\x12\x0e\n\nLIB_SHARED\x10\x0b\x12\n\n\x06KERNEL\x10\x15\x12\x11\n\rKERNEL_MODULE\x10\x16*\xd9\x03\n\rComponentType\x12\x10\n\x0cUNKNOWN_TYPE\x10\x00\x12\t\n\x05\x41UDIO\x10\x01\x12\n\n\x06\x43\x41MERA\x10\x02\x12\x07\n\x03GPS\x10\x03\x12\t\n\x05LIGHT\x10\x04\x12\x08\n\x04WIFI\x10\x05\x12\n\n\x06MOBILE\x10\x06\x12\r\n\tBLUETOOTH\x10\x07\x12\x07\n\x03NFC\x10\x08\x12\t\n\x05POWER\x10\t\x12\x0c\n\x08MEMTRACK\x10\n\x12\x07\n\x03\x42\x46P\x10\x0b\x12\x0c\n\x08VIBRATOR\x10\x0c\x12\x0b\n\x07THERMAL\x10\r\x12\x0c\n\x08TV_INPUT\x10\x0e\x12\n\n\x06TV_CEC\x10\x0f\x12\x0b\n\x07SENSORS\x10\x10\x12\x0b\n\x07VEHICLE\x10\x11\x12\x06\n\x02VR\x10\x12\x12\x16\n\x12GRAPHICS_ALLOCATOR\x10\x13\x12\x13\n\x0fGRAPHICS_MAPPER\x10\x14\x12\t\n\x05RADIO\x10\x15\x12\x0e\n\nCONTEXTHUB\x10\x16\x12\x15\n\x11GRAPHICS_COMPOSER\x10\x17\x12\r\n\tMEDIA_OMX\x10\x18\x12\x0e\n\nTESTS_MSGQ\x10\x19\x12\x10\n\x0cTESTS_MEMORY\x10\x1a\x12\r\n\tDUMPSTATE\x10\x1b\x12\x10\n\x0b\x42IONIC_LIBM\x10\xe9\x07\x12\x10\n\x0b\x42IONIC_LIBC\x10\xea\x07\x12\x13\n\x0eVNDK_LIBCUTILS\x10\xcd\x08\x12\x0c\n\x07SYSCALL\x10\xd1\x0f*\xb3\x03\n\x0cVariableType\x12\x19\n\x15UNKNOWN_VARIABLE_TYPE\x10\x00\x12\x13\n\x0fTYPE_PREDEFINED\x10\x01\x12\x0f\n\x0bTYPE_SCALAR\x10\x02\x12\x0f\n\x0bTYPE_STRING\x10\x03\x12\r\n\tTYPE_ENUM\x10\x04\x12\x0e\n\nTYPE_ARRAY\x10\x05\x12\x0f\n\x0bTYPE_VECTOR\x10\x06\x12\x0f\n\x0bTYPE_STRUCT\x10\x07\x12\x19\n\x15TYPE_FUNCTION_POINTER\x10\x08\x12\r\n\tTYPE_VOID\x10\t\x12\x16\n\x12TYPE_HIDL_CALLBACK\x10\n\x12\x12\n\x0eTYPE_SUBMODULE\x10\x0b\x12\x0e\n\nTYPE_UNION\x10\x0c\x12\x17\n\x13TYPE_HIDL_INTERFACE\x10\r\x12\x0f\n\x0bTYPE_HANDLE\x10\x0e\x12\r\n\tTYPE_MASK\x10\x0f\x12\x14\n\x10TYPE_HIDL_MEMORY\x10\x10\x12\x10\n\x0cTYPE_POINTER\x10\x11\x12\x11\n\rTYPE_FMQ_SYNC\x10\x12\x12\x13\n\x0fTYPE_FMQ_UNSYNC\x10\x13\x12\x0c\n\x08TYPE_REF\x10\x14\x12\x13\n\x0fTYPE_SAFE_UNION\x10\x15*Q\n\nTargetArch\x12\x17\n\x13UNKNOWN_TARGET_ARCH\x10\x00\x12\x13\n\x0fTARGET_ARCH_ARM\x10\x01\x12\x15\n\x11TARGET_ARCH_ARM64\x10\x02*b\n\x06\x46\x64Type\x12\r\n\tFILE_TYPE\x10\x01\x12\x0c\n\x08\x44IR_TYPE\x10\x02\x12\x0c\n\x08\x44\x45V_TYPE\x10\x03\x12\r\n\tPIPE_TYPE\x10\x04\x12\x0f\n\x0bSOCKET_TYPE\x10\x05\x12\r\n\tLINK_TYPE\x10\x06\x42\x39\n\x15\x63om.android.vts.protoB VtsComponentSpecificationMessage')
-)
-
-_COMPONENTCLASS = _descriptor.EnumDescriptor(
- name='ComponentClass',
- full_name='android.vts.ComponentClass',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='UNKNOWN_CLASS', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='HAL_CONVENTIONAL', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='HAL_CONVENTIONAL_SUBMODULE', index=2, number=2,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='HAL_LEGACY', index=3, number=3,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='HAL_HIDL', index=4, number=4,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='HAL_HIDL_WRAPPED_CONVENTIONAL', index=5, number=5,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='LIB_SHARED', index=6, number=11,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='KERNEL', index=7, number=21,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='KERNEL_MODULE', index=8, number=22,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=5138,
- serialized_end=5339,
-)
-_sym_db.RegisterEnumDescriptor(_COMPONENTCLASS)
-
-ComponentClass = enum_type_wrapper.EnumTypeWrapper(_COMPONENTCLASS)
-_COMPONENTTYPE = _descriptor.EnumDescriptor(
- name='ComponentType',
- full_name='android.vts.ComponentType',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='UNKNOWN_TYPE', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='AUDIO', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='CAMERA', index=2, number=2,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='GPS', index=3, number=3,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='LIGHT', index=4, number=4,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='WIFI', index=5, number=5,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='MOBILE', index=6, number=6,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='BLUETOOTH', index=7, number=7,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='NFC', index=8, number=8,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='POWER', index=9, number=9,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='MEMTRACK', index=10, number=10,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='BFP', index=11, number=11,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VIBRATOR', index=12, number=12,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='THERMAL', index=13, number=13,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TV_INPUT', index=14, number=14,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TV_CEC', index=15, number=15,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='SENSORS', index=16, number=16,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VEHICLE', index=17, number=17,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VR', index=18, number=18,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='GRAPHICS_ALLOCATOR', index=19, number=19,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='GRAPHICS_MAPPER', index=20, number=20,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='RADIO', index=21, number=21,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='CONTEXTHUB', index=22, number=22,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='GRAPHICS_COMPOSER', index=23, number=23,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='MEDIA_OMX', index=24, number=24,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TESTS_MSGQ', index=25, number=25,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TESTS_MEMORY', index=26, number=26,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='DUMPSTATE', index=27, number=27,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='BIONIC_LIBM', index=28, number=1001,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='BIONIC_LIBC', index=29, number=1002,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VNDK_LIBCUTILS', index=30, number=1101,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='SYSCALL', index=31, number=2001,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=5342,
- serialized_end=5815,
-)
-_sym_db.RegisterEnumDescriptor(_COMPONENTTYPE)
-
-ComponentType = enum_type_wrapper.EnumTypeWrapper(_COMPONENTTYPE)
-_VARIABLETYPE = _descriptor.EnumDescriptor(
- name='VariableType',
- full_name='android.vts.VariableType',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='UNKNOWN_VARIABLE_TYPE', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_PREDEFINED', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_SCALAR', index=2, number=2,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_STRING', index=3, number=3,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_ENUM', index=4, number=4,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_ARRAY', index=5, number=5,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_VECTOR', index=6, number=6,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_STRUCT', index=7, number=7,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_FUNCTION_POINTER', index=8, number=8,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_VOID', index=9, number=9,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_HIDL_CALLBACK', index=10, number=10,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_SUBMODULE', index=11, number=11,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_UNION', index=12, number=12,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_HIDL_INTERFACE', index=13, number=13,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_HANDLE', index=14, number=14,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_MASK', index=15, number=15,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_HIDL_MEMORY', index=16, number=16,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_POINTER', index=17, number=17,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_FMQ_SYNC', index=18, number=18,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_FMQ_UNSYNC', index=19, number=19,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_REF', index=20, number=20,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TYPE_SAFE_UNION', index=21, number=21,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=5818,
- serialized_end=6253,
-)
-_sym_db.RegisterEnumDescriptor(_VARIABLETYPE)
-
-VariableType = enum_type_wrapper.EnumTypeWrapper(_VARIABLETYPE)
-_TARGETARCH = _descriptor.EnumDescriptor(
- name='TargetArch',
- full_name='android.vts.TargetArch',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='UNKNOWN_TARGET_ARCH', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TARGET_ARCH_ARM', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TARGET_ARCH_ARM64', index=2, number=2,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=6255,
- serialized_end=6336,
-)
-_sym_db.RegisterEnumDescriptor(_TARGETARCH)
-
-TargetArch = enum_type_wrapper.EnumTypeWrapper(_TARGETARCH)
-_FDTYPE = _descriptor.EnumDescriptor(
- name='FdType',
- full_name='android.vts.FdType',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='FILE_TYPE', index=0, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='DIR_TYPE', index=1, number=2,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='DEV_TYPE', index=2, number=3,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='PIPE_TYPE', index=3, number=4,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='SOCKET_TYPE', index=4, number=5,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='LINK_TYPE', index=5, number=6,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=6338,
- serialized_end=6436,
-)
-_sym_db.RegisterEnumDescriptor(_FDTYPE)
-
-FdType = enum_type_wrapper.EnumTypeWrapper(_FDTYPE)
-UNKNOWN_CLASS = 0
-HAL_CONVENTIONAL = 1
-HAL_CONVENTIONAL_SUBMODULE = 2
-HAL_LEGACY = 3
-HAL_HIDL = 4
-HAL_HIDL_WRAPPED_CONVENTIONAL = 5
-LIB_SHARED = 11
-KERNEL = 21
-KERNEL_MODULE = 22
-UNKNOWN_TYPE = 0
-AUDIO = 1
-CAMERA = 2
-GPS = 3
-LIGHT = 4
-WIFI = 5
-MOBILE = 6
-BLUETOOTH = 7
-NFC = 8
-POWER = 9
-MEMTRACK = 10
-BFP = 11
-VIBRATOR = 12
-THERMAL = 13
-TV_INPUT = 14
-TV_CEC = 15
-SENSORS = 16
-VEHICLE = 17
-VR = 18
-GRAPHICS_ALLOCATOR = 19
-GRAPHICS_MAPPER = 20
-RADIO = 21
-CONTEXTHUB = 22
-GRAPHICS_COMPOSER = 23
-MEDIA_OMX = 24
-TESTS_MSGQ = 25
-TESTS_MEMORY = 26
-DUMPSTATE = 27
-BIONIC_LIBM = 1001
-BIONIC_LIBC = 1002
-VNDK_LIBCUTILS = 1101
-SYSCALL = 2001
-UNKNOWN_VARIABLE_TYPE = 0
-TYPE_PREDEFINED = 1
-TYPE_SCALAR = 2
-TYPE_STRING = 3
-TYPE_ENUM = 4
-TYPE_ARRAY = 5
-TYPE_VECTOR = 6
-TYPE_STRUCT = 7
-TYPE_FUNCTION_POINTER = 8
-TYPE_VOID = 9
-TYPE_HIDL_CALLBACK = 10
-TYPE_SUBMODULE = 11
-TYPE_UNION = 12
-TYPE_HIDL_INTERFACE = 13
-TYPE_HANDLE = 14
-TYPE_MASK = 15
-TYPE_HIDL_MEMORY = 16
-TYPE_POINTER = 17
-TYPE_FMQ_SYNC = 18
-TYPE_FMQ_UNSYNC = 19
-TYPE_REF = 20
-TYPE_SAFE_UNION = 21
-UNKNOWN_TARGET_ARCH = 0
-TARGET_ARCH_ARM = 1
-TARGET_ARCH_ARM64 = 2
-FILE_TYPE = 1
-DIR_TYPE = 2
-DEV_TYPE = 3
-PIPE_TYPE = 4
-SOCKET_TYPE = 5
-LINK_TYPE = 6
-
-
-
-_CALLFLOWSPECIFICATIONMESSAGE = _descriptor.Descriptor(
- name='CallFlowSpecificationMessage',
- full_name='android.vts.CallFlowSpecificationMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='entry', full_name='android.vts.CallFlowSpecificationMessage.entry', index=0,
- number=1, type=8, cpp_type=7, label=1,
- has_default_value=True, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='exit', full_name='android.vts.CallFlowSpecificationMessage.exit', index=1,
- number=2, type=8, cpp_type=7, label=1,
- has_default_value=True, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='next', full_name='android.vts.CallFlowSpecificationMessage.next', index=2,
- number=11, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='prev', full_name='android.vts.CallFlowSpecificationMessage.prev', index=3,
- number=12, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=52,
- serialized_end=153,
-)
-
-
-_NATIVECODECOVERAGERAWDATAMESSAGE = _descriptor.Descriptor(
- name='NativeCodeCoverageRawDataMessage',
- full_name='android.vts.NativeCodeCoverageRawDataMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='file_path', full_name='android.vts.NativeCodeCoverageRawDataMessage.file_path', index=0,
- number=1, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='gcda', full_name='android.vts.NativeCodeCoverageRawDataMessage.gcda', index=1,
- number=11, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=155,
- serialized_end=222,
-)
-
-
-_FUNCTIONCALLMESSAGE = _descriptor.Descriptor(
- name='FunctionCallMessage',
- full_name='android.vts.FunctionCallMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='hidl_interface_name', full_name='android.vts.FunctionCallMessage.hidl_interface_name', index=0,
- number=1, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hal_driver_id', full_name='android.vts.FunctionCallMessage.hal_driver_id', index=1,
- number=11, type=5, cpp_type=1, label=1,
- has_default_value=True, default_value=-1,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='component_class', full_name='android.vts.FunctionCallMessage.component_class', index=2,
- number=21, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='component_type', full_name='android.vts.FunctionCallMessage.component_type', index=3,
- number=22, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='component_type_version', full_name='android.vts.FunctionCallMessage.component_type_version', index=4,
- number=23, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=_b('\030\001'), file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='component_name', full_name='android.vts.FunctionCallMessage.component_name', index=5,
- number=24, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='package_name', full_name='android.vts.FunctionCallMessage.package_name', index=6,
- number=25, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='component_type_version_major', full_name='android.vts.FunctionCallMessage.component_type_version_major', index=7,
- number=26, type=5, cpp_type=1, label=1,
- has_default_value=True, default_value=-1,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='component_type_version_minor', full_name='android.vts.FunctionCallMessage.component_type_version_minor', index=8,
- number=27, type=5, cpp_type=1, label=1,
- has_default_value=True, default_value=-1,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='api', full_name='android.vts.FunctionCallMessage.api', index=9,
- number=100, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=225,
- serialized_end=630,
-)
-
-
-_FUNCTIONSPECIFICATIONMESSAGE = _descriptor.Descriptor(
- name='FunctionSpecificationMessage',
- full_name='android.vts.FunctionSpecificationMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='name', full_name='android.vts.FunctionSpecificationMessage.name', index=0,
- number=1, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='submodule_name', full_name='android.vts.FunctionSpecificationMessage.submodule_name', index=1,
- number=2, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hidl_interface_id', full_name='android.vts.FunctionSpecificationMessage.hidl_interface_id', index=2,
- number=3, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='is_inherited', full_name='android.vts.FunctionSpecificationMessage.is_inherited', index=3,
- number=4, type=8, cpp_type=7, label=1,
- has_default_value=False, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='return_type', full_name='android.vts.FunctionSpecificationMessage.return_type', index=4,
- number=11, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='return_type_hidl', full_name='android.vts.FunctionSpecificationMessage.return_type_hidl', index=5,
- number=12, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='return_type_submodule_spec', full_name='android.vts.FunctionSpecificationMessage.return_type_submodule_spec', index=6,
- number=13, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='arg', full_name='android.vts.FunctionSpecificationMessage.arg', index=7,
- number=21, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='callflow', full_name='android.vts.FunctionSpecificationMessage.callflow', index=8,
- number=31, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='do_not_fuzz', full_name='android.vts.FunctionSpecificationMessage.do_not_fuzz', index=9,
- number=32, type=8, cpp_type=7, label=1,
- has_default_value=True, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='is_callback', full_name='android.vts.FunctionSpecificationMessage.is_callback', index=10,
- number=41, type=8, cpp_type=7, label=1,
- has_default_value=False, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=_b('\030\001'), file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='function_pointer', full_name='android.vts.FunctionSpecificationMessage.function_pointer', index=11,
- number=42, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='profiling_data', full_name='android.vts.FunctionSpecificationMessage.profiling_data', index=12,
- number=101, type=2, cpp_type=6, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='processed_coverage_data', full_name='android.vts.FunctionSpecificationMessage.processed_coverage_data', index=13,
- number=201, type=13, cpp_type=3, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='raw_coverage_data', full_name='android.vts.FunctionSpecificationMessage.raw_coverage_data', index=14,
- number=202, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='parent_path', full_name='android.vts.FunctionSpecificationMessage.parent_path', index=15,
- number=301, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='syscall_number', full_name='android.vts.FunctionSpecificationMessage.syscall_number', index=16,
- number=401, type=13, cpp_type=3, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=633,
- serialized_end=1389,
-)
-
-
-_SCALARDATAVALUEMESSAGE = _descriptor.Descriptor(
- name='ScalarDataValueMessage',
- full_name='android.vts.ScalarDataValueMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='bool_t', full_name='android.vts.ScalarDataValueMessage.bool_t', index=0,
- number=1, type=8, cpp_type=7, label=1,
- has_default_value=False, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='int8_t', full_name='android.vts.ScalarDataValueMessage.int8_t', index=1,
- number=11, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='uint8_t', full_name='android.vts.ScalarDataValueMessage.uint8_t', index=2,
- number=12, type=13, cpp_type=3, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='char', full_name='android.vts.ScalarDataValueMessage.char', index=3,
- number=13, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='uchar', full_name='android.vts.ScalarDataValueMessage.uchar', index=4,
- number=14, type=13, cpp_type=3, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='int16_t', full_name='android.vts.ScalarDataValueMessage.int16_t', index=5,
- number=21, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='uint16_t', full_name='android.vts.ScalarDataValueMessage.uint16_t', index=6,
- number=22, type=13, cpp_type=3, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='int32_t', full_name='android.vts.ScalarDataValueMessage.int32_t', index=7,
- number=31, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='uint32_t', full_name='android.vts.ScalarDataValueMessage.uint32_t', index=8,
- number=32, type=13, cpp_type=3, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='int64_t', full_name='android.vts.ScalarDataValueMessage.int64_t', index=9,
- number=41, type=3, cpp_type=2, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='uint64_t', full_name='android.vts.ScalarDataValueMessage.uint64_t', index=10,
- number=42, type=4, cpp_type=4, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='float_t', full_name='android.vts.ScalarDataValueMessage.float_t', index=11,
- number=101, type=2, cpp_type=6, label=1,
- has_default_value=False, default_value=float(0),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='double_t', full_name='android.vts.ScalarDataValueMessage.double_t', index=12,
- number=102, type=1, cpp_type=5, label=1,
- has_default_value=False, default_value=float(0),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='pointer', full_name='android.vts.ScalarDataValueMessage.pointer', index=13,
- number=201, type=13, cpp_type=3, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='opaque', full_name='android.vts.ScalarDataValueMessage.opaque', index=14,
- number=202, type=13, cpp_type=3, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='void_pointer', full_name='android.vts.ScalarDataValueMessage.void_pointer', index=15,
- number=211, type=13, cpp_type=3, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='char_pointer', full_name='android.vts.ScalarDataValueMessage.char_pointer', index=16,
- number=212, type=13, cpp_type=3, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='uchar_pointer', full_name='android.vts.ScalarDataValueMessage.uchar_pointer', index=17,
- number=213, type=13, cpp_type=3, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='pointer_pointer', full_name='android.vts.ScalarDataValueMessage.pointer_pointer', index=18,
- number=251, type=13, cpp_type=3, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=1392,
- serialized_end=1765,
-)
-
-
-_FUNCTIONPOINTERSPECIFICATIONMESSAGE = _descriptor.Descriptor(
- name='FunctionPointerSpecificationMessage',
- full_name='android.vts.FunctionPointerSpecificationMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='function_name', full_name='android.vts.FunctionPointerSpecificationMessage.function_name', index=0,
- number=1, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='address', full_name='android.vts.FunctionPointerSpecificationMessage.address', index=1,
- number=11, type=13, cpp_type=3, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='id', full_name='android.vts.FunctionPointerSpecificationMessage.id', index=2,
- number=21, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='arg', full_name='android.vts.FunctionPointerSpecificationMessage.arg', index=3,
- number=101, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='return_type', full_name='android.vts.FunctionPointerSpecificationMessage.return_type', index=4,
- number=111, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=1768,
- serialized_end=1977,
-)
-
-
-_STRINGDATAVALUEMESSAGE = _descriptor.Descriptor(
- name='StringDataValueMessage',
- full_name='android.vts.StringDataValueMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='message', full_name='android.vts.StringDataValueMessage.message', index=0,
- number=1, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='length', full_name='android.vts.StringDataValueMessage.length', index=1,
- number=11, type=13, cpp_type=3, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=1979,
- serialized_end=2036,
-)
-
-
-_ENUMDATAVALUEMESSAGE = _descriptor.Descriptor(
- name='EnumDataValueMessage',
- full_name='android.vts.EnumDataValueMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='enumerator', full_name='android.vts.EnumDataValueMessage.enumerator', index=0,
- number=1, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='scalar_value', full_name='android.vts.EnumDataValueMessage.scalar_value', index=1,
- number=2, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='scalar_type', full_name='android.vts.EnumDataValueMessage.scalar_type', index=2,
- number=3, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=2038,
- serialized_end=2160,
-)
-
-
-_MEMORYDATAVALUEMESSAGE = _descriptor.Descriptor(
- name='MemoryDataValueMessage',
- full_name='android.vts.MemoryDataValueMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='size', full_name='android.vts.MemoryDataValueMessage.size', index=0,
- number=1, type=3, cpp_type=2, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='contents', full_name='android.vts.MemoryDataValueMessage.contents', index=1,
- number=2, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='mem_id', full_name='android.vts.MemoryDataValueMessage.mem_id', index=2,
- number=3, type=5, cpp_type=1, label=1,
- has_default_value=True, default_value=-1,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hidl_mem_address', full_name='android.vts.MemoryDataValueMessage.hidl_mem_address', index=3,
- number=4, type=4, cpp_type=4, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=2162,
- serialized_end=2264,
-)
-
-
-_FDMESSAGE = _descriptor.Descriptor(
- name='FdMessage',
- full_name='android.vts.FdMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='type', full_name='android.vts.FdMessage.type', index=0,
- number=1, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=1,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='mode', full_name='android.vts.FdMessage.mode', index=1,
- number=2, type=13, cpp_type=3, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='flags', full_name='android.vts.FdMessage.flags', index=2,
- number=3, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='file_name', full_name='android.vts.FdMessage.file_name', index=3,
- number=4, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='file_mode_str', full_name='android.vts.FdMessage.file_mode_str', index=4,
- number=5, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='memory', full_name='android.vts.FdMessage.memory', index=5,
- number=6, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=2267,
- serialized_end=2437,
-)
-
-
-_HANDLEDATAVALUEMESSAGE = _descriptor.Descriptor(
- name='HandleDataValueMessage',
- full_name='android.vts.HandleDataValueMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='version', full_name='android.vts.HandleDataValueMessage.version', index=0,
- number=1, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='num_fds', full_name='android.vts.HandleDataValueMessage.num_fds', index=1,
- number=2, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='num_ints', full_name='android.vts.HandleDataValueMessage.num_ints', index=2,
- number=3, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='fd_val', full_name='android.vts.HandleDataValueMessage.fd_val', index=3,
- number=4, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='int_val', full_name='android.vts.HandleDataValueMessage.int_val', index=4,
- number=5, type=5, cpp_type=1, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='handle_id', full_name='android.vts.HandleDataValueMessage.handle_id', index=5,
- number=6, type=5, cpp_type=1, label=1,
- has_default_value=True, default_value=-1,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hidl_handle_address', full_name='android.vts.HandleDataValueMessage.hidl_handle_address', index=6,
- number=7, type=4, cpp_type=4, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=2440,
- serialized_end=2625,
-)
-
-
-_VARIABLESPECIFICATIONMESSAGE = _descriptor.Descriptor(
- name='VariableSpecificationMessage',
- full_name='android.vts.VariableSpecificationMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='name', full_name='android.vts.VariableSpecificationMessage.name', index=0,
- number=1, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='type', full_name='android.vts.VariableSpecificationMessage.type', index=1,
- number=2, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='scalar_value', full_name='android.vts.VariableSpecificationMessage.scalar_value', index=2,
- number=101, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='scalar_type', full_name='android.vts.VariableSpecificationMessage.scalar_type', index=3,
- number=102, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='string_value', full_name='android.vts.VariableSpecificationMessage.string_value', index=4,
- number=111, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='enum_value', full_name='android.vts.VariableSpecificationMessage.enum_value', index=5,
- number=121, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='vector_value', full_name='android.vts.VariableSpecificationMessage.vector_value', index=6,
- number=131, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='vector_size', full_name='android.vts.VariableSpecificationMessage.vector_size', index=7,
- number=132, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='struct_value', full_name='android.vts.VariableSpecificationMessage.struct_value', index=8,
- number=141, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='struct_type', full_name='android.vts.VariableSpecificationMessage.struct_type', index=9,
- number=142, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='sub_struct', full_name='android.vts.VariableSpecificationMessage.sub_struct', index=10,
- number=143, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='union_value', full_name='android.vts.VariableSpecificationMessage.union_value', index=11,
- number=151, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='union_type', full_name='android.vts.VariableSpecificationMessage.union_type', index=12,
- number=152, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='sub_union', full_name='android.vts.VariableSpecificationMessage.sub_union', index=13,
- number=153, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='safe_union_value', full_name='android.vts.VariableSpecificationMessage.safe_union_value', index=14,
- number=154, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='safe_union_type', full_name='android.vts.VariableSpecificationMessage.safe_union_type', index=15,
- number=155, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='sub_safe_union', full_name='android.vts.VariableSpecificationMessage.sub_safe_union', index=16,
- number=156, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='fmq_value', full_name='android.vts.VariableSpecificationMessage.fmq_value', index=17,
- number=161, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='fmq_id', full_name='android.vts.VariableSpecificationMessage.fmq_id', index=18,
- number=162, type=5, cpp_type=1, label=1,
- has_default_value=True, default_value=-1,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='fmq_desc_address', full_name='android.vts.VariableSpecificationMessage.fmq_desc_address', index=19,
- number=163, type=4, cpp_type=4, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='ref_value', full_name='android.vts.VariableSpecificationMessage.ref_value', index=20,
- number=171, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hidl_memory_value', full_name='android.vts.VariableSpecificationMessage.hidl_memory_value', index=21,
- number=172, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='handle_value', full_name='android.vts.VariableSpecificationMessage.handle_value', index=22,
- number=181, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='predefined_type', full_name='android.vts.VariableSpecificationMessage.predefined_type', index=23,
- number=201, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='function_pointer', full_name='android.vts.VariableSpecificationMessage.function_pointer', index=24,
- number=221, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hidl_callback_type', full_name='android.vts.VariableSpecificationMessage.hidl_callback_type', index=25,
- number=231, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hidl_interface_id', full_name='android.vts.VariableSpecificationMessage.hidl_interface_id', index=26,
- number=241, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hidl_interface_pointer', full_name='android.vts.VariableSpecificationMessage.hidl_interface_pointer', index=27,
- number=242, type=4, cpp_type=4, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='is_input', full_name='android.vts.VariableSpecificationMessage.is_input', index=28,
- number=301, type=8, cpp_type=7, label=1,
- has_default_value=True, default_value=True,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='is_output', full_name='android.vts.VariableSpecificationMessage.is_output', index=29,
- number=302, type=8, cpp_type=7, label=1,
- has_default_value=True, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='is_const', full_name='android.vts.VariableSpecificationMessage.is_const', index=30,
- number=303, type=8, cpp_type=7, label=1,
- has_default_value=True, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='is_callback', full_name='android.vts.VariableSpecificationMessage.is_callback', index=31,
- number=304, type=8, cpp_type=7, label=1,
- has_default_value=True, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=2628,
- serialized_end=4086,
-)
-
-
-_STRUCTSPECIFICATIONMESSAGE = _descriptor.Descriptor(
- name='StructSpecificationMessage',
- full_name='android.vts.StructSpecificationMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='name', full_name='android.vts.StructSpecificationMessage.name', index=0,
- number=1, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='is_pointer', full_name='android.vts.StructSpecificationMessage.is_pointer', index=1,
- number=2, type=8, cpp_type=7, label=1,
- has_default_value=True, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='api', full_name='android.vts.StructSpecificationMessage.api', index=2,
- number=1001, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='sub_struct', full_name='android.vts.StructSpecificationMessage.sub_struct', index=3,
- number=2001, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='attribute', full_name='android.vts.StructSpecificationMessage.attribute', index=4,
- number=3001, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=4089,
- serialized_end=4340,
-)
-
-
-_INTERFACESPECIFICATIONMESSAGE = _descriptor.Descriptor(
- name='InterfaceSpecificationMessage',
- full_name='android.vts.InterfaceSpecificationMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='is_hidl_callback', full_name='android.vts.InterfaceSpecificationMessage.is_hidl_callback', index=0,
- number=101, type=8, cpp_type=7, label=1,
- has_default_value=True, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='api', full_name='android.vts.InterfaceSpecificationMessage.api', index=1,
- number=2001, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='attribute', full_name='android.vts.InterfaceSpecificationMessage.attribute', index=2,
- number=3001, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='sub_struct', full_name='android.vts.InterfaceSpecificationMessage.sub_struct', index=3,
- number=4001, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=4343,
- serialized_end=4589,
-)
-
-
-_COMPONENTSPECIFICATIONMESSAGE = _descriptor.Descriptor(
- name='ComponentSpecificationMessage',
- full_name='android.vts.ComponentSpecificationMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='component_class', full_name='android.vts.ComponentSpecificationMessage.component_class', index=0,
- number=1, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='component_type', full_name='android.vts.ComponentSpecificationMessage.component_type', index=1,
- number=2, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='component_type_version', full_name='android.vts.ComponentSpecificationMessage.component_type_version', index=2,
- number=3, type=2, cpp_type=6, label=1,
- has_default_value=False, default_value=float(0),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=_b('\030\001'), file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='component_name', full_name='android.vts.ComponentSpecificationMessage.component_name', index=3,
- number=4, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='target_arch', full_name='android.vts.ComponentSpecificationMessage.target_arch', index=4,
- number=5, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='component_type_version_major', full_name='android.vts.ComponentSpecificationMessage.component_type_version_major', index=5,
- number=6, type=5, cpp_type=1, label=1,
- has_default_value=True, default_value=-1,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='component_type_version_minor', full_name='android.vts.ComponentSpecificationMessage.component_type_version_minor', index=6,
- number=7, type=5, cpp_type=1, label=1,
- has_default_value=True, default_value=-1,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='package', full_name='android.vts.ComponentSpecificationMessage.package', index=7,
- number=11, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='import', full_name='android.vts.ComponentSpecificationMessage.import', index=8,
- number=12, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='original_data_structure_name', full_name='android.vts.ComponentSpecificationMessage.original_data_structure_name', index=9,
- number=1001, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='header', full_name='android.vts.ComponentSpecificationMessage.header', index=10,
- number=1002, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='interface', full_name='android.vts.ComponentSpecificationMessage.interface', index=11,
- number=2001, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='attribute', full_name='android.vts.ComponentSpecificationMessage.attribute', index=12,
- number=2101, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=4592,
- serialized_end=5135,
-)
-
-_FUNCTIONCALLMESSAGE.fields_by_name['component_class'].enum_type = _COMPONENTCLASS
-_FUNCTIONCALLMESSAGE.fields_by_name['component_type'].enum_type = _COMPONENTTYPE
-_FUNCTIONCALLMESSAGE.fields_by_name['api'].message_type = _FUNCTIONSPECIFICATIONMESSAGE
-_FUNCTIONSPECIFICATIONMESSAGE.fields_by_name['return_type'].message_type = _VARIABLESPECIFICATIONMESSAGE
-_FUNCTIONSPECIFICATIONMESSAGE.fields_by_name['return_type_hidl'].message_type = _VARIABLESPECIFICATIONMESSAGE
-_FUNCTIONSPECIFICATIONMESSAGE.fields_by_name['return_type_submodule_spec'].message_type = _COMPONENTSPECIFICATIONMESSAGE
-_FUNCTIONSPECIFICATIONMESSAGE.fields_by_name['arg'].message_type = _VARIABLESPECIFICATIONMESSAGE
-_FUNCTIONSPECIFICATIONMESSAGE.fields_by_name['callflow'].message_type = _CALLFLOWSPECIFICATIONMESSAGE
-_FUNCTIONSPECIFICATIONMESSAGE.fields_by_name['function_pointer'].message_type = _FUNCTIONPOINTERSPECIFICATIONMESSAGE
-_FUNCTIONSPECIFICATIONMESSAGE.fields_by_name['raw_coverage_data'].message_type = _NATIVECODECOVERAGERAWDATAMESSAGE
-_FUNCTIONPOINTERSPECIFICATIONMESSAGE.fields_by_name['arg'].message_type = _VARIABLESPECIFICATIONMESSAGE
-_FUNCTIONPOINTERSPECIFICATIONMESSAGE.fields_by_name['return_type'].message_type = _VARIABLESPECIFICATIONMESSAGE
-_ENUMDATAVALUEMESSAGE.fields_by_name['scalar_value'].message_type = _SCALARDATAVALUEMESSAGE
-_FDMESSAGE.fields_by_name['type'].enum_type = _FDTYPE
-_FDMESSAGE.fields_by_name['memory'].message_type = _MEMORYDATAVALUEMESSAGE
-_HANDLEDATAVALUEMESSAGE.fields_by_name['fd_val'].message_type = _FDMESSAGE
-_VARIABLESPECIFICATIONMESSAGE.fields_by_name['type'].enum_type = _VARIABLETYPE
-_VARIABLESPECIFICATIONMESSAGE.fields_by_name['scalar_value'].message_type = _SCALARDATAVALUEMESSAGE
-_VARIABLESPECIFICATIONMESSAGE.fields_by_name['string_value'].message_type = _STRINGDATAVALUEMESSAGE
-_VARIABLESPECIFICATIONMESSAGE.fields_by_name['enum_value'].message_type = _ENUMDATAVALUEMESSAGE
-_VARIABLESPECIFICATIONMESSAGE.fields_by_name['vector_value'].message_type = _VARIABLESPECIFICATIONMESSAGE
-_VARIABLESPECIFICATIONMESSAGE.fields_by_name['struct_value'].message_type = _VARIABLESPECIFICATIONMESSAGE
-_VARIABLESPECIFICATIONMESSAGE.fields_by_name['sub_struct'].message_type = _VARIABLESPECIFICATIONMESSAGE
-_VARIABLESPECIFICATIONMESSAGE.fields_by_name['union_value'].message_type = _VARIABLESPECIFICATIONMESSAGE
-_VARIABLESPECIFICATIONMESSAGE.fields_by_name['sub_union'].message_type = _VARIABLESPECIFICATIONMESSAGE
-_VARIABLESPECIFICATIONMESSAGE.fields_by_name['safe_union_value'].message_type = _VARIABLESPECIFICATIONMESSAGE
-_VARIABLESPECIFICATIONMESSAGE.fields_by_name['safe_union_type'].enum_type = _VARIABLETYPE
-_VARIABLESPECIFICATIONMESSAGE.fields_by_name['sub_safe_union'].message_type = _VARIABLESPECIFICATIONMESSAGE
-_VARIABLESPECIFICATIONMESSAGE.fields_by_name['fmq_value'].message_type = _VARIABLESPECIFICATIONMESSAGE
-_VARIABLESPECIFICATIONMESSAGE.fields_by_name['ref_value'].message_type = _VARIABLESPECIFICATIONMESSAGE
-_VARIABLESPECIFICATIONMESSAGE.fields_by_name['hidl_memory_value'].message_type = _MEMORYDATAVALUEMESSAGE
-_VARIABLESPECIFICATIONMESSAGE.fields_by_name['handle_value'].message_type = _HANDLEDATAVALUEMESSAGE
-_VARIABLESPECIFICATIONMESSAGE.fields_by_name['function_pointer'].message_type = _FUNCTIONPOINTERSPECIFICATIONMESSAGE
-_STRUCTSPECIFICATIONMESSAGE.fields_by_name['api'].message_type = _FUNCTIONSPECIFICATIONMESSAGE
-_STRUCTSPECIFICATIONMESSAGE.fields_by_name['sub_struct'].message_type = _STRUCTSPECIFICATIONMESSAGE
-_STRUCTSPECIFICATIONMESSAGE.fields_by_name['attribute'].message_type = _VARIABLESPECIFICATIONMESSAGE
-_INTERFACESPECIFICATIONMESSAGE.fields_by_name['api'].message_type = _FUNCTIONSPECIFICATIONMESSAGE
-_INTERFACESPECIFICATIONMESSAGE.fields_by_name['attribute'].message_type = _VARIABLESPECIFICATIONMESSAGE
-_INTERFACESPECIFICATIONMESSAGE.fields_by_name['sub_struct'].message_type = _STRUCTSPECIFICATIONMESSAGE
-_COMPONENTSPECIFICATIONMESSAGE.fields_by_name['component_class'].enum_type = _COMPONENTCLASS
-_COMPONENTSPECIFICATIONMESSAGE.fields_by_name['component_type'].enum_type = _COMPONENTTYPE
-_COMPONENTSPECIFICATIONMESSAGE.fields_by_name['target_arch'].enum_type = _TARGETARCH
-_COMPONENTSPECIFICATIONMESSAGE.fields_by_name['interface'].message_type = _INTERFACESPECIFICATIONMESSAGE
-_COMPONENTSPECIFICATIONMESSAGE.fields_by_name['attribute'].message_type = _VARIABLESPECIFICATIONMESSAGE
-DESCRIPTOR.message_types_by_name['CallFlowSpecificationMessage'] = _CALLFLOWSPECIFICATIONMESSAGE
-DESCRIPTOR.message_types_by_name['NativeCodeCoverageRawDataMessage'] = _NATIVECODECOVERAGERAWDATAMESSAGE
-DESCRIPTOR.message_types_by_name['FunctionCallMessage'] = _FUNCTIONCALLMESSAGE
-DESCRIPTOR.message_types_by_name['FunctionSpecificationMessage'] = _FUNCTIONSPECIFICATIONMESSAGE
-DESCRIPTOR.message_types_by_name['ScalarDataValueMessage'] = _SCALARDATAVALUEMESSAGE
-DESCRIPTOR.message_types_by_name['FunctionPointerSpecificationMessage'] = _FUNCTIONPOINTERSPECIFICATIONMESSAGE
-DESCRIPTOR.message_types_by_name['StringDataValueMessage'] = _STRINGDATAVALUEMESSAGE
-DESCRIPTOR.message_types_by_name['EnumDataValueMessage'] = _ENUMDATAVALUEMESSAGE
-DESCRIPTOR.message_types_by_name['MemoryDataValueMessage'] = _MEMORYDATAVALUEMESSAGE
-DESCRIPTOR.message_types_by_name['FdMessage'] = _FDMESSAGE
-DESCRIPTOR.message_types_by_name['HandleDataValueMessage'] = _HANDLEDATAVALUEMESSAGE
-DESCRIPTOR.message_types_by_name['VariableSpecificationMessage'] = _VARIABLESPECIFICATIONMESSAGE
-DESCRIPTOR.message_types_by_name['StructSpecificationMessage'] = _STRUCTSPECIFICATIONMESSAGE
-DESCRIPTOR.message_types_by_name['InterfaceSpecificationMessage'] = _INTERFACESPECIFICATIONMESSAGE
-DESCRIPTOR.message_types_by_name['ComponentSpecificationMessage'] = _COMPONENTSPECIFICATIONMESSAGE
-DESCRIPTOR.enum_types_by_name['ComponentClass'] = _COMPONENTCLASS
-DESCRIPTOR.enum_types_by_name['ComponentType'] = _COMPONENTTYPE
-DESCRIPTOR.enum_types_by_name['VariableType'] = _VARIABLETYPE
-DESCRIPTOR.enum_types_by_name['TargetArch'] = _TARGETARCH
-DESCRIPTOR.enum_types_by_name['FdType'] = _FDTYPE
-_sym_db.RegisterFileDescriptor(DESCRIPTOR)
-
-CallFlowSpecificationMessage = _reflection.GeneratedProtocolMessageType('CallFlowSpecificationMessage', (_message.Message,), {
- 'DESCRIPTOR' : _CALLFLOWSPECIFICATIONMESSAGE,
- '__module__' : 'ComponentSpecificationMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.CallFlowSpecificationMessage)
- })
-_sym_db.RegisterMessage(CallFlowSpecificationMessage)
-
-NativeCodeCoverageRawDataMessage = _reflection.GeneratedProtocolMessageType('NativeCodeCoverageRawDataMessage', (_message.Message,), {
- 'DESCRIPTOR' : _NATIVECODECOVERAGERAWDATAMESSAGE,
- '__module__' : 'ComponentSpecificationMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.NativeCodeCoverageRawDataMessage)
- })
-_sym_db.RegisterMessage(NativeCodeCoverageRawDataMessage)
-
-FunctionCallMessage = _reflection.GeneratedProtocolMessageType('FunctionCallMessage', (_message.Message,), {
- 'DESCRIPTOR' : _FUNCTIONCALLMESSAGE,
- '__module__' : 'ComponentSpecificationMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.FunctionCallMessage)
- })
-_sym_db.RegisterMessage(FunctionCallMessage)
-
-FunctionSpecificationMessage = _reflection.GeneratedProtocolMessageType('FunctionSpecificationMessage', (_message.Message,), {
- 'DESCRIPTOR' : _FUNCTIONSPECIFICATIONMESSAGE,
- '__module__' : 'ComponentSpecificationMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.FunctionSpecificationMessage)
- })
-_sym_db.RegisterMessage(FunctionSpecificationMessage)
-
-ScalarDataValueMessage = _reflection.GeneratedProtocolMessageType('ScalarDataValueMessage', (_message.Message,), {
- 'DESCRIPTOR' : _SCALARDATAVALUEMESSAGE,
- '__module__' : 'ComponentSpecificationMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.ScalarDataValueMessage)
- })
-_sym_db.RegisterMessage(ScalarDataValueMessage)
-
-FunctionPointerSpecificationMessage = _reflection.GeneratedProtocolMessageType('FunctionPointerSpecificationMessage', (_message.Message,), {
- 'DESCRIPTOR' : _FUNCTIONPOINTERSPECIFICATIONMESSAGE,
- '__module__' : 'ComponentSpecificationMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.FunctionPointerSpecificationMessage)
- })
-_sym_db.RegisterMessage(FunctionPointerSpecificationMessage)
-
-StringDataValueMessage = _reflection.GeneratedProtocolMessageType('StringDataValueMessage', (_message.Message,), {
- 'DESCRIPTOR' : _STRINGDATAVALUEMESSAGE,
- '__module__' : 'ComponentSpecificationMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.StringDataValueMessage)
- })
-_sym_db.RegisterMessage(StringDataValueMessage)
-
-EnumDataValueMessage = _reflection.GeneratedProtocolMessageType('EnumDataValueMessage', (_message.Message,), {
- 'DESCRIPTOR' : _ENUMDATAVALUEMESSAGE,
- '__module__' : 'ComponentSpecificationMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.EnumDataValueMessage)
- })
-_sym_db.RegisterMessage(EnumDataValueMessage)
-
-MemoryDataValueMessage = _reflection.GeneratedProtocolMessageType('MemoryDataValueMessage', (_message.Message,), {
- 'DESCRIPTOR' : _MEMORYDATAVALUEMESSAGE,
- '__module__' : 'ComponentSpecificationMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.MemoryDataValueMessage)
- })
-_sym_db.RegisterMessage(MemoryDataValueMessage)
-
-FdMessage = _reflection.GeneratedProtocolMessageType('FdMessage', (_message.Message,), {
- 'DESCRIPTOR' : _FDMESSAGE,
- '__module__' : 'ComponentSpecificationMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.FdMessage)
- })
-_sym_db.RegisterMessage(FdMessage)
-
-HandleDataValueMessage = _reflection.GeneratedProtocolMessageType('HandleDataValueMessage', (_message.Message,), {
- 'DESCRIPTOR' : _HANDLEDATAVALUEMESSAGE,
- '__module__' : 'ComponentSpecificationMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.HandleDataValueMessage)
- })
-_sym_db.RegisterMessage(HandleDataValueMessage)
-
-VariableSpecificationMessage = _reflection.GeneratedProtocolMessageType('VariableSpecificationMessage', (_message.Message,), {
- 'DESCRIPTOR' : _VARIABLESPECIFICATIONMESSAGE,
- '__module__' : 'ComponentSpecificationMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.VariableSpecificationMessage)
- })
-_sym_db.RegisterMessage(VariableSpecificationMessage)
-
-StructSpecificationMessage = _reflection.GeneratedProtocolMessageType('StructSpecificationMessage', (_message.Message,), {
- 'DESCRIPTOR' : _STRUCTSPECIFICATIONMESSAGE,
- '__module__' : 'ComponentSpecificationMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.StructSpecificationMessage)
- })
-_sym_db.RegisterMessage(StructSpecificationMessage)
-
-InterfaceSpecificationMessage = _reflection.GeneratedProtocolMessageType('InterfaceSpecificationMessage', (_message.Message,), {
- 'DESCRIPTOR' : _INTERFACESPECIFICATIONMESSAGE,
- '__module__' : 'ComponentSpecificationMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.InterfaceSpecificationMessage)
- })
-_sym_db.RegisterMessage(InterfaceSpecificationMessage)
-
-ComponentSpecificationMessage = _reflection.GeneratedProtocolMessageType('ComponentSpecificationMessage', (_message.Message,), {
- 'DESCRIPTOR' : _COMPONENTSPECIFICATIONMESSAGE,
- '__module__' : 'ComponentSpecificationMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.ComponentSpecificationMessage)
- })
-_sym_db.RegisterMessage(ComponentSpecificationMessage)
-
-
-DESCRIPTOR._options = None
-_FUNCTIONCALLMESSAGE.fields_by_name['component_type_version']._options = None
-_FUNCTIONSPECIFICATIONMESSAGE.fields_by_name['is_callback']._options = None
-_COMPONENTSPECIFICATIONMESSAGE.fields_by_name['component_type_version']._options = None
-# @@protoc_insertion_point(module_scope)
diff --git a/proto/ExecutionSpecificationMessage.proto b/proto/ExecutionSpecificationMessage.proto
deleted file mode 100644
index 615c105..0000000
--- a/proto/ExecutionSpecificationMessage.proto
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 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.
-
-syntax = "proto2";
-
-package android.vts;
-option java_package = "com.android.vts.proto";
-option java_outer_classname = "VtsExecutionSpecificationMessage";
-
-import "test/vts/proto/ComponentSpecificationMessage.proto";
-
-// Specifies API call sequence.
-message ExecutionSpecificationMessage {
- // Lists API calls.
- repeated FunctionCallMessage function_call = 1;
- // Used to ensure that garbage bytes cannot be accidentally parsed.
- optional bool valid = 1000;
-}
diff --git a/proto/ExecutionSpecificationMessage_pb2.py b/proto/ExecutionSpecificationMessage_pb2.py
deleted file mode 100644
index 23b360b..0000000
--- a/proto/ExecutionSpecificationMessage_pb2.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: ExecutionSpecificationMessage.proto
-
-import sys
-_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
-from google.protobuf import descriptor as _descriptor
-from google.protobuf import message as _message
-from google.protobuf import reflection as _reflection
-from google.protobuf import symbol_database as _symbol_database
-# @@protoc_insertion_point(imports)
-
-_sym_db = _symbol_database.Default()
-
-
-import ComponentSpecificationMessage_pb2 as ComponentSpecificationMessage__pb2
-
-
-DESCRIPTOR = _descriptor.FileDescriptor(
- name='ExecutionSpecificationMessage.proto',
- package='android.vts',
- syntax='proto2',
- serialized_options=_b('\n\025com.android.vts.protoB VtsExecutionSpecificationMessage'),
- serialized_pb=_b('\n#ExecutionSpecificationMessage.proto\x12\x0b\x61ndroid.vts\x1a#ComponentSpecificationMessage.proto\"h\n\x1d\x45xecutionSpecificationMessage\x12\x37\n\rfunction_call\x18\x01 \x03(\x0b\x32 .android.vts.FunctionCallMessage\x12\x0e\n\x05valid\x18\xe8\x07 \x01(\x08\x42\x39\n\x15\x63om.android.vts.protoB VtsExecutionSpecificationMessage')
- ,
- dependencies=[ComponentSpecificationMessage__pb2.DESCRIPTOR,])
-
-
-
-
-_EXECUTIONSPECIFICATIONMESSAGE = _descriptor.Descriptor(
- name='ExecutionSpecificationMessage',
- full_name='android.vts.ExecutionSpecificationMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='function_call', full_name='android.vts.ExecutionSpecificationMessage.function_call', index=0,
- number=1, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='valid', full_name='android.vts.ExecutionSpecificationMessage.valid', index=1,
- number=1000, type=8, cpp_type=7, label=1,
- has_default_value=False, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=89,
- serialized_end=193,
-)
-
-_EXECUTIONSPECIFICATIONMESSAGE.fields_by_name['function_call'].message_type = ComponentSpecificationMessage__pb2._FUNCTIONCALLMESSAGE
-DESCRIPTOR.message_types_by_name['ExecutionSpecificationMessage'] = _EXECUTIONSPECIFICATIONMESSAGE
-_sym_db.RegisterFileDescriptor(DESCRIPTOR)
-
-ExecutionSpecificationMessage = _reflection.GeneratedProtocolMessageType('ExecutionSpecificationMessage', (_message.Message,), {
- 'DESCRIPTOR' : _EXECUTIONSPECIFICATIONMESSAGE,
- '__module__' : 'ExecutionSpecificationMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.ExecutionSpecificationMessage)
- })
-_sym_db.RegisterMessage(ExecutionSpecificationMessage)
-
-
-DESCRIPTOR._options = None
-# @@protoc_insertion_point(module_scope)
diff --git a/proto/TestSchedulingPolicyMessage.proto b/proto/TestSchedulingPolicyMessage.proto
deleted file mode 100644
index 93c7826..0000000
--- a/proto/TestSchedulingPolicyMessage.proto
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 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.
-
-syntax = "proto2";
-
-package android.vts;
-option java_package = "com.android.vts.proto";
-option java_outer_classname = "VtsTestSchedulingPolicyMessage";
-
-// Supported test scheduling modes.
-enum TestSchedulingMode {
- UKNOWN_TEST_SCHEDULING_MODE_TYPE = 0;
-
- // to schedule on ToT best effort
- TEST_SCHEDULING_MODE_TOT_BEST_EFFORT = 1;
-
- // to schedule once per period
- TEST_SCHEDULING_MODE_PERIODIC = 2;
-}
-
-// To specify a test scheduling policy.
-message TestSchedulingPolicyMessage {
- // one or multitple tareget test plans.
- repeated bytes target_plans = 1;
- // one or multitple tareget tests. used if plans is not defined.
- repeated bytes target_tests = 2;
-
- // test scheduling mode
- optional TestSchedulingMode scheduling_mode = 101;
-
- // period in seconds (for TEST_SCHEDULING_MODE_PERIODIC).
- optional uint32 period_secs = 110;
-}
diff --git a/proto/TestSchedulingPolicyMessage_pb2.py b/proto/TestSchedulingPolicyMessage_pb2.py
deleted file mode 100644
index d02fc22..0000000
--- a/proto/TestSchedulingPolicyMessage_pb2.py
+++ /dev/null
@@ -1,125 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: TestSchedulingPolicyMessage.proto
-
-import sys
-_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
-from google.protobuf.internal import enum_type_wrapper
-from google.protobuf import descriptor as _descriptor
-from google.protobuf import message as _message
-from google.protobuf import reflection as _reflection
-from google.protobuf import symbol_database as _symbol_database
-# @@protoc_insertion_point(imports)
-
-_sym_db = _symbol_database.Default()
-
-
-
-
-DESCRIPTOR = _descriptor.FileDescriptor(
- name='TestSchedulingPolicyMessage.proto',
- package='android.vts',
- syntax='proto2',
- serialized_options=_b('\n\025com.android.vts.protoB\036VtsTestSchedulingPolicyMessage'),
- serialized_pb=_b('\n!TestSchedulingPolicyMessage.proto\x12\x0b\x61ndroid.vts\"\x98\x01\n\x1bTestSchedulingPolicyMessage\x12\x14\n\x0ctarget_plans\x18\x01 \x03(\x0c\x12\x14\n\x0ctarget_tests\x18\x02 \x03(\x0c\x12\x38\n\x0fscheduling_mode\x18\x65 \x01(\x0e\x32\x1f.android.vts.TestSchedulingMode\x12\x13\n\x0bperiod_secs\x18n \x01(\r*\x87\x01\n\x12TestSchedulingMode\x12$\n UKNOWN_TEST_SCHEDULING_MODE_TYPE\x10\x00\x12(\n$TEST_SCHEDULING_MODE_TOT_BEST_EFFORT\x10\x01\x12!\n\x1dTEST_SCHEDULING_MODE_PERIODIC\x10\x02\x42\x37\n\x15\x63om.android.vts.protoB\x1eVtsTestSchedulingPolicyMessage')
-)
-
-_TESTSCHEDULINGMODE = _descriptor.EnumDescriptor(
- name='TestSchedulingMode',
- full_name='android.vts.TestSchedulingMode',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='UKNOWN_TEST_SCHEDULING_MODE_TYPE', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TEST_SCHEDULING_MODE_TOT_BEST_EFFORT', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TEST_SCHEDULING_MODE_PERIODIC', index=2, number=2,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=206,
- serialized_end=341,
-)
-_sym_db.RegisterEnumDescriptor(_TESTSCHEDULINGMODE)
-
-TestSchedulingMode = enum_type_wrapper.EnumTypeWrapper(_TESTSCHEDULINGMODE)
-UKNOWN_TEST_SCHEDULING_MODE_TYPE = 0
-TEST_SCHEDULING_MODE_TOT_BEST_EFFORT = 1
-TEST_SCHEDULING_MODE_PERIODIC = 2
-
-
-
-_TESTSCHEDULINGPOLICYMESSAGE = _descriptor.Descriptor(
- name='TestSchedulingPolicyMessage',
- full_name='android.vts.TestSchedulingPolicyMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='target_plans', full_name='android.vts.TestSchedulingPolicyMessage.target_plans', index=0,
- number=1, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='target_tests', full_name='android.vts.TestSchedulingPolicyMessage.target_tests', index=1,
- number=2, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='scheduling_mode', full_name='android.vts.TestSchedulingPolicyMessage.scheduling_mode', index=2,
- number=101, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='period_secs', full_name='android.vts.TestSchedulingPolicyMessage.period_secs', index=3,
- number=110, type=13, cpp_type=3, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=51,
- serialized_end=203,
-)
-
-_TESTSCHEDULINGPOLICYMESSAGE.fields_by_name['scheduling_mode'].enum_type = _TESTSCHEDULINGMODE
-DESCRIPTOR.message_types_by_name['TestSchedulingPolicyMessage'] = _TESTSCHEDULINGPOLICYMESSAGE
-DESCRIPTOR.enum_types_by_name['TestSchedulingMode'] = _TESTSCHEDULINGMODE
-_sym_db.RegisterFileDescriptor(DESCRIPTOR)
-
-TestSchedulingPolicyMessage = _reflection.GeneratedProtocolMessageType('TestSchedulingPolicyMessage', (_message.Message,), {
- 'DESCRIPTOR' : _TESTSCHEDULINGPOLICYMESSAGE,
- '__module__' : 'TestSchedulingPolicyMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.TestSchedulingPolicyMessage)
- })
-_sym_db.RegisterMessage(TestSchedulingPolicyMessage)
-
-
-DESCRIPTOR._options = None
-# @@protoc_insertion_point(module_scope)
diff --git a/proto/VtsDriverControlMessage.proto b/proto/VtsDriverControlMessage.proto
deleted file mode 100644
index 5912100..0000000
--- a/proto/VtsDriverControlMessage.proto
+++ /dev/null
@@ -1,153 +0,0 @@
-// Copyright 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.
-
-syntax = "proto2";
-
-package android.vts;
-
-import "test/vts/proto/VtsResourceControllerMessage.proto";
-
-// Type of a command.
-enum VtsDriverCommandType {
- UNKNOWN_VTS_DRIVER_COMMAND_TYPE = 0;
-
- // To request to exit a driver.
- EXIT = 1;
- // To get the status of a driver.
- GET_STATUS = 2;
-
- // for a HAL driver
- // To request to load a HAL.
- LOAD_HAL = 101;
- // To get a list of available functions.
- LIST_FUNCTIONS = 102;
- // To call a function.
- CALL_FUNCTION = 103;
- // To get the value of an attribute.
- GET_ATTRIBUTE = 104;
- // To read the specification message of a component.
- VTS_DRIVER_COMMAND_READ_SPECIFICATION = 105;
-
- // for a shell driver
- // To execute a shell command.
- EXECUTE_COMMAND = 201;
-
- // To invoke a system call.
- INVOKE_SYSCALL = 202;
-
- // To request FMQ resource.
- FMQ_OPERATION = 301;
- // To request hidl_memory resource.
- HIDL_MEMORY_OPERATION = 302;
- // To request hidl_handle resource.
- HIDL_HANDLE_OPERATION = 303;
-}
-
-
-// Type of a response.
-enum VtsDriverResponseCode {
- UNKNOWN_VTS_DRIVER_RESPONSE_CODE = 0;
- // successful
- VTS_DRIVER_RESPONSE_SUCCESS = 1;
- // failed
- VTS_DRIVER_RESPONSE_FAIL = 2;
-}
-
-
-// To specify a command.
-message VtsDriverControlCommandMessage {
- // Command type.
- optional VtsDriverCommandType command_type = 1;
-
- // for EXIT
- // none
-
- // for GET_STATUS
- optional int32 status_type = 1101;
-
- // for LOAD_HAL
- // The name of a target.
- optional bytes file_path = 1201;
- // target class
- optional int32 target_class = 1202;
- // target type
- optional int32 target_type = 1203;
- // target version (should be divided by 100) - float has a compatibility issue
- // between C/C++ and python protoc.
- // Deprecated, use target_version_major and target_version_minor instead.
- optional float target_version = 1204 [deprecated = true];
- // the name of a HAL module to open.
- optional bytes module_name = 1205;
- // the package of a HIDL HAL to open.
- optional bytes target_package = 1206;
- // the name of a target component (currently used for HIDL HALs only).
- optional bytes target_component_name = 1207;
-
- // use two ints to represent major and minor versions separately.
- // HAL major version of target component (e.g. 1.0 -> 1).
- optional int32 target_version_major = 1208 [default = -1];
- // HAL minor version of target component (e.g. 1.0 -> 0).
- optional int32 target_version_minor = 1209 [default = -1];
-
- // the name of a HW Binder service to use (only needed for HIDL HAL).
- optional bytes hw_binder_service_name = 1221;
-
- // for LIST_FUNCTIONS
- // none
-
- // for CALL_FUNCTION
- optional bytes arg = 1401;
-
- // UID of a caller on the driver-side.
- optional bytes driver_caller_uid = 1501;
-
- // for EXECUTE_COMMAND
- repeated bytes shell_command = 2001;
-
- // Arguments for operation on FMQ
- optional FmqRequestMessage fmq_request = 3001;
- // Arguments for operation on hidl_memory
- optional HidlMemoryRequestMessage hidl_memory_request = 3002;
- // Arguments for operation on hidl_handle
- optional HidlHandleRequestMessage hidl_handle_request = 3003;
-}
-
-
-// To specify a response.
-message VtsDriverControlResponseMessage {
- // Response type.
- optional VtsDriverResponseCode response_code = 1;
-
- // Return value.
- optional int32 return_value = 11;
- // Return message.
- optional bytes return_message = 12;
-
- // The stdout message for each command
- repeated bytes stdout_str = 1001;
- // The stderr message for each command
- repeated bytes stderr_str = 1002;
- // The exit code for each command
- repeated int32 exit_code = 1003;
-
- // The retrieved specifications.
- repeated bytes spec = 2001;
-
- // read data and return values from FMQ driver
- optional FmqResponseMessage fmq_response = 3001;
- // response from hidl_memory driver
- optional HidlMemoryResponseMessage hidl_memory_response = 3002;
- // response from hidl_handle driver
- optional HidlHandleResponseMessage hidl_handle_response = 3003;
-}
diff --git a/proto/VtsDriverControlMessage_pb2.py b/proto/VtsDriverControlMessage_pb2.py
deleted file mode 100644
index 5fa131f..0000000
--- a/proto/VtsDriverControlMessage_pb2.py
+++ /dev/null
@@ -1,415 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: VtsDriverControlMessage.proto
-
-import sys
-_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
-from google.protobuf.internal import enum_type_wrapper
-from google.protobuf import descriptor as _descriptor
-from google.protobuf import message as _message
-from google.protobuf import reflection as _reflection
-from google.protobuf import symbol_database as _symbol_database
-# @@protoc_insertion_point(imports)
-
-_sym_db = _symbol_database.Default()
-
-
-import VtsResourceControllerMessage_pb2 as VtsResourceControllerMessage__pb2
-
-
-DESCRIPTOR = _descriptor.FileDescriptor(
- name='VtsDriverControlMessage.proto',
- package='android.vts',
- syntax='proto2',
- serialized_options=None,
- serialized_pb=_b('\n\x1dVtsDriverControlMessage.proto\x12\x0b\x61ndroid.vts\x1a\"VtsResourceControllerMessage.proto\"\x85\x05\n\x1eVtsDriverControlCommandMessage\x12\x37\n\x0c\x63ommand_type\x18\x01 \x01(\x0e\x32!.android.vts.VtsDriverCommandType\x12\x14\n\x0bstatus_type\x18\xcd\x08 \x01(\x05\x12\x12\n\tfile_path\x18\xb1\t \x01(\x0c\x12\x15\n\x0ctarget_class\x18\xb2\t \x01(\x05\x12\x14\n\x0btarget_type\x18\xb3\t \x01(\x05\x12\x1b\n\x0etarget_version\x18\xb4\t \x01(\x02\x42\x02\x18\x01\x12\x14\n\x0bmodule_name\x18\xb5\t \x01(\x0c\x12\x17\n\x0etarget_package\x18\xb6\t \x01(\x0c\x12\x1e\n\x15target_component_name\x18\xb7\t \x01(\x0c\x12!\n\x14target_version_major\x18\xb8\t \x01(\x05:\x02-1\x12!\n\x14target_version_minor\x18\xb9\t \x01(\x05:\x02-1\x12\x1f\n\x16hw_binder_service_name\x18\xc5\t \x01(\x0c\x12\x0c\n\x03\x61rg\x18\xf9\n \x01(\x0c\x12\x1a\n\x11\x64river_caller_uid\x18\xdd\x0b \x01(\x0c\x12\x16\n\rshell_command\x18\xd1\x0f \x03(\x0c\x12\x34\n\x0b\x66mq_request\x18\xb9\x17 \x01(\x0b\x32\x1e.android.vts.FmqRequestMessage\x12\x43\n\x13hidl_memory_request\x18\xba\x17 \x01(\x0b\x32%.android.vts.HidlMemoryRequestMessage\x12\x43\n\x13hidl_handle_request\x18\xbb\x17 \x01(\x0b\x32%.android.vts.HidlHandleRequestMessage\"\x9d\x03\n\x1fVtsDriverControlResponseMessage\x12\x39\n\rresponse_code\x18\x01 \x01(\x0e\x32\".android.vts.VtsDriverResponseCode\x12\x14\n\x0creturn_value\x18\x0b \x01(\x05\x12\x16\n\x0ereturn_message\x18\x0c \x01(\x0c\x12\x13\n\nstdout_str\x18\xe9\x07 \x03(\x0c\x12\x13\n\nstderr_str\x18\xea\x07 \x03(\x0c\x12\x12\n\texit_code\x18\xeb\x07 \x03(\x05\x12\r\n\x04spec\x18\xd1\x0f \x03(\x0c\x12\x36\n\x0c\x66mq_response\x18\xb9\x17 \x01(\x0b\x32\x1f.android.vts.FmqResponseMessage\x12\x45\n\x14hidl_memory_response\x18\xba\x17 \x01(\x0b\x32&.android.vts.HidlMemoryResponseMessage\x12\x45\n\x14hidl_handle_response\x18\xbb\x17 \x01(\x0b\x32&.android.vts.HidlHandleResponseMessage*\xbf\x02\n\x14VtsDriverCommandType\x12#\n\x1fUNKNOWN_VTS_DRIVER_COMMAND_TYPE\x10\x00\x12\x08\n\x04\x45XIT\x10\x01\x12\x0e\n\nGET_STATUS\x10\x02\x12\x0c\n\x08LOAD_HAL\x10\x65\x12\x12\n\x0eLIST_FUNCTIONS\x10\x66\x12\x11\n\rCALL_FUNCTION\x10g\x12\x11\n\rGET_ATTRIBUTE\x10h\x12)\n%VTS_DRIVER_COMMAND_READ_SPECIFICATION\x10i\x12\x14\n\x0f\x45XECUTE_COMMAND\x10\xc9\x01\x12\x13\n\x0eINVOKE_SYSCALL\x10\xca\x01\x12\x12\n\rFMQ_OPERATION\x10\xad\x02\x12\x1a\n\x15HIDL_MEMORY_OPERATION\x10\xae\x02\x12\x1a\n\x15HIDL_HANDLE_OPERATION\x10\xaf\x02*|\n\x15VtsDriverResponseCode\x12$\n UNKNOWN_VTS_DRIVER_RESPONSE_CODE\x10\x00\x12\x1f\n\x1bVTS_DRIVER_RESPONSE_SUCCESS\x10\x01\x12\x1c\n\x18VTS_DRIVER_RESPONSE_FAIL\x10\x02')
- ,
- dependencies=[VtsResourceControllerMessage__pb2.DESCRIPTOR,])
-
-_VTSDRIVERCOMMANDTYPE = _descriptor.EnumDescriptor(
- name='VtsDriverCommandType',
- full_name='android.vts.VtsDriverCommandType',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='UNKNOWN_VTS_DRIVER_COMMAND_TYPE', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='EXIT', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='GET_STATUS', index=2, number=2,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='LOAD_HAL', index=3, number=101,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='LIST_FUNCTIONS', index=4, number=102,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='CALL_FUNCTION', index=5, number=103,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='GET_ATTRIBUTE', index=6, number=104,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_DRIVER_COMMAND_READ_SPECIFICATION', index=7, number=105,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='EXECUTE_COMMAND', index=8, number=201,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='INVOKE_SYSCALL', index=9, number=202,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='FMQ_OPERATION', index=10, number=301,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='HIDL_MEMORY_OPERATION', index=11, number=302,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='HIDL_HANDLE_OPERATION', index=12, number=303,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=1147,
- serialized_end=1466,
-)
-_sym_db.RegisterEnumDescriptor(_VTSDRIVERCOMMANDTYPE)
-
-VtsDriverCommandType = enum_type_wrapper.EnumTypeWrapper(_VTSDRIVERCOMMANDTYPE)
-_VTSDRIVERRESPONSECODE = _descriptor.EnumDescriptor(
- name='VtsDriverResponseCode',
- full_name='android.vts.VtsDriverResponseCode',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='UNKNOWN_VTS_DRIVER_RESPONSE_CODE', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_DRIVER_RESPONSE_SUCCESS', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_DRIVER_RESPONSE_FAIL', index=2, number=2,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=1468,
- serialized_end=1592,
-)
-_sym_db.RegisterEnumDescriptor(_VTSDRIVERRESPONSECODE)
-
-VtsDriverResponseCode = enum_type_wrapper.EnumTypeWrapper(_VTSDRIVERRESPONSECODE)
-UNKNOWN_VTS_DRIVER_COMMAND_TYPE = 0
-EXIT = 1
-GET_STATUS = 2
-LOAD_HAL = 101
-LIST_FUNCTIONS = 102
-CALL_FUNCTION = 103
-GET_ATTRIBUTE = 104
-VTS_DRIVER_COMMAND_READ_SPECIFICATION = 105
-EXECUTE_COMMAND = 201
-INVOKE_SYSCALL = 202
-FMQ_OPERATION = 301
-HIDL_MEMORY_OPERATION = 302
-HIDL_HANDLE_OPERATION = 303
-UNKNOWN_VTS_DRIVER_RESPONSE_CODE = 0
-VTS_DRIVER_RESPONSE_SUCCESS = 1
-VTS_DRIVER_RESPONSE_FAIL = 2
-
-
-
-_VTSDRIVERCONTROLCOMMANDMESSAGE = _descriptor.Descriptor(
- name='VtsDriverControlCommandMessage',
- full_name='android.vts.VtsDriverControlCommandMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='command_type', full_name='android.vts.VtsDriverControlCommandMessage.command_type', index=0,
- number=1, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='status_type', full_name='android.vts.VtsDriverControlCommandMessage.status_type', index=1,
- number=1101, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='file_path', full_name='android.vts.VtsDriverControlCommandMessage.file_path', index=2,
- number=1201, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='target_class', full_name='android.vts.VtsDriverControlCommandMessage.target_class', index=3,
- number=1202, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='target_type', full_name='android.vts.VtsDriverControlCommandMessage.target_type', index=4,
- number=1203, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='target_version', full_name='android.vts.VtsDriverControlCommandMessage.target_version', index=5,
- number=1204, type=2, cpp_type=6, label=1,
- has_default_value=False, default_value=float(0),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=_b('\030\001'), file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='module_name', full_name='android.vts.VtsDriverControlCommandMessage.module_name', index=6,
- number=1205, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='target_package', full_name='android.vts.VtsDriverControlCommandMessage.target_package', index=7,
- number=1206, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='target_component_name', full_name='android.vts.VtsDriverControlCommandMessage.target_component_name', index=8,
- number=1207, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='target_version_major', full_name='android.vts.VtsDriverControlCommandMessage.target_version_major', index=9,
- number=1208, type=5, cpp_type=1, label=1,
- has_default_value=True, default_value=-1,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='target_version_minor', full_name='android.vts.VtsDriverControlCommandMessage.target_version_minor', index=10,
- number=1209, type=5, cpp_type=1, label=1,
- has_default_value=True, default_value=-1,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hw_binder_service_name', full_name='android.vts.VtsDriverControlCommandMessage.hw_binder_service_name', index=11,
- number=1221, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='arg', full_name='android.vts.VtsDriverControlCommandMessage.arg', index=12,
- number=1401, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='driver_caller_uid', full_name='android.vts.VtsDriverControlCommandMessage.driver_caller_uid', index=13,
- number=1501, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='shell_command', full_name='android.vts.VtsDriverControlCommandMessage.shell_command', index=14,
- number=2001, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='fmq_request', full_name='android.vts.VtsDriverControlCommandMessage.fmq_request', index=15,
- number=3001, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hidl_memory_request', full_name='android.vts.VtsDriverControlCommandMessage.hidl_memory_request', index=16,
- number=3002, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hidl_handle_request', full_name='android.vts.VtsDriverControlCommandMessage.hidl_handle_request', index=17,
- number=3003, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=83,
- serialized_end=728,
-)
-
-
-_VTSDRIVERCONTROLRESPONSEMESSAGE = _descriptor.Descriptor(
- name='VtsDriverControlResponseMessage',
- full_name='android.vts.VtsDriverControlResponseMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='response_code', full_name='android.vts.VtsDriverControlResponseMessage.response_code', index=0,
- number=1, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='return_value', full_name='android.vts.VtsDriverControlResponseMessage.return_value', index=1,
- number=11, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='return_message', full_name='android.vts.VtsDriverControlResponseMessage.return_message', index=2,
- number=12, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='stdout_str', full_name='android.vts.VtsDriverControlResponseMessage.stdout_str', index=3,
- number=1001, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='stderr_str', full_name='android.vts.VtsDriverControlResponseMessage.stderr_str', index=4,
- number=1002, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='exit_code', full_name='android.vts.VtsDriverControlResponseMessage.exit_code', index=5,
- number=1003, type=5, cpp_type=1, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='spec', full_name='android.vts.VtsDriverControlResponseMessage.spec', index=6,
- number=2001, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='fmq_response', full_name='android.vts.VtsDriverControlResponseMessage.fmq_response', index=7,
- number=3001, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hidl_memory_response', full_name='android.vts.VtsDriverControlResponseMessage.hidl_memory_response', index=8,
- number=3002, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hidl_handle_response', full_name='android.vts.VtsDriverControlResponseMessage.hidl_handle_response', index=9,
- number=3003, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=731,
- serialized_end=1144,
-)
-
-_VTSDRIVERCONTROLCOMMANDMESSAGE.fields_by_name['command_type'].enum_type = _VTSDRIVERCOMMANDTYPE
-_VTSDRIVERCONTROLCOMMANDMESSAGE.fields_by_name['fmq_request'].message_type = VtsResourceControllerMessage__pb2._FMQREQUESTMESSAGE
-_VTSDRIVERCONTROLCOMMANDMESSAGE.fields_by_name['hidl_memory_request'].message_type = VtsResourceControllerMessage__pb2._HIDLMEMORYREQUESTMESSAGE
-_VTSDRIVERCONTROLCOMMANDMESSAGE.fields_by_name['hidl_handle_request'].message_type = VtsResourceControllerMessage__pb2._HIDLHANDLEREQUESTMESSAGE
-_VTSDRIVERCONTROLRESPONSEMESSAGE.fields_by_name['response_code'].enum_type = _VTSDRIVERRESPONSECODE
-_VTSDRIVERCONTROLRESPONSEMESSAGE.fields_by_name['fmq_response'].message_type = VtsResourceControllerMessage__pb2._FMQRESPONSEMESSAGE
-_VTSDRIVERCONTROLRESPONSEMESSAGE.fields_by_name['hidl_memory_response'].message_type = VtsResourceControllerMessage__pb2._HIDLMEMORYRESPONSEMESSAGE
-_VTSDRIVERCONTROLRESPONSEMESSAGE.fields_by_name['hidl_handle_response'].message_type = VtsResourceControllerMessage__pb2._HIDLHANDLERESPONSEMESSAGE
-DESCRIPTOR.message_types_by_name['VtsDriverControlCommandMessage'] = _VTSDRIVERCONTROLCOMMANDMESSAGE
-DESCRIPTOR.message_types_by_name['VtsDriverControlResponseMessage'] = _VTSDRIVERCONTROLRESPONSEMESSAGE
-DESCRIPTOR.enum_types_by_name['VtsDriverCommandType'] = _VTSDRIVERCOMMANDTYPE
-DESCRIPTOR.enum_types_by_name['VtsDriverResponseCode'] = _VTSDRIVERRESPONSECODE
-_sym_db.RegisterFileDescriptor(DESCRIPTOR)
-
-VtsDriverControlCommandMessage = _reflection.GeneratedProtocolMessageType('VtsDriverControlCommandMessage', (_message.Message,), {
- 'DESCRIPTOR' : _VTSDRIVERCONTROLCOMMANDMESSAGE,
- '__module__' : 'VtsDriverControlMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.VtsDriverControlCommandMessage)
- })
-_sym_db.RegisterMessage(VtsDriverControlCommandMessage)
-
-VtsDriverControlResponseMessage = _reflection.GeneratedProtocolMessageType('VtsDriverControlResponseMessage', (_message.Message,), {
- 'DESCRIPTOR' : _VTSDRIVERCONTROLRESPONSEMESSAGE,
- '__module__' : 'VtsDriverControlMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.VtsDriverControlResponseMessage)
- })
-_sym_db.RegisterMessage(VtsDriverControlResponseMessage)
-
-
-_VTSDRIVERCONTROLCOMMANDMESSAGE.fields_by_name['target_version']._options = None
-# @@protoc_insertion_point(module_scope)
diff --git a/proto/VtsFuzzTaskMessage.proto b/proto/VtsFuzzTaskMessage.proto
deleted file mode 100644
index 7e54547..0000000
--- a/proto/VtsFuzzTaskMessage.proto
+++ /dev/null
@@ -1,139 +0,0 @@
-// Copyright 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.
-
-syntax = "proto2";
-
-package android.vts;
-option java_package = "com.android.vts.proto";
-option java_outer_classname = "VtsFuzzTaskMessageClass";
-
-import "test/vts/proto/ComponentSpecificationMessage.proto";
-import "test/vts/proto/VtsReportMessage.proto";
-
-
-// To specify status of a FuzzTaskUnitMessage
-enum Status {
- // task not processed yet
- READY = 0;
-
- // task in process
- LOCKED = 1;
-
- // task fully processed
- PROCESSED = 2;
-}
-
-
-// To specify result of fuzz task
-enum Result {
- // task not processed yet
- NOT_PROCESSED = 0;
-
- // duplicate crash
- CRASH_DUPLICATE = 1;
-
- // new crash
- CRASH_NEW = 2;
-
- // fuzz test passed with no crash
- PASS = 3;
-}
-
-
-// To specify details of the test suite target
-message TestSuiteSpecificationMessage {
- // target product (e.g., VTS)
- optional bytes test_suite = 1;
-
- // branch name (e.g., master, oc-dev)
- optional bytes branch = 11;
-
- // target product (e.g., aosp_arm64)
- optional bytes target_product = 12;
-
- // build variant (e.g., userdebug)
- optional bytes build_variant = 13;
-
- // build ID
- optional bytes build_id = 21;
-}
-
-
-// To specify details of a corpus
-message CorpusSpecificationMessage {
- // Component class (e.g., HIDL HAL or Conventional HAL)
- optional ComponentClass component_class = 1;
-
- // Corpus file names
- repeated bytes corpus_file_name = 2;
-
- // HAL package name (e.g., android.hardware.audio)
- optional bytes hal_package_name = 11;
-
- // HAL transport type (e.g., hwbinder, passthrough)
- optional bytes hal_transport_type = 12;
-
- // HAL major version (e.g., 2 of 2.0)
- optional int32 hal_major_version = 13;
-
- // HAL minor version (e.g., 0 of 2.0)
- optional int32 hal_minor_version = 14;
-
- // HAL interface name (e.g., IDevicesFactory)
- optional bytes hal_interface_name = 15;
-}
-
-
-// To specify details of a fuzz task per target
-message FuzzTaskUnitMessage {
- // status of fuzz task
- optional Status status = 1;
-
- // result of fuzz task
- optional Result result_type = 2;
-
- // log files (host or device)
- repeated UrlResourceMessage log = 3;
-
- // tracks when the fuzz task unit was created
- optional int64 creation_timestamp = 11;
-
- // tracks when most recent status change occurred
- optional int64 status_change_timestamp = 12;
-
- // specification of fuzz task device target
- optional AndroidDeviceInfoMessage device_info = 21;
-
- // specification of fuzz task device build info
- optional AndroidBuildInfo build_info = 22;
-
- // specification of test suite (e.g., VTS) build target
- optional TestSuiteSpecificationMessage test_suite_target = 23;
-}
-
-
-// To specify a fuzz task
-message VtsFuzzTaskMessage {
- // numeric Task ID
- optional int32 task_id = 1;
-
- // specification of fuzz task per target
- repeated FuzzTaskUnitMessage task_unit = 2;
-
- // VTS test module name
- optional bytes test_module_name = 11;
-
- // specification of corpus
- optional CorpusSpecificationMessage corpus = 21;
-}
diff --git a/proto/VtsFuzzTaskMessage_pb2.py b/proto/VtsFuzzTaskMessage_pb2.py
deleted file mode 100644
index 64a7ff2..0000000
--- a/proto/VtsFuzzTaskMessage_pb2.py
+++ /dev/null
@@ -1,408 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: VtsFuzzTaskMessage.proto
-
-import sys
-_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
-from google.protobuf.internal import enum_type_wrapper
-from google.protobuf import descriptor as _descriptor
-from google.protobuf import message as _message
-from google.protobuf import reflection as _reflection
-from google.protobuf import symbol_database as _symbol_database
-# @@protoc_insertion_point(imports)
-
-_sym_db = _symbol_database.Default()
-
-
-import ComponentSpecificationMessage_pb2 as ComponentSpecificationMessage__pb2
-import VtsReportMessage_pb2 as VtsReportMessage__pb2
-
-
-DESCRIPTOR = _descriptor.FileDescriptor(
- name='VtsFuzzTaskMessage.proto',
- package='android.vts',
- syntax='proto2',
- serialized_options=_b('\n\025com.android.vts.protoB\027VtsFuzzTaskMessageClass'),
- serialized_pb=_b('\n\x18VtsFuzzTaskMessage.proto\x12\x0b\x61ndroid.vts\x1a#ComponentSpecificationMessage.proto\x1a\x16VtsReportMessage.proto\"\x84\x01\n\x1dTestSuiteSpecificationMessage\x12\x12\n\ntest_suite\x18\x01 \x01(\x0c\x12\x0e\n\x06\x62ranch\x18\x0b \x01(\x0c\x12\x16\n\x0etarget_product\x18\x0c \x01(\x0c\x12\x15\n\rbuild_variant\x18\r \x01(\x0c\x12\x10\n\x08\x62uild_id\x18\x15 \x01(\x0c\"\xf4\x01\n\x1a\x43orpusSpecificationMessage\x12\x34\n\x0f\x63omponent_class\x18\x01 \x01(\x0e\x32\x1b.android.vts.ComponentClass\x12\x18\n\x10\x63orpus_file_name\x18\x02 \x03(\x0c\x12\x18\n\x10hal_package_name\x18\x0b \x01(\x0c\x12\x1a\n\x12hal_transport_type\x18\x0c \x01(\x0c\x12\x19\n\x11hal_major_version\x18\r \x01(\x05\x12\x19\n\x11hal_minor_version\x18\x0e \x01(\x05\x12\x1a\n\x12hal_interface_name\x18\x0f \x01(\x0c\"\x85\x03\n\x13\x46uzzTaskUnitMessage\x12#\n\x06status\x18\x01 \x01(\x0e\x32\x13.android.vts.Status\x12(\n\x0bresult_type\x18\x02 \x01(\x0e\x32\x13.android.vts.Result\x12,\n\x03log\x18\x03 \x03(\x0b\x32\x1f.android.vts.UrlResourceMessage\x12\x1a\n\x12\x63reation_timestamp\x18\x0b \x01(\x03\x12\x1f\n\x17status_change_timestamp\x18\x0c \x01(\x03\x12:\n\x0b\x64\x65vice_info\x18\x15 \x01(\x0b\x32%.android.vts.AndroidDeviceInfoMessage\x12\x31\n\nbuild_info\x18\x16 \x01(\x0b\x32\x1d.android.vts.AndroidBuildInfo\x12\x45\n\x11test_suite_target\x18\x17 \x01(\x0b\x32*.android.vts.TestSuiteSpecificationMessage\"\xad\x01\n\x12VtsFuzzTaskMessage\x12\x0f\n\x07task_id\x18\x01 \x01(\x05\x12\x33\n\ttask_unit\x18\x02 \x03(\x0b\x32 .android.vts.FuzzTaskUnitMessage\x12\x18\n\x10test_module_name\x18\x0b \x01(\x0c\x12\x37\n\x06\x63orpus\x18\x15 \x01(\x0b\x32\'.android.vts.CorpusSpecificationMessage*.\n\x06Status\x12\t\n\x05READY\x10\x00\x12\n\n\x06LOCKED\x10\x01\x12\r\n\tPROCESSED\x10\x02*I\n\x06Result\x12\x11\n\rNOT_PROCESSED\x10\x00\x12\x13\n\x0f\x43RASH_DUPLICATE\x10\x01\x12\r\n\tCRASH_NEW\x10\x02\x12\x08\n\x04PASS\x10\x03\x42\x30\n\x15\x63om.android.vts.protoB\x17VtsFuzzTaskMessageClass')
- ,
- dependencies=[ComponentSpecificationMessage__pb2.DESCRIPTOR,VtsReportMessage__pb2.DESCRIPTOR,])
-
-_STATUS = _descriptor.EnumDescriptor(
- name='Status',
- full_name='android.vts.Status',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='READY', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='LOCKED', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='PROCESSED', index=2, number=2,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=1052,
- serialized_end=1098,
-)
-_sym_db.RegisterEnumDescriptor(_STATUS)
-
-Status = enum_type_wrapper.EnumTypeWrapper(_STATUS)
-_RESULT = _descriptor.EnumDescriptor(
- name='Result',
- full_name='android.vts.Result',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='NOT_PROCESSED', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='CRASH_DUPLICATE', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='CRASH_NEW', index=2, number=2,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='PASS', index=3, number=3,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=1100,
- serialized_end=1173,
-)
-_sym_db.RegisterEnumDescriptor(_RESULT)
-
-Result = enum_type_wrapper.EnumTypeWrapper(_RESULT)
-READY = 0
-LOCKED = 1
-PROCESSED = 2
-NOT_PROCESSED = 0
-CRASH_DUPLICATE = 1
-CRASH_NEW = 2
-PASS = 3
-
-
-
-_TESTSUITESPECIFICATIONMESSAGE = _descriptor.Descriptor(
- name='TestSuiteSpecificationMessage',
- full_name='android.vts.TestSuiteSpecificationMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='test_suite', full_name='android.vts.TestSuiteSpecificationMessage.test_suite', index=0,
- number=1, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='branch', full_name='android.vts.TestSuiteSpecificationMessage.branch', index=1,
- number=11, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='target_product', full_name='android.vts.TestSuiteSpecificationMessage.target_product', index=2,
- number=12, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='build_variant', full_name='android.vts.TestSuiteSpecificationMessage.build_variant', index=3,
- number=13, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='build_id', full_name='android.vts.TestSuiteSpecificationMessage.build_id', index=4,
- number=21, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=103,
- serialized_end=235,
-)
-
-
-_CORPUSSPECIFICATIONMESSAGE = _descriptor.Descriptor(
- name='CorpusSpecificationMessage',
- full_name='android.vts.CorpusSpecificationMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='component_class', full_name='android.vts.CorpusSpecificationMessage.component_class', index=0,
- number=1, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='corpus_file_name', full_name='android.vts.CorpusSpecificationMessage.corpus_file_name', index=1,
- number=2, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hal_package_name', full_name='android.vts.CorpusSpecificationMessage.hal_package_name', index=2,
- number=11, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hal_transport_type', full_name='android.vts.CorpusSpecificationMessage.hal_transport_type', index=3,
- number=12, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hal_major_version', full_name='android.vts.CorpusSpecificationMessage.hal_major_version', index=4,
- number=13, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hal_minor_version', full_name='android.vts.CorpusSpecificationMessage.hal_minor_version', index=5,
- number=14, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hal_interface_name', full_name='android.vts.CorpusSpecificationMessage.hal_interface_name', index=6,
- number=15, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=238,
- serialized_end=482,
-)
-
-
-_FUZZTASKUNITMESSAGE = _descriptor.Descriptor(
- name='FuzzTaskUnitMessage',
- full_name='android.vts.FuzzTaskUnitMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='status', full_name='android.vts.FuzzTaskUnitMessage.status', index=0,
- number=1, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='result_type', full_name='android.vts.FuzzTaskUnitMessage.result_type', index=1,
- number=2, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='log', full_name='android.vts.FuzzTaskUnitMessage.log', index=2,
- number=3, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='creation_timestamp', full_name='android.vts.FuzzTaskUnitMessage.creation_timestamp', index=3,
- number=11, type=3, cpp_type=2, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='status_change_timestamp', full_name='android.vts.FuzzTaskUnitMessage.status_change_timestamp', index=4,
- number=12, type=3, cpp_type=2, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='device_info', full_name='android.vts.FuzzTaskUnitMessage.device_info', index=5,
- number=21, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='build_info', full_name='android.vts.FuzzTaskUnitMessage.build_info', index=6,
- number=22, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='test_suite_target', full_name='android.vts.FuzzTaskUnitMessage.test_suite_target', index=7,
- number=23, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=485,
- serialized_end=874,
-)
-
-
-_VTSFUZZTASKMESSAGE = _descriptor.Descriptor(
- name='VtsFuzzTaskMessage',
- full_name='android.vts.VtsFuzzTaskMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='task_id', full_name='android.vts.VtsFuzzTaskMessage.task_id', index=0,
- number=1, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='task_unit', full_name='android.vts.VtsFuzzTaskMessage.task_unit', index=1,
- number=2, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='test_module_name', full_name='android.vts.VtsFuzzTaskMessage.test_module_name', index=2,
- number=11, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='corpus', full_name='android.vts.VtsFuzzTaskMessage.corpus', index=3,
- number=21, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=877,
- serialized_end=1050,
-)
-
-_CORPUSSPECIFICATIONMESSAGE.fields_by_name['component_class'].enum_type = ComponentSpecificationMessage__pb2._COMPONENTCLASS
-_FUZZTASKUNITMESSAGE.fields_by_name['status'].enum_type = _STATUS
-_FUZZTASKUNITMESSAGE.fields_by_name['result_type'].enum_type = _RESULT
-_FUZZTASKUNITMESSAGE.fields_by_name['log'].message_type = VtsReportMessage__pb2._URLRESOURCEMESSAGE
-_FUZZTASKUNITMESSAGE.fields_by_name['device_info'].message_type = VtsReportMessage__pb2._ANDROIDDEVICEINFOMESSAGE
-_FUZZTASKUNITMESSAGE.fields_by_name['build_info'].message_type = VtsReportMessage__pb2._ANDROIDBUILDINFO
-_FUZZTASKUNITMESSAGE.fields_by_name['test_suite_target'].message_type = _TESTSUITESPECIFICATIONMESSAGE
-_VTSFUZZTASKMESSAGE.fields_by_name['task_unit'].message_type = _FUZZTASKUNITMESSAGE
-_VTSFUZZTASKMESSAGE.fields_by_name['corpus'].message_type = _CORPUSSPECIFICATIONMESSAGE
-DESCRIPTOR.message_types_by_name['TestSuiteSpecificationMessage'] = _TESTSUITESPECIFICATIONMESSAGE
-DESCRIPTOR.message_types_by_name['CorpusSpecificationMessage'] = _CORPUSSPECIFICATIONMESSAGE
-DESCRIPTOR.message_types_by_name['FuzzTaskUnitMessage'] = _FUZZTASKUNITMESSAGE
-DESCRIPTOR.message_types_by_name['VtsFuzzTaskMessage'] = _VTSFUZZTASKMESSAGE
-DESCRIPTOR.enum_types_by_name['Status'] = _STATUS
-DESCRIPTOR.enum_types_by_name['Result'] = _RESULT
-_sym_db.RegisterFileDescriptor(DESCRIPTOR)
-
-TestSuiteSpecificationMessage = _reflection.GeneratedProtocolMessageType('TestSuiteSpecificationMessage', (_message.Message,), {
- 'DESCRIPTOR' : _TESTSUITESPECIFICATIONMESSAGE,
- '__module__' : 'VtsFuzzTaskMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.TestSuiteSpecificationMessage)
- })
-_sym_db.RegisterMessage(TestSuiteSpecificationMessage)
-
-CorpusSpecificationMessage = _reflection.GeneratedProtocolMessageType('CorpusSpecificationMessage', (_message.Message,), {
- 'DESCRIPTOR' : _CORPUSSPECIFICATIONMESSAGE,
- '__module__' : 'VtsFuzzTaskMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.CorpusSpecificationMessage)
- })
-_sym_db.RegisterMessage(CorpusSpecificationMessage)
-
-FuzzTaskUnitMessage = _reflection.GeneratedProtocolMessageType('FuzzTaskUnitMessage', (_message.Message,), {
- 'DESCRIPTOR' : _FUZZTASKUNITMESSAGE,
- '__module__' : 'VtsFuzzTaskMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.FuzzTaskUnitMessage)
- })
-_sym_db.RegisterMessage(FuzzTaskUnitMessage)
-
-VtsFuzzTaskMessage = _reflection.GeneratedProtocolMessageType('VtsFuzzTaskMessage', (_message.Message,), {
- 'DESCRIPTOR' : _VTSFUZZTASKMESSAGE,
- '__module__' : 'VtsFuzzTaskMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.VtsFuzzTaskMessage)
- })
-_sym_db.RegisterMessage(VtsFuzzTaskMessage)
-
-
-DESCRIPTOR._options = None
-# @@protoc_insertion_point(module_scope)
diff --git a/proto/VtsProfilingMessage.proto b/proto/VtsProfilingMessage.proto
deleted file mode 100644
index 80e4630..0000000
--- a/proto/VtsProfilingMessage.proto
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright 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.
-
-syntax = "proto2";
-
-package android.vts;
-option java_package = "com.android.vts.proto";
-option java_outer_classname = "VtsProfilingMessageClass";
-
-import "test/vts/proto/ComponentSpecificationMessage.proto";
-
-// Type of an instrumentation event.
-enum InstrumentationEventType {
- // Entry event on the server side of a binderized HAL.
- SERVER_API_ENTRY = 0;
- // Exit event on the server side of a binderized HAL.
- SERVER_API_EXIT = 1;
- // Entry event on the client side of a binderized HAL.
- CLIENT_API_ENTRY = 2;
- // Exit event on the client side of a binderized HAL.
- CLIENT_API_EXIT = 3;
- // Entry event of a synchronize callback.
- SYNC_CALLBACK_ENTRY = 4;
- // Exit event of a synchronize callback.
- SYNC_CALLBACK_EXIT = 5;
- // Entry event of a asynchronize callback.
- ASYNC_CALLBACK_ENTRY = 6;
- // Exit event of a asynchronize callback.
- ASYNC_CALLBACK_EXIT = 7;
- // Entry event of a passthrough HAL.
- PASSTHROUGH_ENTRY = 8;
- // Exit event of a passthrough HAL.
- PASSTHROUGH_EXIT = 9;
-}
-
-// To specify a VTS profiling record.
-message VtsProfilingRecord {
- // The timestamp of the profiling record.
- optional int64 timestamp = 1;
- // Type of the profiling event.
- optional InstrumentationEventType event = 2;
- // Package name of the profiling HAL.
- optional bytes package = 3;
- // Version of the profiling HAL (e.g. 1.0).
- // Deprecated, use version_major and version_minor instead.
- optional float version = 4 [deprecated = true];
- // Interface name of the profiling HAL.
- optional bytes interface = 5;
- // Message of the called function.
- optional FunctionSpecificationMessage func_msg = 6;
- // use two ints to represent major and minor versions separately.
- // HAL major version of the target component (e.g. 1.0 -> 1).
- optional int32 version_major = 7 [default = -1];
- // HAL minor version of the target component (e.g. 1.0 -> 0).
- optional int32 version_minor = 8 [default = -1];
-}
-
-message VtsProfilingMessage {
- repeated VtsProfilingRecord records = 1;
-}
diff --git a/proto/VtsProfilingMessage_pb2.py b/proto/VtsProfilingMessage_pb2.py
deleted file mode 100644
index 27b18d9..0000000
--- a/proto/VtsProfilingMessage_pb2.py
+++ /dev/null
@@ -1,232 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: VtsProfilingMessage.proto
-
-import sys
-_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
-from google.protobuf.internal import enum_type_wrapper
-from google.protobuf import descriptor as _descriptor
-from google.protobuf import message as _message
-from google.protobuf import reflection as _reflection
-from google.protobuf import symbol_database as _symbol_database
-# @@protoc_insertion_point(imports)
-
-_sym_db = _symbol_database.Default()
-
-
-import ComponentSpecificationMessage_pb2 as ComponentSpecificationMessage__pb2
-
-
-DESCRIPTOR = _descriptor.FileDescriptor(
- name='VtsProfilingMessage.proto',
- package='android.vts',
- syntax='proto2',
- serialized_options=_b('\n\025com.android.vts.protoB\030VtsProfilingMessageClass'),
- serialized_pb=_b('\n\x19VtsProfilingMessage.proto\x12\x0b\x61ndroid.vts\x1a#ComponentSpecificationMessage.proto\"\x89\x02\n\x12VtsProfilingRecord\x12\x11\n\ttimestamp\x18\x01 \x01(\x03\x12\x34\n\x05\x65vent\x18\x02 \x01(\x0e\x32%.android.vts.InstrumentationEventType\x12\x0f\n\x07package\x18\x03 \x01(\x0c\x12\x13\n\x07version\x18\x04 \x01(\x02\x42\x02\x18\x01\x12\x11\n\tinterface\x18\x05 \x01(\x0c\x12;\n\x08\x66unc_msg\x18\x06 \x01(\x0b\x32).android.vts.FunctionSpecificationMessage\x12\x19\n\rversion_major\x18\x07 \x01(\x05:\x02-1\x12\x19\n\rversion_minor\x18\x08 \x01(\x05:\x02-1\"G\n\x13VtsProfilingMessage\x12\x30\n\x07records\x18\x01 \x03(\x0b\x32\x1f.android.vts.VtsProfilingRecord*\x81\x02\n\x18InstrumentationEventType\x12\x14\n\x10SERVER_API_ENTRY\x10\x00\x12\x13\n\x0fSERVER_API_EXIT\x10\x01\x12\x14\n\x10\x43LIENT_API_ENTRY\x10\x02\x12\x13\n\x0f\x43LIENT_API_EXIT\x10\x03\x12\x17\n\x13SYNC_CALLBACK_ENTRY\x10\x04\x12\x16\n\x12SYNC_CALLBACK_EXIT\x10\x05\x12\x18\n\x14\x41SYNC_CALLBACK_ENTRY\x10\x06\x12\x17\n\x13\x41SYNC_CALLBACK_EXIT\x10\x07\x12\x15\n\x11PASSTHROUGH_ENTRY\x10\x08\x12\x14\n\x10PASSTHROUGH_EXIT\x10\tB1\n\x15\x63om.android.vts.protoB\x18VtsProfilingMessageClass')
- ,
- dependencies=[ComponentSpecificationMessage__pb2.DESCRIPTOR,])
-
-_INSTRUMENTATIONEVENTTYPE = _descriptor.EnumDescriptor(
- name='InstrumentationEventType',
- full_name='android.vts.InstrumentationEventType',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='SERVER_API_ENTRY', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='SERVER_API_EXIT', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='CLIENT_API_ENTRY', index=2, number=2,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='CLIENT_API_EXIT', index=3, number=3,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='SYNC_CALLBACK_ENTRY', index=4, number=4,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='SYNC_CALLBACK_EXIT', index=5, number=5,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='ASYNC_CALLBACK_ENTRY', index=6, number=6,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='ASYNC_CALLBACK_EXIT', index=7, number=7,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='PASSTHROUGH_ENTRY', index=8, number=8,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='PASSTHROUGH_EXIT', index=9, number=9,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=421,
- serialized_end=678,
-)
-_sym_db.RegisterEnumDescriptor(_INSTRUMENTATIONEVENTTYPE)
-
-InstrumentationEventType = enum_type_wrapper.EnumTypeWrapper(_INSTRUMENTATIONEVENTTYPE)
-SERVER_API_ENTRY = 0
-SERVER_API_EXIT = 1
-CLIENT_API_ENTRY = 2
-CLIENT_API_EXIT = 3
-SYNC_CALLBACK_ENTRY = 4
-SYNC_CALLBACK_EXIT = 5
-ASYNC_CALLBACK_ENTRY = 6
-ASYNC_CALLBACK_EXIT = 7
-PASSTHROUGH_ENTRY = 8
-PASSTHROUGH_EXIT = 9
-
-
-
-_VTSPROFILINGRECORD = _descriptor.Descriptor(
- name='VtsProfilingRecord',
- full_name='android.vts.VtsProfilingRecord',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='timestamp', full_name='android.vts.VtsProfilingRecord.timestamp', index=0,
- number=1, type=3, cpp_type=2, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='event', full_name='android.vts.VtsProfilingRecord.event', index=1,
- number=2, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='package', full_name='android.vts.VtsProfilingRecord.package', index=2,
- number=3, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='version', full_name='android.vts.VtsProfilingRecord.version', index=3,
- number=4, type=2, cpp_type=6, label=1,
- has_default_value=False, default_value=float(0),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=_b('\030\001'), file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='interface', full_name='android.vts.VtsProfilingRecord.interface', index=4,
- number=5, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='func_msg', full_name='android.vts.VtsProfilingRecord.func_msg', index=5,
- number=6, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='version_major', full_name='android.vts.VtsProfilingRecord.version_major', index=6,
- number=7, type=5, cpp_type=1, label=1,
- has_default_value=True, default_value=-1,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='version_minor', full_name='android.vts.VtsProfilingRecord.version_minor', index=7,
- number=8, type=5, cpp_type=1, label=1,
- has_default_value=True, default_value=-1,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=80,
- serialized_end=345,
-)
-
-
-_VTSPROFILINGMESSAGE = _descriptor.Descriptor(
- name='VtsProfilingMessage',
- full_name='android.vts.VtsProfilingMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='records', full_name='android.vts.VtsProfilingMessage.records', index=0,
- number=1, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=347,
- serialized_end=418,
-)
-
-_VTSPROFILINGRECORD.fields_by_name['event'].enum_type = _INSTRUMENTATIONEVENTTYPE
-_VTSPROFILINGRECORD.fields_by_name['func_msg'].message_type = ComponentSpecificationMessage__pb2._FUNCTIONSPECIFICATIONMESSAGE
-_VTSPROFILINGMESSAGE.fields_by_name['records'].message_type = _VTSPROFILINGRECORD
-DESCRIPTOR.message_types_by_name['VtsProfilingRecord'] = _VTSPROFILINGRECORD
-DESCRIPTOR.message_types_by_name['VtsProfilingMessage'] = _VTSPROFILINGMESSAGE
-DESCRIPTOR.enum_types_by_name['InstrumentationEventType'] = _INSTRUMENTATIONEVENTTYPE
-_sym_db.RegisterFileDescriptor(DESCRIPTOR)
-
-VtsProfilingRecord = _reflection.GeneratedProtocolMessageType('VtsProfilingRecord', (_message.Message,), {
- 'DESCRIPTOR' : _VTSPROFILINGRECORD,
- '__module__' : 'VtsProfilingMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.VtsProfilingRecord)
- })
-_sym_db.RegisterMessage(VtsProfilingRecord)
-
-VtsProfilingMessage = _reflection.GeneratedProtocolMessageType('VtsProfilingMessage', (_message.Message,), {
- 'DESCRIPTOR' : _VTSPROFILINGMESSAGE,
- '__module__' : 'VtsProfilingMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.VtsProfilingMessage)
- })
-_sym_db.RegisterMessage(VtsProfilingMessage)
-
-
-DESCRIPTOR._options = None
-_VTSPROFILINGRECORD.fields_by_name['version']._options = None
-# @@protoc_insertion_point(module_scope)
diff --git a/proto/VtsReportMessage.proto b/proto/VtsReportMessage.proto
deleted file mode 100644
index 25bf3eb..0000000
--- a/proto/VtsReportMessage.proto
+++ /dev/null
@@ -1,355 +0,0 @@
-// Copyright 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.
-
-syntax = "proto2";
-
-package android.vts;
-option java_package = "com.android.vts.proto";
-option java_outer_classname = "VtsReportMessage";
-option java_multiple_files = false;
-
-
-// To specify test case execution result.
-enum TestCaseResult {
- UNKNOWN_RESULT = 0;
- TEST_CASE_RESULT_PASS = 1;
- TEST_CASE_RESULT_FAIL = 2;
- TEST_CASE_RESULT_SKIP = 3;
- TEST_CASE_RESULT_EXCEPTION = 4;
- TEST_CASE_RESULT_TIMEOUT = 5;
-}
-
-
-// To specify the VTS test type.
-enum VtsTestType {
- UNKNOWN_VTS_TESTTYPE = 0;
- VTS_HOST_DRIVEN_STRUCTURAL = 1;
- VTS_HOST_DRIVEN_FUZZING = 2;
- VTS_TARGET_SIDE_GTEST = 3;
- VTS_TARGET_SIDE_FUZZING = 4;
-}
-
-enum VtsProfilingRegressionMode {
- UNKNOWN_REGRESSION_MODE = 0;
- // disable analysis
- VTS_REGRESSION_MODE_DISABLED = 1;
- // interpret increases in values as regression
- VTS_REGRESSION_MODE_INCREASING = 2;
- // interpret decreases in values as regression
- VTS_REGRESSION_MODE_DECREASING= 3;
-}
-
-enum VtsProfilingType {
- UNKNOWN_VTS_PROFILING_TYPE = 0;
- // for one sample which measures the time between two profiling points.
- VTS_PROFILING_TYPE_TIMESTAMP = 1;
- // for multiple single-type samples with labels.
- VTS_PROFILING_TYPE_LABELED_VECTOR = 2;
- // for multiple single-type samples without labels.
- VTS_PROFILING_TYPE_UNLABELED_VECTOR = 3;
-}
-
-// To specify a call flow event.
-message AndroidDeviceInfoMessage {
- // product type (e.g., bullhead).
- optional bytes product_type = 1;
-
- // product type variant (e.g., still bullhead or another name).
- optional bytes product_variant = 2;
-
- // build type (e.g., userdebug).
- optional bytes build_flavor = 11;
-
- // Android Build ID.
- optional bytes build_id = 12;
-
- // branch name (e.g., main or nyc-dev).
- optional bytes branch = 21;
-
- // build alias implies the branch name.
- optional bytes build_alias = 22;
-
- // API level
- optional bytes api_level = 31;
-
- // ABI name that is current in use for the test
- optional bytes abi_name = 51;
-
- // ABI bitness that is current in use for the test. Example: '32', '64',
- optional bytes abi_bitness = 52;
-
- // Device USB serial number
- optional bytes serial = 101;
-}
-
-
-// To specify build info.
-message AndroidBuildInfo {
- // build ID.
- optional bytes id = 1;
-
- // device name (e.g., bullhead).
- optional bytes name = 11;
-
- // build type (e.g., userdebug)
- optional bytes build_type = 12;
-
- // branch name (e.g., main or nyc-dev)
- optional bytes branch = 13;
-
- // indicates the latest commit information of each branch (e.g., xml format).
- optional bytes build_summary = 21;
-}
-
-
-// To specify the information about a host node.
-message VtsHostInfo {
- // the host name (i.e., full domain name).
- optional bytes hostname = 1;
-}
-
-
-// To specify a test case execution report.
-message TestCaseReportMessage {
- // the test case name.
- optional bytes name = 1;
-
- // the test result.
- optional TestCaseResult test_result = 11;
-
- // execution start and end time stamp.
- optional int64 start_timestamp = 21;
- optional int64 end_timestamp = 22;
-
- // coverage report per file
- repeated CoverageReportMessage coverage = 31;
-
- // profiling reports
- repeated ProfilingReportMessage profiling = 41;
-
- // systrace report message per file
- repeated SystraceReportMessage systrace = 42 [deprecated=true];
-
- // log for each test case. May contain multiple logs such as logcat, host log,
- // etc.
- repeated LogMessage log = 101;
-}
-
-
-// To specify a profiling report.
-message ProfilingReportMessage {
- // the instrumentation point name.
- optional bytes name = 1;
- optional VtsProfilingType type = 2;
- optional VtsProfilingRegressionMode regression_mode = 3;
-
- // profiling start and end time stamp (for performance).
- optional int64 start_timestamp = 11;
- optional int64 end_timestamp = 12;
-
- repeated bytes label = 21;
- repeated int64 value = 22;
-
- // x-axis and y-axis title labels when displaying the data as a graph
- optional bytes x_axis_label = 31;
- optional bytes y_axis_label = 32;
-
- // a list of strings where each string has the form of 'key=value'.
- // used to tell certain properties of the data (e.g., passthrough vs.
- // binderized).
- repeated bytes options = 41;
-}
-
-// To specify a systrace report.
-message SystraceReportMessage {
- // the target process name used by systrace
- optional bytes process_name = 1;
-
- // the produced html report
- repeated bytes html = 11;
-
- // URLs of the produced html reports
- repeated bytes url = 21;
-}
-
-// To specify a coverage report.
-message CoverageReportMessage {
- // the path to the source file from the project root.
- optional bytes file_path = 11;
-
- // the name of the project where the file can be found
- optional bytes project_name = 12;
-
- // the commit ID identifying the code revision
- optional bytes revision = 13;
-
- // i-th element gives the number of times i-th line is executed.
- repeated int64 line_coverage_vector = 23;
-
- // the number of source code lines that are instrumented for code coverage
- // measurement.
- optional int32 total_line_count = 101;
-
- // the number of source code lines that are executed.
- optional int32 covered_line_count = 102;
-
- // TODO(ryanjcampbell@) delete deprecated field
- // the directory path of a source file.
- optional bytes dir_path = 1 [deprecated=true];
-
- // TODO(ryanjcampbell@) delete deprecated field
- // the name of the source file.
- optional bytes file_name = 2 [deprecated=true];
-
- // TODO(ryanjcampbell@) delete deprecated field
- // produced html report.
- optional bytes html = 3 [deprecated=true];
-}
-
-// Information for a HAL interface.
-message HalInterfaceMessage {
- // HAL package name. e.g. android.hardware.foo.
- optional bytes hal_package_name = 1;
- // HAL (major) version. e.g. 1.
- optional int32 hal_version_major = 2;
- // HAL (minor) version. e.g. 0.
- optional int32 hal_version_minor = 3;
- // HAL interface name. e.g. IFoo.
- optional bytes hal_interface_name = 4;
- // HAL release level (e.g. "current", "27", "28")
- optional bytes hal_release_level = 5;
-}
-
-// To specify a API coverage report. Currently only for HAL API coverage.
-message ApiCoverageReportMessage {
- // Hal interface info.
- optional HalInterfaceMessage hal_interface = 1;
-
- // APIs provided by the HAL with given package, version and interface name.
- repeated bytes hal_api = 11;
-
- // APIs covered by the test.
- repeated bytes covered_hal_api = 12;
-}
-
-// To specify log report. This can be used either for per-test-module
-// log message or per-test-case log message.
-message LogMessage {
- // URL of a produced log file (e.g., stdout, stderr).
- optional bytes url = 1;
-
- // Name of a log file.
- optional bytes name = 2;
-
- // Content of log. Caution: do not put too much log in protobuf message,
- // as BigTable for example recommends < 10 MB for each record cell.
- optional bytes content = 3;
-}
-
-// To specify a resource object (reachable via a URL or contained in the
-// message). This can be used to store a log file or an XML (or HTML) report
-// file kept in a Google Cloud Storage (GCS) bucket or partner's network file
-// system, or hosted by a HTTP server.
-message UrlResourceMessage {
- // URL of a resource file.
- optional bytes url = 1;
-
- // Name of a resource file representing its type and does not have to be
- // the same as the exact file name.
- optional bytes name = 2;
-
- // Raw content of a resource file. Used if the file is small.
- optional bytes content = 3;
-}
-
-// To specify a test execution report.
-message TestReportMessage {
- // The test suite name.
- optional bytes test_suite = 1 [deprecated=true];
-
- // The test name.
- optional bytes test = 2;
-
- // The test type
- optional VtsTestType test_type = 3;
-
- // Target device info
- repeated AndroidDeviceInfoMessage device_info = 4;
-
- // Build info
- optional AndroidBuildInfo build_info = 5;
-
- // Email addresses of subscribers to the test results
- repeated bytes subscriber_email = 6;
-
- // Info about the host computer
- optional VtsHostInfo host_info = 7;
-
- // Test case reports
- repeated TestCaseReportMessage test_case = 11;
-
- // Profiling reports
- repeated ProfilingReportMessage profiling = 21;
-
- // Systrace report per file
- repeated SystraceReportMessage systrace = 22 [deprecated=true];
-
- // Execution start and end time stamp.
- optional int64 start_timestamp = 101;
- optional int64 end_timestamp = 102;
-
- // Coverage report per file
- repeated CoverageReportMessage coverage = 103;
-
- // API coverage report for each HAL interface.
- repeated ApiCoverageReportMessage api_coverage = 104;
-
- // Log for a test module. May contain multiple logs such as logcat, host log,
- // etc.
- repeated LogMessage log = 1001;
-
- // URL links for the test run.
- repeated UrlResourceMessage link_resource = 1011;
-}
-
-// To specify a test execution report.
-message TestPlanReportMessage {
- // Keys used to find all TestReportMessage messages of test modules in
- // this plan.
- repeated string test_module_name = 11;
- repeated int64 test_module_start_timestamp = 12;
-
- // The test plan name.
- optional string test_plan_name = 21;
-
- // Report resource flies.
- repeated UrlResourceMessage partner_report = 31;
-
- // Available HAL APIs for coverage measurement.
- // Only used for profiling test plan.
- repeated ApiCoverageReportMessage hal_api_report = 41;
-
- // Detailed information about the execution environment (e.g., branch,
- // build ID, and device) can be found in the associated TestReportMessage(s)
- // which share the same test_plan_execution_id.
-}
-
-// Proto wrapper for posting data to the VTS Dashboard
-message DashboardPostMessage {
- // oauth2.0 access token
- optional string access_token = 1;
-
- repeated TestReportMessage test_report = 2;
- repeated TestPlanReportMessage test_plan_report = 3;
-}
diff --git a/proto/VtsReportMessage_pb2.py b/proto/VtsReportMessage_pb2.py
deleted file mode 100644
index 75177c2..0000000
--- a/proto/VtsReportMessage_pb2.py
+++ /dev/null
@@ -1,1257 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: VtsReportMessage.proto
-
-import sys
-_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
-from google.protobuf.internal import enum_type_wrapper
-from google.protobuf import descriptor as _descriptor
-from google.protobuf import message as _message
-from google.protobuf import reflection as _reflection
-from google.protobuf import symbol_database as _symbol_database
-# @@protoc_insertion_point(imports)
-
-_sym_db = _symbol_database.Default()
-
-
-
-
-DESCRIPTOR = _descriptor.FileDescriptor(
- name='VtsReportMessage.proto',
- package='android.vts',
- syntax='proto2',
- serialized_options=_b('\n\025com.android.vts.protoB\020VtsReportMessageP\000'),
- serialized_pb=_b('\n\x16VtsReportMessage.proto\x12\x0b\x61ndroid.vts\"\xe0\x01\n\x18\x41ndroidDeviceInfoMessage\x12\x14\n\x0cproduct_type\x18\x01 \x01(\x0c\x12\x17\n\x0fproduct_variant\x18\x02 \x01(\x0c\x12\x14\n\x0c\x62uild_flavor\x18\x0b \x01(\x0c\x12\x10\n\x08\x62uild_id\x18\x0c \x01(\x0c\x12\x0e\n\x06\x62ranch\x18\x15 \x01(\x0c\x12\x13\n\x0b\x62uild_alias\x18\x16 \x01(\x0c\x12\x11\n\tapi_level\x18\x1f \x01(\x0c\x12\x10\n\x08\x61\x62i_name\x18\x33 \x01(\x0c\x12\x13\n\x0b\x61\x62i_bitness\x18\x34 \x01(\x0c\x12\x0e\n\x06serial\x18\x65 \x01(\x0c\"g\n\x10\x41ndroidBuildInfo\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\x0c\n\x04name\x18\x0b \x01(\x0c\x12\x12\n\nbuild_type\x18\x0c \x01(\x0c\x12\x0e\n\x06\x62ranch\x18\r \x01(\x0c\x12\x15\n\rbuild_summary\x18\x15 \x01(\x0c\"\x1f\n\x0bVtsHostInfo\x12\x10\n\x08hostname\x18\x01 \x01(\x0c\"\xd5\x02\n\x15TestCaseReportMessage\x12\x0c\n\x04name\x18\x01 \x01(\x0c\x12\x30\n\x0btest_result\x18\x0b \x01(\x0e\x32\x1b.android.vts.TestCaseResult\x12\x17\n\x0fstart_timestamp\x18\x15 \x01(\x03\x12\x15\n\rend_timestamp\x18\x16 \x01(\x03\x12\x34\n\x08\x63overage\x18\x1f \x03(\x0b\x32\".android.vts.CoverageReportMessage\x12\x36\n\tprofiling\x18) \x03(\x0b\x32#.android.vts.ProfilingReportMessage\x12\x38\n\x08systrace\x18* \x03(\x0b\x32\".android.vts.SystraceReportMessageB\x02\x18\x01\x12$\n\x03log\x18\x65 \x03(\x0b\x32\x17.android.vts.LogMessage\"\xa0\x02\n\x16ProfilingReportMessage\x12\x0c\n\x04name\x18\x01 \x01(\x0c\x12+\n\x04type\x18\x02 \x01(\x0e\x32\x1d.android.vts.VtsProfilingType\x12@\n\x0fregression_mode\x18\x03 \x01(\x0e\x32\'.android.vts.VtsProfilingRegressionMode\x12\x17\n\x0fstart_timestamp\x18\x0b \x01(\x03\x12\x15\n\rend_timestamp\x18\x0c \x01(\x03\x12\r\n\x05label\x18\x15 \x03(\x0c\x12\r\n\x05value\x18\x16 \x03(\x03\x12\x14\n\x0cx_axis_label\x18\x1f \x01(\x0c\x12\x14\n\x0cy_axis_label\x18 \x01(\x0c\x12\x0f\n\x07options\x18) \x03(\x0c\"H\n\x15SystraceReportMessage\x12\x14\n\x0cprocess_name\x18\x01 \x01(\x0c\x12\x0c\n\x04html\x18\x0b \x03(\x0c\x12\x0b\n\x03url\x18\x15 \x03(\x0c\"\xe5\x01\n\x15\x43overageReportMessage\x12\x11\n\tfile_path\x18\x0b \x01(\x0c\x12\x14\n\x0cproject_name\x18\x0c \x01(\x0c\x12\x10\n\x08revision\x18\r \x01(\x0c\x12\x1c\n\x14line_coverage_vector\x18\x17 \x03(\x03\x12\x18\n\x10total_line_count\x18\x65 \x01(\x05\x12\x1a\n\x12\x63overed_line_count\x18\x66 \x01(\x05\x12\x14\n\x08\x64ir_path\x18\x01 \x01(\x0c\x42\x02\x18\x01\x12\x15\n\tfile_name\x18\x02 \x01(\x0c\x42\x02\x18\x01\x12\x10\n\x04html\x18\x03 \x01(\x0c\x42\x02\x18\x01\"\x9c\x01\n\x13HalInterfaceMessage\x12\x18\n\x10hal_package_name\x18\x01 \x01(\x0c\x12\x19\n\x11hal_version_major\x18\x02 \x01(\x05\x12\x19\n\x11hal_version_minor\x18\x03 \x01(\x05\x12\x1a\n\x12hal_interface_name\x18\x04 \x01(\x0c\x12\x19\n\x11hal_release_level\x18\x05 \x01(\x0c\"}\n\x18\x41piCoverageReportMessage\x12\x37\n\rhal_interface\x18\x01 \x01(\x0b\x32 .android.vts.HalInterfaceMessage\x12\x0f\n\x07hal_api\x18\x0b \x03(\x0c\x12\x17\n\x0f\x63overed_hal_api\x18\x0c \x03(\x0c\"8\n\nLogMessage\x12\x0b\n\x03url\x18\x01 \x01(\x0c\x12\x0c\n\x04name\x18\x02 \x01(\x0c\x12\x0f\n\x07\x63ontent\x18\x03 \x01(\x0c\"@\n\x12UrlResourceMessage\x12\x0b\n\x03url\x18\x01 \x01(\x0c\x12\x0c\n\x04name\x18\x02 \x01(\x0c\x12\x0f\n\x07\x63ontent\x18\x03 \x01(\x0c\"\xc8\x05\n\x11TestReportMessage\x12\x16\n\ntest_suite\x18\x01 \x01(\x0c\x42\x02\x18\x01\x12\x0c\n\x04test\x18\x02 \x01(\x0c\x12+\n\ttest_type\x18\x03 \x01(\x0e\x32\x18.android.vts.VtsTestType\x12:\n\x0b\x64\x65vice_info\x18\x04 \x03(\x0b\x32%.android.vts.AndroidDeviceInfoMessage\x12\x31\n\nbuild_info\x18\x05 \x01(\x0b\x32\x1d.android.vts.AndroidBuildInfo\x12\x18\n\x10subscriber_email\x18\x06 \x03(\x0c\x12+\n\thost_info\x18\x07 \x01(\x0b\x32\x18.android.vts.VtsHostInfo\x12\x35\n\ttest_case\x18\x0b \x03(\x0b\x32\".android.vts.TestCaseReportMessage\x12\x36\n\tprofiling\x18\x15 \x03(\x0b\x32#.android.vts.ProfilingReportMessage\x12\x38\n\x08systrace\x18\x16 \x03(\x0b\x32\".android.vts.SystraceReportMessageB\x02\x18\x01\x12\x17\n\x0fstart_timestamp\x18\x65 \x01(\x03\x12\x15\n\rend_timestamp\x18\x66 \x01(\x03\x12\x34\n\x08\x63overage\x18g \x03(\x0b\x32\".android.vts.CoverageReportMessage\x12;\n\x0c\x61pi_coverage\x18h \x03(\x0b\x32%.android.vts.ApiCoverageReportMessage\x12%\n\x03log\x18\xe9\x07 \x03(\x0b\x32\x17.android.vts.LogMessage\x12\x37\n\rlink_resource\x18\xf3\x07 \x03(\x0b\x32\x1f.android.vts.UrlResourceMessage\"\xe6\x01\n\x15TestPlanReportMessage\x12\x18\n\x10test_module_name\x18\x0b \x03(\t\x12#\n\x1btest_module_start_timestamp\x18\x0c \x03(\x03\x12\x16\n\x0etest_plan_name\x18\x15 \x01(\t\x12\x37\n\x0epartner_report\x18\x1f \x03(\x0b\x32\x1f.android.vts.UrlResourceMessage\x12=\n\x0ehal_api_report\x18) \x03(\x0b\x32%.android.vts.ApiCoverageReportMessage\"\x9f\x01\n\x14\x44\x61shboardPostMessage\x12\x14\n\x0c\x61\x63\x63\x65ss_token\x18\x01 \x01(\t\x12\x33\n\x0btest_report\x18\x02 \x03(\x0b\x32\x1e.android.vts.TestReportMessage\x12<\n\x10test_plan_report\x18\x03 \x03(\x0b\x32\".android.vts.TestPlanReportMessage*\xb3\x01\n\x0eTestCaseResult\x12\x12\n\x0eUNKNOWN_RESULT\x10\x00\x12\x19\n\x15TEST_CASE_RESULT_PASS\x10\x01\x12\x19\n\x15TEST_CASE_RESULT_FAIL\x10\x02\x12\x19\n\x15TEST_CASE_RESULT_SKIP\x10\x03\x12\x1e\n\x1aTEST_CASE_RESULT_EXCEPTION\x10\x04\x12\x1c\n\x18TEST_CASE_RESULT_TIMEOUT\x10\x05*\x9c\x01\n\x0bVtsTestType\x12\x18\n\x14UNKNOWN_VTS_TESTTYPE\x10\x00\x12\x1e\n\x1aVTS_HOST_DRIVEN_STRUCTURAL\x10\x01\x12\x1b\n\x17VTS_HOST_DRIVEN_FUZZING\x10\x02\x12\x19\n\x15VTS_TARGET_SIDE_GTEST\x10\x03\x12\x1b\n\x17VTS_TARGET_SIDE_FUZZING\x10\x04*\xa3\x01\n\x1aVtsProfilingRegressionMode\x12\x1b\n\x17UNKNOWN_REGRESSION_MODE\x10\x00\x12 \n\x1cVTS_REGRESSION_MODE_DISABLED\x10\x01\x12\"\n\x1eVTS_REGRESSION_MODE_INCREASING\x10\x02\x12\"\n\x1eVTS_REGRESSION_MODE_DECREASING\x10\x03*\xa4\x01\n\x10VtsProfilingType\x12\x1e\n\x1aUNKNOWN_VTS_PROFILING_TYPE\x10\x00\x12 \n\x1cVTS_PROFILING_TYPE_TIMESTAMP\x10\x01\x12%\n!VTS_PROFILING_TYPE_LABELED_VECTOR\x10\x02\x12\'\n#VTS_PROFILING_TYPE_UNLABELED_VECTOR\x10\x03\x42+\n\x15\x63om.android.vts.protoB\x10VtsReportMessageP\x00')
-)
-
-_TESTCASERESULT = _descriptor.EnumDescriptor(
- name='TestCaseResult',
- full_name='android.vts.TestCaseResult',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='UNKNOWN_RESULT', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TEST_CASE_RESULT_PASS', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TEST_CASE_RESULT_FAIL', index=2, number=2,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TEST_CASE_RESULT_SKIP', index=3, number=3,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TEST_CASE_RESULT_EXCEPTION', index=4, number=4,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='TEST_CASE_RESULT_TIMEOUT', index=5, number=5,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=2866,
- serialized_end=3045,
-)
-_sym_db.RegisterEnumDescriptor(_TESTCASERESULT)
-
-TestCaseResult = enum_type_wrapper.EnumTypeWrapper(_TESTCASERESULT)
-_VTSTESTTYPE = _descriptor.EnumDescriptor(
- name='VtsTestType',
- full_name='android.vts.VtsTestType',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='UNKNOWN_VTS_TESTTYPE', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_HOST_DRIVEN_STRUCTURAL', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_HOST_DRIVEN_FUZZING', index=2, number=2,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_TARGET_SIDE_GTEST', index=3, number=3,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_TARGET_SIDE_FUZZING', index=4, number=4,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=3048,
- serialized_end=3204,
-)
-_sym_db.RegisterEnumDescriptor(_VTSTESTTYPE)
-
-VtsTestType = enum_type_wrapper.EnumTypeWrapper(_VTSTESTTYPE)
-_VTSPROFILINGREGRESSIONMODE = _descriptor.EnumDescriptor(
- name='VtsProfilingRegressionMode',
- full_name='android.vts.VtsProfilingRegressionMode',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='UNKNOWN_REGRESSION_MODE', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_REGRESSION_MODE_DISABLED', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_REGRESSION_MODE_INCREASING', index=2, number=2,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_REGRESSION_MODE_DECREASING', index=3, number=3,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=3207,
- serialized_end=3370,
-)
-_sym_db.RegisterEnumDescriptor(_VTSPROFILINGREGRESSIONMODE)
-
-VtsProfilingRegressionMode = enum_type_wrapper.EnumTypeWrapper(_VTSPROFILINGREGRESSIONMODE)
-_VTSPROFILINGTYPE = _descriptor.EnumDescriptor(
- name='VtsProfilingType',
- full_name='android.vts.VtsProfilingType',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='UNKNOWN_VTS_PROFILING_TYPE', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_PROFILING_TYPE_TIMESTAMP', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_PROFILING_TYPE_LABELED_VECTOR', index=2, number=2,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='VTS_PROFILING_TYPE_UNLABELED_VECTOR', index=3, number=3,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=3373,
- serialized_end=3537,
-)
-_sym_db.RegisterEnumDescriptor(_VTSPROFILINGTYPE)
-
-VtsProfilingType = enum_type_wrapper.EnumTypeWrapper(_VTSPROFILINGTYPE)
-UNKNOWN_RESULT = 0
-TEST_CASE_RESULT_PASS = 1
-TEST_CASE_RESULT_FAIL = 2
-TEST_CASE_RESULT_SKIP = 3
-TEST_CASE_RESULT_EXCEPTION = 4
-TEST_CASE_RESULT_TIMEOUT = 5
-UNKNOWN_VTS_TESTTYPE = 0
-VTS_HOST_DRIVEN_STRUCTURAL = 1
-VTS_HOST_DRIVEN_FUZZING = 2
-VTS_TARGET_SIDE_GTEST = 3
-VTS_TARGET_SIDE_FUZZING = 4
-UNKNOWN_REGRESSION_MODE = 0
-VTS_REGRESSION_MODE_DISABLED = 1
-VTS_REGRESSION_MODE_INCREASING = 2
-VTS_REGRESSION_MODE_DECREASING = 3
-UNKNOWN_VTS_PROFILING_TYPE = 0
-VTS_PROFILING_TYPE_TIMESTAMP = 1
-VTS_PROFILING_TYPE_LABELED_VECTOR = 2
-VTS_PROFILING_TYPE_UNLABELED_VECTOR = 3
-
-
-
-_ANDROIDDEVICEINFOMESSAGE = _descriptor.Descriptor(
- name='AndroidDeviceInfoMessage',
- full_name='android.vts.AndroidDeviceInfoMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='product_type', full_name='android.vts.AndroidDeviceInfoMessage.product_type', index=0,
- number=1, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='product_variant', full_name='android.vts.AndroidDeviceInfoMessage.product_variant', index=1,
- number=2, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='build_flavor', full_name='android.vts.AndroidDeviceInfoMessage.build_flavor', index=2,
- number=11, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='build_id', full_name='android.vts.AndroidDeviceInfoMessage.build_id', index=3,
- number=12, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='branch', full_name='android.vts.AndroidDeviceInfoMessage.branch', index=4,
- number=21, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='build_alias', full_name='android.vts.AndroidDeviceInfoMessage.build_alias', index=5,
- number=22, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='api_level', full_name='android.vts.AndroidDeviceInfoMessage.api_level', index=6,
- number=31, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='abi_name', full_name='android.vts.AndroidDeviceInfoMessage.abi_name', index=7,
- number=51, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='abi_bitness', full_name='android.vts.AndroidDeviceInfoMessage.abi_bitness', index=8,
- number=52, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='serial', full_name='android.vts.AndroidDeviceInfoMessage.serial', index=9,
- number=101, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=40,
- serialized_end=264,
-)
-
-
-_ANDROIDBUILDINFO = _descriptor.Descriptor(
- name='AndroidBuildInfo',
- full_name='android.vts.AndroidBuildInfo',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='id', full_name='android.vts.AndroidBuildInfo.id', index=0,
- number=1, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='name', full_name='android.vts.AndroidBuildInfo.name', index=1,
- number=11, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='build_type', full_name='android.vts.AndroidBuildInfo.build_type', index=2,
- number=12, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='branch', full_name='android.vts.AndroidBuildInfo.branch', index=3,
- number=13, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='build_summary', full_name='android.vts.AndroidBuildInfo.build_summary', index=4,
- number=21, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=266,
- serialized_end=369,
-)
-
-
-_VTSHOSTINFO = _descriptor.Descriptor(
- name='VtsHostInfo',
- full_name='android.vts.VtsHostInfo',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='hostname', full_name='android.vts.VtsHostInfo.hostname', index=0,
- number=1, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=371,
- serialized_end=402,
-)
-
-
-_TESTCASEREPORTMESSAGE = _descriptor.Descriptor(
- name='TestCaseReportMessage',
- full_name='android.vts.TestCaseReportMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='name', full_name='android.vts.TestCaseReportMessage.name', index=0,
- number=1, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='test_result', full_name='android.vts.TestCaseReportMessage.test_result', index=1,
- number=11, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='start_timestamp', full_name='android.vts.TestCaseReportMessage.start_timestamp', index=2,
- number=21, type=3, cpp_type=2, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='end_timestamp', full_name='android.vts.TestCaseReportMessage.end_timestamp', index=3,
- number=22, type=3, cpp_type=2, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='coverage', full_name='android.vts.TestCaseReportMessage.coverage', index=4,
- number=31, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='profiling', full_name='android.vts.TestCaseReportMessage.profiling', index=5,
- number=41, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='systrace', full_name='android.vts.TestCaseReportMessage.systrace', index=6,
- number=42, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=_b('\030\001'), file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='log', full_name='android.vts.TestCaseReportMessage.log', index=7,
- number=101, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=405,
- serialized_end=746,
-)
-
-
-_PROFILINGREPORTMESSAGE = _descriptor.Descriptor(
- name='ProfilingReportMessage',
- full_name='android.vts.ProfilingReportMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='name', full_name='android.vts.ProfilingReportMessage.name', index=0,
- number=1, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='type', full_name='android.vts.ProfilingReportMessage.type', index=1,
- number=2, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='regression_mode', full_name='android.vts.ProfilingReportMessage.regression_mode', index=2,
- number=3, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='start_timestamp', full_name='android.vts.ProfilingReportMessage.start_timestamp', index=3,
- number=11, type=3, cpp_type=2, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='end_timestamp', full_name='android.vts.ProfilingReportMessage.end_timestamp', index=4,
- number=12, type=3, cpp_type=2, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='label', full_name='android.vts.ProfilingReportMessage.label', index=5,
- number=21, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='value', full_name='android.vts.ProfilingReportMessage.value', index=6,
- number=22, type=3, cpp_type=2, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='x_axis_label', full_name='android.vts.ProfilingReportMessage.x_axis_label', index=7,
- number=31, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='y_axis_label', full_name='android.vts.ProfilingReportMessage.y_axis_label', index=8,
- number=32, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='options', full_name='android.vts.ProfilingReportMessage.options', index=9,
- number=41, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=749,
- serialized_end=1037,
-)
-
-
-_SYSTRACEREPORTMESSAGE = _descriptor.Descriptor(
- name='SystraceReportMessage',
- full_name='android.vts.SystraceReportMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='process_name', full_name='android.vts.SystraceReportMessage.process_name', index=0,
- number=1, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='html', full_name='android.vts.SystraceReportMessage.html', index=1,
- number=11, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='url', full_name='android.vts.SystraceReportMessage.url', index=2,
- number=21, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=1039,
- serialized_end=1111,
-)
-
-
-_COVERAGEREPORTMESSAGE = _descriptor.Descriptor(
- name='CoverageReportMessage',
- full_name='android.vts.CoverageReportMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='file_path', full_name='android.vts.CoverageReportMessage.file_path', index=0,
- number=11, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='project_name', full_name='android.vts.CoverageReportMessage.project_name', index=1,
- number=12, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='revision', full_name='android.vts.CoverageReportMessage.revision', index=2,
- number=13, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='line_coverage_vector', full_name='android.vts.CoverageReportMessage.line_coverage_vector', index=3,
- number=23, type=3, cpp_type=2, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='total_line_count', full_name='android.vts.CoverageReportMessage.total_line_count', index=4,
- number=101, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='covered_line_count', full_name='android.vts.CoverageReportMessage.covered_line_count', index=5,
- number=102, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='dir_path', full_name='android.vts.CoverageReportMessage.dir_path', index=6,
- number=1, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=_b('\030\001'), file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='file_name', full_name='android.vts.CoverageReportMessage.file_name', index=7,
- number=2, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=_b('\030\001'), file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='html', full_name='android.vts.CoverageReportMessage.html', index=8,
- number=3, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=_b('\030\001'), file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=1114,
- serialized_end=1343,
-)
-
-
-_HALINTERFACEMESSAGE = _descriptor.Descriptor(
- name='HalInterfaceMessage',
- full_name='android.vts.HalInterfaceMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='hal_package_name', full_name='android.vts.HalInterfaceMessage.hal_package_name', index=0,
- number=1, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hal_version_major', full_name='android.vts.HalInterfaceMessage.hal_version_major', index=1,
- number=2, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hal_version_minor', full_name='android.vts.HalInterfaceMessage.hal_version_minor', index=2,
- number=3, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hal_interface_name', full_name='android.vts.HalInterfaceMessage.hal_interface_name', index=3,
- number=4, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hal_release_level', full_name='android.vts.HalInterfaceMessage.hal_release_level', index=4,
- number=5, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=1346,
- serialized_end=1502,
-)
-
-
-_APICOVERAGEREPORTMESSAGE = _descriptor.Descriptor(
- name='ApiCoverageReportMessage',
- full_name='android.vts.ApiCoverageReportMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='hal_interface', full_name='android.vts.ApiCoverageReportMessage.hal_interface', index=0,
- number=1, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hal_api', full_name='android.vts.ApiCoverageReportMessage.hal_api', index=1,
- number=11, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='covered_hal_api', full_name='android.vts.ApiCoverageReportMessage.covered_hal_api', index=2,
- number=12, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=1504,
- serialized_end=1629,
-)
-
-
-_LOGMESSAGE = _descriptor.Descriptor(
- name='LogMessage',
- full_name='android.vts.LogMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='url', full_name='android.vts.LogMessage.url', index=0,
- number=1, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='name', full_name='android.vts.LogMessage.name', index=1,
- number=2, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='content', full_name='android.vts.LogMessage.content', index=2,
- number=3, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=1631,
- serialized_end=1687,
-)
-
-
-_URLRESOURCEMESSAGE = _descriptor.Descriptor(
- name='UrlResourceMessage',
- full_name='android.vts.UrlResourceMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='url', full_name='android.vts.UrlResourceMessage.url', index=0,
- number=1, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='name', full_name='android.vts.UrlResourceMessage.name', index=1,
- number=2, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='content', full_name='android.vts.UrlResourceMessage.content', index=2,
- number=3, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=1689,
- serialized_end=1753,
-)
-
-
-_TESTREPORTMESSAGE = _descriptor.Descriptor(
- name='TestReportMessage',
- full_name='android.vts.TestReportMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='test_suite', full_name='android.vts.TestReportMessage.test_suite', index=0,
- number=1, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=_b('\030\001'), file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='test', full_name='android.vts.TestReportMessage.test', index=1,
- number=2, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='test_type', full_name='android.vts.TestReportMessage.test_type', index=2,
- number=3, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='device_info', full_name='android.vts.TestReportMessage.device_info', index=3,
- number=4, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='build_info', full_name='android.vts.TestReportMessage.build_info', index=4,
- number=5, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='subscriber_email', full_name='android.vts.TestReportMessage.subscriber_email', index=5,
- number=6, type=12, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='host_info', full_name='android.vts.TestReportMessage.host_info', index=6,
- number=7, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='test_case', full_name='android.vts.TestReportMessage.test_case', index=7,
- number=11, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='profiling', full_name='android.vts.TestReportMessage.profiling', index=8,
- number=21, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='systrace', full_name='android.vts.TestReportMessage.systrace', index=9,
- number=22, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=_b('\030\001'), file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='start_timestamp', full_name='android.vts.TestReportMessage.start_timestamp', index=10,
- number=101, type=3, cpp_type=2, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='end_timestamp', full_name='android.vts.TestReportMessage.end_timestamp', index=11,
- number=102, type=3, cpp_type=2, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='coverage', full_name='android.vts.TestReportMessage.coverage', index=12,
- number=103, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='api_coverage', full_name='android.vts.TestReportMessage.api_coverage', index=13,
- number=104, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='log', full_name='android.vts.TestReportMessage.log', index=14,
- number=1001, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='link_resource', full_name='android.vts.TestReportMessage.link_resource', index=15,
- number=1011, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=1756,
- serialized_end=2468,
-)
-
-
-_TESTPLANREPORTMESSAGE = _descriptor.Descriptor(
- name='TestPlanReportMessage',
- full_name='android.vts.TestPlanReportMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='test_module_name', full_name='android.vts.TestPlanReportMessage.test_module_name', index=0,
- number=11, type=9, cpp_type=9, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='test_module_start_timestamp', full_name='android.vts.TestPlanReportMessage.test_module_start_timestamp', index=1,
- number=12, type=3, cpp_type=2, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='test_plan_name', full_name='android.vts.TestPlanReportMessage.test_plan_name', index=2,
- number=21, type=9, cpp_type=9, label=1,
- has_default_value=False, default_value=_b("").decode('utf-8'),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='partner_report', full_name='android.vts.TestPlanReportMessage.partner_report', index=3,
- number=31, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='hal_api_report', full_name='android.vts.TestPlanReportMessage.hal_api_report', index=4,
- number=41, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=2471,
- serialized_end=2701,
-)
-
-
-_DASHBOARDPOSTMESSAGE = _descriptor.Descriptor(
- name='DashboardPostMessage',
- full_name='android.vts.DashboardPostMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='access_token', full_name='android.vts.DashboardPostMessage.access_token', index=0,
- number=1, type=9, cpp_type=9, label=1,
- has_default_value=False, default_value=_b("").decode('utf-8'),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='test_report', full_name='android.vts.DashboardPostMessage.test_report', index=1,
- number=2, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='test_plan_report', full_name='android.vts.DashboardPostMessage.test_plan_report', index=2,
- number=3, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=2704,
- serialized_end=2863,
-)
-
-_TESTCASEREPORTMESSAGE.fields_by_name['test_result'].enum_type = _TESTCASERESULT
-_TESTCASEREPORTMESSAGE.fields_by_name['coverage'].message_type = _COVERAGEREPORTMESSAGE
-_TESTCASEREPORTMESSAGE.fields_by_name['profiling'].message_type = _PROFILINGREPORTMESSAGE
-_TESTCASEREPORTMESSAGE.fields_by_name['systrace'].message_type = _SYSTRACEREPORTMESSAGE
-_TESTCASEREPORTMESSAGE.fields_by_name['log'].message_type = _LOGMESSAGE
-_PROFILINGREPORTMESSAGE.fields_by_name['type'].enum_type = _VTSPROFILINGTYPE
-_PROFILINGREPORTMESSAGE.fields_by_name['regression_mode'].enum_type = _VTSPROFILINGREGRESSIONMODE
-_APICOVERAGEREPORTMESSAGE.fields_by_name['hal_interface'].message_type = _HALINTERFACEMESSAGE
-_TESTREPORTMESSAGE.fields_by_name['test_type'].enum_type = _VTSTESTTYPE
-_TESTREPORTMESSAGE.fields_by_name['device_info'].message_type = _ANDROIDDEVICEINFOMESSAGE
-_TESTREPORTMESSAGE.fields_by_name['build_info'].message_type = _ANDROIDBUILDINFO
-_TESTREPORTMESSAGE.fields_by_name['host_info'].message_type = _VTSHOSTINFO
-_TESTREPORTMESSAGE.fields_by_name['test_case'].message_type = _TESTCASEREPORTMESSAGE
-_TESTREPORTMESSAGE.fields_by_name['profiling'].message_type = _PROFILINGREPORTMESSAGE
-_TESTREPORTMESSAGE.fields_by_name['systrace'].message_type = _SYSTRACEREPORTMESSAGE
-_TESTREPORTMESSAGE.fields_by_name['coverage'].message_type = _COVERAGEREPORTMESSAGE
-_TESTREPORTMESSAGE.fields_by_name['api_coverage'].message_type = _APICOVERAGEREPORTMESSAGE
-_TESTREPORTMESSAGE.fields_by_name['log'].message_type = _LOGMESSAGE
-_TESTREPORTMESSAGE.fields_by_name['link_resource'].message_type = _URLRESOURCEMESSAGE
-_TESTPLANREPORTMESSAGE.fields_by_name['partner_report'].message_type = _URLRESOURCEMESSAGE
-_TESTPLANREPORTMESSAGE.fields_by_name['hal_api_report'].message_type = _APICOVERAGEREPORTMESSAGE
-_DASHBOARDPOSTMESSAGE.fields_by_name['test_report'].message_type = _TESTREPORTMESSAGE
-_DASHBOARDPOSTMESSAGE.fields_by_name['test_plan_report'].message_type = _TESTPLANREPORTMESSAGE
-DESCRIPTOR.message_types_by_name['AndroidDeviceInfoMessage'] = _ANDROIDDEVICEINFOMESSAGE
-DESCRIPTOR.message_types_by_name['AndroidBuildInfo'] = _ANDROIDBUILDINFO
-DESCRIPTOR.message_types_by_name['VtsHostInfo'] = _VTSHOSTINFO
-DESCRIPTOR.message_types_by_name['TestCaseReportMessage'] = _TESTCASEREPORTMESSAGE
-DESCRIPTOR.message_types_by_name['ProfilingReportMessage'] = _PROFILINGREPORTMESSAGE
-DESCRIPTOR.message_types_by_name['SystraceReportMessage'] = _SYSTRACEREPORTMESSAGE
-DESCRIPTOR.message_types_by_name['CoverageReportMessage'] = _COVERAGEREPORTMESSAGE
-DESCRIPTOR.message_types_by_name['HalInterfaceMessage'] = _HALINTERFACEMESSAGE
-DESCRIPTOR.message_types_by_name['ApiCoverageReportMessage'] = _APICOVERAGEREPORTMESSAGE
-DESCRIPTOR.message_types_by_name['LogMessage'] = _LOGMESSAGE
-DESCRIPTOR.message_types_by_name['UrlResourceMessage'] = _URLRESOURCEMESSAGE
-DESCRIPTOR.message_types_by_name['TestReportMessage'] = _TESTREPORTMESSAGE
-DESCRIPTOR.message_types_by_name['TestPlanReportMessage'] = _TESTPLANREPORTMESSAGE
-DESCRIPTOR.message_types_by_name['DashboardPostMessage'] = _DASHBOARDPOSTMESSAGE
-DESCRIPTOR.enum_types_by_name['TestCaseResult'] = _TESTCASERESULT
-DESCRIPTOR.enum_types_by_name['VtsTestType'] = _VTSTESTTYPE
-DESCRIPTOR.enum_types_by_name['VtsProfilingRegressionMode'] = _VTSPROFILINGREGRESSIONMODE
-DESCRIPTOR.enum_types_by_name['VtsProfilingType'] = _VTSPROFILINGTYPE
-_sym_db.RegisterFileDescriptor(DESCRIPTOR)
-
-AndroidDeviceInfoMessage = _reflection.GeneratedProtocolMessageType('AndroidDeviceInfoMessage', (_message.Message,), {
- 'DESCRIPTOR' : _ANDROIDDEVICEINFOMESSAGE,
- '__module__' : 'VtsReportMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.AndroidDeviceInfoMessage)
- })
-_sym_db.RegisterMessage(AndroidDeviceInfoMessage)
-
-AndroidBuildInfo = _reflection.GeneratedProtocolMessageType('AndroidBuildInfo', (_message.Message,), {
- 'DESCRIPTOR' : _ANDROIDBUILDINFO,
- '__module__' : 'VtsReportMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.AndroidBuildInfo)
- })
-_sym_db.RegisterMessage(AndroidBuildInfo)
-
-VtsHostInfo = _reflection.GeneratedProtocolMessageType('VtsHostInfo', (_message.Message,), {
- 'DESCRIPTOR' : _VTSHOSTINFO,
- '__module__' : 'VtsReportMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.VtsHostInfo)
- })
-_sym_db.RegisterMessage(VtsHostInfo)
-
-TestCaseReportMessage = _reflection.GeneratedProtocolMessageType('TestCaseReportMessage', (_message.Message,), {
- 'DESCRIPTOR' : _TESTCASEREPORTMESSAGE,
- '__module__' : 'VtsReportMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.TestCaseReportMessage)
- })
-_sym_db.RegisterMessage(TestCaseReportMessage)
-
-ProfilingReportMessage = _reflection.GeneratedProtocolMessageType('ProfilingReportMessage', (_message.Message,), {
- 'DESCRIPTOR' : _PROFILINGREPORTMESSAGE,
- '__module__' : 'VtsReportMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.ProfilingReportMessage)
- })
-_sym_db.RegisterMessage(ProfilingReportMessage)
-
-SystraceReportMessage = _reflection.GeneratedProtocolMessageType('SystraceReportMessage', (_message.Message,), {
- 'DESCRIPTOR' : _SYSTRACEREPORTMESSAGE,
- '__module__' : 'VtsReportMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.SystraceReportMessage)
- })
-_sym_db.RegisterMessage(SystraceReportMessage)
-
-CoverageReportMessage = _reflection.GeneratedProtocolMessageType('CoverageReportMessage', (_message.Message,), {
- 'DESCRIPTOR' : _COVERAGEREPORTMESSAGE,
- '__module__' : 'VtsReportMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.CoverageReportMessage)
- })
-_sym_db.RegisterMessage(CoverageReportMessage)
-
-HalInterfaceMessage = _reflection.GeneratedProtocolMessageType('HalInterfaceMessage', (_message.Message,), {
- 'DESCRIPTOR' : _HALINTERFACEMESSAGE,
- '__module__' : 'VtsReportMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.HalInterfaceMessage)
- })
-_sym_db.RegisterMessage(HalInterfaceMessage)
-
-ApiCoverageReportMessage = _reflection.GeneratedProtocolMessageType('ApiCoverageReportMessage', (_message.Message,), {
- 'DESCRIPTOR' : _APICOVERAGEREPORTMESSAGE,
- '__module__' : 'VtsReportMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.ApiCoverageReportMessage)
- })
-_sym_db.RegisterMessage(ApiCoverageReportMessage)
-
-LogMessage = _reflection.GeneratedProtocolMessageType('LogMessage', (_message.Message,), {
- 'DESCRIPTOR' : _LOGMESSAGE,
- '__module__' : 'VtsReportMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.LogMessage)
- })
-_sym_db.RegisterMessage(LogMessage)
-
-UrlResourceMessage = _reflection.GeneratedProtocolMessageType('UrlResourceMessage', (_message.Message,), {
- 'DESCRIPTOR' : _URLRESOURCEMESSAGE,
- '__module__' : 'VtsReportMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.UrlResourceMessage)
- })
-_sym_db.RegisterMessage(UrlResourceMessage)
-
-TestReportMessage = _reflection.GeneratedProtocolMessageType('TestReportMessage', (_message.Message,), {
- 'DESCRIPTOR' : _TESTREPORTMESSAGE,
- '__module__' : 'VtsReportMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.TestReportMessage)
- })
-_sym_db.RegisterMessage(TestReportMessage)
-
-TestPlanReportMessage = _reflection.GeneratedProtocolMessageType('TestPlanReportMessage', (_message.Message,), {
- 'DESCRIPTOR' : _TESTPLANREPORTMESSAGE,
- '__module__' : 'VtsReportMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.TestPlanReportMessage)
- })
-_sym_db.RegisterMessage(TestPlanReportMessage)
-
-DashboardPostMessage = _reflection.GeneratedProtocolMessageType('DashboardPostMessage', (_message.Message,), {
- 'DESCRIPTOR' : _DASHBOARDPOSTMESSAGE,
- '__module__' : 'VtsReportMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.DashboardPostMessage)
- })
-_sym_db.RegisterMessage(DashboardPostMessage)
-
-
-DESCRIPTOR._options = None
-_TESTCASEREPORTMESSAGE.fields_by_name['systrace']._options = None
-_COVERAGEREPORTMESSAGE.fields_by_name['dir_path']._options = None
-_COVERAGEREPORTMESSAGE.fields_by_name['file_name']._options = None
-_COVERAGEREPORTMESSAGE.fields_by_name['html']._options = None
-_TESTREPORTMESSAGE.fields_by_name['test_suite']._options = None
-_TESTREPORTMESSAGE.fields_by_name['systrace']._options = None
-# @@protoc_insertion_point(module_scope)
diff --git a/proto/VtsResourceControllerMessage.proto b/proto/VtsResourceControllerMessage.proto
deleted file mode 100644
index 760901b..0000000
--- a/proto/VtsResourceControllerMessage.proto
+++ /dev/null
@@ -1,206 +0,0 @@
-// 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.
-
-syntax = "proto2";
-
-package android.vts;
-option java_package = "com.android.vts.proto";
-option java_outer_classname = "VtsResourceControllerMessage";
-
-import "test/vts/proto/ComponentSpecificationMessage.proto";
-
-// Possible operations on Fast Message Queue.
-enum FmqOp {
- // Unknown operation.
- FMQ_UNKNOWN = 0;
- // Create a new FMQ object.
- FMQ_CREATE = 1;
- // Read from a FMQ (no blocking).
- FMQ_READ = 2;
- // Read from a FMQ (with short-form blocking).
- FMQ_READ_BLOCKING = 3;
- // Read from a FMQ (with long-form blocking).
- // TODO: support this from host side in the future
- FMQ_READ_BLOCKING_LONG = 4;
- // Write to a FMQ (no blocking).
- FMQ_WRITE = 5;
- // Write to a FMQ (with short-form blocking).
- FMQ_WRITE_BLOCKING = 6;
- // Write to a FMQ (with long-form blocking).
- // TODO: support this from host side in the future
- FMQ_WRITE_BLOCKING_LONG = 7;
- // Get space available to write in FMQ.
- FMQ_AVAILABLE_WRITE = 8;
- // Get number of items available to read.
- FMQ_AVAILABLE_READ = 9;
- // Get size of item in FMQ.
- FMQ_GET_QUANTUM_SIZE = 10;
- // Get number of items that fit in FMQ.
- FMQ_GET_QUANTUM_COUNT = 11;
- // Check if FMQ is valid.
- FMQ_IS_VALID = 12;
- // Get address of queue descriptor.
- // This is an operation that is used in the target-side
- // drivers to pass queue descriptor address to identify
- // the FMQ. It is not for communication between host and
- // target.
- FMQ_GET_DESC_ADDR = 13;
-}
-
-// Possible operations on hidl_memory.
-enum HidlMemoryOp {
- // Unknown operation.
- MEM_PROTO_UNKNOWN = 0;
- // Allcate a new memory region.
- MEM_PROTO_ALLOCATE = 1;
- // Signal starting to read memory.
- MEM_PROTO_START_READ = 2;
- // Signal starting to read a particular region of memory.
- MEM_PROTO_START_READ_RANGE = 3;
- // Perform actual read operation.
- MEM_PROTO_READ_BYTES = 4;
- // Signal starting to write to memory.
- MEM_PROTO_START_UPDATE = 5;
- // Signal starting to write to a particular region of memory.
- MEM_PROTO_START_UPDATE_RANGE = 6;
- // Perform actual write operation.
- MEM_PROTO_UPDATE_BYTES = 7;
- // Commit to a read/write operation.
- MEM_PROTO_COMMIT = 8;
- // Get the size of memory region.
- MEM_PROTO_GET_SIZE = 9;
-}
-
-// Possible operations on hidl_handle.
-enum HidlHandleOp {
- // Unknown operation.
- HANDLE_PROTO_UNKNOWN = 0;
- // Create a handle object for a single file.
- HANDLE_PROTO_CREATE_FILE = 1;
- // Read from a handle object with one file.
- HANDLE_PROTO_READ_FILE = 2;
- // Write to a handle object with one file.
- HANDLE_PROTO_WRITE_FILE = 3;
- // Delete a handle object.
- HANDLE_PROTO_DELETE = 4;
-}
-
-// The arguments for a FMQ operation.
-message FmqRequestMessage {
- // operation to be performed
- optional FmqOp operation = 1;
-
- // string to represent type of data in the queue
- // TODO: support user-defined types
- optional bytes data_type = 2;
- // queue flavor
- optional bool sync = 3;
-
- // queue id
- optional int32 queue_id = 4 [default = -1];
-
- // queue size
- optional uint64 queue_size = 5;
- // whether to enable blocking
- optional bool blocking = 6;
- // whether to reset read/write pointers
- optional bool reset_pointers = 7;
-
- // data to be written
- repeated VariableSpecificationMessage write_data = 8;
- // length of data to be read
- optional uint64 read_data_size = 9;
- // wait time when blocking
- optional int64 time_out_nanos = 10;
-
- // store address of queue descriptor
- // This is a field that is used by internal drivers
- // to identify a FMQ.
- // It is not used for communication between host and target.
- optional uint64 queue_desc_addr = 11;
-}
-
-// The response for a FMQ operation,
-// including scalar values and data read back from the queue.
-message FmqResponseMessage {
- // data read from the queue
- repeated VariableSpecificationMessage read_data = 1;
-
- // three possible return types from FMQ
- // basic util function return values
- optional uint64 sizet_return_val = 2;
- // function that returns a queue id
- optional int32 queue_id = 3;
- // signal if the operation succeeds on target side
- optional bool success = 4;
-}
-
-// The arguments for a hidl_memory operation.
-message HidlMemoryRequestMessage {
- // operation to be performed
- optional HidlMemoryOp operation = 1;
- // id to identify memory region
- optional int32 mem_id = 2 [default = -1];
- // requested memory size
- optional uint64 mem_size = 3;
- // offset from the start of memory region
- optional uint64 start = 4;
- // length of memory to be modified
- optional uint64 length = 5;
- // data to be written into memory
- optional bytes write_data = 6;
-}
-
-// The response for a hidl_memory operation.
-message HidlMemoryResponseMessage {
- // indicate if the memory region is found
- optional bool success = 1;
- // new id assigned to the new memory region
- optional int32 new_mem_id = 2;
- // result returned by GetSize() method on the memory region
- optional uint64 mem_size = 3;
- // data read from memory
- optional bytes read_data = 4;
-}
-
-// The arguments for a hidl_handle operation.
-message HidlHandleRequestMessage {
- // operation to be performed
- optional HidlHandleOp operation = 1;
- // identifies the handle object
- optional int32 handle_id = 2 [default = -1];
- // to specify what files to open, and additional integers
- // in a handle object
- optional HandleDataValueMessage handle_info = 3;
- // number of bytes to read from the file
- // read() function in C I/O takes in a size_t,
- // so use unsigned integer here.
- optional uint64 read_data_size = 4;
- // data to be written into file
- optional bytes write_data = 5;
-}
-
-// The response for a hidl_handle operation.
-message HidlHandleResponseMessage {
- // indicate if the operation succeeds
- optional bool success = 1;
- // new id assigned to the new handle object
- optional int32 new_handle_id = 2;
- // data read from the file
- optional bytes read_data = 3;
- // number of bytes written into the file if the request is a write operation
- // write() function in C I/O returns a ssize_t,
- // so use signed integer here.
- optional int64 write_data_size = 4;
-}
diff --git a/proto/VtsResourceControllerMessage_pb2.py b/proto/VtsResourceControllerMessage_pb2.py
deleted file mode 100644
index d9acb3f..0000000
--- a/proto/VtsResourceControllerMessage_pb2.py
+++ /dev/null
@@ -1,664 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: VtsResourceControllerMessage.proto
-
-import sys
-_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
-from google.protobuf.internal import enum_type_wrapper
-from google.protobuf import descriptor as _descriptor
-from google.protobuf import message as _message
-from google.protobuf import reflection as _reflection
-from google.protobuf import symbol_database as _symbol_database
-# @@protoc_insertion_point(imports)
-
-_sym_db = _symbol_database.Default()
-
-
-import ComponentSpecificationMessage_pb2 as ComponentSpecificationMessage__pb2
-
-
-DESCRIPTOR = _descriptor.FileDescriptor(
- name='VtsResourceControllerMessage.proto',
- package='android.vts',
- syntax='proto2',
- serialized_options=_b('\n\025com.android.vts.protoB\034VtsResourceControllerMessage'),
- serialized_pb=_b('\n\"VtsResourceControllerMessage.proto\x12\x0b\x61ndroid.vts\x1a#ComponentSpecificationMessage.proto\"\xb7\x02\n\x11\x46mqRequestMessage\x12%\n\toperation\x18\x01 \x01(\x0e\x32\x12.android.vts.FmqOp\x12\x11\n\tdata_type\x18\x02 \x01(\x0c\x12\x0c\n\x04sync\x18\x03 \x01(\x08\x12\x14\n\x08queue_id\x18\x04 \x01(\x05:\x02-1\x12\x12\n\nqueue_size\x18\x05 \x01(\x04\x12\x10\n\x08\x62locking\x18\x06 \x01(\x08\x12\x16\n\x0ereset_pointers\x18\x07 \x01(\x08\x12=\n\nwrite_data\x18\x08 \x03(\x0b\x32).android.vts.VariableSpecificationMessage\x12\x16\n\x0eread_data_size\x18\t \x01(\x04\x12\x16\n\x0etime_out_nanos\x18\n \x01(\x03\x12\x17\n\x0fqueue_desc_addr\x18\x0b \x01(\x04\"\x8f\x01\n\x12\x46mqResponseMessage\x12<\n\tread_data\x18\x01 \x03(\x0b\x32).android.vts.VariableSpecificationMessage\x12\x18\n\x10sizet_return_val\x18\x02 \x01(\x04\x12\x10\n\x08queue_id\x18\x03 \x01(\x05\x12\x0f\n\x07success\x18\x04 \x01(\x08\"\xa1\x01\n\x18HidlMemoryRequestMessage\x12,\n\toperation\x18\x01 \x01(\x0e\x32\x19.android.vts.HidlMemoryOp\x12\x12\n\x06mem_id\x18\x02 \x01(\x05:\x02-1\x12\x10\n\x08mem_size\x18\x03 \x01(\x04\x12\r\n\x05start\x18\x04 \x01(\x04\x12\x0e\n\x06length\x18\x05 \x01(\x04\x12\x12\n\nwrite_data\x18\x06 \x01(\x0c\"e\n\x19HidlMemoryResponseMessage\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\x12\n\nnew_mem_id\x18\x02 \x01(\x05\x12\x10\n\x08mem_size\x18\x03 \x01(\x04\x12\x11\n\tread_data\x18\x04 \x01(\x0c\"\xc5\x01\n\x18HidlHandleRequestMessage\x12,\n\toperation\x18\x01 \x01(\x0e\x32\x19.android.vts.HidlHandleOp\x12\x15\n\thandle_id\x18\x02 \x01(\x05:\x02-1\x12\x38\n\x0bhandle_info\x18\x03 \x01(\x0b\x32#.android.vts.HandleDataValueMessage\x12\x16\n\x0eread_data_size\x18\x04 \x01(\x04\x12\x12\n\nwrite_data\x18\x05 \x01(\x0c\"o\n\x19HidlHandleResponseMessage\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\x15\n\rnew_handle_id\x18\x02 \x01(\x05\x12\x11\n\tread_data\x18\x03 \x01(\x0c\x12\x17\n\x0fwrite_data_size\x18\x04 \x01(\x03*\xbc\x02\n\x05\x46mqOp\x12\x0f\n\x0b\x46MQ_UNKNOWN\x10\x00\x12\x0e\n\nFMQ_CREATE\x10\x01\x12\x0c\n\x08\x46MQ_READ\x10\x02\x12\x15\n\x11\x46MQ_READ_BLOCKING\x10\x03\x12\x1a\n\x16\x46MQ_READ_BLOCKING_LONG\x10\x04\x12\r\n\tFMQ_WRITE\x10\x05\x12\x16\n\x12\x46MQ_WRITE_BLOCKING\x10\x06\x12\x1b\n\x17\x46MQ_WRITE_BLOCKING_LONG\x10\x07\x12\x17\n\x13\x46MQ_AVAILABLE_WRITE\x10\x08\x12\x16\n\x12\x46MQ_AVAILABLE_READ\x10\t\x12\x18\n\x14\x46MQ_GET_QUANTUM_SIZE\x10\n\x12\x19\n\x15\x46MQ_GET_QUANTUM_COUNT\x10\x0b\x12\x10\n\x0c\x46MQ_IS_VALID\x10\x0c\x12\x15\n\x11\x46MQ_GET_DESC_ADDR\x10\r*\x99\x02\n\x0cHidlMemoryOp\x12\x15\n\x11MEM_PROTO_UNKNOWN\x10\x00\x12\x16\n\x12MEM_PROTO_ALLOCATE\x10\x01\x12\x18\n\x14MEM_PROTO_START_READ\x10\x02\x12\x1e\n\x1aMEM_PROTO_START_READ_RANGE\x10\x03\x12\x18\n\x14MEM_PROTO_READ_BYTES\x10\x04\x12\x1a\n\x16MEM_PROTO_START_UPDATE\x10\x05\x12 \n\x1cMEM_PROTO_START_UPDATE_RANGE\x10\x06\x12\x1a\n\x16MEM_PROTO_UPDATE_BYTES\x10\x07\x12\x14\n\x10MEM_PROTO_COMMIT\x10\x08\x12\x16\n\x12MEM_PROTO_GET_SIZE\x10\t*\x98\x01\n\x0cHidlHandleOp\x12\x18\n\x14HANDLE_PROTO_UNKNOWN\x10\x00\x12\x1c\n\x18HANDLE_PROTO_CREATE_FILE\x10\x01\x12\x1a\n\x16HANDLE_PROTO_READ_FILE\x10\x02\x12\x1b\n\x17HANDLE_PROTO_WRITE_FILE\x10\x03\x12\x17\n\x13HANDLE_PROTO_DELETE\x10\x04\x42\x35\n\x15\x63om.android.vts.protoB\x1cVtsResourceControllerMessage')
- ,
- dependencies=[ComponentSpecificationMessage__pb2.DESCRIPTOR,])
-
-_FMQOP = _descriptor.EnumDescriptor(
- name='FmqOp',
- full_name='android.vts.FmqOp',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='FMQ_UNKNOWN', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='FMQ_CREATE', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='FMQ_READ', index=2, number=2,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='FMQ_READ_BLOCKING', index=3, number=3,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='FMQ_READ_BLOCKING_LONG', index=4, number=4,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='FMQ_WRITE', index=5, number=5,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='FMQ_WRITE_BLOCKING', index=6, number=6,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='FMQ_WRITE_BLOCKING_LONG', index=7, number=7,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='FMQ_AVAILABLE_WRITE', index=8, number=8,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='FMQ_AVAILABLE_READ', index=9, number=9,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='FMQ_GET_QUANTUM_SIZE', index=10, number=10,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='FMQ_GET_QUANTUM_COUNT', index=11, number=11,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='FMQ_IS_VALID', index=12, number=12,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='FMQ_GET_DESC_ADDR', index=13, number=13,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=1129,
- serialized_end=1445,
-)
-_sym_db.RegisterEnumDescriptor(_FMQOP)
-
-FmqOp = enum_type_wrapper.EnumTypeWrapper(_FMQOP)
-_HIDLMEMORYOP = _descriptor.EnumDescriptor(
- name='HidlMemoryOp',
- full_name='android.vts.HidlMemoryOp',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='MEM_PROTO_UNKNOWN', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='MEM_PROTO_ALLOCATE', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='MEM_PROTO_START_READ', index=2, number=2,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='MEM_PROTO_START_READ_RANGE', index=3, number=3,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='MEM_PROTO_READ_BYTES', index=4, number=4,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='MEM_PROTO_START_UPDATE', index=5, number=5,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='MEM_PROTO_START_UPDATE_RANGE', index=6, number=6,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='MEM_PROTO_UPDATE_BYTES', index=7, number=7,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='MEM_PROTO_COMMIT', index=8, number=8,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='MEM_PROTO_GET_SIZE', index=9, number=9,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=1448,
- serialized_end=1729,
-)
-_sym_db.RegisterEnumDescriptor(_HIDLMEMORYOP)
-
-HidlMemoryOp = enum_type_wrapper.EnumTypeWrapper(_HIDLMEMORYOP)
-_HIDLHANDLEOP = _descriptor.EnumDescriptor(
- name='HidlHandleOp',
- full_name='android.vts.HidlHandleOp',
- filename=None,
- file=DESCRIPTOR,
- values=[
- _descriptor.EnumValueDescriptor(
- name='HANDLE_PROTO_UNKNOWN', index=0, number=0,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='HANDLE_PROTO_CREATE_FILE', index=1, number=1,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='HANDLE_PROTO_READ_FILE', index=2, number=2,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='HANDLE_PROTO_WRITE_FILE', index=3, number=3,
- serialized_options=None,
- type=None),
- _descriptor.EnumValueDescriptor(
- name='HANDLE_PROTO_DELETE', index=4, number=4,
- serialized_options=None,
- type=None),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=1732,
- serialized_end=1884,
-)
-_sym_db.RegisterEnumDescriptor(_HIDLHANDLEOP)
-
-HidlHandleOp = enum_type_wrapper.EnumTypeWrapper(_HIDLHANDLEOP)
-FMQ_UNKNOWN = 0
-FMQ_CREATE = 1
-FMQ_READ = 2
-FMQ_READ_BLOCKING = 3
-FMQ_READ_BLOCKING_LONG = 4
-FMQ_WRITE = 5
-FMQ_WRITE_BLOCKING = 6
-FMQ_WRITE_BLOCKING_LONG = 7
-FMQ_AVAILABLE_WRITE = 8
-FMQ_AVAILABLE_READ = 9
-FMQ_GET_QUANTUM_SIZE = 10
-FMQ_GET_QUANTUM_COUNT = 11
-FMQ_IS_VALID = 12
-FMQ_GET_DESC_ADDR = 13
-MEM_PROTO_UNKNOWN = 0
-MEM_PROTO_ALLOCATE = 1
-MEM_PROTO_START_READ = 2
-MEM_PROTO_START_READ_RANGE = 3
-MEM_PROTO_READ_BYTES = 4
-MEM_PROTO_START_UPDATE = 5
-MEM_PROTO_START_UPDATE_RANGE = 6
-MEM_PROTO_UPDATE_BYTES = 7
-MEM_PROTO_COMMIT = 8
-MEM_PROTO_GET_SIZE = 9
-HANDLE_PROTO_UNKNOWN = 0
-HANDLE_PROTO_CREATE_FILE = 1
-HANDLE_PROTO_READ_FILE = 2
-HANDLE_PROTO_WRITE_FILE = 3
-HANDLE_PROTO_DELETE = 4
-
-
-
-_FMQREQUESTMESSAGE = _descriptor.Descriptor(
- name='FmqRequestMessage',
- full_name='android.vts.FmqRequestMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='operation', full_name='android.vts.FmqRequestMessage.operation', index=0,
- number=1, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='data_type', full_name='android.vts.FmqRequestMessage.data_type', index=1,
- number=2, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='sync', full_name='android.vts.FmqRequestMessage.sync', index=2,
- number=3, type=8, cpp_type=7, label=1,
- has_default_value=False, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='queue_id', full_name='android.vts.FmqRequestMessage.queue_id', index=3,
- number=4, type=5, cpp_type=1, label=1,
- has_default_value=True, default_value=-1,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='queue_size', full_name='android.vts.FmqRequestMessage.queue_size', index=4,
- number=5, type=4, cpp_type=4, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='blocking', full_name='android.vts.FmqRequestMessage.blocking', index=5,
- number=6, type=8, cpp_type=7, label=1,
- has_default_value=False, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='reset_pointers', full_name='android.vts.FmqRequestMessage.reset_pointers', index=6,
- number=7, type=8, cpp_type=7, label=1,
- has_default_value=False, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='write_data', full_name='android.vts.FmqRequestMessage.write_data', index=7,
- number=8, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='read_data_size', full_name='android.vts.FmqRequestMessage.read_data_size', index=8,
- number=9, type=4, cpp_type=4, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='time_out_nanos', full_name='android.vts.FmqRequestMessage.time_out_nanos', index=9,
- number=10, type=3, cpp_type=2, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='queue_desc_addr', full_name='android.vts.FmqRequestMessage.queue_desc_addr', index=10,
- number=11, type=4, cpp_type=4, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=89,
- serialized_end=400,
-)
-
-
-_FMQRESPONSEMESSAGE = _descriptor.Descriptor(
- name='FmqResponseMessage',
- full_name='android.vts.FmqResponseMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='read_data', full_name='android.vts.FmqResponseMessage.read_data', index=0,
- number=1, type=11, cpp_type=10, label=3,
- has_default_value=False, default_value=[],
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='sizet_return_val', full_name='android.vts.FmqResponseMessage.sizet_return_val', index=1,
- number=2, type=4, cpp_type=4, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='queue_id', full_name='android.vts.FmqResponseMessage.queue_id', index=2,
- number=3, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='success', full_name='android.vts.FmqResponseMessage.success', index=3,
- number=4, type=8, cpp_type=7, label=1,
- has_default_value=False, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=403,
- serialized_end=546,
-)
-
-
-_HIDLMEMORYREQUESTMESSAGE = _descriptor.Descriptor(
- name='HidlMemoryRequestMessage',
- full_name='android.vts.HidlMemoryRequestMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='operation', full_name='android.vts.HidlMemoryRequestMessage.operation', index=0,
- number=1, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='mem_id', full_name='android.vts.HidlMemoryRequestMessage.mem_id', index=1,
- number=2, type=5, cpp_type=1, label=1,
- has_default_value=True, default_value=-1,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='mem_size', full_name='android.vts.HidlMemoryRequestMessage.mem_size', index=2,
- number=3, type=4, cpp_type=4, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='start', full_name='android.vts.HidlMemoryRequestMessage.start', index=3,
- number=4, type=4, cpp_type=4, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='length', full_name='android.vts.HidlMemoryRequestMessage.length', index=4,
- number=5, type=4, cpp_type=4, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='write_data', full_name='android.vts.HidlMemoryRequestMessage.write_data', index=5,
- number=6, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=549,
- serialized_end=710,
-)
-
-
-_HIDLMEMORYRESPONSEMESSAGE = _descriptor.Descriptor(
- name='HidlMemoryResponseMessage',
- full_name='android.vts.HidlMemoryResponseMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='success', full_name='android.vts.HidlMemoryResponseMessage.success', index=0,
- number=1, type=8, cpp_type=7, label=1,
- has_default_value=False, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='new_mem_id', full_name='android.vts.HidlMemoryResponseMessage.new_mem_id', index=1,
- number=2, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='mem_size', full_name='android.vts.HidlMemoryResponseMessage.mem_size', index=2,
- number=3, type=4, cpp_type=4, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='read_data', full_name='android.vts.HidlMemoryResponseMessage.read_data', index=3,
- number=4, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=712,
- serialized_end=813,
-)
-
-
-_HIDLHANDLEREQUESTMESSAGE = _descriptor.Descriptor(
- name='HidlHandleRequestMessage',
- full_name='android.vts.HidlHandleRequestMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='operation', full_name='android.vts.HidlHandleRequestMessage.operation', index=0,
- number=1, type=14, cpp_type=8, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='handle_id', full_name='android.vts.HidlHandleRequestMessage.handle_id', index=1,
- number=2, type=5, cpp_type=1, label=1,
- has_default_value=True, default_value=-1,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='handle_info', full_name='android.vts.HidlHandleRequestMessage.handle_info', index=2,
- number=3, type=11, cpp_type=10, label=1,
- has_default_value=False, default_value=None,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='read_data_size', full_name='android.vts.HidlHandleRequestMessage.read_data_size', index=3,
- number=4, type=4, cpp_type=4, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='write_data', full_name='android.vts.HidlHandleRequestMessage.write_data', index=4,
- number=5, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=816,
- serialized_end=1013,
-)
-
-
-_HIDLHANDLERESPONSEMESSAGE = _descriptor.Descriptor(
- name='HidlHandleResponseMessage',
- full_name='android.vts.HidlHandleResponseMessage',
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- fields=[
- _descriptor.FieldDescriptor(
- name='success', full_name='android.vts.HidlHandleResponseMessage.success', index=0,
- number=1, type=8, cpp_type=7, label=1,
- has_default_value=False, default_value=False,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='new_handle_id', full_name='android.vts.HidlHandleResponseMessage.new_handle_id', index=1,
- number=2, type=5, cpp_type=1, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='read_data', full_name='android.vts.HidlHandleResponseMessage.read_data', index=2,
- number=3, type=12, cpp_type=9, label=1,
- has_default_value=False, default_value=_b(""),
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- _descriptor.FieldDescriptor(
- name='write_data_size', full_name='android.vts.HidlHandleResponseMessage.write_data_size', index=3,
- number=4, type=3, cpp_type=2, label=1,
- has_default_value=False, default_value=0,
- message_type=None, enum_type=None, containing_type=None,
- is_extension=False, extension_scope=None,
- serialized_options=None, file=DESCRIPTOR),
- ],
- extensions=[
- ],
- nested_types=[],
- enum_types=[
- ],
- serialized_options=None,
- is_extendable=False,
- syntax='proto2',
- extension_ranges=[],
- oneofs=[
- ],
- serialized_start=1015,
- serialized_end=1126,
-)
-
-_FMQREQUESTMESSAGE.fields_by_name['operation'].enum_type = _FMQOP
-_FMQREQUESTMESSAGE.fields_by_name['write_data'].message_type = ComponentSpecificationMessage__pb2._VARIABLESPECIFICATIONMESSAGE
-_FMQRESPONSEMESSAGE.fields_by_name['read_data'].message_type = ComponentSpecificationMessage__pb2._VARIABLESPECIFICATIONMESSAGE
-_HIDLMEMORYREQUESTMESSAGE.fields_by_name['operation'].enum_type = _HIDLMEMORYOP
-_HIDLHANDLEREQUESTMESSAGE.fields_by_name['operation'].enum_type = _HIDLHANDLEOP
-_HIDLHANDLEREQUESTMESSAGE.fields_by_name['handle_info'].message_type = ComponentSpecificationMessage__pb2._HANDLEDATAVALUEMESSAGE
-DESCRIPTOR.message_types_by_name['FmqRequestMessage'] = _FMQREQUESTMESSAGE
-DESCRIPTOR.message_types_by_name['FmqResponseMessage'] = _FMQRESPONSEMESSAGE
-DESCRIPTOR.message_types_by_name['HidlMemoryRequestMessage'] = _HIDLMEMORYREQUESTMESSAGE
-DESCRIPTOR.message_types_by_name['HidlMemoryResponseMessage'] = _HIDLMEMORYRESPONSEMESSAGE
-DESCRIPTOR.message_types_by_name['HidlHandleRequestMessage'] = _HIDLHANDLEREQUESTMESSAGE
-DESCRIPTOR.message_types_by_name['HidlHandleResponseMessage'] = _HIDLHANDLERESPONSEMESSAGE
-DESCRIPTOR.enum_types_by_name['FmqOp'] = _FMQOP
-DESCRIPTOR.enum_types_by_name['HidlMemoryOp'] = _HIDLMEMORYOP
-DESCRIPTOR.enum_types_by_name['HidlHandleOp'] = _HIDLHANDLEOP
-_sym_db.RegisterFileDescriptor(DESCRIPTOR)
-
-FmqRequestMessage = _reflection.GeneratedProtocolMessageType('FmqRequestMessage', (_message.Message,), {
- 'DESCRIPTOR' : _FMQREQUESTMESSAGE,
- '__module__' : 'VtsResourceControllerMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.FmqRequestMessage)
- })
-_sym_db.RegisterMessage(FmqRequestMessage)
-
-FmqResponseMessage = _reflection.GeneratedProtocolMessageType('FmqResponseMessage', (_message.Message,), {
- 'DESCRIPTOR' : _FMQRESPONSEMESSAGE,
- '__module__' : 'VtsResourceControllerMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.FmqResponseMessage)
- })
-_sym_db.RegisterMessage(FmqResponseMessage)
-
-HidlMemoryRequestMessage = _reflection.GeneratedProtocolMessageType('HidlMemoryRequestMessage', (_message.Message,), {
- 'DESCRIPTOR' : _HIDLMEMORYREQUESTMESSAGE,
- '__module__' : 'VtsResourceControllerMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.HidlMemoryRequestMessage)
- })
-_sym_db.RegisterMessage(HidlMemoryRequestMessage)
-
-HidlMemoryResponseMessage = _reflection.GeneratedProtocolMessageType('HidlMemoryResponseMessage', (_message.Message,), {
- 'DESCRIPTOR' : _HIDLMEMORYRESPONSEMESSAGE,
- '__module__' : 'VtsResourceControllerMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.HidlMemoryResponseMessage)
- })
-_sym_db.RegisterMessage(HidlMemoryResponseMessage)
-
-HidlHandleRequestMessage = _reflection.GeneratedProtocolMessageType('HidlHandleRequestMessage', (_message.Message,), {
- 'DESCRIPTOR' : _HIDLHANDLEREQUESTMESSAGE,
- '__module__' : 'VtsResourceControllerMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.HidlHandleRequestMessage)
- })
-_sym_db.RegisterMessage(HidlHandleRequestMessage)
-
-HidlHandleResponseMessage = _reflection.GeneratedProtocolMessageType('HidlHandleResponseMessage', (_message.Message,), {
- 'DESCRIPTOR' : _HIDLHANDLERESPONSEMESSAGE,
- '__module__' : 'VtsResourceControllerMessage_pb2'
- # @@protoc_insertion_point(class_scope:android.vts.HidlHandleResponseMessage)
- })
-_sym_db.RegisterMessage(HidlHandleResponseMessage)
-
-
-DESCRIPTOR._options = None
-# @@protoc_insertion_point(module_scope)
diff --git a/proto/__init__.py b/proto/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/proto/__init__.py
+++ /dev/null
diff --git a/runners/__init__.py b/runners/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/runners/__init__.py
+++ /dev/null
diff --git a/runners/adapters/__init__.py b/runners/adapters/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/runners/adapters/__init__.py
+++ /dev/null
diff --git a/runners/adapters/acts/__init__.py b/runners/adapters/acts/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/runners/adapters/acts/__init__.py
+++ /dev/null
diff --git a/runners/adapters/acts/acts_adapter.py b/runners/adapters/acts/acts_adapter.py
deleted file mode 100644
index 53f247a..0000000
--- a/runners/adapters/acts/acts_adapter.py
+++ /dev/null
@@ -1,205 +0,0 @@
-#
-# 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.
-#
-
-import importlib
-import json
-import logging
-import os
-import subprocess
-import sys
-import time
-
-from vts.runners.host import asserts
-from vts.runners.host import base_test
-from vts.runners.host import config_parser
-from vts.runners.host import records
-from vts.runners.host import test_runner
-from vts.utils.python.io import capture_printout
-from vts.utils.python.io import file_util
-
-ACTS_TEST_MODULE = 'ACTS_TEST_MODULE'
-LIST_TEST_OUTPUT_START = '==========> '
-LIST_TEST_OUTPUT_END = ' <=========='
-# Temp directory inside python log path. The name is required to be
-# 'temp' for the Java framework to skip reading contents as regular test logs.
-TEMP_DIR_NAME = 'temp'
-CONFIG_FILE_NAME = 'acts_config.txt'
-RESULT_FILE_NAME = 'test_run_summary.json'
-
-CONFIG_TEXT = '''{{
- "_description": "VTS acts tests",
- "testbed":
- [
- {{
- "_description": "ACTS test bed",
- "name": "{module_name}",
- "AndroidDevice":
- [
- {serials}
- ]
- }}
- ],
- "logpath": "{log_path}",
- "testpaths":
- [
- "{src_path}"
- ]
-}}
-'''
-
-
-class ActsAdapter(base_test.BaseTestClass):
- '''Template class for running acts test cases.
-
- Attributes:
- test_type: string, name of test type this adapter is for
- result_path: string, test result directory for the adaptor
- config_path: string, test config file path
- module_name: string, ACTS module name
- test_path: string, ACTS module source directory
- '''
- test_type = 'ACTS'
-
- def setUpClass(self):
- '''Set up result directory, generate configuration file, and list tests.'''
- self.result_path = os.path.join(logging.log_path, TEMP_DIR_NAME,
- self.test_type, str(time.time()))
- file_util.Makedirs(self.result_path)
- logging.debug('Result path for %s: %s' % (self.test_type,
- self.result_path))
- self.test_path, self.module_name = self.getUserParam(
- ACTS_TEST_MODULE).rsplit('/', 1)
-
- self.config_path = os.path.join(self.result_path, CONFIG_FILE_NAME)
- self.GenerateConfigFile()
-
- testcases = self.ListTestCases()
- logging.debug('ACTS Test cases: %s', testcases)
-
- def tearDownClass(self):
- '''Clear the result path.'''
- file_util.Rmdirs(self.result_path, ignore_errors=True)
-
- def GenerateConfigFile(self):
- '''Generate test configuration file.'''
- serials = []
- for ad in self.android_devices:
- serials.append('{"serial":"%s"}' % ad.serial)
-
- config_text = CONFIG_TEXT.format(
- module_name=self.module_name,
- serials=','.join(serials),
- log_path=self.result_path,
- src_path=self.test_path)
-
- with open(self.config_path, 'w') as f:
- f.write(config_text)
-
- def ListTestCases(self):
- '''List test cases.
-
- Returns:
- List of string, test names.
- '''
- # TODO use ACTS runner to list test cases and add requested record.
- # This step is optional but desired. To be implemented later
-
- def Run(self):
- '''Execute test cases.'''
- # acts.py is installed to user bin by ACTS setup script.
- # In the future, it is preferred to use the source code
- # from repo directory.
- bin = 'acts/bin/act.py'
-
- cmd = '{bin} -c {config} -tb {module_name} -tc {module_name}'.format(
- bin=bin, config=self.config_path, module_name=self.module_name)
- logging.debug('cmd is: %s', cmd)
-
- # Calling through subprocess is required because ACTS requires python3
- # while VTS is currently using python2. In the future, ACTS runner
- # can be invoked through importing when VTS upgrades to python3.
-
- # A "hack" to call python3 outside of python2 virtualenv created by
- # VTS framework
- environ = {
- key: val
- for key, val in os.environ.iteritems() if 'virtualenv' not in val
- }
-
- # TODO(yuexima): disable buffer
- p = subprocess.Popen(
- cmd,
- shell=True,
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT,
- env=environ)
-
- for line in iter(p.stdout.readline, b''):
- print line.rstrip()
-
- p.communicate()
- if p.returncode:
- asserts.fail('Subprocess of ACTS command failed. Return code: %s' %
- p.returncode)
-
- def ParseResults(self):
- '''Get module run results and put in vts results.'''
- file_path = file_util.FindFile(self.result_path, RESULT_FILE_NAME)
-
- if file_path:
- logging.debug('ACTS test result path: %s', file_path)
- self.ParseJsonResults(file_path)
- else:
- logging.error('Cannot find result file name %s in %s',
- RESULT_FILE_NAME, self.result_path)
-
- def generateAllTests(self):
- '''Run the test module and parse results.'''
- self.Run()
- self.ParseResults()
-
- def ParseJsonResults(self, result_path):
- '''Parse test json result.
-
- Args:
- result_path: string, result json file path.
- '''
- with open(result_path, 'r') as f:
- summary = json.load(f)
-
- results = summary['Results']
- for result in results:
- logging.debug('Adding result for %s' %
- result[records.TestResultEnums.RECORD_NAME])
- record = records.TestResultRecord(
- result[records.TestResultEnums.RECORD_NAME])
- record.test_class = result[records.TestResultEnums.RECORD_CLASS]
- record.begin_time = result[
- records.TestResultEnums.RECORD_BEGIN_TIME]
- record.end_time = result[records.TestResultEnums.RECORD_END_TIME]
- record.result = result[records.TestResultEnums.RECORD_RESULT]
- record.uid = result[records.TestResultEnums.RECORD_UID]
- record.extras = result[records.TestResultEnums.RECORD_EXTRAS]
- record.details = result[records.TestResultEnums.RECORD_DETAILS]
- record.extra_errors = result[
- records.TestResultEnums.RECORD_EXTRA_ERRORS]
-
- self.results.addRecord(record)
-
- # TODO(yuexima): parse new result types
-
-if __name__ == "__main__":
- test_runner.main()
diff --git a/runners/host/__init__.py b/runners/host/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/runners/host/__init__.py
+++ /dev/null
diff --git a/runners/host/asserts.py b/runners/host/asserts.py
deleted file mode 100644
index 42ac027..0000000
--- a/runners/host/asserts.py
+++ /dev/null
@@ -1,339 +0,0 @@
-#
-# 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.
-#
-
-import re
-import unittest
-
-from vts.runners.host import signals
-
-
-# Have an instance of unittest.TestCase so we could reuse some logic from
-# python's own unittest.
-# _ProxyTest is required because py2 does not allow instantiating
-# unittest.TestCase directly.
-class _ProxyTest(unittest.TestCase):
- def runTest(self):
- pass
-
-
-_pyunit_proxy = _ProxyTest()
-
-
-def assertEqual(first, second, msg=None, extras=None):
- """Assert an expression evaluates to true, otherwise fail the test.
-
- Error message is "first != second" by default. Additional explanation can
- be supplied in the message.
-
- Args:
- first, second: The arguments that will be tested for equality.
- msg: A string that adds additional info about the failure.
- extras: An optional field for extra information to be included in
- test result.
- """
- try:
- _pyunit_proxy.assertEqual(first, second)
- except AssertionError as e:
- my_msg = str(e)
- if msg:
- my_msg = "%s %s" % (my_msg, msg)
- fail(my_msg, extras=extras)
-
-
-def assertNotEqual(first, second, msg=None, extras=None):
- """Assert that the first and second args are not equal, otherwise fail
- the test.
-
- Error message is "first == second" by default. Additional explanation can
- be supplied in the message.
-
- Args:
- first, second: The arguments that will be tested for inequality.
- msg: A string that adds additional info about the failure.
- extras: An optional field for extra information to be included in
- test result.
- """
- try:
- _pyunit_proxy.assertNotEqual(first, second)
- except AssertionError as e:
- my_msg = str(e)
- if msg:
- my_msg = "%s %s" % (my_msg, msg)
- fail(my_msg, extras=extras)
-
-
-def assertRaises(expected_exception, extras=None, *args, **kwargs):
- """Assert that an exception is raised when a function is called.
-
- If no exception is raised, test fail. If an exception is raised but not
- of the expected type, the exception is let through.
-
- This should only be used as a context manager:
- with assertRaises(Exception):
- func()
-
- Args:
- expected_exception: An exception class that is expected to be
- raised.
- extras: An optional field for extra information to be included in
- test result.
- """
- context = _AssertRaisesContext(expected_exception, extras=extras)
- return context
-
-
-def assertRaisesRegex(expected_exception,
- expected_regex,
- extras=None,
- *args,
- **kwargs):
- """Assert that an exception is raised when a function is called.
-
- If no exception is raised, test fail. If an exception is raised but not
- of the expected type, the exception is let through. If an exception of the
- expected type is raised but the error message does not match the
- expected_regex, test fail.
-
- This should only be used as a context manager:
- with assertRaises(Exception):
- func()
-
- Args:
- expected_exception: An exception class that is expected to be
- raised.
- extras: An optional field for extra information to be included in
- test result.
- """
- context = _AssertRaisesContext(
- expected_exception, expected_regex, extras=extras)
- return context
-
-
-def assertTrue(expr, msg, extras=None):
- """Assert an expression evaluates to True, otherwise fail the test.
-
- Args:
- expr: The expression that is evaluated.
- msg: A string explaining the details in case of failure.
- extras: An optional field for extra information to be included in
- test result.
- """
- if not expr:
- fail(msg, extras)
-
-
-def assertFalse(expr, msg, extras=None):
- """Assert an expression evaluates to False, otherwise fail the test.
-
- Args:
- expr: The expression that is evaluated.
- msg: A string explaining the details in case of failure.
- extras: An optional field for extra information to be included in
- test result.
- """
- if expr:
- fail(msg, extras)
-
-
-def assertLess(first, second, msg=None, extras=None):
- """Assert first < second, otherwise fail the test.
-
- Error message is "first >= second" by default. Additional explanation can
- be supplied in the message.
-
- Args:
- first: The actual value which is supposed to be smaller than `second`.
- second: The threshold.
- msg: A string that adds additional info about the failure.
- extras: An optional field for extra information to be included in
- test result.
- """
- try:
- _pyunit_proxy.assertLess(first, second)
- except AssertionError as e:
- my_msg = str(e)
- if msg:
- my_msg = "%s %s" % (my_msg, msg)
- fail(my_msg, extras=extras)
-
-
-def skip(reason, extras=None):
- """Skip a test case.
-
- Args:
- reason: The reason this test is skipped.
- extras: An optional field for extra information to be included in
- test result.
-
- Raises:
- signals.TestSkip is raised to mark a test case as skipped.
- """
- raise signals.TestSkip(reason, extras)
-
-
-def skipIf(expr, reason, extras=None):
- """Skip a test case if expression evaluates to True.
-
- Args:
- expr: The expression that is evaluated.
- reason: The reason this test is skipped.
- extras: An optional field for extra information to be included in
- test result.
- """
- if expr:
- skip(reason, extras)
-
-
-def abortClass(reason, extras=None):
- """Abort all subsequent test cases within the same test class in one
- iteration.
-
- If one test class is requested multiple times in a test run, this can
- only abort one of the requested executions, NOT all.
-
- Args:
- reason: The reason to abort.
- extras: An optional field for extra information to be included in
- test result.
-
- Raises:
- signals.TestAbortClass is raised to abort all subsequent tests in a
- test class.
- """
- raise signals.TestAbortClass(reason, extras)
-
-
-def abortClassIf(expr, reason, extras=None):
- """Abort all subsequent test cases within the same test class in one
- iteration, if expression evaluates to True.
-
- If one test class is requested multiple times in a test run, this can
- only abort one of the requested executions, NOT all.
-
- Args:
- expr: The expression that is evaluated.
- reason: The reason to abort.
- extras: An optional field for extra information to be included in
- test result.
-
- Raises:
- signals.TestAbortClass is raised to abort all subsequent tests in a
- test class.
- """
- if expr:
- abortClass(reason, extras)
-
-
-def abortAll(reason, extras=None):
- """Abort all subsequent test cases, including the ones not in this test
- class or iteration.
-
- Args:
- reason: The reason to abort.
- extras: An optional field for extra information to be included in
- test result.
-
- Raises:
- signals.TestAbortAll is raised to abort all subsequent tests.
- """
- raise signals.TestAbortAll(reason, extras)
-
-
-def abortAllIf(expr, reason, extras=None):
- """Abort all subsequent test cases, if the expression evaluates to
- True.
-
- Args:
- expr: The expression that is evaluated.
- reason: The reason to abort.
- extras: An optional field for extra information to be included in
- test result.
-
- Raises:
- signals.TestAbortAll is raised to abort all subsequent tests.
- """
- if expr:
- abortAll(reason, extras)
-
-
-def fail(msg, extras=None):
- """Explicitly fail a test case.
-
- Args:
- msg: A string explaining the details of the failure.
- extras: An optional field for extra information to be included in
- test result.
-
- Raises:
- signals.TestFailure is raised to mark a test case as failed.
- """
- raise signals.TestFailure(msg, extras)
-
-
-def explicitPass(msg, extras=None):
- """Explicitly pass a test case.
-
- A test with not uncaught exception will pass implicitly so the usage of
- this is optional. It is intended for reporting extra information when a
- test passes.
-
- Args:
- msg: A string explaining the details of the passed test.
- extras: An optional field for extra information to be included in
- test result.
-
- Raises:
- signals.TestPass is raised to mark a test case as passed.
- """
- raise signals.TestPass(msg, extras)
-
-
-class _AssertRaisesContext(object):
- """A context manager used to implement TestCase.assertRaises* methods."""
-
- def __init__(self, expected, expected_regexp=None, extras=None):
- self.expected = expected
- self.failureException = signals.TestFailure
- self.expected_regexp = expected_regexp
- self.extras = extras
-
- def __enter__(self):
- return self
-
- def __exit__(self, exc_type, exc_value, tb):
- if exc_type is None:
- try:
- exc_name = self.expected.__name__
- except AttributeError:
- exc_name = str(self.expected)
- raise signals.TestFailure(
- "{} not raised".format(exc_name), extras=self.extras)
- if not issubclass(exc_type, self.expected):
- # let unexpected exceptions pass through
- return False
- self.exception = exc_value # store for later retrieval
- if self.expected_regexp is None:
- return True
-
- expected_regexp = self.expected_regexp
- if isinstance(expected_regexp, str):
- expected_regexp = re.compile(expected_regexp)
- if not expected_regexp.search(str(exc_value)):
- raise signals.TestFailure(
- '"%s" does not match "%s"' %
- (expected_regexp.pattern, str(exc_value)),
- extras=self.extras)
- return True
diff --git a/runners/host/base_test.py b/runners/host/base_test.py
deleted file mode 100644
index 3406502..0000000
--- a/runners/host/base_test.py
+++ /dev/null
@@ -1,1601 +0,0 @@
-#
-# 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.
-#
-
-import logging
-import os
-import re
-import signal
-import sys
-import threading
-import time
-
-from vts.proto import VtsReportMessage_pb2 as ReportMsg
-from vts.runners.host import asserts
-from vts.runners.host import const
-from vts.runners.host import errors
-from vts.runners.host import keys
-from vts.runners.host import logger
-from vts.runners.host import records
-from vts.runners.host import signals
-from vts.runners.host import utils
-from vts.utils.python.controllers import adb
-from vts.utils.python.controllers import android_device
-from vts.utils.python.controllers.adb import AdbError
-from vts.utils.python.common import cmd_utils
-from vts.utils.python.common import filter_utils
-from vts.utils.python.common import list_utils
-from vts.utils.python.common import timeout_utils
-from vts.utils.python.coverage import coverage_utils
-from vts.utils.python.coverage import sancov_utils
-from vts.utils.python.instrumentation import test_framework_instrumentation as tfi
-from vts.utils.python.io import file_util
-from vts.utils.python.precondition import precondition_utils
-from vts.utils.python.profiling import profiling_utils
-from vts.utils.python.reporting import log_uploading_utils
-from vts.utils.python.systrace import systrace_utils
-from vts.utils.python.web import feature_utils
-from vts.utils.python.web import web_utils
-
-
-# Macro strings for test result reporting
-TEST_CASE_TEMPLATE = "[Test Case] %s %s"
-RESULT_LINE_TEMPLATE = TEST_CASE_TEMPLATE + " %s"
-STR_TEST = "test"
-STR_GENERATE = "generate"
-TIMEOUT_SECS_LOG_UPLOADING = 60
-TIMEOUT_SECS_TEARDOWN_CLASS = 120
-_REPORT_MESSAGE_FILE_NAME = "report_proto.msg"
-_BUG_REPORT_FILE_PREFIX = "bugreport_"
-_BUG_REPORT_FILE_EXTENSION = ".zip"
-_DEFAULT_TEST_TIMEOUT_SECS = 60 * 3
-_LOGCAT_FILE_PREFIX = "logcat_"
-_LOGCAT_FILE_EXTENSION = ".txt"
-_ANDROID_DEVICES = '_android_devices'
-_REASON_TO_SKIP_ALL_TESTS = '_reason_to_skip_all_tests'
-_SETUP_RETRY_NUMBER = 5
-# the name of a system property which tells whether to stop properly configured
-# native servers where properly configured means a server's init.rc is
-# configured to stop when that property's value is 1.
-SYSPROP_VTS_NATIVE_SERVER = "vts.native_server.on"
-
-LOGCAT_BUFFERS = [
- 'radio',
- 'events',
- 'main',
- 'system',
- 'crash'
-]
-
-
-class BaseTestClass(object):
- """Base class for all test classes to inherit from.
-
- This class gets all the controller objects from test_runner and executes
- the test cases requested within itself.
-
- Most attributes of this class are set at runtime based on the configuration
- provided.
-
- Attributes:
- android_devices: A list of AndroidDevice object, representing android
- devices.
- test_module_name: A string representing the test module name.
- tests: A list of strings, each representing a test case name.
- log: A logger object used for logging.
- results: A records.TestResult object for aggregating test results from
- the execution of test cases.
- _current_record: A records.TestResultRecord object for the test case
- currently being executed. If no test is running, this
- should be None.
- _interrupted: Whether the test execution has been interrupted.
- _interrupt_lock: The threading.Lock object that protects _interrupted.
- _timer: The threading.Timer object that interrupts main thread when
- timeout.
- timeout: A float, the timeout, in seconds, configured for this object.
- include_filer: A list of string, each representing a test case name to
- include.
- exclude_filer: A list of string, each representing a test case name to
- exclude. Has no effect if include_filer is not empty.
- abi_name: String, name of abi in use
- abi_bitness: String, bitness of abi in use
- web: WebFeature, object storing web feature util for test run
- coverage: CoverageFeature, object storing coverage feature util for test run
- sancov: SancovFeature, object storing sancov feature util for test run
- start_time_sec: int, time value in seconds when the module execution starts.
- start_vts_agents: whether to start vts agents when registering new
- android devices.
- profiling: ProfilingFeature, object storing profiling feature util for test run
- _bug_report_on_failure: bool, whether to catch bug report at the end
- of failed test cases. Default is False
- _logcat_on_failure: bool, whether to dump logcat at the end
- of failed test cases. Default is True
- _is_final_run: bool, whether the current test run is the final run during retry.
- test_filter: Filter object to filter test names.
- _test_filter_retry: Filter object for retry filtering.
- max_retry_count: int, max number of retries.
- """
- _current_record = None
- start_vts_agents = True
-
- def __init__(self, configs):
- self.start_time_sec = time.time()
- self.tests = []
- # Set all the controller objects and params.
- for name, value in configs.items():
- setattr(self, name, value)
- self.results = records.TestResult()
- self.log = logger.LoggerProxy()
-
- # Timeout
- self._interrupted = False
- self._interrupt_lock = threading.Lock()
- self._timer = None
-
- timeout_milli = self.getUserParam(keys.ConfigKeys.KEY_TEST_TIMEOUT, 0)
- self.timeout = timeout_milli / 1000 if timeout_milli > 0 else _DEFAULT_TEST_TIMEOUT_SECS
-
- # Setup test filters
- # TODO(yuexima): remove include_filter and exclude_filter from class attributes
- # after confirming all modules no longer have reference to them
- self.include_filter = self.getUserParam(
- [
- keys.ConfigKeys.KEY_TEST_SUITE,
- keys.ConfigKeys.KEY_INCLUDE_FILTER
- ],
- default_value=[])
- self.exclude_filter = self.getUserParam(
- [
- keys.ConfigKeys.KEY_TEST_SUITE,
- keys.ConfigKeys.KEY_EXCLUDE_FILTER
- ],
- default_value=[])
-
- self.test_module_name = self.getUserParam(
- keys.ConfigKeys.KEY_TESTBED_NAME,
- warn_if_not_found=True,
- default_value=self.__class__.__name__)
-
- self.updateTestFilter()
-
- logging.debug('Test filter: %s' % self.test_filter)
-
- # TODO: get abi information differently for multi-device support.
- # Set other optional parameters
- self.abi_name = self.getUserParam(
- keys.ConfigKeys.IKEY_ABI_NAME, default_value=None)
- self.abi_bitness = self.getUserParam(
- keys.ConfigKeys.IKEY_ABI_BITNESS, default_value=None)
- self.skip_on_32bit_abi = self.getUserParam(
- keys.ConfigKeys.IKEY_SKIP_ON_32BIT_ABI, default_value=False)
- self.skip_on_64bit_abi = self.getUserParam(
- keys.ConfigKeys.IKEY_SKIP_ON_64BIT_ABI, default_value=False)
- self.run_32bit_on_64bit_abi = self.getUserParam(
- keys.ConfigKeys.IKEY_RUN_32BIT_ON_64BIT_ABI, default_value=False)
- self.max_retry_count = self.getUserParam(
- keys.ConfigKeys.IKEY_MAX_RETRY_COUNT, default_value=0)
-
- self.web = web_utils.WebFeature(self.user_params)
- self.coverage = coverage_utils.CoverageFeature(
- self.user_params, web=self.web)
- self.sancov = sancov_utils.SancovFeature(
- self.user_params, web=self.web)
- self.profiling = profiling_utils.ProfilingFeature(
- self.user_params, web=self.web)
- self.systrace = systrace_utils.SystraceFeature(
- self.user_params, web=self.web)
- self.log_uploading = log_uploading_utils.LogUploadingFeature(
- self.user_params, web=self.web)
- self.collect_tests_only = self.getUserParam(
- keys.ConfigKeys.IKEY_COLLECT_TESTS_ONLY, default_value=False)
- self.run_as_vts_self_test = self.getUserParam(
- keys.ConfigKeys.RUN_AS_VTS_SELFTEST, default_value=False)
- self.run_as_compliance_test = self.getUserParam(
- keys.ConfigKeys.RUN_AS_COMPLIANCE_TEST, default_value=False)
- self._bug_report_on_failure = self.getUserParam(
- keys.ConfigKeys.IKEY_BUG_REPORT_ON_FAILURE, default_value=False)
- self._logcat_on_failure = self.getUserParam(
- keys.ConfigKeys.IKEY_LOGCAT_ON_FAILURE, default_value=True)
- self._test_filter_retry = None
-
- @property
- def android_devices(self):
- """Returns a list of AndroidDevice objects"""
- if not hasattr(self, _ANDROID_DEVICES):
- event = tfi.Begin('base_test registering android_device. '
- 'Start agents: %s' % self.start_vts_agents,
- tfi.categories.FRAMEWORK_SETUP)
- setattr(self, _ANDROID_DEVICES,
- self.registerController(android_device,
- start_services=self.start_vts_agents))
- event.End()
-
- for device in getattr(self, _ANDROID_DEVICES):
- device.shell_default_nohup = self.getUserParam(
- keys.ConfigKeys.SHELL_DEFAULT_NOHUP, default_value=True)
- return getattr(self, _ANDROID_DEVICES)
-
- @android_devices.setter
- def android_devices(self, devices):
- """Set the list of AndroidDevice objects"""
- setattr(self, _ANDROID_DEVICES, devices)
-
- def __enter__(self):
- return self
-
- def __exit__(self, *args):
- self._exec_func(self.cleanUp)
-
- def updateTestFilter(self):
- """Updates test filter using include and exclude filters."""
- self.include_filter = list_utils.ExpandItemDelimiters(
- list_utils.ItemsToStr(self.include_filter), ',')
- self.exclude_filter = list_utils.ExpandItemDelimiters(
- list_utils.ItemsToStr(self.exclude_filter), ',')
-
- exclude_over_include = self.getUserParam(
- keys.ConfigKeys.KEY_EXCLUDE_OVER_INCLUDE, default_value=None)
-
- self.test_filter = filter_utils.Filter(
- self.include_filter,
- self.exclude_filter,
- enable_regex=True,
- exclude_over_include=exclude_over_include,
- enable_negative_pattern=True,
- enable_module_name_prefix_matching=True,
- module_name=self.test_module_name,
- expand_bitness=True)
-
- def unpack_userparams(self, req_param_names=[], opt_param_names=[], **kwargs):
- """Wrapper for test cases using ACTS runner API."""
- return self.getUserParams(req_param_names, opt_param_names, **kwargs)
-
- def getUserParams(self, req_param_names=[], opt_param_names=[], **kwargs):
- """Unpacks user defined parameters in test config into individual
- variables.
-
- Instead of accessing the user param with self.user_params["xxx"], the
- variable can be directly accessed with self.xxx.
-
- A missing required param will raise an exception. If an optional param
- is missing, an INFO line will be logged.
-
- Args:
- req_param_names: A list of names of the required user params.
- opt_param_names: A list of names of the optional user params.
- **kwargs: Arguments that provide default values.
- e.g. getUserParams(required_list, opt_list, arg_a="hello")
- self.arg_a will be "hello" unless it is specified again in
- required_list or opt_list.
-
- Raises:
- BaseTestError is raised if a required user params is missing from
- test config.
- """
- for k, v in kwargs.items():
- setattr(self, k, v)
- for name in req_param_names:
- if name not in self.user_params:
- raise errors.BaseTestError(("Missing required user param '%s' "
- "in test configuration.") % name)
- setattr(self, name, self.user_params[name])
- for name in opt_param_names:
- if name not in self.user_params:
- logging.debug(("Missing optional user param '%s' in "
- "configuration, continue."), name)
- else:
- setattr(self, name, self.user_params[name])
-
- def getUserParam(self,
- param_name,
- error_if_not_found=False,
- warn_if_not_found=False,
- default_value=None,
- to_str=False):
- """Get the value of a single user parameter.
-
- This method returns the value of specified user parameter.
-
- Note: unlike getUserParams(), this method will not automatically set
- attribute using the parameter name and value.
-
- Args:
- param_name: string or list of string, denoting user parameter names. If provided
- a single string, self.user_params["<param_name>"] will be accessed.
- If provided multiple strings,
- self.user_params["<param_name1>"]["<param_name2>"]["<param_name3>"]...
- will be accessed.
- error_if_not_found: bool, whether to raise error if parameter not
- exists. Default: False
- warn_if_not_found: bool, log a warning message if parameter value
- not found. Default: False
- default_value: object, default value to return if not found.
- If error_if_not_found is true, this parameter has no
- effect. Default: None
- to_str: boolean, whether to convert the result object to string if
- not None.
- Note, strings passing in from java json config are often
- unicode.
-
- Returns:
- object, value of the specified parameter name chain if exists;
- <default_value> otherwise.
- """
-
- def ToStr(return_value):
- """Check to_str option and convert to string if not None"""
- if to_str and return_value is not None:
- return str(return_value)
- return return_value
-
- if not param_name:
- if error_if_not_found:
- raise errors.BaseTestError("empty param_name provided")
- logging.error("empty param_name")
- return ToStr(default_value)
-
- if not isinstance(param_name, list):
- param_name = [param_name]
-
- curr_obj = self.user_params
- for param in param_name:
- if param not in curr_obj:
- msg = ("Missing user param '%s' in test configuration.\n"
- "User params: %s") % (param_name, self.user_params)
- if error_if_not_found:
- raise errors.BaseTestError(msg)
- elif warn_if_not_found:
- logging.warn(msg)
- return ToStr(default_value)
- curr_obj = curr_obj[param]
-
- return ToStr(curr_obj)
-
- def _getUserConfig(self,
- config_type,
- key,
- default_value=None,
- error_if_not_found=False,
- warn_if_not_found=False,
- to_str=False):
- """Get the value of a user config given the key.
-
- This method returns the value of specified user config type.
-
- Args:
- config_type: string, type of user config
- key: string, key of the value string in string config map.
- default_value: object, default value to return if not found.
- If error_if_not_found is true, this parameter has no
- effect. Default: None
- error_if_not_found: bool, whether to raise error if parameter not
- exists. Default: False
- warn_if_not_found: bool, log a warning message if parameter value
- not found. Default: False
- to_str: boolean, whether to apply str() method to result value
- if result is not None.
- Note, strings passing in from java json config are ofen
- unicode.
-
- Returns:
- Value in config matching the given key and type if exists;
- <default_value> otherwise.
- """
- dic = self.getUserParam(config_type,
- error_if_not_found=False,
- warn_if_not_found=False,
- default_value=None,
- to_str=False)
-
- if dic is None or key not in dic:
- msg = ("Config key %s not found in user config type %s.\n"
- "User params: %s") % (key, config_type, self.user_params)
- if error_if_not_found:
- raise errors.BaseTestError(msg)
- elif warn_if_not_found:
- logging.warn(msg)
-
- return default_value
-
- return dic[key] if not to_str else str(dic[key])
-
- def getUserConfigStr(self, key, **kwargs):
- """Get the value of a user config string given the key.
-
- See _getUserConfig method for more details.
- """
- kwargs["to_str"] = True
- return self._getUserConfig(keys.ConfigKeys.IKEY_USER_CONFIG_STR,
- key,
- **kwargs)
-
- def getUserConfigInt(self, key, **kwargs):
- """Get the value of a user config int given the key.
-
- See _getUserConfig method for more details.
- """
- return self._getUserConfig(keys.ConfigKeys.IKEY_USER_CONFIG_INT,
- key,
- **kwargs)
-
- def getUserConfigBool(self, key, **kwargs):
- """Get the value of a user config bool given the key.
-
- See _getUserConfig method for more details.
- """
- return self._getUserConfig(keys.ConfigKeys.IKEY_USER_CONFIG_BOOL,
- key,
- **kwargs)
-
- def _setUpClass(self):
- """Proxy function to guarantee the base implementation of setUpClass
- is called.
- """
- event = tfi.Begin('_setUpClass method for test class',
- tfi.categories.TEST_CLASS_SETUP)
- timeout = self.timeout - time.time() + self.start_time_sec
- if timeout < 0:
- timeout = 1
- self.resetTimeout(timeout)
- if not precondition_utils.MeetFirstApiLevelPrecondition(self):
- self.skipAllTests("The device's first API level doesn't meet the "
- "precondition.")
- for device in self.android_devices:
- if not precondition_utils.CheckFeaturePrecondition(self, device):
- self.skipAllTests("Precondition feature check fail.")
-
- if (self.getUserParam(
- keys.ConfigKeys.IKEY_DISABLE_FRAMEWORK, default_value=False) or
- # @Deprecated Legacy configuration option name.
- self.getUserParam(
- keys.ConfigKeys.IKEY_BINARY_TEST_DISABLE_FRAMEWORK,
- default_value=False)):
- stop_native_server = (
- self.getUserParam(
- keys.ConfigKeys.IKEY_STOP_NATIVE_SERVERS,
- default_value=False) or
- # @Deprecated Legacy configuration option name.
- self.getUserParam(
- keys.ConfigKeys.IKEY_BINARY_TEST_STOP_NATIVE_SERVERS,
- default_value=False))
- # Disable the framework if requested.
- for device in self.android_devices:
- device.stop(stop_native_server)
- else:
- # Enable the framework if requested.
- for device in self.android_devices:
- device.start()
-
- # Wait for the native service process to stop.
- native_server_process_names = self.getUserParam(
- keys.ConfigKeys.IKEY_NATIVE_SERVER_PROCESS_NAME,
- default_value=[])
- for device in self.android_devices:
- device.waitForProcessStop(native_server_process_names)
-
-
- event_sub = tfi.Begin('setUpClass method from test script',
- tfi.categories.TEST_CLASS_SETUP,
- enable_logging=False)
- result = self.setUpClass()
- event_sub.End()
- event.End()
- return result
-
- def setUpClass(self):
- """Setup function that will be called before executing any test case in
- the test class.
-
- To signal setup failure, return False or raise an exception. If
- exceptions were raised, the stack trace would appear in log, but the
- exceptions would not propagate to upper levels.
-
- Implementation is optional.
- """
- pass
-
- def _tearDownClass(self):
- """Proxy function to guarantee the base implementation of tearDownClass
- is called.
- """
- event = tfi.Begin('_tearDownClass method for test class',
- tfi.categories.TEST_CLASS_TEARDOWN)
- self.cancelTimeout()
-
- event_sub = tfi.Begin('tearDownClass method from test script',
- tfi.categories.TEST_CLASS_TEARDOWN,
- enable_logging=False)
-
- @timeout_utils.timeout(TIMEOUT_SECS_TEARDOWN_CLASS,
- message='tearDownClass method timed out.',
- no_exception=True)
- def _executeTearDownClass(baseTest):
- baseTest._exec_func(baseTest.tearDownClass)
- _executeTearDownClass(self)
-
- event_sub.End()
-
- if self.web.enabled:
- if self.results.class_errors:
- # Create a result to make the module shown as failure.
- self.web.AddTestReport("setup_class")
- self.web.SetTestResult(ReportMsg.TEST_CASE_RESULT_FAIL)
-
- # Attach log destination urls to proto message so the urls will be
- # recorded and uploaded to dashboard. The actual log uploading is postponed
- # after generating report message to prevent failure due to timeout of log uploading.
- self.log_uploading.UploadLogs(dryrun=True)
-
- message_b = self.web.GenerateReportMessage(self.results.requested,
- self.results.executed)
- else:
- message_b = ''
-
- report_proto_path = os.path.join(logging.log_path,
- _REPORT_MESSAGE_FILE_NAME)
-
- if message_b:
- logging.debug('Result proto message path: %s', report_proto_path)
-
- with open(report_proto_path, "wb") as f:
- f.write(message_b)
-
- if self.log_uploading.enabled:
- @timeout_utils.timeout(TIMEOUT_SECS_LOG_UPLOADING,
- message='_tearDownClass method in base_test timed out.',
- no_exception=True)
- def _executeLogUpload(_log_uploading):
- _log_uploading.UploadLogs()
-
- event_upload = tfi.Begin('Log upload',
- tfi.categories.RESULT_PROCESSING)
- _executeLogUpload(self.log_uploading)
- event_upload.End()
-
- event.End()
-
- def tearDownClass(self):
- """Teardown function that will be called after all the selected test
- cases in the test class have been executed.
-
- Implementation is optional.
- """
- pass
-
- def interrupt(self):
- """Interrupts test execution and terminates process."""
- with self._interrupt_lock:
- if self._interrupted:
- logging.warning("Cannot interrupt more than once.")
- return
- self._interrupted = True
- logging.info("Test timed out, interrupt")
- utils.stop_current_process(TIMEOUT_SECS_TEARDOWN_CLASS)
-
- def cancelTimeout(self):
- """Cancels main thread timer."""
- if hasattr(signal, "SIGALRM"):
- signal.alarm(0)
- else:
- with self._interrupt_lock:
- if self._interrupted:
- logging.warning("Test execution has been interrupted. "
- "Cannot cancel or reset timeout.")
- return
-
- if self._timer:
- self._timer.cancel()
-
- def resetTimeout(self, timeout):
- """Restarts the timer that will interrupt the main thread.
-
- This class starts the timer before setUpClass. As the timeout depends
- on number of generated tests, the subclass can restart the timer.
-
- Args:
- timeout: A float, wait time in seconds before interrupt.
- """
- logging.debug("Start timer with timeout=%ssec.", timeout)
- if hasattr(signal, "SIGALRM"):
- signal.signal(signal.SIGALRM, utils._timeout_handler)
- signal.alarm(int(timeout))
- else:
- self.cancelTimeout()
-
- self._timer = threading.Timer(timeout, self.interrupt)
- self._timer.daemon = True
- self._timer.start()
-
- def _testEntry(self, test_record):
- """Internal function to be called upon entry of a test case.
-
- Args:
- test_record: The TestResultRecord object for the test case going to
- be executed.
- """
- self._current_record = test_record
- if self.web.enabled:
- self.web.AddTestReport(test_record.test_name)
-
- def _setUp(self, test_name):
- """Proxy function to guarantee the base implementation of setUp is
- called.
- """
- event = tfi.Begin('_setUp method for test case',
- tfi.categories.TEST_CASE_SETUP,)
- if not self.Heal(passive=True):
- msg = 'Framework self diagnose didn\'t pass for %s. Marking test as fail.' % test_name
- logging.error(msg)
- event.Remove(msg)
- asserts.fail(msg)
-
- if self.systrace.enabled:
- self.systrace.StartSystrace()
-
- event_sub = tfi.Begin('_setUp method from test script',
- tfi.categories.TEST_CASE_SETUP,
- enable_logging=False)
- result = self.setUp()
- event_sub.End()
- event.End()
-
- def setUp(self):
- """Setup function that will be called every time before executing each
- test case in the test class.
-
- To signal setup failure, return False or raise an exception. If
- exceptions were raised, the stack trace would appear in log, but the
- exceptions would not propagate to upper levels.
-
- Implementation is optional.
- """
-
- def _testExit(self):
- """Internal function to be called upon exit of a test."""
- self._current_record = None
-
- def _tearDown(self, test_name):
- """Proxy function to guarantee the base implementation of tearDown
- is called.
- """
- event = tfi.Begin('_tearDown method from base_test',
- tfi.categories.TEST_CASE_TEARDOWN)
- if self.systrace.enabled:
- self._exec_func(self.systrace.ProcessAndUploadSystrace, test_name)
- event_sub = tfi.Begin('_tearDown method from test script',
- tfi.categories.TEST_CASE_TEARDOWN,
- enable_logging=False)
- self._exec_func(self.tearDown)
- event_sub.End()
- event.End()
-
- def tearDown(self):
- """Teardown function that will be called every time a test case has
- been executed.
-
- Implementation is optional.
- """
-
- def _onFail(self):
- """Proxy function to guarantee the base implementation of onFail is
- called.
- """
- record = self._current_record
- logging.error(record.details)
- begin_time = logger.epochToLogLineTimestamp(record.begin_time)
- logging.error(RESULT_LINE_TEMPLATE, self.results.progressStr,
- record.test_name, record.result)
- if self.web.enabled:
- self.web.SetTestResult(ReportMsg.TEST_CASE_RESULT_FAIL)
-
- event = tfi.Begin('_onFail method from BaseTest',
- tfi.categories.FAILED_TEST_CASE_PROCESSING,
- enable_logging=False)
- self.onFail(record.test_name, begin_time)
- if self._bug_report_on_failure:
- self.DumpBugReport(record.test_name)
- if self._logcat_on_failure:
- self.DumpLogcat(record.test_name)
- event.End()
-
- def onFail(self, test_name, begin_time):
- """A function that is executed upon a test case failure.
-
- User implementation is optional.
-
- Args:
- test_name: Name of the test that triggered this function.
- begin_time: Logline format timestamp taken when the test started.
- """
-
- def _onPass(self):
- """Proxy function to guarantee the base implementation of onPass is
- called.
- """
- record = self._current_record
- begin_time = logger.epochToLogLineTimestamp(record.begin_time)
- msg = record.details
- if msg:
- logging.debug(msg)
- logging.info(RESULT_LINE_TEMPLATE, self.results.progressStr,
- record.test_name, record.result)
- if self.web.enabled:
- self.web.SetTestResult(ReportMsg.TEST_CASE_RESULT_PASS)
- self.onPass(record.test_name, begin_time)
-
- def onPass(self, test_name, begin_time):
- """A function that is executed upon a test case passing.
-
- Implementation is optional.
-
- Args:
- test_name: Name of the test that triggered this function.
- begin_time: Logline format timestamp taken when the test started.
- """
-
- def _onSkip(self):
- """Proxy function to guarantee the base implementation of onSkip is
- called.
- """
- record = self._current_record
- begin_time = logger.epochToLogLineTimestamp(record.begin_time)
- logging.info(RESULT_LINE_TEMPLATE, self.results.progressStr,
- record.test_name, record.result)
- logging.debug("Reason to skip: %s", record.details)
- if self.web.enabled:
- self.web.SetTestResult(ReportMsg.TEST_CASE_RESULT_SKIP)
- self.onSkip(record.test_name, begin_time)
-
- def onSkip(self, test_name, begin_time):
- """A function that is executed upon a test case being skipped.
-
- Implementation is optional.
-
- Args:
- test_name: Name of the test that triggered this function.
- begin_time: Logline format timestamp taken when the test started.
- """
-
- def _onSilent(self):
- """Proxy function to guarantee the base implementation of onSilent is
- called.
- """
- record = self._current_record
- begin_time = logger.epochToLogLineTimestamp(record.begin_time)
- if self.web.enabled:
- self.web.SetTestResult(None)
- self.onSilent(record.test_name, begin_time)
-
- def onSilent(self, test_name, begin_time):
- """A function that is executed upon a test case being marked as silent.
-
- Implementation is optional.
-
- Args:
- test_name: Name of the test that triggered this function.
- begin_time: Logline format timestamp taken when the test started.
- """
-
- def _onException(self):
- """Proxy function to guarantee the base implementation of onException
- is called.
- """
- record = self._current_record
- logging.exception(record.details)
- begin_time = logger.epochToLogLineTimestamp(record.begin_time)
- if self.web.enabled:
- self.web.SetTestResult(ReportMsg.TEST_CASE_RESULT_EXCEPTION)
-
- event = tfi.Begin('_onFail method from BaseTest',
- tfi.categories.FAILED_TEST_CASE_PROCESSING,
- enable_logging=False)
- self.onException(record.test_name, begin_time)
- if self._bug_report_on_failure:
- self.DumpBugReport(ecord.test_name)
- if self._logcat_on_failure:
- self.DumpLogcat(record.test_name)
- event.End()
-
- def onException(self, test_name, begin_time):
- """A function that is executed upon an unhandled exception from a test
- case.
-
- Implementation is optional.
-
- Args:
- test_name: Name of the test that triggered this function.
- begin_time: Logline format timestamp taken when the test started.
- """
-
- def _exec_procedure_func(self, func):
- """Executes a procedure function like onPass, onFail etc.
-
- This function will alternate the 'Result' of the test's record if
- exceptions happened when executing the procedure function.
-
- This will let signals.TestAbortAll through so abortAll works in all
- procedure functions.
-
- Args:
- func: The procedure function to be executed.
- """
- record = self._current_record
-
- if (func not in (self._onPass, self._onSilent, self._onSkip)
- and not self._is_final_run):
- logging.debug('Skipping test failure procedure function during retry')
- logging.info(RESULT_LINE_TEMPLATE, self.results.progressStr,
- record.test_name, 'RETRY')
- return
-
- if record is None:
- logging.error("Cannot execute %s. No record for current test.",
- func.__name__)
- return
- try:
- func()
- except signals.TestAbortAll as e:
- raise signals.TestAbortAll, e, sys.exc_info()[2]
- except Exception as e:
- logging.exception("Exception happened when executing %s for %s.",
- func.__name__, record.test_name)
- record.addError(func.__name__, e)
-
- def addTableToResult(self, name, rows):
- """Adds a table to current test record.
-
- A subclass can call this method to add a table to _current_record when
- running test cases.
-
- Args:
- name: String, the table name.
- rows: A 2-dimensional list which contains the data.
- """
- self._current_record.addTable(name, rows)
-
- def filterOneTest(self, test_name, test_filter=None):
- """Check test filters for a test name.
-
- The first layer of filter is user defined test filters:
- if a include filter is not empty, only tests in include filter will
- be executed regardless whether they are also in exclude filter. Else
- if include filter is empty, only tests not in exclude filter will be
- executed.
-
- The second layer of filter is checking whether skipAllTests method is
- called. If the flag is set, this method raises signals.TestSkip.
-
- The third layer of filter is checking abi bitness:
- if a test has a suffix indicating the intended architecture bitness,
- and the current abi bitness information is available, non matching tests
- will be skipped. By our convention, this function will look for bitness in suffix
- formated as "32bit", "32Bit", "32BIT", or 64 bit equivalents.
-
- This method assumes const.SUFFIX_32BIT and const.SUFFIX_64BIT are in lower cases.
-
- Args:
- test_name: string, name of a test
- test_filter: Filter object, test filter
-
- Raises:
- signals.TestSilent if a test should not be executed
- signals.TestSkip if a test should be logged but not be executed
- """
- if self._test_filter_retry and not self._test_filter_retry.Filter(test_name):
- # TODO: TestSilent will remove test case from record,
- # TestSkip will record test skip with a reason.
- # skip during retry is neither of these, as the test should be skipped,
- # not being recorded and not being deleted.
- # Create a new signal type if callers outside this class wants to distinguish
- # between these skip types.
- raise signals.TestSkip('Skipping completed tests in retry run attempt.')
-
- self._filterOneTestThroughTestFilter(test_name, test_filter)
- self._filterOneTestThroughAbiBitness(test_name)
-
- def _filterOneTestThroughTestFilter(self, test_name, test_filter=None):
- """Check test filter for the given test name.
-
- Args:
- test_name: string, name of a test
-
- Raises:
- signals.TestSilent if a test should not be executed
- signals.TestSkip if a test should be logged but not be executed
- """
- if not test_filter:
- test_filter = self.test_filter
-
- if not test_filter.Filter(test_name):
- raise signals.TestSilent("Test case '%s' did not pass filters.")
-
- if self.isSkipAllTests():
- raise signals.TestSkip(self.getSkipAllTestsReason())
-
- def _filterOneTestThroughAbiBitness(self, test_name):
- """Check test filter for the given test name.
-
- Args:
- test_name: string, name of a test
-
- Raises:
- signals.TestSilent if a test should not be executed
- """
- asserts.skipIf(
- self.abi_bitness and
- ((self.skip_on_32bit_abi is True) and self.abi_bitness == "32") or
- ((self.skip_on_64bit_abi is True) and self.abi_bitness == "64") or
- (test_name.lower().endswith(const.SUFFIX_32BIT) and
- self.abi_bitness != "32") or
- (test_name.lower().endswith(const.SUFFIX_64BIT) and
- self.abi_bitness != "64" and not self.run_32bit_on_64bit_abi),
- "Test case '{}' excluded as ABI bitness is {}.".format(
- test_name, self.abi_bitness))
-
- def execOneTest(self, test_name, test_func, args, **kwargs):
- """Executes one test case and update test results.
-
- Executes one test case, create a records.TestResultRecord object with
- the execution information, and add the record to the test class's test
- results.
-
- Args:
- test_name: Name of the test.
- test_func: The test function.
- args: A tuple of params.
- kwargs: Extra kwargs.
- """
- if self._test_filter_retry and not self._test_filter_retry.Filter(test_name):
- return
-
- is_silenced = False
- tr_record = records.TestResultRecord(test_name, self.test_module_name)
- tr_record.testBegin()
- logging.info(TEST_CASE_TEMPLATE, self.results.progressStr, test_name)
- verdict = None
- finished = False
- try:
- ret = self._testEntry(tr_record)
- asserts.assertTrue(ret is not False,
- "Setup test entry for %s failed." % test_name)
- self.filterOneTest(test_name)
- if self.collect_tests_only:
- asserts.explicitPass("Collect tests only.")
-
- try:
- ret = self._setUp(test_name)
- asserts.assertTrue(ret is not False,
- "Setup for %s failed." % test_name)
-
- event_test = tfi.Begin("test function",
- tfi.categories.TEST_CASE_EXECUTION)
- if args or kwargs:
- verdict = test_func(*args, **kwargs)
- else:
- verdict = test_func()
- event_test.End()
- finished = True
- finally:
- self._tearDown(test_name)
- except (signals.TestFailure, AssertionError) as e:
- tr_record.testFail(e)
- self._exec_procedure_func(self._onFail)
- finished = True
- except signals.TestSkip as e:
- # Test skipped.
- tr_record.testSkip(e)
- self._exec_procedure_func(self._onSkip)
- finished = True
- except signals.TestAbortClass as e:
- # Abort signals, pass along.
- tr_record.testFail(e)
- self._is_final_run = True
- finished = True
- raise signals.TestAbortClass, e, sys.exc_info()[2]
- except signals.TestAbortAll as e:
- # Abort signals, pass along.
- tr_record.testFail(e)
- self._is_final_run = True
- finished = True
- raise signals.TestAbortAll, e, sys.exc_info()[2]
- except utils.TimeoutError as e:
- logging.exception(e)
- # Mark current test case as failure and abort remaining tests.
- tr_record.testFail(e)
- self._is_final_run = True
- finished = True
- raise signals.TestAbortAll, e, sys.exc_info()[2]
- except KeyboardInterrupt as e:
- logging.error("Received KeyboardInterrupt signal")
- # Abort signals, pass along.
- tr_record.testFail(e)
- self._is_final_run = True
- finished = True
- raise
- except AdbError as e:
- logging.error(e)
- if not self.Heal():
- # Non-recoverable adb failure. Mark test failure and abort
- tr_record.testFail(e)
- self._is_final_run = True
- finished = True
- raise signals.TestAbortAll, e, sys.exc_info()[2]
- # error specific to the test case, mark test failure and continue with remaining test
- tr_record.testFail(e)
- self._exec_procedure_func(self._onFail)
- finished = True
- except signals.TestPass as e:
- # Explicit test pass.
- tr_record.testPass(e)
- self._exec_procedure_func(self._onPass)
- finished = True
- except signals.TestSilent as e:
- # Suppress test reporting.
- is_silenced = True
- self._exec_procedure_func(self._onSilent)
- self.results.removeRecord(tr_record)
- finished = True
- except Exception as e:
- # Exception happened during test.
- logging.exception(e)
- tr_record.testError(e)
- self._exec_procedure_func(self._onException)
- self._exec_procedure_func(self._onFail)
- finished = True
- else:
- # Keep supporting return False for now.
- # TODO(angli): Deprecate return False support.
- if verdict or (verdict is None):
- # Test passed.
- tr_record.testPass()
- self._exec_procedure_func(self._onPass)
- return
- # Test failed because it didn't return True.
- # This should be removed eventually.
- tr_record.testFail()
- self._exec_procedure_func(self._onFail)
- finished = True
- finally:
- if not finished:
- for device in self.android_devices:
- # if shell has not been set up yet
- if device.shell is not None:
- device.shell.DisableShell()
-
- logging.error('Test timed out.')
- tr_record.testError()
- self._exec_procedure_func(self._onException)
- self._exec_procedure_func(self._onFail)
-
- if not is_silenced:
- self.results.addRecord(tr_record)
- self._testExit()
-
- def runGeneratedTests(self,
- test_func,
- settings,
- args=None,
- kwargs=None,
- tag="",
- name_func=None):
- """Runs generated test cases.
-
- Generated test cases are not written down as functions, but as a list
- of parameter sets. This way we reduce code repetition and improve
- test case scalability.
-
- Args:
- test_func: The common logic shared by all these generated test
- cases. This function should take at least one argument,
- which is a parameter set.
- settings: A list of strings representing parameter sets. These are
- usually json strings that get loaded in the test_func.
- args: Iterable of additional position args to be passed to
- test_func.
- kwargs: Dict of additional keyword args to be passed to test_func
- tag: Name of this group of generated test cases. Ignored if
- name_func is provided and operates properly.
- name_func: A function that takes a test setting and generates a
- proper test name. The test name should be shorter than
- utils.MAX_FILENAME_LEN. Names over the limit will be
- truncated.
-
- Returns:
- A list of settings that did not pass.
- """
- args = args or ()
- kwargs = kwargs or {}
- failed_settings = []
-
- def GenerateTestName(setting):
- test_name = "{} {}".format(tag, setting)
- if name_func:
- try:
- test_name = name_func(setting, *args, **kwargs)
- except:
- logging.exception(("Failed to get test name from "
- "test_func. Fall back to default %s"),
- test_name)
-
- if len(test_name) > utils.MAX_FILENAME_LEN:
- test_name = test_name[:utils.MAX_FILENAME_LEN]
-
- return test_name
-
- for setting in settings:
- test_name = GenerateTestName(setting)
-
- tr_record = records.TestResultRecord(test_name, self.test_module_name)
- self.results.requested.append(tr_record)
-
- for setting in settings:
- test_name = GenerateTestName(setting)
- previous_success_cnt = len(self.results.passed)
-
- event_exec = tfi.Begin('BaseTest execOneTest method for generated tests',
- enable_logging=False)
- self.execOneTest(test_name, test_func, (setting, ) + args, **kwargs)
- event_exec.End()
- if len(self.results.passed) - previous_success_cnt != 1:
- failed_settings.append(setting)
-
- return failed_settings
-
- def _exec_func(self, func, *args):
- """Executes a function with exception safeguard.
-
- This will let signals.TestAbortAll through so abortAll works in all
- procedure functions.
-
- Args:
- func: Function to be executed.
- args: Arguments to be passed to the function.
-
- Returns:
- Whatever the function returns, or False if non-caught exception
- occurred.
- """
- try:
- return func(*args)
- except signals.TestAbortAll as e:
- raise signals.TestAbortAll, e, sys.exc_info()[2]
- except:
- logging.exception("Exception happened when executing %s in %s.",
- func.__name__, self.test_module_name)
- return False
-
- def _get_all_test_names(self):
- """Finds all the function names that match the test case naming
- convention in this class.
-
- Returns:
- A list of strings, each is a test case name.
- """
- test_names = []
- for name in dir(self):
- if name.startswith(STR_TEST) or name.startswith(STR_GENERATE):
- attr_func = getattr(self, name)
- if hasattr(attr_func, "__call__"):
- test_names.append(name)
- return test_names
-
- def _get_test_funcs(self, test_names):
- """Obtain the actual functions of test cases based on test names.
-
- Args:
- test_names: A list of strings, each string is a test case name.
-
- Returns:
- A list of tuples of (string, function). String is the test case
- name, function is the actual test case function.
-
- Raises:
- errors.USERError is raised if the test name does not follow
- naming convention "test_*". This can only be caused by user input
- here.
- """
- test_funcs = []
- for test_name in test_names:
- if not hasattr(self, test_name):
- logging.warning("%s does not have test case %s.",
- self.test_module_name, test_name)
- elif (test_name.startswith(STR_TEST) or
- test_name.startswith(STR_GENERATE)):
- test_funcs.append((test_name, getattr(self, test_name)))
- else:
- msg = ("Test case name %s does not follow naming convention "
- "test*, abort.") % test_name
- raise errors.USERError(msg)
-
- return test_funcs
-
- def getTests(self, test_names=None):
- """Get the test cases within a test class.
-
- Args:
- test_names: A list of string that are test case names requested in
- cmd line.
-
- Returns:
- A list of tuples of (string, function). String is the test case
- name, function is the actual test case function.
- """
- if not test_names:
- if self.tests:
- # Specified by run list in class.
- test_names = list(self.tests)
- else:
- # No test case specified by user, execute all in the test class
- test_names = self._get_all_test_names()
-
- tests = self._get_test_funcs(test_names)
- return tests
-
- def _DiagnoseHost(self):
- """Runs diagnosis commands on host and logs the results."""
- commands = ['ps aux | grep adb',
- 'adb --version',
- 'adb devices']
- for cmd in commands:
- results = cmd_utils.ExecuteShellCommand(cmd)
- logging.debug('host diagnosis command %s', cmd)
- logging.debug(' output: %s', results[cmd_utils.STDOUT][0])
-
- def _DiagnoseDevice(self, device):
- """Runs diagnosis commands on device and logs the results."""
- commands = ['ps aux | grep vts',
- 'cat /proc/meminfo']
- for cmd in commands:
- results = device.adb.shell(cmd, no_except=True, timeout=adb.DEFAULT_ADB_SHORT_TIMEOUT)
- logging.debug('device diagnosis command %s', cmd)
- logging.debug(' output: %s', results[const.STDOUT])
-
- def Heal(self, passive=False, timeout=900):
- """Performs a self healing.
-
- Includes self diagnosis that looks for any framework or device state errors.
- Includes self recovery that attempts to correct discovered errors.
-
- Args:
- passive: bool, whether to perform passive only self-check. A passive check means
- only to check known status stored in memory. No command will be issued
- to host or device - which makes the check fast.
- timeout: int, timeout in seconds.
-
- Returns:
- bool, True if everything is ok. Fales if some error is not recoverable.
- """
- start = time.time()
-
- if not passive:
- available_devices = android_device.list_adb_devices()
- self._DiagnoseHost()
-
- for device in self.android_devices:
- if device.serial not in available_devices:
- device.log.warn(
- "device become unavailable after tests. wait for device come back")
- _timeout = timeout - time.time() + start
- if _timeout < 0 or not device.waitForBootCompletion(timeout=_timeout):
- device.log.error('failed to restore device %s')
- return False
- device.rootAdb()
- device.stopServices()
- device.startServices()
- self._DiagnoseHost()
- else:
- self._DiagnoseDevice(device)
-
- return all(map(lambda device: device.Heal(), self.android_devices))
-
- def runTestsWithRetry(self, tests):
- """Run tests with retry and collect test results.
-
- Args:
- tests: A list of tests to be run.
- """
- for count in range(self.max_retry_count + 1):
- if count:
- if not self.Heal():
- logging.error('Self heal failed. '
- 'Some error is not recoverable within time constraint.')
- return
-
- include_filter = map(lambda item: item.test_name,
- self.results.getNonPassingRecords(skipped=False))
- self._test_filter_retry = filter_utils.Filter(include_filter=include_filter)
- logging.info('Automatically retrying %s test cases. Run attempt %s of %s',
- len(include_filter),
- count + 1,
- self.max_retry_count + 1)
- msg = 'Retrying the following test cases: %s' % include_filter
- logging.debug(msg)
-
- path_retry_log = os.path.join(logging.log_path, 'retry_log.txt')
- with open(path_retry_log, 'a+') as f:
- f.write(msg + '\n')
-
- self._is_final_run = count == self.max_retry_count
-
- try:
- self._runTests(tests)
- except Exception as e:
- if self._is_final_run:
- raise e
-
- if self._is_final_run:
- break
-
- def _runTests(self, tests):
- """Run tests and collect test results.
-
- Args:
- tests: A list of tests to be run.
- """
- # Setup for the class with retry.
- for i in xrange(_SETUP_RETRY_NUMBER):
- setup_done = False
- caught_exception = None
- try:
- if self._setUpClass() is False:
- raise signals.TestFailure(
- "Failed to setup %s." % self.test_module_name)
- else:
- setup_done = True
- except Exception as e:
- caught_exception = e
- logging.exception("Failed to setup %s.", self.test_module_name)
- finally:
- if setup_done:
- break
- elif not caught_exception or i + 1 == _SETUP_RETRY_NUMBER:
- self.results.failClass(self.test_module_name,
- caught_exception)
- self._exec_func(self._tearDownClass)
- self._is_final_run = True
- return
- else:
- # restart services before retry setup.
- for device in self.android_devices:
- logging.info("restarting service on device %s", device.serial)
- device.stopServices()
- device.startServices()
-
- class_error = None
- # Run tests in order.
- try:
- # Check if module is running in self test mode.
- if self.run_as_vts_self_test:
- logging.debug('setUpClass function was executed successfully.')
- self.results.passClass(self.test_module_name)
- return
-
- for test_name, test_func in tests:
- if test_name.startswith(STR_GENERATE):
- logging.debug(
- "Executing generated test trigger function '%s'",
- test_name)
- test_func()
- logging.debug("Finished '%s'", test_name)
- else:
- event_exec = tfi.Begin('BaseTest execOneTest method for individual tests',
- enable_logging=False)
- self.execOneTest(test_name, test_func, None)
- event_exec.End()
- if self.isSkipAllTests() and not self.results.executed:
- self.results.skipClass(
- self.test_module_name,
- "All test cases skipped; unable to find any test case.")
- except signals.TestAbortClass as e:
- logging.error("Received TestAbortClass signal")
- class_error = e
- self._is_final_run = True
- except signals.TestAbortAll as e:
- logging.info("Received TestAbortAll signal")
- class_error = e
- self._is_final_run = True
- # Piggy-back test results on this exception object so we don't lose
- # results from this test class.
- setattr(e, "results", self.results)
- raise signals.TestAbortAll, e, sys.exc_info()[2]
- except KeyboardInterrupt as e:
- class_error = e
- self._is_final_run = True
- # Piggy-back test results on this exception object so we don't lose
- # results from this test class.
- setattr(e, "results", self.results)
- raise
- except Exception as e:
- # Exception happened during test.
- logging.exception(e)
- class_error = e
- raise e
- finally:
- if not self.results.getNonPassingRecords(skipped=False):
- self._is_final_run = True
-
- if class_error and self._is_final_run:
- self.results.failClass(self.test_module_name, class_error)
-
- self._exec_func(self._tearDownClass)
-
- if self._is_final_run:
- if self.web.enabled:
- name, timestamp = self.web.GetTestModuleKeys()
- self.results.setTestModuleKeys(name, timestamp)
-
- logging.info("Summary for test class %s: %s",
- self.test_module_name, self.results.summary())
-
- def run(self, test_names=None):
- """Runs test cases within a test class by the order they appear in the
- execution list.
-
- One of these test cases lists will be executed, shown here in priority
- order:
- 1. The test_names list, which is passed from cmd line. Invalid names
- are guarded by cmd line arg parsing.
- 2. The self.tests list defined in test class. Invalid names are
- ignored.
- 3. All function that matches test case naming convention in the test
- class.
-
- Args:
- test_names: A list of string that are test case names requested in
- cmd line.
-
- Returns:
- The test results object of this class.
- """
- logging.info("==========> %s <==========", self.test_module_name)
- # Devise the actual test cases to run in the test class.
- tests = self.getTests(test_names)
-
- if not self.run_as_vts_self_test:
- self.results.requested = [
- records.TestResultRecord(test_name, self.test_module_name)
- for test_name,_ in tests if test_name.startswith(STR_TEST)
- ]
-
- self.runTestsWithRetry(tests)
- return self.results
-
- def cleanUp(self):
- """A function that is executed upon completion of all tests cases
- selected in the test class.
-
- This function should clean up objects initialized in the constructor by
- user.
- """
-
- def DumpBugReport(self, prefix=''):
- """Get device bugreport through adb command.
-
- Args:
- prefix: string, file name prefix. Usually in format of
- <test_module>-<test_case>
- """
- event = tfi.Begin('dump Bugreport',
- tfi.categories.FAILED_TEST_CASE_PROCESSING)
- if prefix:
- prefix = re.sub('[^\w\-_\. ]', '_', prefix) + '_'
-
- parent_dir = os.path.join(logging.log_path, 'bugreport')
-
- if not file_util.Mkdir(parent_dir):
- logging.error('Failed to create bugreport output directory %s', parent_dir)
- return
-
- for device in self.android_devices:
- if device.fatal_error: continue
- file_name = (_BUG_REPORT_FILE_PREFIX
- + prefix
- + '_%s' % device.serial
- + _BUG_REPORT_FILE_EXTENSION)
-
- file_path = os.path.join(parent_dir, file_name)
-
- logging.info('Dumping bugreport %s...' % file_path)
- device.adb.bugreport(file_path)
- event.End()
-
- def skipAllTestsIf(self, condition, msg):
- """Skip all test cases if the given condition is true.
-
- This method is usually called in setup functions when a precondition
- to the test module is not met.
-
- Args:
- condition: object that can be evaluated by bool(), a condition that
- will trigger skipAllTests if evaluated to be True.
- msg: string, reason why tests are skipped. If set to None or empty
- string, a default message will be used (not recommended)
- """
- if condition:
- self.skipAllTests(msg)
-
- def skipAllTests(self, msg):
- """Skip all test cases.
-
- This method is usually called in setup functions when a precondition
- to the test module is not met.
-
- Args:
- msg: string, reason why tests are skipped. If set to None or empty
- string, a default message will be used (not recommended)
- """
- if not msg:
- msg = "No reason provided."
-
- setattr(self, _REASON_TO_SKIP_ALL_TESTS, msg)
-
- def isSkipAllTests(self):
- """Returns whether all tests are set to be skipped.
-
- Note: If all tests are being skipped not due to skipAllTests
- being called, or there is no tests defined, this method will
- still return False (since skipAllTests is not called.)
-
- Returns:
- bool, True if skipAllTests has been called; False otherwise.
- """
- return self.getSkipAllTestsReason() is not None
-
- def getSkipAllTestsReason(self):
- """Returns the reason why all tests are skipped.
-
- Note: If all tests are being skipped not due to skipAllTests
- being called, or there is no tests defined, this method will
- still return None (since skipAllTests is not called.)
-
- Returns:
- String, reason why tests are skipped. None if skipAllTests
- is not called.
- """
- return getattr(self, _REASON_TO_SKIP_ALL_TESTS, None)
-
- def DumpLogcat(self, prefix=''):
- """Dumps device logcat outputs to log directory.
-
- Args:
- prefix: string, file name prefix. Usually in format of
- <test_module>-<test_case>
- """
- event = tfi.Begin('dump logcat',
- tfi.categories.FAILED_TEST_CASE_PROCESSING)
- if prefix:
- prefix = re.sub('[^\w\-_\. ]', '_', prefix) + '_'
-
- parent_dir = os.path.join(logging.log_path, 'logcat')
-
- if not file_util.Mkdir(parent_dir):
- logging.error('Failed to create bugreport output directory %s', parent_dir)
- return
-
- for device in self.android_devices:
- if (not device.isAdbLogcatOn) or device.fatal_error:
- continue
- for buffer in LOGCAT_BUFFERS:
- file_name = (_LOGCAT_FILE_PREFIX
- + prefix
- + '_%s_' % buffer
- + device.serial
- + _LOGCAT_FILE_EXTENSION)
-
- file_path = os.path.join(parent_dir, file_name)
-
- logging.info('Dumping logcat %s...' % file_path)
- device.adb.logcat('-b', buffer, '-d', '>', file_path)
- event.End()
diff --git a/runners/host/config_parser.py b/runners/host/config_parser.py
deleted file mode 100755
index ad1d845..0000000
--- a/runners/host/config_parser.py
+++ /dev/null
@@ -1,272 +0,0 @@
-#
-# 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.
-#
-
-from builtins import str
-
-import copy
-import signal
-import sys
-import traceback
-
-from vts.runners.host import keys
-from vts.runners.host import errors
-from vts.runners.host import signals
-from vts.runners.host import utils
-
-_DEFAULT_CONFIG_TEMPLATE = {
- "test_bed": {
- "AndroidDevice": "*",
- },
- "log_path": "/tmp/logs",
- "test_paths": ["./"],
- "enable_web": False,
-}
-
-
-def GetDefaultConfig(test_name):
- """Returns a default config data structure (when no config file is given)."""
- result = copy.deepcopy(_DEFAULT_CONFIG_TEMPLATE)
- result[keys.ConfigKeys.KEY_TESTBED][
- keys.ConfigKeys.KEY_TESTBED_NAME] = test_name
- return result
-
-
-def load_test_config_file(test_config_path,
- tb_filters=None,
- baseline_config=None):
- """Processes the test configuration file provided by user.
-
- Loads the configuration file into a json object, unpacks each testbed
- config into its own json object, and validate the configuration in the
- process.
-
- Args:
- test_config_path: Path to the test configuration file.
- tb_filters: A list of strings, each is a test bed name. If None, all
- test beds are picked up. Otherwise only test bed names
- specified will be picked up.
- baseline_config: dict, the baseline config to use (used iff
- test_config_path does not have device info).
-
- Returns:
- A list of test configuration json objects to be passed to TestRunner.
- """
- try:
- configs = utils.load_config(test_config_path)
- if keys.ConfigKeys.KEY_TESTBED not in configs and baseline_config:
- configs.update(baseline_config)
-
- if tb_filters:
- tbs = []
- for tb in configs[keys.ConfigKeys.KEY_TESTBED]:
- if tb[keys.ConfigKeys.KEY_TESTBED_NAME] in tb_filters:
- tbs.append(tb)
- if len(tbs) != len(tb_filters):
- print("Expect to find %d test bed configs, found %d." %
- (len(tb_filters), len(tbs)))
- print("Check if you have the correct test bed names.")
- return None
- configs[keys.ConfigKeys.KEY_TESTBED] = tbs
- _validate_test_config(configs)
- _validate_testbed_configs(configs[keys.ConfigKeys.KEY_TESTBED])
- k_log_path = keys.ConfigKeys.KEY_LOG_PATH
- configs[k_log_path] = utils.abs_path(configs[k_log_path])
- tps = configs[keys.ConfigKeys.KEY_TEST_PATHS]
- except errors.USERError as e:
- print("Something is wrong in the test configurations.")
- print(str(e))
- return None
- except Exception as e:
- print("Error loading test config {}".format(test_config_path))
- print(traceback.format_exc())
- return None
- # Unpack testbeds into separate json objects.
- beds = configs.pop(keys.ConfigKeys.KEY_TESTBED)
- config_jsons = []
- for original_bed_config in beds:
- new_test_config = dict(configs)
- new_test_config[keys.ConfigKeys.KEY_TESTBED] = original_bed_config
- # Keys in each test bed config will be copied to a level up to be
- # picked up for user_params. If the key already exists in the upper
- # level, the local one defined in test bed config overwrites the
- # general one.
- new_test_config.update(original_bed_config)
- config_jsons.append(new_test_config)
- return config_jsons
-
-
-def parse_test_list(test_list):
- """Parse user provided test list into internal format for test_runner.
-
- Args:
- test_list: A list of test classes/cases.
-
- Returns:
- A list of tuples, each has a test class name and a list of test case
- names.
- """
- result = []
- for elem in test_list:
- result.append(_parse_one_test_specifier(elem))
- return result
-
-
-def _validate_test_config(test_config):
- """Validates the raw configuration loaded from the config file.
-
- Making sure all the required keys exist.
-
- Args:
- test_config: A dict that is the config to validate.
-
- Raises:
- errors.USERError is raised if any required key is missing from the
- config.
- """
- for k in keys.ConfigKeys.RESERVED_KEYS:
- if k not in test_config:
- raise errors.USERError(("Required key {} missing in test "
- "config.").format(k))
-
-
-def _parse_one_test_specifier(item):
- """Parse one test specifier from command line input.
-
- This also verifies that the test class name and test case names follow
- ACTS's naming conventions. A test class name has to end with "Test"; a test
- case name has to start with "test".
-
- Args:
- item: A string that specifies a test class or test cases in one test
- class to run.
-
- Returns:
- A tuple of a string and a list of strings. The string is the test class
- name, the list of strings is a list of test case names. The list can be
- None.
- """
- tokens = item.split(':')
- if len(tokens) > 2:
- raise errors.USERError("Syntax error in test specifier %s" % item)
- if len(tokens) == 1:
- # This should be considered a test class name
- test_cls_name = tokens[0]
- _validate_test_class_name(test_cls_name)
- return (test_cls_name, None)
- elif len(tokens) == 2:
- # This should be considered a test class name followed by
- # a list of test case names.
- test_cls_name, test_case_names = tokens
- clean_names = []
- _validate_test_class_name(test_cls_name)
- for elem in test_case_names.split(','):
- test_case_name = elem.strip()
- if not test_case_name.startswith("test_"):
- raise errors.USERError(
- ("Requested test case '%s' in test class "
- "'%s' does not follow the test case "
- "naming convention test_*.") % (test_case_name,
- test_cls_name))
- clean_names.append(test_case_name)
- return (test_cls_name, clean_names)
-
-
-def _parse_test_file(fpath):
- """Parses a test file that contains test specifiers.
-
- Args:
- fpath: A string that is the path to the test file to parse.
-
- Returns:
- A list of strings, each is a test specifier.
- """
- try:
- with open(fpath, 'r') as f:
- tf = []
- for line in f:
- line = line.strip()
- if not line:
- continue
- if len(tf) and (tf[-1].endswith(':') or tf[-1].endswith(',')):
- tf[-1] += line
- else:
- tf.append(line)
- return tf
- except:
- print("Error loading test file.")
- raise
-
-
-def _validate_test_class_name(test_cls_name):
- """Checks if a string follows the test class name convention.
-
- Args:
- test_cls_name: A string that should be a test class name.
-
- Raises:
- errors.USERError is raised if the input does not follow test class
- naming convention.
- """
- if not test_cls_name.endswith("Test"):
- raise errors.USERError(
- ("Requested test class '%s' does not follow the test "
- "class naming convention *Test.") % test_cls_name)
-
-
-def _validate_testbed_configs(testbed_configs):
- """Validates the testbed configurations.
-
- Args:
- testbed_configs: A list of testbed configuration json objects.
-
- Raises:
- If any part of the configuration is invalid, errors.USERError is raised.
- """
- seen_names = set()
- # Cross checks testbed configs for resource conflicts.
- for config in testbed_configs:
- # Check for conflicts between multiple concurrent testbed configs.
- # No need to call it if there's only one testbed config.
- name = config[keys.ConfigKeys.KEY_TESTBED_NAME]
- _validate_testbed_name(name)
- # Test bed names should be unique.
- if name in seen_names:
- raise errors.USERError("Duplicate testbed name {} found.".format(
- name))
- seen_names.add(name)
-
-
-def _validate_testbed_name(name):
- """Validates the name of a test bed.
-
- Since test bed names are used as part of the test run id, it needs to meet
- certain requirements.
-
- Args:
- name: The test bed's name specified in config file.
-
- Raises:
- If the name does not meet any criteria, errors.USERError is raised.
- """
- if not name:
- raise errors.USERError("Test bed names can't be empty.")
- if not isinstance(name, str) and not isinstance(name, basestring):
- raise errors.USERError("Test bed names have to be string. Found: %s" %
- type(name))
- for l in name:
- if l not in utils.valid_filename_chars:
- raise errors.USERError(
- "Char '%s' is not allowed in test bed names." % l)
diff --git a/runners/host/const.py b/runners/host/const.py
deleted file mode 100644
index d5ba837..0000000
--- a/runners/host/const.py
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# 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.
-#
-from vts.utils.python.common import cmd_utils
-
-STDOUT = cmd_utils.STDOUT
-STDERR = cmd_utils.STDERR
-EXIT_CODE = cmd_utils.EXIT_CODE
-
-# Note: filterOneTest method in base_test.py assumes SUFFIX_32BIT and SUFFIX_64BIT
-# are in lower cases.
-SUFFIX_32BIT = "32bit"
-SUFFIX_64BIT = "64bit"
-
-# for toggling hal hidl test passthrough mode
-VTS_HAL_HIDL_GET_STUB = 'VTS_HAL_HIDL_GET_STUB'
diff --git a/runners/host/errors.py b/runners/host/errors.py
deleted file mode 100644
index 7eee3e0..0000000
--- a/runners/host/errors.py
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# 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.
-#
-
-from vts.runners.host import signals
-
-
-class VtsError(Exception):
- """Raised for general VTS exceptions."""
-
-
-class BaseTestError(VtsError):
- """Raised for exceptions that occured in BaseTestClass."""
-
-
-class USERError(VtsError):
- """Raised when a problem is caused by user mistake, e.g. wrong command,
- misformatted config, test info, wrong test paths etc.
- """
-
-
-class ComponentLoadingError(VtsError):
- """Raised if it is unable to load a target component on a target device."""
-
-
-class ConnectionRefusedError(VtsError):
- """Failure due to wrong port number.
-
- Raised when an attempt to connect to a TCP server fails due to incorrect
- port number, such as 21.
- """
-
-
-class VtsTcpClientCreationError(VtsError):
- """Raised when TcpClient creation failed."""
-
-
-class VtsTcpCommunicationError(VtsError):
- """Raised when TcpClient communication failed."""
-
-
-class VtsUnsupportedTypeError(VtsError):
- """Raised when an unsupported type is used."""
-
-
-class VtsMalformedProtoStringError(VtsError):
- """Raised when a StringDataValueMessage is not populated or corrupted."""
-
diff --git a/runners/host/keys.py b/runners/host/keys.py
deleted file mode 100644
index a958382..0000000
--- a/runners/host/keys.py
+++ /dev/null
@@ -1,169 +0,0 @@
-#
-# 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.
-#
-"""This module has the global key values that are used across framework
-modules.
-"""
-
-
-class ConfigKeys(object):
- """Enum values for test config related lookups.
- """
- # Keys used to look up values from test config files.
- # These keys define the wording of test configs and their internal
- # references.
- KEY_LOG_PATH = "log_path"
- KEY_LOG_SEVERITY = "log_severity"
- KEY_TESTBED = "test_bed"
- KEY_TESTBED_NAME = "name"
- KEY_TEST_PATHS = "test_paths"
- KEY_TEST_SUITE = "test_suite"
- KEY_TEST_TIMEOUT = "test_timeout"
-
- # Keys in test suite
- KEY_INCLUDE_FILTER = "include_filter"
- KEY_EXCLUDE_FILTER = "exclude_filter"
- KEY_EXCLUDE_OVER_INCLUDE = "exclude_over_include"
-
- # Keys for base test.
- IKEY_MAX_RETRY_COUNT = "max_retry_count"
-
- # Keys for binary tests
- IKEY_BINARY_TEST_SOURCE = "binary_test_source"
- IKEY_BINARY_TEST_WORKING_DIRECTORY = "binary_test_working_directory"
- IKEY_BINARY_TEST_ENVP = "binary_test_envp"
- IKEY_BINARY_TEST_ARGS = "binary_test_args"
- IKEY_BINARY_TEST_LD_LIBRARY_PATH = "binary_test_ld_library_path"
- IKEY_NATIVE_SERVER_PROCESS_NAME = "native_server_process_name"
- IKEY_GTEST_BATCH_MODE = "gtest_batch_mode"
-
- # @Deprecated use IKEY_DISABLE_FRAMEWORK
- IKEY_BINARY_TEST_DISABLE_FRAMEWORK = "binary_test_disable_framework"
- IKEY_DISABLE_FRAMEWORK = "DISABLE_FRAMEWORK"
- # @Deprecated use IKEY_STOP_NATIVE_SERVERS
- IKEY_BINARY_TEST_STOP_NATIVE_SERVERS = "binary_test_stop_native_servers"
- IKEY_STOP_NATIVE_SERVERS = "STOP_NATIVE_SERVERS"
-
- # Internal keys, used internally, not exposed to user's config files.
- IKEY_USER_PARAM = "user_params"
- IKEY_TESTBED_NAME = "testbed_name"
- IKEY_LOG_PATH = "log_path"
- IKEY_ABI_NAME = "abi_name"
- IKEY_ABI_BITNESS = "abi_bitness"
- IKEY_RUN_32BIT_ON_64BIT_ABI = "run_32bit_on_64bit_abi"
- IKEY_SKIP_ON_32BIT_ABI = "skip_on_32bit_abi"
- IKEY_SKIP_ON_64BIT_ABI = "skip_on_64bit_abi"
- IKEY_SKIP_IF_THERMAL_THROTTLING = "skip_if_thermal_throttling"
- IKEY_DISABLE_CPU_FREQUENCY_SCALING = "disable_cpu_frequency_scaling"
-
- IKEY_BUILD = "build"
- IKEY_DATA_FILE_PATH = "data_file_path"
-
- IKEY_BUG_REPORT_ON_FAILURE = "BUG_REPORT_ON_FAILURE"
- IKEY_LOGCAT_ON_FAILURE = "LOGCAT_ON_FAILURE"
-
- # sub fields of test_bed
- IKEY_ANDROID_DEVICE = "AndroidDevice"
- IKEY_PRODUCT_TYPE = "product_type"
- IKEY_PRODUCT_VARIANT = "product_variant"
- IKEY_BUILD_FLAVOR = "build_flavor"
- IKEY_BUILD_ID = "build_id"
- IKEY_BRANCH = "branch"
- IKEY_BUILD_ALIAS = "build_alias"
- IKEY_API_LEVEL = "api_level"
- IKEY_SERIAL = "serial"
-
- # Keys for web
- IKEY_ENABLE_WEB = "enable_web"
-
- # Keys for profiling
- IKEY_ENABLE_PROFILING = "enable_profiling"
- IKEY_BINARY_TEST_PROFILING_LIBRARY_PATH = "binary_test_profiling_library_path"
- IKEY_PROFILING_TRACING_PATH = "profiling_trace_path"
- IKEY_TRACE_FILE_TOOL_NAME = "trace_file_tool_name"
- IKEY_SAVE_TRACE_FILE_REMOTE = "save_trace_file_remote"
- IKEY_PROFILING_ARG_VALUE = "profiling_arg_value"
-
- # Keys for systrace (for hal tests)
- IKEY_ENABLE_SYSTRACE = "enable_systrace"
- IKEY_SYSTRACE_PROCESS_NAME = "systrace_process_name"
- IKEY_SYSTRACE_REPORT_PATH = "systrace_report_path"
- IKEY_SYSTRACE_REPORT_URL_PREFIX = "systrace_report_url_prefix"
- IKEY_SYSTRACE_REPORT_USE_DATE_DIRECTORY = "systrace_report_path_use_date_directory"
- IKEY_SYSTRACE_UPLAD_TO_DASHBOARD = "systrace_upload_to_dashboard"
-
- # Keys for coverage
- IKEY_ENABLE_COVERAGE = "enable_coverage"
- IKEY_ENABLE_SANCOV = "enable_sancov"
- IKEY_MODULES = "modules"
- IKEY_SERVICE_JSON_PATH = "service_key_json_path"
- IKEY_DASHBOARD_POST_COMMAND = "dashboard_post_command"
- IKEY_OUTPUT_COVERAGE_REPORT = "output_coverage_report"
- IKEY_GLOBAL_COVERAGE = "global_coverage"
- IKEY_SANCOV_RESOURCES_PATH = "sancov_resources_path"
- IKEY_GCOV_RESOURCES_PATH = "gcov_resources_path"
- IKEY_COVERAGE_REPORT_PATH = "coverage_report_path"
- IKEY_EXCLUDE_COVERAGE_PATH = "exclude_coverage_path"
- IKEY_FUZZING_GCS_BUCKET_NAME = "fuzzing_gcs_bucket_name"
-
- # Keys for the HAL HIDL GTest type (see VtsMultiDeviceTest.java).
- IKEY_PRECONDITION_HWBINDER_SERVICE = "precondition_hwbinder_service"
- IKEY_PRECONDITION_FEATURE = "precondition_feature"
- IKEY_PRECONDITION_FILE_PATH_PREFIX = "precondition_file_path_prefix"
- IKEY_PRECONDITION_FIRST_API_LEVEL = "precondition_first_api_level"
- IKEY_PRECONDITION_LSHAL = "precondition_lshal"
- IKEY_PRECONDITION_SYSPROP = "precondition_sysprop"
- IKEY_PRECONDITION_VINTF = "precondition_vintf"
-
- # Keys for toggle passthrough mode
- IKEY_PASSTHROUGH_MODE = "passthrough_mode"
-
- # Keys for the HAL HIDL Replay Test type.
- IKEY_HAL_HIDL_REPLAY_TEST_TRACE_PATHS = "hal_hidl_replay_test_trace_paths"
- IKEY_HAL_HIDL_PACKAGE_NAME = "hal_hidl_package_name"
-
- # Keys for special test cases
- IKEY_FFMPEG_BINARY_PATH = "ffmpeg_binary_path"
- IKEY_SYZKALLER_PACKAGES_PATH = "syzkaller_packages_path"
- IKEY_SYZKALLER_TEMPLATE_PATH = "syzkaller_template_path"
-
- # Keys for log uploading
- IKEY_ENABLE_LOG_UPLOADING = "enable_log_uploading"
- IKEY_LOG_UPLOADING_PATH = "log_uploading_path"
- IKEY_LOG_UPLOADING_USE_DATE_DIRECTORY = "log_uploading_use_date_directory"
- IKEY_LOG_UPLOADING_URL_PREFIX = "log_uploading_url_prefix"
- IKEY_LOG_UPLOADING_GCS_BUCKET_NAME = "log_uploading_gcs_bucket_name"
-
- # Keys for general user config types
- IKEY_USER_CONFIG_STR = 'CONFIG_STR'
- IKEY_USER_CONFIG_INT = 'CONFIG_INT'
- IKEY_USER_CONFIG_BOOL = 'CONFIG_BOOL'
-
- # A list of keys whose values in configs should not be passed to test
- # classes without unpacking first.
- RESERVED_KEYS = (KEY_TESTBED, KEY_LOG_PATH, KEY_TEST_PATHS)
-
- # Keys for special run modes
- IKEY_COLLECT_TESTS_ONLY = "collect_tests_only"
- RUN_AS_VTS_SELFTEST = "run_as_vts_self_test"
-
- # Vts compliance test related keys
- RUN_AS_COMPLIANCE_TEST = "run_as_compliance_test"
-
- # Mobly test related keys
- MOBLY_TEST_MODULE = "MOBLY_TEST_MODULE"
-
- # Controller option keys
- SHELL_DEFAULT_NOHUP = "shell_default_nohup"
diff --git a/runners/host/logger.py b/runners/host/logger.py
deleted file mode 100755
index a273d5b..0000000
--- a/runners/host/logger.py
+++ /dev/null
@@ -1,307 +0,0 @@
-#
-# 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.
-#
-
-from __future__ import print_function
-
-import datetime
-import logging
-import os
-import re
-import sys
-
-from vts.runners.host import utils
-
-log_line_format = "%(asctime)s.%(msecs).03d %(levelname)s %(message)s"
-# The micro seconds are added by the format string above,
-# so the time format does not include ms.
-log_line_time_format = "%m-%d %H:%M:%S"
-log_line_timestamp_len = 18
-
-logline_timestamp_re = re.compile("\d\d-\d\d \d\d:\d\d:\d\d.\d\d\d")
-
-log_severity_map = {
- "ERROR": logging.ERROR,
- "WARNING": logging.WARNING,
- "INFO": logging.INFO,
- "DEBUG": logging.DEBUG,
-}
-
-# Directory name in the log path in which files will be included in TradeFed output
-PYTHON_CUSTOM_OUTPUT = 'custom_output_files'
-
-def _parse_logline_timestamp(t):
- """Parses a logline timestamp into a tuple.
-
- Args:
- t: Timestamp in logline format.
-
- Returns:
- An iterable of date and time elements in the order of month, day, hour,
- minute, second, microsecond.
- """
- date, time = t.split(' ')
- month, day = date.split('-')
- h, m, s = time.split(':')
- s, ms = s.split('.')
- return (month, day, h, m, s, ms)
-
-
-def isValidLogLineTimestamp(timestamp):
- if len(timestamp) == log_line_timestamp_len:
- if logline_timestamp_re.match(timestamp):
- return True
- return False
-
-
-def logLineTimestampComparator(t1, t2):
- """Comparator for timestamps in logline format.
-
- Args:
- t1: Timestamp in logline format.
- t2: Timestamp in logline format.
-
- Returns:
- -1 if t1 < t2; 1 if t1 > t2; 0 if t1 == t2.
- """
- dt1 = _parse_logline_timestamp(t1)
- dt2 = _parse_logline_timestamp(t2)
- for u1, u2 in zip(dt1, dt2):
- if u1 < u2:
- return -1
- elif u1 > u2:
- return 1
- return 0
-
-
-def _get_timestamp(time_format, delta=None):
- t = datetime.datetime.now()
- if delta:
- t = t + datetime.timedelta(seconds=delta)
- return t.strftime(time_format)[:-3]
-
-
-def epochToLogLineTimestamp(epoch_time):
- d = datetime.datetime.fromtimestamp(epoch_time / 1000)
- return d.strftime("%m-%d %H:%M:%S.%f")[:-3]
-
-
-def getLogLineTimestamp(delta=None):
- """Returns a timestamp in the format used by log lines.
-
- Default is current time. If a delta is set, the return value will be
- the current time offset by delta seconds.
-
- Args:
- delta: Number of seconds to offset from current time; can be negative.
-
- Returns:
- A timestamp in log line format with an offset.
- """
- return _get_timestamp("%m-%d %H:%M:%S.%f", delta)
-
-
-def getLogFileTimestamp(delta=None):
- """Returns a timestamp in the format used for log file names.
-
- Default is current time. If a delta is set, the return value will be
- the current time offset by delta seconds.
-
- Args:
- delta: Number of seconds to offset from current time; can be negative.
-
- Returns:
- A timestamp in log filen name format with an offset.
- """
- return _get_timestamp("%m-%d-%Y_%H-%M-%S-%f", delta)
-
-
-def _initiateTestLogger(log_path, prefix=None, filename=None, log_severity="INFO"):
- """Customizes the root logger for a test run.
-
- The logger object has a stream handler and a file handler. Both handler logs data
- according to the log severty level.
-
- Args:
- log_path: Location of the log file.
- prefix: A prefix for each log line in terminal.
- filename: Name of the log file. The default is the time the logger
- is requested.
- log_severity: string, set the log severity level, default is INFO.
- This value affects console stream log handler and the python runner
- part of TradeFed host_log.
- """
- log = logging.getLogger()
- # Clean up any remaining handlers.
- killTestLogger(log)
- log.propagate = False
-
- log.setLevel(logging.DEBUG)
-
- # Log into stream
- terminal_format = log_line_format
- if prefix:
- terminal_format = "[{}] {}".format(prefix, log_line_format)
- c_formatter = logging.Formatter(terminal_format, log_line_time_format)
- ch = logging.StreamHandler(sys.stdout)
- ch.setFormatter(c_formatter)
- ch.setLevel(log_severity_map.get(log_severity, logging.INFO))
- log.addHandler(ch)
-
- # Log everything to file
- f_formatter = logging.Formatter(log_line_format, log_line_time_format)
-
- # All the logs of this test class go into one directory
- if filename is None:
- filename = getLogFileTimestamp()
- utils.create_dir(log_path)
-
- default_log_levels = ('ERROR', 'INFO', 'DEBUG')
- for level in default_log_levels:
- idx = filename.rfind('.')
- if idx < 0:
- idx = len(filename)
- addLogFile(log_path=log_path,
- filename=filename[:idx] + '_' + level + filename[idx:],
- log_severity=level)
-
- log.log_path = log_path
- logging.log_path = log_path
-
-
-def killTestLogger(logger):
- """Cleans up the handlers attached to a test logger object.
-
- Args:
- logger: The logging object to clean up.
- """
- for h in list(logger.handlers):
- if isinstance(h, logging.FileHandler):
- h.close()
- logger.removeHandler(h)
-
-
-def isSymlinkSupported():
- """Checks whether the OS supports symbolic link.
-
- Returns:
- A boolean representing whether the OS supports symbolic link.
- """
- return hasattr(os, "symlink")
-
-
-def createLatestLogAlias(actual_path):
- """Creates a symlink to the latest test run logs.
-
- Args:
- actual_path: The source directory where the latest test run's logs are.
- """
- link_path = os.path.join(os.path.dirname(actual_path), "latest")
- if os.path.islink(link_path):
- os.remove(link_path)
- os.symlink(actual_path, link_path)
-
-
-def setupTestLogger(log_path,
- prefix=None,
- filename=None,
- log_severity="INFO",
- create_symlink=True):
- """Customizes the root logger for a test run.
-
- Args:
- log_path: Location of the report file.
- prefix: A prefix for each log line in terminal.
- filename: Name of the files. The default is the time the objects
- are requested.
- create_symlink: bool. determines whether to create the symlink or not.
- set to True as default.
-
- Returns:
- A string, abs path to the created log file.
- """
- if filename is None:
- filename = getLogFileTimestamp()
- utils.create_dir(log_path)
- logger = _initiateTestLogger(log_path, prefix, filename, log_severity)
- if create_symlink and isSymlinkSupported():
- createLatestLogAlias(log_path)
- return os.path.join(log_path, filename)
-
-
-def addLogFile(log_path, filename=None, log_severity="INFO"):
- """Creates a log file and adds the handler to the root logger.
-
- Args:
- log_path: Location of the report file.
- filename: Name of the log file. The default is the time the logger
- is requested.
-
- Returns:
- A string, abs path to the created log file.
- logging.FileHandler instance which is added to the logger.
- """
- if filename is None:
- filename = getLogFileTimestamp()
- f_formatter = logging.Formatter(log_line_format, log_line_time_format)
- fh = logging.FileHandler(os.path.join(log_path, filename))
- fh.setFormatter(f_formatter)
- fh.setLevel(log_severity_map.get(log_severity, logging.INFO))
- logging.getLogger().addHandler(fh)
- return os.path.join(log_path, filename), fh
-
-
-def normalizeLogLineTimestamp(log_line_timestamp):
- """Replace special characters in log line timestamp with normal characters.
-
- Args:
- log_line_timestamp: A string in the log line timestamp format. Obtained
- with getLogLineTimestamp.
-
- Returns:
- A string representing the same time as input timestamp, but without
- special characters.
- """
- norm_tp = log_line_timestamp.replace(' ', '_')
- norm_tp = norm_tp.replace(':', '-')
- return norm_tp
-
-
-class LoggerProxy(object):
- """This class is for situations where a logger may or may not exist.
-
- e.g. In controller classes, sometimes we don't have a logger to pass in,
- like during a quick try in python console. In these cases, we don't want to
- crash on the log lines because logger is None, so we should set self.log to
- an object of this class in the controller classes, instead of the actual
- logger object.
- """
-
- def __init__(self, logger=None):
- self.log = logger
-
- @property
- def log_path(self):
- if self.log:
- return self.log.log_path
- return "/tmp/logs"
-
- def __getattr__(self, name):
- def log_call(*args):
- if self.log:
- return getattr(self.log, name)(*args)
- print(*args)
-
- return log_call
diff --git a/runners/host/records.py b/runners/host/records.py
deleted file mode 100644
index f053056..0000000
--- a/runners/host/records.py
+++ /dev/null
@@ -1,505 +0,0 @@
-#
-# 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.
-#
-from __builtin__ import property
-"""This module is where all the record definitions and record containers live.
-"""
-
-import json
-import logging
-import pprint
-
-from vts.runners.host import signals
-from vts.runners.host import utils
-from vts.utils.python.common import list_utils
-
-
-class TestResultEnums(object):
- """Enums used for TestResultRecord class.
-
- Includes the tokens to mark test result with, and the string names for each
- field in TestResultRecord.
- """
-
- RECORD_NAME = "Test Name"
- RECORD_CLASS = "Test Class"
- RECORD_BEGIN_TIME = "Begin Time"
- RECORD_END_TIME = "End Time"
- RECORD_RESULT = "Result"
- RECORD_UID = "UID"
- RECORD_EXTRAS = "Extras"
- RECORD_EXTRA_ERRORS = "Extra Errors"
- RECORD_DETAILS = "Details"
- RECORD_TABLES = "Tables"
- TEST_RESULT_PASS = "PASS"
- TEST_RESULT_FAIL = "FAIL"
- TEST_RESULT_SKIP = "SKIP"
- TEST_RESULT_ERROR = "ERROR"
-
-
-class TestResultRecord(object):
- """A record that holds the information of a test case execution.
-
- Attributes:
- test_name: A string representing the name of the test case.
- begin_time: Epoch timestamp of when the test case started.
- end_time: Epoch timestamp of when the test case ended.
- uid: Unique identifier of a test case.
- result: Test result, PASS/FAIL/SKIP.
- extras: User defined extra information of the test result.
- details: A string explaining the details of the test case.
- tables: A dict of 2-dimensional lists containing tabular results.
- """
-
- def __init__(self, t_name, t_class=None):
- self.test_name = t_name
- self.test_class = t_class
- self.begin_time = None
- self.end_time = None
- self.uid = None
- self.result = None
- self.extras = None
- self.details = None
- self.extra_errors = {}
- self.tables = {}
-
- @property
- def fullname(self):
- return '%s.%s' % (self.test_class, self.test_name)
-
- def isSameTestCase(self, record):
- return self.fullname == record.fullname
-
- def testBegin(self):
- """Call this when the test case it records begins execution.
-
- Sets the begin_time of this record.
- """
- self.begin_time = utils.get_current_epoch_time()
-
- def _testEnd(self, result, e):
- """Class internal function to signal the end of a test case execution.
-
- Args:
- result: One of the TEST_RESULT enums in TestResultEnums.
- e: A test termination signal (usually an exception object). It can
- be any exception instance or of any subclass of
- vts.runners.host.signals.TestSignal.
- """
- self.end_time = utils.get_current_epoch_time()
- self.result = result
- if isinstance(e, signals.TestSignal):
- self.details = e.details
- self.extras = e.extras
- elif e:
- self.details = str(e)
-
- def testPass(self, e=None):
- """To mark the test as passed in this record.
-
- Args:
- e: An instance of vts.runners.host.signals.TestPass.
- """
- self._testEnd(TestResultEnums.TEST_RESULT_PASS, e)
-
- def testFail(self, e=None):
- """To mark the test as failed in this record.
-
- Only testFail does instance check because we want "assert xxx" to also
- fail the test same way assert_true does.
-
- Args:
- e: An exception object. It can be an instance of AssertionError or
- vts.runners.host.base_test.TestFailure.
- """
- self._testEnd(TestResultEnums.TEST_RESULT_FAIL, e)
-
- def testSkip(self, e=None):
- """To mark the test as skipped in this record.
-
- Args:
- e: An instance of vts.runners.host.signals.TestSkip.
- """
- self._testEnd(TestResultEnums.TEST_RESULT_SKIP, e)
-
- def testError(self, e=None):
- """To mark the test as error in this record.
-
- Args:
- e: An exception object.
- """
- self._testEnd(TestResultEnums.TEST_RESULT_ERROR, e)
-
- def addError(self, tag, e):
- """Add extra error happened during a test mark the test result as
- ERROR.
-
- If an error is added the test record, the record's result is equivalent
- to the case where an uncaught exception happened.
-
- Args:
- tag: A string describing where this error came from, e.g. 'on_pass'.
- e: An exception object.
- """
- self.result = TestResultEnums.TEST_RESULT_ERROR
- self.extra_errors[tag] = str(e)
-
- def addTable(self, name, rows):
- """Add a table as part of the test result.
-
- Args:
- name: The table name.
- rows: A 2-dimensional list which contains the data.
- """
- if name in self.tables:
- logging.warning("Overwrite table %s" % name)
- self.tables[name] = rows
-
- def __str__(self):
- d = self.getDict()
- l = ["%s = %s" % (k, v) for k, v in d.items()]
- s = ', '.join(l)
- return s
-
- def __repr__(self):
- """This returns a short string representation of the test record."""
- t = utils.epoch_to_human_time(self.begin_time)
- return "%s %s %s" % (t, self.test_name, self.result)
-
- def getDict(self):
- """Gets a dictionary representating the content of this class.
-
- Returns:
- A dictionary representating the content of this class.
- """
- d = {}
- d[TestResultEnums.RECORD_NAME] = self.test_name
- d[TestResultEnums.RECORD_CLASS] = self.test_class
- d[TestResultEnums.RECORD_BEGIN_TIME] = self.begin_time
- d[TestResultEnums.RECORD_END_TIME] = self.end_time
- d[TestResultEnums.RECORD_RESULT] = self.result
- d[TestResultEnums.RECORD_UID] = self.uid
- d[TestResultEnums.RECORD_EXTRAS] = self.extras
- d[TestResultEnums.RECORD_DETAILS] = self.details
- d[TestResultEnums.RECORD_EXTRA_ERRORS] = self.extra_errors
- d[TestResultEnums.RECORD_TABLES] = self.tables
- return d
-
- def jsonString(self):
- """Converts this test record to a string in json format.
-
- Format of the json string is:
- {
- 'Test Name': <test name>,
- 'Begin Time': <epoch timestamp>,
- 'Details': <details>,
- ...
- }
-
- Returns:
- A json-format string representing the test record.
- """
- return json.dumps(self.getDict())
-
-
-class TestResult(object):
- """A class that contains metrics of a test run.
-
- This class is essentially a container of TestResultRecord objects.
-
- Attributes:
- self.requested: A list of records for tests requested by user.
- self.failed: A list of records for tests failed.
- self.executed: A list of records for tests that were actually executed.
- self.passed: A list of records for tests passed.
- self.skipped: A list of records for tests skipped.
- self.error: A list of records for tests with error result token.
- self.class_errors: A list of strings, the errors that occurred during
- class setup.
- self._test_module_name: A string, test module's name.
- self._test_module_timestamp: An integer, test module's execution start
- timestamp.
- """
-
- def __init__(self):
- self.requested = []
- self.failed = []
- self.executed = []
- self.passed = []
- self.skipped = []
- self.error = []
- self._test_module_name = None
- self._test_module_timestamp = None
- self.class_errors = []
-
- def __add__(self, r):
- """Overrides '+' operator for TestResult class.
-
- The add operator merges two TestResult objects by concatenating all of
- their lists together.
-
- Args:
- r: another instance of TestResult to be added
-
- Returns:
- A TestResult instance that's the sum of two TestResult instances.
- """
- if not isinstance(r, TestResult):
- raise TypeError("Operand %s of type %s is not a TestResult." %
- (r, type(r)))
- r.reportNonExecutedRecord()
- sum_result = TestResult()
- for name in sum_result.__dict__:
- if name.startswith("_test_module"):
- l_value = getattr(self, name)
- r_value = getattr(r, name)
- if l_value is None and r_value is None:
- continue
- elif l_value is None and r_value is not None:
- value = r_value
- elif l_value is not None and r_value is None:
- value = l_value
- else:
- if name == "_test_module_name":
- if l_value != r_value:
- raise TypeError("_test_module_name is different.")
- value = l_value
- elif name == "_test_module_timestamp":
- if int(l_value) < int(r_value):
- value = l_value
- else:
- value = r_value
- else:
- raise TypeError("unknown _test_module* attribute.")
- setattr(sum_result, name, value)
- else:
- l_value = list(getattr(self, name))
- r_value = list(getattr(r, name))
- setattr(sum_result, name, l_value + r_value)
- return sum_result
-
- def getNonPassingRecords(self, non_executed=True, failed=True, skipped=False, error=True):
- """Returns a list of non-passing test records.
-
- Returns:
- a list of TestResultRecord, records that do not have passing result.
- non_executed: bool, whether to include non-executed results
- failed: bool, whether to include failed results
- skipped: bool, whether to include skipped results
- error: bool, whether to include error results
- """
- return ((self.getNonExecutedRecords() if non_executed else [])
- + (self.failed if failed else [])
- + (self.skipped if skipped else [])
- + (self.error if error else []))
-
- def getNonExecutedRecords(self):
- """Returns a list of records that were requested but not executed."""
- res = []
-
- for requested in self.requested:
- found = False
-
- for executed in self.executed:
- if requested.isSameTestCase(executed):
- found = True
- break
-
- if not found:
- res.append(requested)
-
- return res
-
- def reportNonExecutedRecord(self):
- """Check and report any requested tests that did not finish.
-
- Adds a test record to self.error list iff it is in requested list but not
- self.executed result list.
- """
- for requested in self.getNonExecutedRecords():
- requested.testBegin()
- requested.testError(
- "Unknown error: test case requested but not executed.")
- self.error.append(requested)
-
- def removeRecord(self, record, remove_requested=True):
- """Remove a test record from test results.
-
- Records will be ed using test_name and test_class attribute.
- All entries that match the provided record in all result lists will
- be removed after calling this method.
-
- Args:
- record: A test record object to add.
- remove_requested: bool, whether to remove the test case from requested
- list as well.
- """
- lists = [
- self.requested, self.failed, self.executed, self.passed,
- self.skipped, self.error
- ]
-
- for l in lists:
- indexToRemove = []
- for idx in range(len(l)):
- if l[idx].isSameTestCase(record):
- indexToRemove.append(idx)
-
- for idx in reversed(indexToRemove):
- del l[idx]
-
- def addRecord(self, record):
- """Adds a test record to test results.
-
- A record is considered executed once it's added to the test result.
-
- Args:
- record: A test record object to add.
- """
- self.removeRecord(record, remove_requested=False)
-
- self.executed.append(record)
- if record.result == TestResultEnums.TEST_RESULT_FAIL:
- self.failed.append(record)
- elif record.result == TestResultEnums.TEST_RESULT_SKIP:
- self.skipped.append(record)
- elif record.result == TestResultEnums.TEST_RESULT_PASS:
- self.passed.append(record)
- else:
- self.error.append(record)
-
- def setTestModuleKeys(self, name, start_timestamp):
- """Sets the test module's name and start_timestamp."""
- self._test_module_name = name
- self._test_module_timestamp = start_timestamp
-
- def failClass(self, class_name, e):
- """Add a record to indicate a test class setup has failed and no test
- in the class was executed.
-
- Args:
- class_name: A string that is the name of the failed test class.
- e: An exception object.
- """
- self.class_errors.append("%s: %s" % (class_name, e))
-
- def passClass(self, class_name, e=None):
- """Add a record to indicate a test class setup has passed and no test
- in the class was executed.
-
- Args:
- class_name: A string that is the name of the failed test class.
- e: An exception object.
- """
- record = TestResultRecord("setup_class", class_name)
- record.testBegin()
- record.testPass(e)
- self.executed.append(record)
- self.passed.append(record)
-
- def skipClass(self, class_name, reason):
- """Add a record to indicate all test cases in the class are skipped.
-
- Args:
- class_name: A string that is the name of the skipped test class.
- reason: A string that is the reason for skipping.
- """
- record = TestResultRecord("skip_class", class_name)
- record.testBegin()
- record.testSkip(signals.TestSkip(reason))
- self.executed.append(record)
- self.skipped.append(record)
-
- def jsonString(self):
- """Converts this test result to a string in json format.
-
- Format of the json string is:
- {
- "Results": [
- {<executed test record 1>},
- {<executed test record 2>},
- ...
- ],
- "Summary": <summary dict>
- }
-
- Returns:
- A json-format string representing the test results.
- """
- records = list_utils.MergeUniqueKeepOrder(
- self.executed, self.failed, self.passed, self.skipped, self.error)
- executed = [record.getDict() for record in records]
-
- d = {}
- d["Results"] = executed
- d["Summary"] = self.summaryDict()
- d["TestModule"] = self.testModuleDict()
- d["Class Errors"] = ("\n".join(self.class_errors)
- if self.class_errors else None)
- jsonString = json.dumps(d, indent=4, sort_keys=True)
- return jsonString
-
- def summary(self):
- """Gets a string that summarizes the stats of this test result.
-
- The summary rovides the counts of how many test cases fall into each
- category, like "Passed", "Failed" etc.
-
- Format of the string is:
- Requested <int>, Executed <int>, ...
-
- Returns:
- A summary string of this test result.
- """
- l = ["%s %d" % (k, v) for k, v in self.summaryDict().items()]
- # Sort the list so the order is the same every time.
- msg = ", ".join(sorted(l))
- return msg
-
- @property
- def progressStr(self):
- """Gets a string that shows test progress.
-
- Format of the string is:
- x/n, where x is number of executed + skipped + 1,
- and n is number of requested tests.
- """
- return '%s/%s' % (len(self.executed) + len(self.skipped) + 1,
- len(self.requested))
-
- def summaryDict(self):
- """Gets a dictionary that summarizes the stats of this test result.
-
- The summary rovides the counts of how many test cases fall into each
- category, like "Passed", "Failed" etc.
-
- Returns:
- A dictionary with the stats of this test result.
- """
- d = {}
- d["Requested"] = len(self.requested)
- d["Executed"] = len(self.executed)
- d["Passed"] = len(self.passed)
- d["Failed"] = len(self.failed)
- d["Skipped"] = len(self.skipped)
- d["Error"] = len(self.error)
- return d
-
- def testModuleDict(self):
- """Returns a dict that summarizes the test module DB indexing keys."""
- d = {}
- d["Name"] = self._test_module_name
- d["Timestamp"] = self._test_module_timestamp
- return d
diff --git a/runners/host/signals.py b/runners/host/signals.py
deleted file mode 100644
index aa2e49b..0000000
--- a/runners/host/signals.py
+++ /dev/null
@@ -1,102 +0,0 @@
-#
-# 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.
-#
-"""This module is where all the test signal classes and related utilities live.
-"""
-
-import functools
-import json
-import logging
-
-
-def GeneratedTest(func):
- """A decorator used to suppress result reporting for the test case that
- kicks off a group of generated test cases.
-
- Returns:
- What the decorated function returns.
- """
-
- @functools.wraps(func)
- def wrapper(*args, **kwargs):
- func(*args, **kwargs)
- raise TestSilent("Result reporting for %s is suppressed" %
- func.__name__)
-
- return wrapper
-
-
-class TestSignalError(Exception):
- """Raised when an error occurs inside a test signal."""
-
-class TestSignal(Exception):
- """Base class for all test result control signals.
-
- Attributes:
- details: A string that describes the reason for raising this signal.
- extras: A json-serializable data type to convey extra information about
- a test result.
- """
-
- def __init__(self, details, extras=None):
- super(TestSignal, self).__init__(details)
- try:
- self.details = str(details)
- except UnicodeEncodeError:
- # TODO: remove when we stop supporting Python 2
- logging.warning(u"Details contain non-ASCII characters: %s",
- details)
- self.details = details.encode("utf-8")
- try:
- json.dumps(extras)
- self.extras = extras
- except TypeError:
- raise TestSignalError(("Extras must be json serializable. %s "
- "is not.") % extras)
-
- def __str__(self):
- return "Details=%s, Extras=%s" % (self.details, self.extras)
-
-
-class TestFailure(TestSignal):
- """Raised when a test has failed."""
-
-
-class TestPass(TestSignal):
- """Raised when a test has passed."""
-
-
-class TestSkip(TestSignal):
- """Raised when a test has been skipped."""
-
-
-class TestSilent(TestSignal):
- """Raised when a test should not be reported. This should only be used for
- generated test cases.
- """
-
-
-class TestAbortClass(TestSignal):
- """Raised when all subsequent test cases within the same test class should
- be aborted.
- """
-
-
-class TestAbortAll(TestSignal):
- """Raised when all subsequent test cases should be aborted."""
-
-
-class ControllerError(Exception):
- """Raised when an error occured in controller classes."""
diff --git a/runners/host/tcp_client/__init__.py b/runners/host/tcp_client/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/runners/host/tcp_client/__init__.py
+++ /dev/null
diff --git a/runners/host/tcp_client/vts_tcp_client.py b/runners/host/tcp_client/vts_tcp_client.py
deleted file mode 100755
index e00acfd..0000000
--- a/runners/host/tcp_client/vts_tcp_client.py
+++ /dev/null
@@ -1,768 +0,0 @@
-#
-# 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.
-#
-
-import json
-import logging
-import os
-import socket
-import time
-
-from vts.proto import AndroidSystemControlMessage_pb2 as SysMsg_pb2
-from vts.proto import ComponentSpecificationMessage_pb2 as CompSpecMsg_pb2
-from vts.proto import VtsResourceControllerMessage_pb2 as ResControlMsg_pb2
-from vts.runners.host import const
-from vts.runners.host import errors
-from vts.utils.python.mirror import mirror_object
-
-from google.protobuf import text_format
-
-TARGET_IP = os.environ.get("TARGET_IP", None)
-TARGET_PORT = os.environ.get("TARGET_PORT", None)
-_DEFAULT_SOCKET_TIMEOUT_SECS = 1800
-_SOCKET_CONN_TIMEOUT_SECS = 60
-_SOCKET_CONN_RETRY_NUMBER = 5
-COMMAND_TYPE_NAME = {
- 1: "LIST_HALS",
- 2: "SET_HOST_INFO",
- 101: "CHECK_DRIVER_SERVICE",
- 102: "LAUNCH_DRIVER_SERVICE",
- 103: "VTS_AGENT_COMMAND_READ_SPECIFICATION",
- 201: "LIST_APIS",
- 202: "CALL_API",
- 203: "VTS_AGENT_COMMAND_GET_ATTRIBUTE",
- 301: "VTS_AGENT_COMMAND_EXECUTE_SHELL_COMMAND",
- 401: "VTS_FMQ_COMMAND",
- 402: "VTS_HIDL_MEMORY_COMMAND",
- 403: "VTS_HIDL_HANDLE_COMMAND"
-}
-
-
-class VtsTcpClient(object):
- """VTS TCP Client class.
-
- Attribute:
- NO_RESPONSE_MSG: string, error message when there is no response
- from device.
- FAIL_RESPONSE_MSG: string, error message when the device sends back
- a failure message.
- connection: a TCP socket instance.
- channel: a file to write and read data.
- error: string, ongoing tcp connection error. None means no error.
- _mode: the connection mode (adb_forwarding or ssh_tunnel)
- timeout: tcp connection timeout.
- """
-
- NO_RESPONSE_MSG = "Framework error: TCP client did not receive response from device."
- FAIL_RESPONSE_MSG = "Framework error: TCP client received unsuccessful response code."
-
- def __init__(self,
- mode="adb_forwarding",
- timeout=_DEFAULT_SOCKET_TIMEOUT_SECS):
- self.connection = None
- self.channel = None
- self._mode = mode
- self.timeout = timeout
- self.error = None
-
- @property
- def timeout(self):
- """Get TCP connection timeout.
-
- This function assumes timeout property setter is in __init__before
- any getter calls.
-
- Returns:
- int, timeout
- """
- return self._timeout
-
- @timeout.setter
- def timeout(self, timeout):
- """Set TCP connection timeout.
-
- Args:
- timeout: int, TCP connection timeout in seconds.
- """
- self._timeout = timeout
-
- def Heal(self):
- """Performs a self healing.
-
- Includes self diagnosis that looks for any framework errors.
-
- Returns:
- bool, True if everything is ok; False otherwise.
- """
- res = self.error is None
-
- if not res:
- logging.error('Self diagnosis found problems in TCP client: %s', self.error)
-
- return res
-
- def Connect(self,
- ip=TARGET_IP,
- command_port=TARGET_PORT,
- callback_port=None,
- retry=_SOCKET_CONN_RETRY_NUMBER,
- timeout=None):
- """Connects to a target device.
-
- Args:
- ip: string, the IP address of a target device.
- command_port: int, the TCP port which can be used to connect to
- a target device.
- callback_port: int, the TCP port number of a host-side callback
- server.
- retry: int, the number of times to retry connecting before giving
- up.
- timeout: tcp connection timeout.
-
- Returns:
- True if success, False otherwise
-
- Raises:
- socket.error when the connection fails.
- """
- if not command_port:
- logging.error("ip %s, command_port %s, callback_port %s invalid",
- ip, command_port, callback_port)
- return False
-
- for i in xrange(retry):
- connection_timeout = self._timeout if timeout is None else timeout
- try:
- self.connection = socket.create_connection(
- (ip, command_port), timeout=connection_timeout)
- break
- except socket.error as e:
- # Wait a bit and retry.
- logging.exception("Connect failed %s", e)
- time.sleep(1)
- if i + 1 == retry:
- raise errors.VtsTcpClientCreationError(
- "Couldn't connect to %s:%s" % (ip, command_port))
- self.channel = self.connection.makefile(mode="brw")
-
- if callback_port is not None:
- self.SendCommand(
- SysMsg_pb2.SET_HOST_INFO, callback_port=callback_port)
- resp = self.RecvResponse()
- if (resp.response_code != SysMsg_pb2.SUCCESS):
- return False
- return True
-
- def Disconnect(self):
- """Disconnects from the target device.
-
- TODO(yim): Send a msg to the target side to teardown handler session
- and release memory before closing the socket.
- """
- if self.connection is not None:
- self.channel = None
- self.connection.close()
- self.connection = None
-
- def ListHals(self, base_paths):
- """RPC to LIST_HALS."""
- self.SendCommand(SysMsg_pb2.LIST_HALS, paths=base_paths)
- resp = self.RecvResponse()
- if (resp.response_code == SysMsg_pb2.SUCCESS):
- return resp.file_names
- return None
-
- def CheckDriverService(self, service_name):
- """RPC to CHECK_DRIVER_SERVICE."""
- self.SendCommand(
- SysMsg_pb2.CHECK_DRIVER_SERVICE, service_name=service_name)
- resp = self.RecvResponse()
- return (resp.response_code == SysMsg_pb2.SUCCESS)
-
- def LaunchDriverService(self,
- driver_type,
- service_name,
- bits,
- file_path=None,
- target_class=None,
- target_type=None,
- target_version_major=None,
- target_version_minor=None,
- target_package=None,
- target_component_name=None,
- hw_binder_service_name=None,
- is_test_hal=None):
- """RPC to LAUNCH_DRIVER_SERVICE.
-
- Args:
- driver_type: enum, type of the driver (shared lib, shell).
- service_name: string, binder service name.
- bits: int, whether a target driver binary is 64-bits or 32-bits.
- file_path: string, the name of a target.
- target_class: int, target class.
- target_type: int, target type.
- target_version_major: int, HAL major version, e.g. 1.0 -> 1.
- target_version_minor: int, HAL minor version, e.g. 1.0 -> 0.
- target_package: string, package name of a HIDL HAL.
- target_component_name: string, name of a target component.
- hw_binder_service_name: name of a HW Binder service to use.
- is_test_hal: bool, whether the HAL service is a test HAL
- (e.g. msgq).
-
- Returns:
- response code, -1 or 0 on failure, other values on success.
- """
- logging.debug("service_name: %s", service_name)
- logging.debug("file_path: %s", file_path)
- logging.debug("bits: %s", bits)
- logging.debug("driver_type: %s", driver_type)
- self.SendCommand(
- SysMsg_pb2.LAUNCH_DRIVER_SERVICE,
- driver_type=driver_type,
- service_name=service_name,
- bits=bits,
- file_path=file_path,
- target_class=target_class,
- target_type=target_type,
- target_version_major=target_version_major,
- target_version_minor=target_version_minor,
- target_package=target_package,
- target_component_name=target_component_name,
- hw_binder_service_name=hw_binder_service_name,
- is_test_hal=is_test_hal)
- resp = self.RecvResponse()
- logging.debug("resp for LAUNCH_DRIVER_SERVICE: %s", resp)
- if driver_type == SysMsg_pb2.VTS_DRIVER_TYPE_HAL_HIDL \
- or driver_type == SysMsg_pb2.VTS_DRIVER_TYPE_HAL_CONVENTIONAL \
- or driver_type == SysMsg_pb2.VTS_DRIVER_TYPE_HAL_LEGACY:
- if resp.response_code == SysMsg_pb2.SUCCESS:
- return int(resp.result)
- else:
- return -1
- else:
- return (resp.response_code == SysMsg_pb2.SUCCESS)
-
- def ListApis(self):
- """RPC to LIST_APIS."""
- self.SendCommand(SysMsg_pb2.LIST_APIS)
- resp = self.RecvResponse()
- logging.debug("resp for LIST_APIS: %s", resp)
- if (resp.response_code == SysMsg_pb2.SUCCESS):
- return resp.spec
- return None
-
- def GetPythonDataOfVariableSpecMsg(self, var_spec_msg):
- """Returns the python native data structure for a given message.
-
- Args:
- var_spec_msg: VariableSpecificationMessage
-
- Returns:
- python native data structure (e.g., string, integer, list).
-
- Raises:
- VtsUnsupportedTypeError if unsupported type is specified.
- VtsMalformedProtoStringError if StringDataValueMessage is
- not populated.
- """
- if var_spec_msg.type == CompSpecMsg_pb2.TYPE_SCALAR:
- scalar_type = getattr(var_spec_msg, "scalar_type", "")
- if scalar_type:
- return getattr(var_spec_msg.scalar_value, scalar_type)
- elif var_spec_msg.type == CompSpecMsg_pb2.TYPE_ENUM:
- scalar_type = getattr(var_spec_msg, "scalar_type", "")
- if scalar_type:
- return getattr(var_spec_msg.scalar_value, scalar_type)
- else:
- return var_spec_msg.scalar_value.int32_t
- elif var_spec_msg.type == CompSpecMsg_pb2.TYPE_STRING:
- if hasattr(var_spec_msg, "string_value"):
- return getattr(var_spec_msg.string_value, "message", "")
- raise errors.VtsMalformedProtoStringError()
- elif var_spec_msg.type == CompSpecMsg_pb2.TYPE_STRUCT:
- result = {}
- index = 1
- for struct_value in var_spec_msg.struct_value:
- if len(struct_value.name) > 0:
- result[struct_value.
- name] = self.GetPythonDataOfVariableSpecMsg(
- struct_value)
- else:
- result["attribute%d" %
- index] = self.GetPythonDataOfVariableSpecMsg(
- struct_value)
- index += 1
- return result
- elif var_spec_msg.type == CompSpecMsg_pb2.TYPE_UNION:
- result = {}
- index = 1
- for union_value in var_spec_msg.union_value:
- if len(union_value.name) > 0:
- result[union_value.
- name] = self.GetPythonDataOfVariableSpecMsg(
- union_value)
- else:
- result["attribute%d" %
- index] = self.GetPythonDataOfVariableSpecMsg(
- union_value)
- index += 1
- return result
- elif (var_spec_msg.type == CompSpecMsg_pb2.TYPE_VECTOR
- or var_spec_msg.type == CompSpecMsg_pb2.TYPE_ARRAY):
- result = []
- for vector_value in var_spec_msg.vector_value:
- result.append(
- self.GetPythonDataOfVariableSpecMsg(vector_value))
- return result
- elif (var_spec_msg.type == CompSpecMsg_pb2.TYPE_HIDL_INTERFACE
- or var_spec_msg.type == CompSpecMsg_pb2.TYPE_FMQ_SYNC
- or var_spec_msg.type == CompSpecMsg_pb2.TYPE_FMQ_UNSYNC
- or var_spec_msg.type == CompSpecMsg_pb2.TYPE_HIDL_MEMORY
- or var_spec_msg.type == CompSpecMsg_pb2.TYPE_HANDLE):
- logging.debug("var_spec_msg: %s", var_spec_msg)
- return var_spec_msg
-
- raise errors.VtsUnsupportedTypeError(
- "unsupported type %s" % var_spec_msg.type)
-
- def CallApi(self, arg, caller_uid=None):
- """RPC to CALL_API."""
- self.SendCommand(SysMsg_pb2.CALL_API, arg=arg, caller_uid=caller_uid)
- resp = self.RecvResponse()
- resp_code = resp.response_code
- if (resp_code == SysMsg_pb2.SUCCESS):
- result = CompSpecMsg_pb2.FunctionSpecificationMessage()
- if resp.result == "error":
- raise errors.VtsTcpCommunicationError(
- "API call error by the VTS driver.")
- try:
- text_format.Merge(resp.result, result)
- except text_format.ParseError as e:
- logging.exception(e)
- logging.error("Paring error\n%s", resp.result)
- if result.return_type.type == CompSpecMsg_pb2.TYPE_SUBMODULE:
- logging.debug("returned a submodule spec")
- logging.debug("spec: %s", result.return_type_submodule_spec)
- return mirror_object.MirrorObject(
- self, result.return_type_submodule_spec, None)
-
- if result.HasField("return_type"): # For non-HIDL return value
- result_value = result
- else:
- result_value = []
- for return_type_hidl in result.return_type_hidl:
- result_value.append(
- self.GetPythonDataOfVariableSpecMsg(return_type_hidl))
-
- if len(result.raw_coverage_data) > 0:
- return result_value, {"coverage": result.raw_coverage_data}
- else:
- return result_value
-
- logging.error("NOTICE - Likely a crash discovery!")
- logging.error("SysMsg_pb2.SUCCESS is %s", SysMsg_pb2.SUCCESS)
- raise errors.VtsTcpCommunicationError(
- "RPC Error, response code for %s is %s" % (arg, resp_code))
-
- def GetAttribute(self, arg):
- """RPC to VTS_AGENT_COMMAND_GET_ATTRIBUTE."""
- self.SendCommand(SysMsg_pb2.VTS_AGENT_COMMAND_GET_ATTRIBUTE, arg=arg)
- resp = self.RecvResponse()
- resp_code = resp.response_code
- if (resp_code == SysMsg_pb2.SUCCESS):
- result = CompSpecMsg_pb2.FunctionSpecificationMessage()
- if resp.result == "error":
- raise errors.VtsTcpCommunicationError(
- "Get attribute request failed on target.")
- try:
- text_format.Merge(resp.result, result)
- except text_format.ParseError as e:
- logging.exception(e)
- logging.error("Paring error\n%s", resp.result)
- if result.return_type.type == CompSpecMsg_pb2.TYPE_SUBMODULE:
- logging.debug("returned a submodule spec")
- logging.debug("spec: %s", result.return_type_submodule_spec)
- return mirror_object.MirrorObject(
- self, result.return_type_submodule_spec, None)
- elif result.return_type.type == CompSpecMsg_pb2.TYPE_SCALAR:
- return getattr(result.return_type.scalar_value,
- result.return_type.scalar_type)
- return result
- logging.error("NOTICE - Likely a crash discovery!")
- logging.error("SysMsg_pb2.SUCCESS is %s", SysMsg_pb2.SUCCESS)
- raise errors.VtsTcpCommunicationError(
- "RPC Error, response code for %s is %s" % (arg, resp_code))
-
- def ExecuteShellCommand(self, command, no_except=False):
- """RPC to VTS_AGENT_COMMAND_EXECUTE_SHELL_COMMAND.
-
- Args:
- command: string or list or tuple, command to execute on device
- no_except: bool, whether to throw exceptions. If set to True,
- when exception happens, return code will be -1 and
- str(err) will be in stderr. Result will maintain the
- same length as with input command.
-
- Returns:
- dictionary of list, command results that contains stdout,
- stderr, and exit_code.
- """
- try:
- return self.__ExecuteShellCommand(command)
- except Exception as e:
- self.error = e
- if not no_except:
- raise e
- logging.exception(e)
- return {
- const.STDOUT: [""] * len(command),
- const.STDERR: [str(e)] * len(command),
- const.EXIT_CODE: [-1] * len(command)
- }
-
- def __ExecuteShellCommand(self, command):
- """RPC to VTS_AGENT_COMMAND_EXECUTE_SHELL_COMMAND.
-
- Args:
- command: string or list of string, command to execute on device
-
- Returns:
- dictionary of list, command results that contains stdout,
- stderr, and exit_code.
- """
- self.SendCommand(
- SysMsg_pb2.VTS_AGENT_COMMAND_EXECUTE_SHELL_COMMAND,
- shell_command=command)
- resp = self.RecvResponse(retries=2)
- logging.debug("resp for VTS_AGENT_COMMAND_EXECUTE_SHELL_COMMAND: %s",
- resp)
-
- stdout = []
- stderr = []
- exit_code = -1
-
- if not resp:
- logging.error(self.NO_RESPONSE_MSG)
- stderr = [self.NO_RESPONSE_MSG]
- self.error = self.NO_RESPONSE_MSG
- elif resp.response_code != SysMsg_pb2.SUCCESS:
- logging.error(self.FAIL_RESPONSE_MSG)
- stderr = [self.FAIL_RESPONSE_MSG]
- self.error = self.FAIL_RESPONSE_MSG
- else:
- stdout = resp.stdout_str
- stderr = resp.stderr_str
- exit_code = resp.exit_code
- self.error = None
-
- return {
- const.STDOUT: stdout,
- const.STDERR: stderr,
- const.EXIT_CODE: exit_code
- }
-
- def SendFmqRequest(self, message):
- """Sends a command to the FMQ driver and receives the response.
-
- Args:
- message: FmqRequestMessage, message that contains the arguments
- in the FMQ request.
-
- Returns:
- FmqResponseMessage, which includes all possible return value types,
- including int, bool, and data read from the queue.
- """
- self.SendCommand(SysMsg_pb2.VTS_FMQ_COMMAND, fmq_request=message)
- resp = self.RecvResponse()
- logging.debug("resp for VTS_FMQ_COMMAND: %s", resp)
- return self.CheckResourceCommandResponse(
- resp, getattr(resp, "fmq_response", None))
-
- def SendHidlMemoryRequest(self, message):
- """Sends a command to the hidl_memory driver and receives the response.
-
- Args:
- message: HidlMemoryRequestMessage, message that contains the arguments
- in the hidl_memory request.
-
- Returns:
- HidlMemoryResponseMessage, return values needed by the host-side caller.
- """
- self.SendCommand(
- SysMsg_pb2.VTS_HIDL_MEMORY_COMMAND, hidl_memory_request=message)
- resp = self.RecvResponse()
- logging.debug("resp for VTS_HIDL_MEMORY_COMMAND: %s", resp)
- return self.CheckResourceCommandResponse(
- resp, getattr(resp, "hidl_memory_response", None))
-
- def SendHidlHandleRequest(self, message):
- """Sends a command to the hidl_handle driver and receives the response.
-
- Args:
- message: HidlHandleRequestMessage, message that contains the arguments
- in the hidl_handle request.
-
- Returns:
- HidlHandleResponseMessage, return values needed by the host-side caller.
- """
- self.SendCommand(
- SysMsg_pb2.VTS_HIDL_HANDLE_COMMAND, hidl_handle_request=message)
- resp = self.RecvResponse()
- logging.debug("resp for VTS_HIDL_HANDLE_COMMAND: %s", resp)
- return self.CheckResourceCommandResponse(
- resp, getattr(resp, "hidl_handle_response", None))
-
- @staticmethod
- def CheckResourceCommandResponse(agent_response, resource_response):
- """Checks the response from a VTS resource command.
-
- This function checks and logs framework errors such as not receiving
- a response, receving a failure response. Then it checks the response
- for the resource type is not None, and logs error if needed.
-
- Args:
- agent_response: AndroidSystemControlResponseMessage,
- response from agent.
- resource_response: FmqResponseMessage, HidlMemoryResponseMessage,
- or HidlHandleResponseMessage, the response for
- one of fmq, hidl_memory, and hidl_handle.
-
- Returns:
- resource_response that is passed in.
- """
- if agent_response is None:
- logging.error(VtsTcpClient.NO_RESPONSE_MSG)
- elif agent_response.response_code != SysMsg_pb2.SUCCESS:
- logging.error(VtsTcpClient.FAIL_RESPONSE_MSG)
- elif resource_response is None:
- logging.error("TCP client did not receive a response for " +
- "the resource command.")
- return resource_response
-
- def Ping(self):
- """RPC to send a PING request.
-
- Returns:
- True if the agent is alive, False otherwise.
- """
- self.SendCommand(SysMsg_pb2.PING)
- resp = self.RecvResponse()
- logging.debug("resp for PING: %s", resp)
- if resp is not None and resp.response_code == SysMsg_pb2.SUCCESS:
- return True
- return False
-
- def ReadSpecification(self,
- interface_name,
- target_class,
- target_type,
- target_version_major,
- target_version_minor,
- target_package,
- recursive=False):
- """RPC to VTS_AGENT_COMMAND_READ_SPECIFICATION.
-
- Args:
- other args: see SendCommand
- recursive: boolean, set to recursively read the imported
- specification(s) and return the merged one.
- """
- self.SendCommand(
- SysMsg_pb2.VTS_AGENT_COMMAND_READ_SPECIFICATION,
- service_name=interface_name,
- target_class=target_class,
- target_type=target_type,
- target_version_major=target_version_major,
- target_version_minor=target_version_minor,
- target_package=target_package)
- resp = self.RecvResponse(retries=2)
- logging.debug("resp for VTS_AGENT_COMMAND_EXECUTE_READ_INTERFACE: %s",
- resp)
- logging.debug("proto: %s", resp.result)
- result = CompSpecMsg_pb2.ComponentSpecificationMessage()
- if resp.result == "error":
- raise errors.VtsTcpCommunicationError(
- "API call error by the VTS driver.")
- try:
- text_format.Merge(resp.result, result)
- except text_format.ParseError as e:
- logging.exception(e)
- logging.error("Paring error\n%s", resp.result)
-
- if recursive and hasattr(result, "import"):
- for imported_interface in getattr(result, "import"):
- if imported_interface == "android.hidl.base@1.0::types":
- logging.warn("import android.hidl.base@1.0::types skipped")
- continue
- [package, version_str] = imported_interface.split("@")
- [version_major,
- version_minor] = (version_str.split("::")[0]).split(".")
- imported_result = self.ReadSpecification(
- imported_interface.split("::")[1],
- # TODO(yim): derive target_class and
- # target_type from package path or remove them
- msg.component_class
- if target_class is None else target_class,
- msg.component_type if target_type is None else target_type,
- int(version_major),
- int(version_minor),
- package)
- # Merge the attributes from imported interface.
- for attribute in imported_result.attribute:
- imported_attribute = result.attribute.add()
- imported_attribute.CopyFrom(attribute)
-
- return result
-
- def SendCommand(self,
- command_type,
- paths=None,
- file_path=None,
- bits=None,
- target_class=None,
- target_type=None,
- target_version_major=None,
- target_version_minor=None,
- target_package=None,
- target_component_name=None,
- hw_binder_service_name=None,
- is_test_hal=None,
- module_name=None,
- service_name=None,
- callback_port=None,
- driver_type=None,
- shell_command=None,
- caller_uid=None,
- arg=None,
- fmq_request=None,
- hidl_memory_request=None,
- hidl_handle_request=None):
- """Sends a command.
-
- Args:
- command_type: integer, the command type.
- each of the other args are to fill in a field in
- AndroidSystemControlCommandMessage.
- """
- if not self.channel:
- raise errors.VtsTcpCommunicationError(
- "channel is None, unable to send command.")
-
- command_msg = SysMsg_pb2.AndroidSystemControlCommandMessage()
- command_msg.command_type = command_type
- logging.debug("sending a command (type %s)",
- COMMAND_TYPE_NAME[command_type])
- if command_type == 202:
- logging.debug("target API: %s", arg)
-
- if target_class is not None:
- command_msg.target_class = target_class
-
- if target_type is not None:
- command_msg.target_type = target_type
-
- if target_version_major is not None:
- command_msg.target_version_major = target_version_major
-
- if target_version_minor is not None:
- command_msg.target_version_minor = target_version_minor
-
- if target_package is not None:
- command_msg.target_package = target_package
-
- if target_component_name is not None:
- command_msg.target_component_name = target_component_name
-
- if hw_binder_service_name is not None:
- command_msg.hw_binder_service_name = hw_binder_service_name
-
- if is_test_hal is not None:
- command_msg.is_test_hal = is_test_hal
-
- if module_name is not None:
- command_msg.module_name = module_name
-
- if service_name is not None:
- command_msg.service_name = service_name
-
- if driver_type is not None:
- command_msg.driver_type = driver_type
-
- if paths is not None:
- command_msg.paths.extend(paths)
-
- if file_path is not None:
- command_msg.file_path = file_path
-
- if bits is not None:
- command_msg.bits = bits
-
- if callback_port is not None:
- command_msg.callback_port = callback_port
-
- if caller_uid is not None:
- command_msg.driver_caller_uid = caller_uid
-
- if arg is not None:
- command_msg.arg = arg
-
- if shell_command is not None:
- if isinstance(shell_command, (list, tuple)):
- command_msg.shell_command.extend(shell_command)
- else:
- command_msg.shell_command.append(shell_command)
-
- if fmq_request is not None:
- command_msg.fmq_request.CopyFrom(fmq_request)
-
- if hidl_memory_request is not None:
- command_msg.hidl_memory_request.CopyFrom(hidl_memory_request)
-
- if hidl_handle_request is not None:
- command_msg.hidl_handle_request.CopyFrom(hidl_handle_request)
-
- logging.debug("command %s" % command_msg)
- message = command_msg.SerializeToString()
- message_len = len(message)
- logging.debug("sending %d bytes", message_len)
- self.channel.write(str(message_len) + b'\n')
- self.channel.write(message)
- self.channel.flush()
-
- def RecvResponse(self, retries=0):
- """Receives and parses the response, and returns the relevant ResponseMessage.
-
- Args:
- retries: an integer indicating the max number of retries in case of
- session timeout error.
- """
- for index in xrange(1 + retries):
- try:
- if index != 0:
- logging.info("retrying...")
- header = self.channel.readline().strip("\n")
- length = int(header) if header else 0
- logging.debug("resp %d bytes", length)
- data = self.channel.read(length)
- response_msg = SysMsg_pb2.AndroidSystemControlResponseMessage()
- response_msg.ParseFromString(data)
- logging.debug(
- "Response %s", "success"
- if response_msg.response_code == SysMsg_pb2.SUCCESS else
- "fail")
- return response_msg
- except socket.timeout as e:
- logging.exception(e)
- return None
diff --git a/runners/host/tcp_server/__init__.py b/runners/host/tcp_server/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/runners/host/tcp_server/__init__.py
+++ /dev/null
diff --git a/runners/host/tcp_server/callback_server.py b/runners/host/tcp_server/callback_server.py
deleted file mode 100644
index 3da7ef4..0000000
--- a/runners/host/tcp_server/callback_server.py
+++ /dev/null
@@ -1,194 +0,0 @@
-#
-# 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.
-#
-
-import logging
-import socket
-import socketserver
-import threading
-
-from vts.runners.host import errors
-from vts.proto import AndroidSystemControlMessage_pb2 as SysMsg
-from vts.proto import ComponentSpecificationMessage_pb2 as CompSpecMsg
-from vts.utils.python.mirror import pb2py
-
-_functions = dict() # Dictionary to hold function pointers
-
-
-class CallbackServerError(errors.VtsError):
- """Raised when an error occurs in VTS TCP server."""
-
-
-class CallbackRequestHandler(socketserver.StreamRequestHandler):
- """The request handler class for our server."""
-
- def handle(self):
- """Receives requests from clients.
-
- When a callback happens on the target side, a request message is posted
- to the host side and is handled here. The message is parsed and the
- appropriate callback function on the host side is called.
- """
- header = self.rfile.readline().strip()
- try:
- len = int(header)
- except ValueError:
- if header:
- logging.exception("Unable to convert '%s' into an integer, which "
- "is required for reading the next message." %
- header)
- raise
- else:
- logging.error('CallbackRequestHandler received empty message header. Skipping...')
- return
- # Read the request message.
- received_data = self.rfile.read(len)
- logging.debug("Received callback message: %s", received_data)
- request_message = SysMsg.AndroidSystemCallbackRequestMessage()
- request_message.ParseFromString(received_data)
- logging.debug('Handling callback ID: %s', request_message.id)
- response_message = SysMsg.AndroidSystemCallbackResponseMessage()
- # Call the appropriate callback function and construct the response
- # message.
- if request_message.id in _functions:
- callback_args = []
- for arg in request_message.arg:
- callback_args.append(pb2py.Convert(arg))
- args = tuple(callback_args)
- _functions[request_message.id](*args)
- response_message.response_code = SysMsg.SUCCESS
- else:
- logging.error("Callback function ID %s is not registered!",
- request_message.id)
- response_message.response_code = SysMsg.FAIL
-
- # send the response back to client
- message = response_message.SerializeToString()
- # self.request is the TCP socket connected to the client
- self.request.sendall(message)
-
-
-class CallbackServer(object):
- """This class creates TCPServer in separate thread.
-
- Attributes:
- _server: an instance of socketserver.TCPServer.
- _port: this variable maintains the port number used in creating
- the server connection.
- _ip: variable to hold the IP Address of the host.
- _hostname: IP Address to which initial connection is made.
- """
-
- def __init__(self):
- self._server = None
- self._port = 0 # Port 0 means to select an arbitrary unused port
- self._ip = "" # Used to store the IP address for the server
- self._hostname = "localhost" # IP address to which initial connection is made
-
- def RegisterCallback(self, callback_func):
- """Registers a callback function.
-
- Args:
- callback_func: The function to register.
-
- Returns:
- string, Id of the registered callback function.
-
- Raises:
- CallbackServerError is raised if the func_id is already registered.
- """
- if self.GetCallbackId(callback_func):
- raise CallbackServerError("Function is already registered")
- id = 0
- if _functions:
- id = int(max(_functions, key=int)) + 1
- _functions[str(id)] = callback_func
- return str(id)
-
- def UnregisterCallback(self, func_id):
- """Removes a callback function from the registry.
-
- Args:
- func_id: The ID of the callback function to remove.
-
- Raises:
- CallbackServerError is raised if the func_id is not registered.
- """
- try:
- _functions.pop(func_id)
- except KeyError:
- raise CallbackServerError(
- "Can't remove function ID '%s', which is not registered." %
- func_id)
-
- def GetCallbackId(self, callback_func):
- """Get ID of the callback function. Registers a callback function.
-
- Args:
- callback_func: The function to register.
-
- Returns:
- string, Id of the callback function if found, None otherwise.
- """
- # dict _functions is { id : func }
- for id, func in _functions.items():
- if func is callback_func:
- return id
-
- def Start(self, port=0):
- """Starts the server.
-
- Args:
- port: integer, number of the port on which the server listens.
- Default is 0, which means auto-select a port available.
-
- Returns:
- IP Address, port number
-
- Raises:
- CallbackServerError is raised if the server fails to start.
- """
- try:
- self._server = socketserver.TCPServer(
- (self._hostname, port), CallbackRequestHandler)
- self._ip, self._port = self._server.server_address
-
- # Start a thread with the server.
- # Each request will be handled in a child thread.
- server_thread = threading.Thread(target=self._server.serve_forever)
- server_thread.daemon = True
- server_thread.start()
- logging.debug('TcpServer %s started (%s:%s)', server_thread.name,
- self._ip, self._port)
- return self._ip, self._port
- except (RuntimeError, IOError, socket.error) as e:
- logging.exception(e)
- raise CallbackServerError(
- 'Failed to start CallbackServer on (%s:%s).' %
- (self._hostname, port))
-
- def Stop(self):
- """Stops the server.
- """
- self._server.shutdown()
- self._server.server_close()
-
- @property
- def ip(self):
- return self._ip
-
- @property
- def port(self):
- return self._port
diff --git a/runners/host/tcp_server/callback_server_test.py b/runners/host/tcp_server/callback_server_test.py
deleted file mode 100644
index ed1ee38..0000000
--- a/runners/host/tcp_server/callback_server_test.py
+++ /dev/null
@@ -1,226 +0,0 @@
-#
-# 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.
-#
-
-import socket
-import unittest
-import logging
-import errno
-from socket import error as socket_error
-
-from vts.runners.host import errors
-from vts.proto import AndroidSystemControlMessage_pb2 as SysMsg_pb2
-from vts.runners.host.tcp_server import callback_server
-
-HOST, PORT = "localhost", 0
-ERROR_PORT = 380 # port at which we test the error case.
-
-
-class TestMethods(unittest.TestCase):
- """This class defines unit test methods.
-
- The common scenarios are when we wish to test the whether we are able to
- receive the expected data from the server; and whether we receive the
- correct error when we try to connect to server from a wrong port.
-
- Attributes:
- _callback_server: an instance of CallbackServer that is used to
- start and stop the TCP server.
- _counter: This is used to keep track of number of calls made to the
- callback function.
- """
- _callback_server = None
- _counter = 0
-
- def setUp(self):
- """This function initiates starting the server in CallbackServer."""
- self._callback_server = callback_server.CallbackServer()
- self._callback_server.Start()
-
- def tearDown(self):
- """To initiate shutdown of the server.
-
- This function calls the callback_server.CallbackServer.Stop which
- shutdowns the server.
- """
- self._callback_server.Stop()
-
- def DoErrorCase(self):
- """Unit test for Error case.
-
- This function tests the cases that throw exception.
- e.g sending requests to port 25.
-
- Raises:
- ConnectionRefusedError: ConnectionRefusedError occurred in
- test_ErrorCase().
- """
- host = self._callback_server.ip
-
- # Create a socket (SOCK_STREAM means a TCP socket)
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-
- try:
- # Connect to server; this should result in Connection refused error
- sock.connect((host, ERROR_PORT))
- except socket_error as e:
- # We are comparing the error number of the error we expect and
- # the error that we get.
- # Test fails if ConnectionRefusedError is not raised at this step.
- if e.errno == errno.ECONNREFUSED:
- raise errors.ConnectionRefusedError # Test is a success here
- else:
- raise e # Test fails, since ConnectionRefusedError was expected
- finally:
- sock.close()
-
- def ConnectToServer(self, func_id):
- """This function creates a connection to TCP server and sends/receives
- message.
-
- Args:
- func_id: This is the unique key corresponding to a function and
- also the id field of the request_message that we send to the
- server.
-
- Returns:
- response_message: The object that the TCP host returns.
-
- Raises:
- TcpServerConnectionError: Exception occurred while stopping server.
- """
- # This object is sent to the TCP host
- request_message = SysMsg_pb2.AndroidSystemCallbackRequestMessage()
- request_message.id = func_id
-
- # The response in string format that we receive from host
- received_message = ""
-
- # The final object that this function returns
- response_message = SysMsg_pb2.AndroidSystemCallbackResponseMessage()
-
- # Create a socket (SOCK_STREAM means a TCP socket)
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- host = self._callback_server.ip
- port = self._callback_server.port
- logging.debug('Sending Request to host %s using port %s', host, port)
-
- try:
- # Connect to server and send request_message
- sock.connect((host, port))
-
- message = request_message.SerializeToString()
- sock.sendall(str(len(message)) + "\n" + message)
- logging.debug("Sent: %s", message)
-
- # Receive request_message from the server and shut down
- received_message = sock.recv(1024)
- response_message.ParseFromString(received_message)
- logging.debug('Received: %s', received_message)
- except socket_error as e:
- logging.error(e)
- raise errors.TcpServerConnectionError('Exception occurred.')
- finally:
- sock.close()
-
- return response_message
-
- def testDoErrorCase(self):
- """Unit test for error cases."""
- with self.assertRaises(errors.ConnectionRefusedError):
- self.DoErrorCase()
-
- def testCallback(self):
- """Tests two callback use cases."""
- self.TestNormalCase()
- self.TestDoRegisterCallback()
-
- def TestNormalCase(self):
- """Tests the normal request to TCPServer.
-
- This function sends the request to the Tcp server where the request
- should be a success.
-
- This function also checks the register callback feature by ensuring that
- callback_func() is called and the value of the global counter is
- increased by one.
- """
- def callback_func():
- self._counter += 1
-
- # Function should be registered with RegisterCallback
- func_id = self._callback_server.RegisterCallback(callback_func)
- self.assertEqual(func_id, '0')
-
- # Capture the previous value of global counter
- prev_value = self._counter
-
- # Connect to server
- response_message = self.ConnectToServer(func_id)
-
- # Confirm whether the callback_func() was called thereby increasing
- # value of global counter by 1
- self.assertEqual(self._counter, prev_value + 1)
-
- # Also confirm if query resulted in a success
- self.assertEqual(response_message.response_code, SysMsg_pb2.SUCCESS)
-
- def TestDoRegisterCallback(self):
- """Checks the register callback functionality of the Server.
-
- This function checks whether the value of global counter remains same
- if function is not registered. It also checks whether it's incremented
- by 1 when the function is registered.
- """
- def callback_func():
- self._counter += 1
-
- # Capture the previous value of global counter
- prev_value = self._counter
-
- # Function should be registered with RegisterCallback
- func_id = self._callback_server.RegisterCallback(callback_func)
- found_func_id = self._callback_server.GetCallbackId(callback_func)
- self.assertEqual(func_id, found_func_id)
-
- # Connect to server
- response_message = self.ConnectToServer(func_id)
-
- # Confirm whether the callback_func() was not called.
- self.assertEqual(self._counter, prev_value + 1)
-
- # also confirm the error message
- self.assertEqual(response_message.response_code, SysMsg_pb2.SUCCESS)
-
- # Now unregister the function and check again
- # Function should be unregistered with UnegisterCallback
- # and the key should also be present
- self._callback_server.UnregisterCallback(func_id)
-
- # Capture the previous value of global counter
- prev_value = self._counter
-
- # Connect to server
- response_message = self.ConnectToServer(func_id)
-
- # Confirm whether the callback_func() was not called.
- self.assertEqual(self._counter, prev_value)
-
- # also confirm the error message
- self.assertEqual(response_message.response_code, SysMsg_pb2.FAIL)
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/runners/host/test_runner.py b/runners/host/test_runner.py
deleted file mode 100644
index cb7b62f..0000000
--- a/runners/host/test_runner.py
+++ /dev/null
@@ -1,486 +0,0 @@
-#
-# 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.
-#
-
-from future import standard_library
-standard_library.install_aliases()
-
-import copy
-import importlib
-import inspect
-import logging
-import os
-import pkgutil
-import signal
-import sys
-import threading
-
-from vts.runners.host import base_test
-from vts.runners.host import config_parser
-from vts.runners.host import keys
-from vts.runners.host import logger
-from vts.runners.host import records
-from vts.runners.host import signals
-from vts.runners.host import utils
-from vts.utils.python.common import timeout_utils
-from vts.utils.python.instrumentation import test_framework_instrumentation as tfi
-
-
-def main():
- """Execute the test class in a test module.
-
- This is to be used in a test script's main so the script can be executed
- directly. It will discover all the classes that inherit from BaseTestClass
- and excute them. all the test results will be aggregated into one.
-
- A VTS host-driven test case has three args:
- 1st arg: the path of a test case config file.
- 2nd arg: the serial ID of a target device (device config).
- 3rd arg: the path of a test case data dir.
-
- Returns:
- The TestResult object that holds the results of the test run.
- """
- event = tfi.Begin('Test runner main method')
- test_classes = []
- main_module_members = sys.modules["__main__"]
- for _, module_member in main_module_members.__dict__.items():
- if inspect.isclass(module_member):
- if issubclass(module_member, base_test.BaseTestClass):
- test_classes.append(module_member)
- # TODO(angli): Need to handle the case where more than one test class is in
- # a test script. The challenge is to handle multiple configs and how to do
- # default config in this case.
- if len(test_classes) != 1:
- logging.error("Expected 1 test class per file, found %s (%s).",
- len(test_classes), test_classes)
- sys.exit(1)
- test_result = runTestClass(test_classes[0])
- event.End()
- tfi.CompileResults()
- return test_result
-
-
-def runTestClass(test_class):
- """Execute one test class.
-
- This will create a TestRunner, execute one test run with one test class.
-
- Args:
- test_class: The test class to instantiate and execute.
-
- Returns:
- The TestResult object that holds the results of the test run.
- """
- test_cls_name = test_class.__name__
- if len(sys.argv) < 2:
- logging.warning("Missing a configuration file. Using the default.")
- test_configs = [config_parser.GetDefaultConfig(test_cls_name)]
- else:
- try:
- config_path = sys.argv[1]
- baseline_config = config_parser.GetDefaultConfig(test_cls_name)
- baseline_config[keys.ConfigKeys.KEY_TESTBED] = [
- baseline_config[keys.ConfigKeys.KEY_TESTBED]
- ]
- test_configs = config_parser.load_test_config_file(
- config_path, baseline_config=baseline_config)
- except IndexError:
- logging.error("No valid config file found.")
- sys.exit(1)
- except Exception as e:
- logging.error("Unexpected exception")
- logging.exception(e)
-
- test_identifiers = [(test_cls_name, None)]
-
- for config in test_configs:
- def watchStdin():
- while True:
- line = sys.stdin.readline()
- if not line:
- break
- utils.stop_current_process(base_test.TIMEOUT_SECS_TEARDOWN_CLASS)
-
- watcher_thread = threading.Thread(target=watchStdin, name="watchStdin")
- watcher_thread.daemon = True
- watcher_thread.start()
-
- tr = TestRunner(config, test_identifiers)
- tr.parseTestConfig(config)
- try:
- tr.runTestClass(test_class, None)
- except (signals.TestAbortAll, KeyboardInterrupt) as e:
- logging.error("Abort all test")
- except Exception as e:
- logging.error("Unexpected exception")
- logging.exception(e)
- finally:
- tr.stop()
- return tr.results
-
-
-class TestRunner(object):
- """The class that instantiates test classes, executes test cases, and
- report results.
-
- Attributes:
- test_run_info: A dictionary containing the information needed by
- test classes for this test run, including params,
- controllers, and other objects. All of these will
- be passed to test classes.
- test_configs: A dictionary that is the original test configuration
- passed in by user.
- id: A string that is the unique identifier of this test run.
- log_path: A string representing the path of the dir under which
- all logs from this test run should be written.
- controller_registry: A dictionary that holds the controller
- objects used in a test run.
- controller_destructors: A dictionary that holds the controller
- distructors. Keys are controllers' names.
- run_list: A list of tuples specifying what tests to run.
- results: The test result object used to record the results of
- this test run.
- running: A boolean signifies whether this test run is ongoing or
- not.
- test_cls_instances: list of test class instances that were executed
- or scheduled to be executed.
- log_severity: string, log severity level for the test logger.
- Currently, this parameter only affects how logs are displayed
- to the console, and is not recommended to be used.
- """
-
- def __init__(self, test_configs, run_list):
- self.test_run_info = {}
- self.test_run_info[keys.ConfigKeys.IKEY_DATA_FILE_PATH] = getattr(
- test_configs, keys.ConfigKeys.IKEY_DATA_FILE_PATH, "./")
- self.test_configs = test_configs
- self.testbed_configs = self.test_configs[keys.ConfigKeys.KEY_TESTBED]
- self.testbed_name = self.testbed_configs[
- keys.ConfigKeys.KEY_TESTBED_NAME]
- start_time = logger.getLogFileTimestamp()
- self.id = "{}@{}".format(self.testbed_name, start_time)
- # log_path should be set before parsing configs.
- l_path = os.path.join(self.test_configs[keys.ConfigKeys.KEY_LOG_PATH],
- self.testbed_name, start_time)
- self.log_path = os.path.abspath(l_path)
- self.log_severity = self.test_configs.get(
- keys.ConfigKeys.KEY_LOG_SEVERITY, "INFO").upper()
- logger.setupTestLogger(
- self.log_path,
- self.testbed_name,
- filename="test_run_details.txt",
- log_severity=self.log_severity)
- self.controller_registry = {}
- self.controller_destructors = {}
- self.run_list = run_list
- self.results = records.TestResult()
- self.running = False
- self.test_cls_instances = []
-
- def __enter__(self):
- return self
-
- def __exit__(self, *args):
- self.stop()
-
- def importTestModules(self, test_paths):
- """Imports test classes from test scripts.
-
- 1. Locate all .py files under test paths.
- 2. Import the .py files as modules.
- 3. Find the module members that are test classes.
- 4. Categorize the test classes by name.
-
- Args:
- test_paths: A list of directory paths where the test files reside.
-
- Returns:
- A dictionary where keys are test class name strings, values are
- actual test classes that can be instantiated.
- """
-
- def is_testfile_name(name, ext):
- if ext == ".py":
- if name.endswith("Test") or name.endswith("_test"):
- return True
- return False
-
- file_list = utils.find_files(test_paths, is_testfile_name)
- test_classes = {}
- for path, name, _ in file_list:
- sys.path.append(path)
- try:
- module = importlib.import_module(name)
- except:
- for test_cls_name, _ in self.run_list:
- alt_name = name.replace('_', '').lower()
- alt_cls_name = test_cls_name.lower()
- # Only block if a test class on the run list causes an
- # import error. We need to check against both naming
- # conventions: AaaBbb and aaa_bbb.
- if name == test_cls_name or alt_name == alt_cls_name:
- msg = ("Encountered error importing test class %s, "
- "abort.") % test_cls_name
- # This exception is logged here to help with debugging
- # under py2, because "raise X from Y" syntax is only
- # supported under py3.
- logging.exception(msg)
- raise USERError(msg)
- continue
- for member_name in dir(module):
- if not member_name.startswith("__"):
- if member_name.endswith("Test"):
- test_class = getattr(module, member_name)
- if inspect.isclass(test_class):
- test_classes[member_name] = test_class
- return test_classes
-
- def verifyControllerModule(self, module):
- """Verifies a module object follows the required interface for
- controllers.
-
- Args:
- module: An object that is a controller module. This is usually
- imported with import statements or loaded by importlib.
-
- Raises:
- ControllerError is raised if the module does not match the vts.runners.host
- controller interface, or one of the required members is null.
- """
- required_attributes = ("create", "destroy",
- "VTS_CONTROLLER_CONFIG_NAME")
- for attr in required_attributes:
- if not hasattr(module, attr):
- raise signals.ControllerError(
- ("Module %s missing required "
- "controller module attribute %s.") % (module.__name__,
- attr))
- if not getattr(module, attr):
- raise signals.ControllerError(
- ("Controller interface %s in %s "
- "cannot be null.") % (attr, module.__name__))
-
- def registerController(self, module, start_services=True):
- """Registers a controller module for a test run.
-
- This declares a controller dependency of this test class. If the target
- module exists and matches the controller interface, the controller
- module will be instantiated with corresponding configs in the test
- config file. The module should be imported first.
-
- Params:
- module: A module that follows the controller module interface.
- start_services: boolean, controls whether services (e.g VTS agent)
- are started on the target.
-
- Returns:
- A list of controller objects instantiated from controller_module.
-
- Raises:
- ControllerError is raised if no corresponding config can be found,
- or if the controller module has already been registered.
- """
- event = tfi.Begin('test_runner registerController',
- tfi.categories.FRAMEWORK_SETUP)
- logging.debug("cwd: %s", os.getcwd())
- logging.info("adb devices: %s", module.list_adb_devices())
- self.verifyControllerModule(module)
- module_ref_name = module.__name__.split('.')[-1]
- if module_ref_name in self.controller_registry:
- event.End()
- raise signals.ControllerError(
- ("Controller module %s has already "
- "been registered. It can not be "
- "registered again.") % module_ref_name)
- # Create controller objects.
- create = module.create
- module_config_name = module.VTS_CONTROLLER_CONFIG_NAME
- if module_config_name not in self.testbed_configs:
- msg = "No corresponding config found for %s" % module_config_name
- event.Remove(msg)
- raise signals.ControllerError(msg)
- try:
- # Make a deep copy of the config to pass to the controller module,
- # in case the controller module modifies the config internally.
- original_config = self.testbed_configs[module_config_name]
- controller_config = copy.deepcopy(original_config)
- # Add log_severity config to device controller config.
- if isinstance(controller_config, list):
- for config in controller_config:
- if isinstance(config, dict):
- config["log_severity"] = self.log_severity
- logging.debug("controller_config: %s", controller_config)
- if "use_vts_agent" not in self.testbed_configs:
- objects = create(controller_config, start_services)
- else:
- objects = create(controller_config,
- self.testbed_configs["use_vts_agent"])
- except:
- msg = "Failed to initialize objects for controller %s, abort!" % module_config_name
- event.Remove(msg)
- logging.error(msg)
- raise
- if not isinstance(objects, list):
- msg = "Controller module %s did not return a list of objects, abort." % module_ref_name
- event.Remove(msg)
- raise signals.ControllerError(msg)
-
- self.controller_registry[module_ref_name] = objects
- logging.debug("Found %d objects for controller %s",
- len(objects), module_config_name)
- destroy_func = module.destroy
- self.controller_destructors[module_ref_name] = destroy_func
- event.End()
- return objects
-
- @timeout_utils.timeout(base_test.TIMEOUT_SECS_TEARDOWN_CLASS,
- message='unregisterControllers method timed out.',
- no_exception=True)
- def unregisterControllers(self):
- """Destroy controller objects and clear internal registry.
-
- This will be called at the end of each TestRunner.run call.
- """
- event = tfi.Begin('test_runner unregisterControllers',
- tfi.categories.FRAMEWORK_TEARDOWN)
- for name, destroy in self.controller_destructors.items():
- try:
- logging.debug("Destroying %s.", name)
- dut = self.controller_destructors[name]
- destroy(self.controller_registry[name])
- except:
- logging.exception("Exception occurred destroying %s.", name)
- self.controller_registry = {}
- self.controller_destructors = {}
- event.End()
-
- def parseTestConfig(self, test_configs):
- """Parses the test configuration and unpacks objects and parameters
- into a dictionary to be passed to test classes.
-
- Args:
- test_configs: A json object representing the test configurations.
- """
- self.test_run_info[
- keys.ConfigKeys.IKEY_TESTBED_NAME] = self.testbed_name
- # Unpack other params.
- self.test_run_info["registerController"] = self.registerController
- self.test_run_info[keys.ConfigKeys.IKEY_LOG_PATH] = self.log_path
- user_param_pairs = []
- for item in test_configs.items():
- if item[0] not in keys.ConfigKeys.RESERVED_KEYS:
- user_param_pairs.append(item)
- self.test_run_info[keys.ConfigKeys.IKEY_USER_PARAM] = copy.deepcopy(
- dict(user_param_pairs))
-
- def runTestClass(self, test_cls, test_cases=None):
- """Instantiates and executes a test class.
-
- If test_cases is None, the test cases listed by self.tests will be
- executed instead. If self.tests is empty as well, no test case in this
- test class will be executed.
-
- Args:
- test_cls: The test class to be instantiated and executed.
- test_cases: List of test case names to execute within the class.
-
- Returns:
- A tuple, with the number of cases passed at index 0, and the total
- number of test cases at index 1.
- """
- self.running = True
- with test_cls(self.test_run_info) as test_cls_instance:
- try:
- if test_cls_instance not in self.test_cls_instances:
- self.test_cls_instances.append(test_cls_instance)
- cls_result = test_cls_instance.run(test_cases)
- finally:
- self.unregisterControllers()
-
- def run(self):
- """Executes test cases.
-
- This will instantiate controller and test classes, and execute test
- classes. This can be called multiple times to repeatly execute the
- requested test cases.
-
- A call to TestRunner.stop should eventually happen to conclude the life
- cycle of a TestRunner.
-
- Args:
- test_classes: A dictionary where the key is test class name, and
- the values are actual test classes.
- """
- if not self.running:
- self.running = True
- # Initialize controller objects and pack appropriate objects/params
- # to be passed to test class.
- self.parseTestConfig(self.test_configs)
- t_configs = self.test_configs[keys.ConfigKeys.KEY_TEST_PATHS]
- test_classes = self.importTestModules(t_configs)
- logging.debug("Executing run list %s.", self.run_list)
- try:
- for test_cls_name, test_case_names in self.run_list:
- if not self.running:
- break
- if test_case_names:
- logging.debug("Executing test cases %s in test class %s.",
- test_case_names, test_cls_name)
- else:
- logging.debug("Executing test class %s", test_cls_name)
- try:
- test_cls = test_classes[test_cls_name]
- except KeyError:
- raise USERError(
- ("Unable to locate class %s in any of the test "
- "paths specified.") % test_cls_name)
- try:
- self.runTestClass(test_cls, test_case_names)
- except signals.TestAbortAll as e:
- logging.warning(
- ("Abort all subsequent test classes. Reason: "
- "%s"), e)
- raise
- except Exception as e:
- logging.error("Unexpected exception")
- logging.exception(e)
- finally:
- self.unregisterControllers()
-
- def stop(self):
- """Releases resources from test run. Should always be called after
- TestRunner.run finishes.
-
- This function concludes a test run and writes out a test report.
- """
- if self.running:
-
- for test_cls_instance in self.test_cls_instances:
- self.results += test_cls_instance.results
-
- msg = "\nSummary for test run %s: %s\n" % (self.id,
- self.results.summary())
- self._writeResultsJsonString()
- logging.info(msg.strip())
- logger.killTestLogger(logging.getLogger())
- self.running = False
-
- def _writeResultsJsonString(self):
- """Writes out a json file with the test result info for easy parsing.
- """
- path = os.path.join(self.log_path, "test_run_summary.json")
- with open(path, 'w') as f:
- f.write(self.results.jsonString())
diff --git a/runners/host/utils.py b/runners/host/utils.py
deleted file mode 100755
index bd6b0a1..0000000
--- a/runners/host/utils.py
+++ /dev/null
@@ -1,736 +0,0 @@
-#
-# 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.
-#
-
-import base64
-import concurrent.futures
-import datetime
-import functools
-import json
-import logging
-import os
-import random
-import re
-import signal
-import string
-import subprocess
-import time
-import traceback
-
-try:
- # TODO: remove when we stop supporting Python 2
- import thread
-except ImportError as e:
- import _thread as thread
-
-# The limit for maximum file name length and path length is set to as low as
-# 140 to accomodate gtest behavior when running as a 32bit process.
-MAX_FILENAME_LEN = 140
-MAX_PATH_LEN = 140
-
-
-class VTSUtilsError(Exception):
- """Generic error raised for exceptions in VTS utils."""
-
-
-class NexusModelNames:
- # TODO(angli): This will be fixed later by angli.
- ONE = 'sprout'
- N5 = 'hammerhead'
- N5v2 = 'bullhead'
- N6 = 'shamu'
- N6v2 = 'angler'
-
-
-ascii_letters_and_digits = string.ascii_letters + string.digits
-valid_filename_chars = "-_." + ascii_letters_and_digits
-
-models = ("sprout", "occam", "hammerhead", "bullhead", "razor", "razorg",
- "shamu", "angler", "volantis", "volantisg", "mantaray", "fugu",
- "ryu")
-
-manufacture_name_to_model = {
- "flo": "razor",
- "flo_lte": "razorg",
- "flounder": "volantis",
- "flounder_lte": "volantisg",
- "dragon": "ryu"
-}
-
-GMT_to_olson = {
- "GMT-9": "America/Anchorage",
- "GMT-8": "US/Pacific",
- "GMT-7": "US/Mountain",
- "GMT-6": "US/Central",
- "GMT-5": "US/Eastern",
- "GMT-4": "America/Barbados",
- "GMT-3": "America/Buenos_Aires",
- "GMT-2": "Atlantic/South_Georgia",
- "GMT-1": "Atlantic/Azores",
- "GMT+0": "Africa/Casablanca",
- "GMT+1": "Europe/Amsterdam",
- "GMT+2": "Europe/Athens",
- "GMT+3": "Europe/Moscow",
- "GMT+4": "Asia/Baku",
- "GMT+5": "Asia/Oral",
- "GMT+6": "Asia/Almaty",
- "GMT+7": "Asia/Bangkok",
- "GMT+8": "Asia/Hong_Kong",
- "GMT+9": "Asia/Tokyo",
- "GMT+10": "Pacific/Guam",
- "GMT+11": "Pacific/Noumea",
- "GMT+12": "Pacific/Fiji",
- "GMT+13": "Pacific/Tongatapu",
- "GMT-11": "Pacific/Midway",
- "GMT-10": "Pacific/Honolulu"
-}
-
-
-def abs_path(path):
- """Resolve the '.' and '~' in a path to get the absolute path.
-
- Args:
- path: The path to expand.
-
- Returns:
- The absolute path of the input path.
- """
- return os.path.abspath(os.path.expanduser(path))
-
-
-def create_dir(path):
- """Creates a directory if it does not exist already.
-
- Args:
- path: The path of the directory to create.
- """
- full_path = abs_path(path)
- if not os.path.exists(full_path):
- os.makedirs(full_path)
-
-
-def get_current_epoch_time():
- """Current epoch time in milliseconds.
-
- Returns:
- An integer representing the current epoch time in milliseconds.
- """
- return int(round(time.time() * 1000))
-
-
-def get_current_human_time():
- """Returns the current time in human readable format.
-
- Returns:
- The current time stamp in Month-Day-Year Hour:Min:Sec format.
- """
- return time.strftime("%m-%d-%Y %H:%M:%S ")
-
-
-def epoch_to_human_time(epoch_time):
- """Converts an epoch timestamp to human readable time.
-
- This essentially converts an output of get_current_epoch_time to an output
- of get_current_human_time
-
- Args:
- epoch_time: An integer representing an epoch timestamp in milliseconds.
-
- Returns:
- A time string representing the input time.
- None if input param is invalid.
- """
- if isinstance(epoch_time, int):
- try:
- d = datetime.datetime.fromtimestamp(epoch_time / 1000)
- return d.strftime("%m-%d-%Y %H:%M:%S ")
- except ValueError:
- return None
-
-
-def get_timezone_olson_id():
- """Return the Olson ID of the local (non-DST) timezone.
-
- Returns:
- A string representing one of the Olson IDs of the local (non-DST)
- timezone.
- """
- tzoffset = int(time.timezone / 3600)
- gmt = None
- if tzoffset <= 0:
- gmt = "GMT+{}".format(-tzoffset)
- else:
- gmt = "GMT-{}".format(tzoffset)
- return GMT_to_olson[gmt]
-
-
-def find_files(paths, file_predicate):
- """Locate files whose names and extensions match the given predicate in
- the specified directories.
-
- Args:
- paths: A list of directory paths where to find the files.
- file_predicate: A function that returns True if the file name and
- extension are desired.
-
- Returns:
- A list of files that match the predicate.
- """
- file_list = []
- for path in paths:
- p = abs_path(path)
- for dirPath, subdirList, fileList in os.walk(p):
- for fname in fileList:
- name, ext = os.path.splitext(fname)
- if file_predicate(name, ext):
- file_list.append((dirPath, name, ext))
- return file_list
-
-
-def iterate_files(dir_path):
- """A generator yielding regular files in a directory recursively.
-
- Args:
- dir_path: A string representing the path to search.
-
- Yields:
- A tuple of strings (directory, file). The directory containing
- the file and the file name.
- """
- for root_dir, dir_names, file_names in os.walk(dir_path):
- for file_name in file_names:
- yield root_dir, file_name
-
-
-def load_config(file_full_path):
- """Loads a JSON config file.
-
- Returns:
- A JSON object.
- """
- if not os.path.isfile(file_full_path):
- logging.warning('cwd: %s', os.getcwd())
- pypath = os.environ['PYTHONPATH']
- if pypath:
- for base_path in pypath.split(':'):
- logging.debug('checking base_path %s', base_path)
- new_path = os.path.join(base_path, file_full_path)
- if os.path.isfile(new_path):
- logging.debug('new_path %s found', new_path)
- file_full_path = new_path
- break
-
- with open(file_full_path, 'r') as f:
- conf = json.load(f)
- return conf
-
-
-def load_file_to_base64_str(f_path):
- """Loads the content of a file into a base64 string.
-
- Args:
- f_path: full path to the file including the file name.
-
- Returns:
- A base64 string representing the content of the file in utf-8 encoding.
- """
- path = abs_path(f_path)
- with open(path, 'rb') as f:
- f_bytes = f.read()
- base64_str = base64.b64encode(f_bytes).decode("utf-8")
- return base64_str
-
-
-def find_field(item_list, cond, comparator, target_field):
- """Finds the value of a field in a dict object that satisfies certain
- conditions.
-
- Args:
- item_list: A list of dict objects.
- cond: A param that defines the condition.
- comparator: A function that checks if an dict satisfies the condition.
- target_field: Name of the field whose value to be returned if an item
- satisfies the condition.
-
- Returns:
- Target value or None if no item satisfies the condition.
- """
- for item in item_list:
- if comparator(item, cond) and target_field in item:
- return item[target_field]
- return None
-
-
-def rand_ascii_str(length):
- """Generates a random string of specified length, composed of ascii letters
- and digits.
-
- Args:
- length: The number of characters in the string.
-
- Returns:
- The random string generated.
- """
- letters = [random.choice(ascii_letters_and_digits) for i in range(length)]
- return ''.join(letters)
-
-
-# Thead/Process related functions.
-def concurrent_exec(func, param_list):
- """Executes a function with different parameters pseudo-concurrently.
-
- This is basically a map function. Each element (should be an iterable) in
- the param_list is unpacked and passed into the function. Due to Python's
- GIL, there's no true concurrency. This is suited for IO-bound tasks.
-
- Args:
- func: The function that parforms a task.
- param_list: A list of iterables, each being a set of params to be
- passed into the function.
-
- Returns:
- A list of return values from each function execution. If an execution
- caused an exception, the exception object will be the corresponding
- result.
- """
- with concurrent.futures.ThreadPoolExecutor(max_workers=30) as executor:
- # Start the load operations and mark each future with its params
- future_to_params = {executor.submit(func, *p): p for p in param_list}
- return_vals = []
- for future in concurrent.futures.as_completed(future_to_params):
- params = future_to_params[future]
- try:
- return_vals.append(future.result())
- except Exception as exc:
- print("{} generated an exception: {}".format(
- params, traceback.format_exc()))
- return_vals.append(exc)
- return return_vals
-
-
-def exe_cmd(*cmds):
- """Executes commands in a new shell.
-
- Args:
- cmds: A sequence of commands and arguments.
-
- Returns:
- The output of the command run.
-
- Raises:
- OSError is raised if an error occurred during the command execution.
- """
- cmd = ' '.join(cmds)
- proc = subprocess.Popen(
- cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
- (out, err) = proc.communicate()
- if not err:
- return out
- raise OSError(err)
-
-
-def _assert_subprocess_running(proc):
- """Checks if a subprocess has terminated on its own.
-
- Args:
- proc: A subprocess returned by subprocess.Popen.
-
- Raises:
- VTSUtilsError is raised if the subprocess has stopped.
- """
- ret = proc.poll()
- if ret is not None:
- out, err = proc.communicate()
- raise VTSUtilsError("Process %d has terminated. ret: %d, stderr: %s,"
- " stdout: %s" % (proc.pid, ret, err, out))
-
-
-def is_on_windows():
- """Checks whether the OS is Windows.
-
- Returns:
- A boolean representing whether the OS is Windows.
- """
- return os.name == "nt"
-
-
-def stop_current_process(terminate_timeout):
- """Sends KeyboardInterrupt to main thread and then terminates process.
-
- The daemon thread calls this function when timeout or user interrupt.
-
- Args:
- terminate_timeout: A float, the interval in seconds between interrupt
- and termination.
- """
- logging.error("Interrupt main thread.")
- if not is_on_windows():
- # Default SIGINT handler sends KeyboardInterrupt to main thread
- # and unblocks it.
- os.kill(os.getpid(), signal.SIGINT)
- else:
- # On Windows, raising CTRL_C_EVENT, which is received as
- # SIGINT, has no effect on non-console process.
- # interrupt_main() behaves like SIGINT but does not unblock
- # main thread immediately.
- thread.interrupt_main()
-
- time.sleep(terminate_timeout)
- logging.error("Terminate current process.")
- # Send SIGTERM on Linux. Call terminateProcess() on Windows.
- os.kill(os.getpid(), signal.SIGTERM)
-
-
-def kill_process_group(proc, signal_no=signal.SIGTERM):
- """Sends signal to a process group.
-
- Logs when there is an OSError or PermissionError. The latter one only
- happens on Mac.
-
- On Windows, SIGABRT, SIGINT, and SIGTERM are replaced with CTRL_BREAK_EVENT
- so as to kill every subprocess in the group.
-
- Args:
- proc: The Popen object whose pid is the group id.
- signal_no: The signal sent to the subprocess group.
- """
- pid = proc.pid
- try:
- if not is_on_windows():
- os.killpg(pid, signal_no)
- else:
- if signal_no in [signal.SIGABRT,
- signal.SIGINT,
- signal.SIGTERM]:
- windows_signal_no = signal.CTRL_BREAK_EVENT
- else:
- windows_signal_no = signal_no
- os.kill(pid, windows_signal_no)
- except (OSError, PermissionError) as e:
- logging.exception("Cannot send signal %s to process group %d: %s",
- signal_no, pid, str(e))
-
-
-def start_standing_subprocess(cmd, check_health_delay=0):
- """Starts a long-running subprocess.
-
- This is not a blocking call and the subprocess started by it should be
- explicitly terminated with stop_standing_subprocess.
-
- For short-running commands, you should use exe_cmd, which blocks.
-
- You can specify a health check after the subprocess is started to make sure
- it did not stop prematurely.
-
- Args:
- cmd: string, the command to start the subprocess with.
- check_health_delay: float, the number of seconds to wait after the
- subprocess starts to check its health. Default is 0,
- which means no check.
-
- Returns:
- The subprocess that got started.
- """
- if not is_on_windows():
- proc = subprocess.Popen(
- cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- shell=True,
- preexec_fn=os.setpgrp)
- else:
- proc = subprocess.Popen(
- cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- shell=True,
- creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
- logging.debug("Start standing subprocess with cmd: %s", cmd)
- if check_health_delay > 0:
- time.sleep(check_health_delay)
- _assert_subprocess_running(proc)
- return proc
-
-
-def stop_standing_subprocess(proc, signal_no=signal.SIGTERM):
- """Stops a subprocess started by start_standing_subprocess.
-
- Before killing the process, we check if the process is running, if it has
- terminated, VTSUtilsError is raised.
-
- Args:
- proc: Subprocess to terminate.
- signal_no: The signal sent to the subprocess group.
- """
- logging.debug("Stop standing subprocess %d", proc.pid)
- _assert_subprocess_running(proc)
- kill_process_group(proc, signal_no)
-
-
-def wait_for_standing_subprocess(proc, timeout=None):
- """Waits for a subprocess started by start_standing_subprocess to finish
- or times out.
-
- Propagates the exception raised by the subprocess.wait(.) function.
- The subprocess.TimeoutExpired exception is raised if the process timed-out
- rather then terminating.
-
- If no exception is raised: the subprocess terminated on its own. No need
- to call stop_standing_subprocess() to kill it.
-
- If an exception is raised: the subprocess is still alive - it did not
- terminate. Either call stop_standing_subprocess() to kill it, or call
- wait_for_standing_subprocess() to keep waiting for it to terminate on its
- own.
-
- Args:
- p: Subprocess to wait for.
- timeout: An integer number of seconds to wait before timing out.
- """
- proc.wait(timeout)
-
-
-def sync_device_time(ad):
- """Sync the time of an android device with the current system time.
-
- Both epoch time and the timezone will be synced.
-
- Args:
- ad: The android device to sync time on.
- """
- droid = ad.droid
- droid.setTimeZone(get_timezone_olson_id())
- droid.setTime(get_current_epoch_time())
-
-
-# Timeout decorator block
-class TimeoutError(Exception):
- """Exception for timeout decorator related errors.
- """
- pass
-
-
-def _timeout_handler(signum, frame):
- """Handler function used by signal to terminate a timed out function.
- """
- raise TimeoutError()
-
-
-def timeout(sec):
- """A decorator used to add time out check to a function.
-
- Args:
- sec: Number of seconds to wait before the function times out.
- No timeout if set to 0
-
- Returns:
- What the decorated function returns.
-
- Raises:
- TimeoutError is raised when time out happens.
- """
-
- def decorator(func):
- @functools.wraps(func)
- def wrapper(*args, **kwargs):
- if sec:
- signal.signal(signal.SIGALRM, _timeout_handler)
- signal.alarm(sec)
- try:
- return func(*args, **kwargs)
- except TimeoutError:
- raise TimeoutError(("Function {} timed out after {} "
- "seconds.").format(func.__name__, sec))
- finally:
- signal.alarm(0)
-
- return wrapper
-
- return decorator
-
-
-def trim_model_name(model):
- """Trim any prefix and postfix and return the android designation of the
- model name.
-
- e.g. "m_shamu" will be trimmed to "shamu".
-
- Args:
- model: model name to be trimmed.
-
- Returns
- Trimmed model name if one of the known model names is found.
- None otherwise.
- """
- # Directly look up first.
- if model in models:
- return model
- if model in manufacture_name_to_model:
- return manufacture_name_to_model[model]
- # If not found, try trimming off prefix/postfix and look up again.
- tokens = re.split("_|-", model)
- for t in tokens:
- if t in models:
- return t
- if t in manufacture_name_to_model:
- return manufacture_name_to_model[t]
- return None
-
-
-def force_airplane_mode(ad, new_state, timeout_value=60):
- """Force the device to set airplane mode on or off by adb shell command.
-
- Args:
- ad: android device object.
- new_state: Turn on airplane mode if True.
- Turn off airplane mode if False.
- timeout_value: max wait time for 'adb wait-for-device'
-
- Returns:
- True if success.
- False if timeout.
- """
- # Using timeout decorator.
- # Wait for device with timeout. If after <timeout_value> seconds, adb
- # is still waiting for device, throw TimeoutError exception.
- @timeout(timeout_value)
- def wait_for_device_with_timeout(ad):
- ad.adb.wait_for_device()
-
- try:
- wait_for_device_with_timeout(ad)
- ad.adb.shell("settings put global airplane_mode_on {}".format(
- 1 if new_state else 0))
- except TimeoutError:
- # adb wait for device timeout
- return False
- return True
-
-
-def enable_doze(ad):
- """Force the device into doze mode.
-
- Args:
- ad: android device object.
-
- Returns:
- True if device is in doze mode.
- False otherwise.
- """
- ad.adb.shell("dumpsys battery unplug")
- ad.adb.shell("dumpsys deviceidle enable")
- if (ad.adb.shell("dumpsys deviceidle force-idle") !=
- b'Now forced in to idle mode\r\n'):
- return False
- ad.droid.goToSleepNow()
- time.sleep(5)
- adb_shell_result = ad.adb.shell("dumpsys deviceidle step")
- if adb_shell_result not in [b'Stepped to: IDLE_MAINTENANCE\r\n',
- b'Stepped to: IDLE\r\n']:
- info = ("dumpsys deviceidle step: {}dumpsys battery: {}"
- "dumpsys deviceidle: {}".format(
- adb_shell_result.decode('utf-8'),
- ad.adb.shell("dumpsys battery").decode('utf-8'),
- ad.adb.shell("dumpsys deviceidle").decode('utf-8')))
- print(info)
- return False
- return True
-
-
-def disable_doze(ad):
- """Force the device not in doze mode.
-
- Args:
- ad: android device object.
-
- Returns:
- True if device is not in doze mode.
- False otherwise.
- """
- ad.adb.shell("dumpsys deviceidle disable")
- ad.adb.shell("dumpsys battery reset")
- adb_shell_result = ad.adb.shell("dumpsys deviceidle step")
- if (adb_shell_result != b'Stepped to: ACTIVE\r\n'):
- info = ("dumpsys deviceidle step: {}dumpsys battery: {}"
- "dumpsys deviceidle: {}".format(
- adb_shell_result.decode('utf-8'),
- ad.adb.shell("dumpsys battery").decode('utf-8'),
- ad.adb.shell("dumpsys deviceidle").decode('utf-8')))
- print(info)
- return False
- return True
-
-
-def set_ambient_display(ad, new_state):
- """Set "Ambient Display" in Settings->Display
-
- Args:
- ad: android device object.
- new_state: new state for "Ambient Display". True or False.
- """
- ad.adb.shell("settings put secure doze_enabled {}".format(1 if new_state
- else 0))
-
-
-def set_adaptive_brightness(ad, new_state):
- """Set "Adaptive Brightness" in Settings->Display
-
- Args:
- ad: android device object.
- new_state: new state for "Adaptive Brightness". True or False.
- """
- ad.adb.shell("settings put system screen_brightness_mode {}".format(
- 1 if new_state else 0))
-
-
-def set_auto_rotate(ad, new_state):
- """Set "Auto-rotate" in QuickSetting
-
- Args:
- ad: android device object.
- new_state: new state for "Auto-rotate". True or False.
- """
- ad.adb.shell("settings put system accelerometer_rotation {}".format(
- 1 if new_state else 0))
-
-
-def set_location_service(ad, new_state):
- """Set Location service on/off in Settings->Location
-
- Args:
- ad: android device object.
- new_state: new state for "Location service".
- If new_state is False, turn off location service.
- If new_state if True, set location service to "High accuracy".
- """
- if new_state:
- ad.adb.shell("settings put secure location_providers_allowed +gps")
- ad.adb.shell("settings put secure location_providers_allowed +network")
- else:
- ad.adb.shell("settings put secure location_providers_allowed -gps")
- ad.adb.shell("settings put secure location_providers_allowed -network")
-
-
-def set_mobile_data_always_on(ad, new_state):
- """Set Mobile_Data_Always_On feature bit
-
- Args:
- ad: android device object.
- new_state: new state for "mobile_data_always_on"
- if new_state is False, set mobile_data_always_on disabled.
- if new_state if True, set mobile_data_always_on enabled.
- """
- ad.adb.shell("settings put global mobile_data_always_on {}".format(
- 1 if new_state else 0))
diff --git a/runners/target/gtest/Android.bp b/runners/target/gtest/Android.bp
deleted file mode 100644
index 5f73425..0000000
--- a/runners/target/gtest/Android.bp
+++ /dev/null
@@ -1,32 +0,0 @@
-//
-// 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 {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-cc_library_static {
- name: "libVtsGtestMain",
- srcs: ["gtest_main.cpp"],
- static_libs: ["libgtest"],
-
- cflags: [
- "-Wall",
- "-Wextra",
- "-Wunused",
- "-Werror",
- ],
-}
diff --git a/runners/target/gtest/gtest_main.cpp b/runners/target/gtest/gtest_main.cpp
deleted file mode 100644
index c929292..0000000
--- a/runners/target/gtest/gtest_main.cpp
+++ /dev/null
@@ -1,1259 +0,0 @@
-/*
- * Copyright (C) 2014 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.
- */
-
-#include <gtest/gtest.h>
-
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <limits.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/wait.h>
-#include <unistd.h>
-
-#include <chrono>
-#include <string>
-#include <tuple>
-#include <utility>
-#include <vector>
-
-#ifndef TEMP_FAILURE_RETRY
-
-/* Used to retry syscalls that can return EINTR. */
-#define TEMP_FAILURE_RETRY(exp) \
- ({ \
- __typeof__(exp) _rc; \
- do { \
- _rc = (exp); \
- } while (_rc == -1 && errno == EINTR); \
- _rc; \
- })
-
-#endif
-
-static constexpr const char* COLOR_RESET = "\033[m";
-static constexpr const char* COLOR_RED = "\033[0;31m";
-static constexpr const char* COLOR_GREEN = "\033[0;32m";
-static constexpr const char* COLOR_YELLOW = "\033[0;33m";
-
-static bool ShouldUseColor() {
- const auto& gtest_color = ::testing::GTEST_FLAG(color);
- if (gtest_color == "yes" || gtest_color == "true" || gtest_color == "t") {
- return true;
- }
-
- bool stdout_is_tty = isatty(STDOUT_FILENO) != 0;
- if (!stdout_is_tty) {
- return false;
- }
-
- if (gtest_color != "auto") {
- return false;
- }
-
- const char* const term = getenv("COLORTERM");
- return term != nullptr && term[0] != 0;
-}
-
-static void ColoredPrintf(const char* const color, const char* fmt, ...) {
- static const bool use_color = ShouldUseColor();
-
- va_list args;
- va_start(args, fmt);
-
- if (!use_color) {
- vprintf(fmt, args);
- } else {
- printf("%s", color);
- vprintf(fmt, args);
- printf("%s", COLOR_RESET);
- }
-
- va_end(args);
-}
-
-constexpr int DEFAULT_GLOBAL_TEST_RUN_DEADLINE_MS = 90000;
-constexpr int DEFAULT_GLOBAL_TEST_RUN_WARNLINE_MS = 2000;
-
-// The time each test can run before killed for the reason of timeout.
-// It takes effect only with --isolate option.
-static int global_test_run_deadline_ms = DEFAULT_GLOBAL_TEST_RUN_DEADLINE_MS;
-
-// The time each test can run before be warned for too much running time.
-// It takes effect only with --isolate option.
-static int global_test_run_warnline_ms = DEFAULT_GLOBAL_TEST_RUN_WARNLINE_MS;
-
-// Return deadline duration for a test, in ms.
-static int GetDeadlineInfo(const std::string& /*test_name*/) {
- return global_test_run_deadline_ms;
-}
-
-// Return warnline duration for a test, in ms.
-static int GetWarnlineInfo(const std::string& /*test_name*/) {
- return global_test_run_warnline_ms;
-}
-
-static void PrintHelpInfo() {
- printf(
- "VTS Unit Test Options:\n"
- " -j [JOB_COUNT] or -j[JOB_COUNT]\n"
- " Run up to JOB_COUNT tests in parallel.\n"
- " Use isolation mode, Run each test in a separate process.\n"
- " If JOB_COUNT is not given, it is set to the count of available "
- "processors.\n"
- " --no-isolate\n"
- " Don't use isolation mode, run all tests in a single process.\n"
- " --deadline=[TIME_IN_MS]\n"
- " Run each test in no longer than [TIME_IN_MS] time.\n"
- " It takes effect only in isolation mode. Deafult deadline is 90000 "
- "ms.\n"
- " --warnline=[TIME_IN_MS]\n"
- " Test running longer than [TIME_IN_MS] will be warned.\n"
- " It takes effect only in isolation mode. Default warnline is 2000 "
- "ms.\n"
- " --gtest-filter=POSITIVE_PATTERNS[-NEGATIVE_PATTERNS]\n"
- " Used as a synonym for --gtest_filter option in gtest.\n"
- "Default vts unit test option is -j.\n"
- "In isolation mode, you can send SIGQUIT to the parent process to show "
- "current\n"
- "running tests, or send SIGINT to the parent process to stop testing "
- "and\n"
- "clean up current running tests.\n"
- "\n");
-}
-
-enum TestResult { TEST_SUCCESS = 0, TEST_FAILED, TEST_TIMEOUT };
-
-class Test {
- public:
- Test() {} // For std::vector<Test>.
- explicit Test(const char* name) : name_(name) {}
-
- const std::string& GetName() const { return name_; }
-
- void SetResult(TestResult result) { result_ = result; }
-
- TestResult GetResult() const { return result_; }
-
- void SetTestTime(int64_t elapsed_time_ns) {
- elapsed_time_ns_ = elapsed_time_ns;
- }
-
- int64_t GetTestTime() const { return elapsed_time_ns_; }
-
- void AppendTestOutput(const std::string& s) { output_ += s; }
-
- const std::string& GetTestOutput() const { return output_; }
-
- private:
- const std::string name_;
- TestResult result_;
- int64_t elapsed_time_ns_;
- std::string output_;
-};
-
-class TestCase {
- public:
- TestCase() {} // For std::vector<TestCase>.
- explicit TestCase(const char* name) : name_(name) {}
-
- const std::string& GetName() const { return name_; }
-
- void AppendTest(const char* test_name) {
- test_list_.push_back(Test(test_name));
- }
-
- size_t TestCount() const { return test_list_.size(); }
-
- std::string GetTestName(size_t test_id) const {
- VerifyTestId(test_id);
- return name_ + "." + test_list_[test_id].GetName();
- }
-
- Test& GetTest(size_t test_id) {
- VerifyTestId(test_id);
- return test_list_[test_id];
- }
-
- const Test& GetTest(size_t test_id) const {
- VerifyTestId(test_id);
- return test_list_[test_id];
- }
-
- void SetTestResult(size_t test_id, TestResult result) {
- VerifyTestId(test_id);
- test_list_[test_id].SetResult(result);
- }
-
- TestResult GetTestResult(size_t test_id) const {
- VerifyTestId(test_id);
- return test_list_[test_id].GetResult();
- }
-
- void SetTestTime(size_t test_id, int64_t elapsed_time_ns) {
- VerifyTestId(test_id);
- test_list_[test_id].SetTestTime(elapsed_time_ns);
- }
-
- int64_t GetTestTime(size_t test_id) const {
- VerifyTestId(test_id);
- return test_list_[test_id].GetTestTime();
- }
-
- private:
- void VerifyTestId(size_t test_id) const {
- if (test_id >= test_list_.size()) {
- fprintf(stderr, "test_id %zu out of range [0, %zu)\n", test_id,
- test_list_.size());
- exit(1);
- }
- }
-
- private:
- const std::string name_;
- std::vector<Test> test_list_;
-};
-
-class TestResultPrinter : public testing::EmptyTestEventListener {
- public:
- TestResultPrinter() : pinfo_(NULL) {}
- virtual void OnTestStart(const testing::TestInfo& test_info) {
- pinfo_ = &test_info; // Record test_info for use in OnTestPartResult.
- }
- virtual void OnTestPartResult(const testing::TestPartResult& result);
-
- private:
- const testing::TestInfo* pinfo_;
-};
-
-// Called after an assertion failure.
-void TestResultPrinter::OnTestPartResult(
- const testing::TestPartResult& result) {
- // If the test part succeeded, we don't need to do anything.
- if (result.type() == testing::TestPartResult::kSuccess) return;
-
- // Print failure message from the assertion (e.g. expected this and got that).
- printf("%s:(%d) Failure in test %s.%s\n%s\n", result.file_name(),
- result.line_number(), pinfo_->test_case_name(), pinfo_->name(),
- result.message());
- fflush(stdout);
-}
-
-static int64_t NanoTime() {
- std::chrono::nanoseconds duration(
- std::chrono::steady_clock::now().time_since_epoch());
- return static_cast<int64_t>(duration.count());
-}
-
-static bool EnumerateTests(int argc, char** argv,
- std::vector<TestCase>& testcase_list) {
- std::string command;
- for (int i = 0; i < argc; ++i) {
- command += argv[i];
- command += " ";
- }
- command += "--gtest_list_tests";
- FILE* fp = popen(command.c_str(), "r");
- if (fp == NULL) {
- perror("popen");
- return false;
- }
-
- char buf[200];
- while (fgets(buf, sizeof(buf), fp) != NULL) {
- char* p = buf;
-
- while (*p != '\0' && isspace(*p)) {
- ++p;
- }
- if (*p == '\0') continue;
- char* start = p;
- while (*p != '\0' && !isspace(*p)) {
- ++p;
- }
- char* end = p;
- while (*p != '\0' && isspace(*p)) {
- ++p;
- }
- if (*p != '\0' && *p != '#') {
- // This is not we want, gtest must meet with some error when parsing the
- // arguments.
- fprintf(stderr, "argument error, check with --help\n");
- return false;
- }
- *end = '\0';
- if (*(end - 1) == '.') {
- *(end - 1) = '\0';
- testcase_list.push_back(TestCase(start));
- } else {
- testcase_list.back().AppendTest(start);
- }
- }
- int result = pclose(fp);
- return (result != -1 && WEXITSTATUS(result) == 0);
-}
-
-// Part of the following *Print functions are copied from
-// external/gtest/src/gtest.cc:
-// PrettyUnitTestResultPrinter. The reason for copy is that
-// PrettyUnitTestResultPrinter
-// is defined and used in gtest.cc, which is hard to reuse.
-static void OnTestIterationStartPrint(
- const std::vector<TestCase>& testcase_list, size_t iteration,
- int iteration_count) {
- if (iteration_count != 1) {
- printf("\nRepeating all tests (iteration %zu) . . .\n\n", iteration);
- }
- ColoredPrintf(COLOR_GREEN, "[==========] ");
-
- size_t testcase_count = testcase_list.size();
- size_t test_count = 0;
- for (const auto& testcase : testcase_list) {
- test_count += testcase.TestCount();
- }
-
- printf("Running %zu %s from %zu %s.\n", test_count,
- (test_count == 1) ? "test" : "tests", testcase_count,
- (testcase_count == 1) ? "test case" : "test cases");
- fflush(stdout);
-}
-
-// vts cts test needs gtest output format.
-static void OnTestEndPrint(const TestCase& testcase, size_t test_id) {
- ColoredPrintf(COLOR_GREEN, "[ RUN ] ");
- printf("%s\n", testcase.GetTestName(test_id).c_str());
-
- const std::string& test_output = testcase.GetTest(test_id).GetTestOutput();
- printf("%s", test_output.c_str());
-
- TestResult result = testcase.GetTestResult(test_id);
- if (result == TEST_SUCCESS) {
- ColoredPrintf(COLOR_GREEN, "[ OK ] ");
- } else {
- ColoredPrintf(COLOR_RED, "[ FAILED ] ");
- }
- printf("%s", testcase.GetTestName(test_id).c_str());
- if (testing::GTEST_FLAG(print_time)) {
- printf(" (%" PRId64 " ms)", testcase.GetTestTime(test_id) / 1000000);
- }
- printf("\n");
- fflush(stdout);
-}
-
-static void OnTestIterationEndPrint(const std::vector<TestCase>& testcase_list,
- size_t /*iteration*/,
- int64_t elapsed_time_ns) {
- std::vector<std::string> fail_test_name_list;
- std::vector<std::pair<std::string, int64_t>> timeout_test_list;
-
- // For tests run exceed warnline but not timeout.
- std::vector<std::tuple<std::string, int64_t, int>> slow_test_list;
- size_t testcase_count = testcase_list.size();
- size_t test_count = 0;
- size_t success_test_count = 0;
-
- for (const auto& testcase : testcase_list) {
- test_count += testcase.TestCount();
- for (size_t i = 0; i < testcase.TestCount(); ++i) {
- TestResult result = testcase.GetTestResult(i);
- if (result == TEST_SUCCESS) {
- ++success_test_count;
- } else if (result == TEST_FAILED) {
- fail_test_name_list.push_back(testcase.GetTestName(i));
- } else if (result == TEST_TIMEOUT) {
- timeout_test_list.push_back(
- std::make_pair(testcase.GetTestName(i), testcase.GetTestTime(i)));
- }
- if (result != TEST_TIMEOUT &&
- testcase.GetTestTime(i) / 1000000 >=
- GetWarnlineInfo(testcase.GetTestName(i))) {
- slow_test_list.push_back(
- std::make_tuple(testcase.GetTestName(i), testcase.GetTestTime(i),
- GetWarnlineInfo(testcase.GetTestName(i))));
- }
- }
- }
-
- ColoredPrintf(COLOR_GREEN, "[==========] ");
- printf("%zu %s from %zu %s ran.", test_count,
- (test_count == 1) ? "test" : "tests", testcase_count,
- (testcase_count == 1) ? "test case" : "test cases");
- if (testing::GTEST_FLAG(print_time)) {
- printf(" (%" PRId64 " ms total)", elapsed_time_ns / 1000000);
- }
- printf("\n");
- ColoredPrintf(COLOR_GREEN, "[ PASS ] ");
- printf("%zu %s.\n", success_test_count,
- (success_test_count == 1) ? "test" : "tests");
-
- // Print tests failed.
- size_t fail_test_count = fail_test_name_list.size();
- if (fail_test_count > 0) {
- ColoredPrintf(COLOR_RED, "[ FAIL ] ");
- printf("%zu %s, listed below:\n", fail_test_count,
- (fail_test_count == 1) ? "test" : "tests");
- for (const auto& name : fail_test_name_list) {
- ColoredPrintf(COLOR_RED, "[ FAIL ] ");
- printf("%s\n", name.c_str());
- }
- }
-
- // Print tests run timeout.
- size_t timeout_test_count = timeout_test_list.size();
- if (timeout_test_count > 0) {
- ColoredPrintf(COLOR_RED, "[ TIMEOUT ] ");
- printf("%zu %s, listed below:\n", timeout_test_count,
- (timeout_test_count == 1) ? "test" : "tests");
- for (const auto& timeout_pair : timeout_test_list) {
- ColoredPrintf(COLOR_RED, "[ TIMEOUT ] ");
- printf("%s (stopped at %" PRId64 " ms)\n", timeout_pair.first.c_str(),
- timeout_pair.second / 1000000);
- }
- }
-
- // Print tests run exceed warnline.
- size_t slow_test_count = slow_test_list.size();
- if (slow_test_count > 0) {
- ColoredPrintf(COLOR_YELLOW, "[ SLOW ] ");
- printf("%zu %s, listed below:\n", slow_test_count,
- (slow_test_count == 1) ? "test" : "tests");
- for (const auto& slow_tuple : slow_test_list) {
- ColoredPrintf(COLOR_YELLOW, "[ SLOW ] ");
- printf("%s (%" PRId64 " ms, exceed warnline %d ms)\n",
- std::get<0>(slow_tuple).c_str(), std::get<1>(slow_tuple) / 1000000,
- std::get<2>(slow_tuple));
- }
- }
-
- if (fail_test_count > 0) {
- printf("\n%2zu FAILED %s\n", fail_test_count,
- (fail_test_count == 1) ? "TEST" : "TESTS");
- }
- if (timeout_test_count > 0) {
- printf("%2zu TIMEOUT %s\n", timeout_test_count,
- (timeout_test_count == 1) ? "TEST" : "TESTS");
- }
- if (slow_test_count > 0) {
- printf("%2zu SLOW %s\n", slow_test_count,
- (slow_test_count == 1) ? "TEST" : "TESTS");
- }
- fflush(stdout);
-}
-
-std::string XmlEscape(const std::string& xml) {
- std::string escaped;
- escaped.reserve(xml.size());
-
- for (auto c : xml) {
- switch (c) {
- case '<':
- escaped.append("<");
- break;
- case '>':
- escaped.append(">");
- break;
- case '&':
- escaped.append("&");
- break;
- case '\'':
- escaped.append("'");
- break;
- case '"':
- escaped.append(""");
- break;
- default:
- escaped.append(1, c);
- break;
- }
- }
-
- return escaped;
-}
-
-// Output xml file when --gtest_output is used, write this function as we can't
-// reuse
-// gtest.cc:XmlUnitTestResultPrinter. The reason is XmlUnitTestResultPrinter is
-// totally
-// defined in gtest.cc and not expose to outside. What's more, as we don't run
-// gtest in
-// the parent process, we don't have gtest classes which are needed by
-// XmlUnitTestResultPrinter.
-void OnTestIterationEndXmlPrint(const std::string& xml_output_filename,
- const std::vector<TestCase>& testcase_list,
- time_t epoch_iteration_start_time,
- int64_t elapsed_time_ns) {
- FILE* fp = fopen(xml_output_filename.c_str(), "w");
- if (fp == NULL) {
- fprintf(stderr, "failed to open '%s': %s\n", xml_output_filename.c_str(),
- strerror(errno));
- exit(1);
- }
-
- size_t total_test_count = 0;
- size_t total_failed_count = 0;
- std::vector<size_t> failed_count_list(testcase_list.size(), 0);
- std::vector<int64_t> elapsed_time_list(testcase_list.size(), 0);
- for (size_t i = 0; i < testcase_list.size(); ++i) {
- auto& testcase = testcase_list[i];
- total_test_count += testcase.TestCount();
- for (size_t j = 0; j < testcase.TestCount(); ++j) {
- if (testcase.GetTestResult(j) != TEST_SUCCESS) {
- ++failed_count_list[i];
- }
- elapsed_time_list[i] += testcase.GetTestTime(j);
- }
- total_failed_count += failed_count_list[i];
- }
-
- const tm* time_struct = localtime(&epoch_iteration_start_time);
- char timestamp[40];
- snprintf(timestamp, sizeof(timestamp), "%4d-%02d-%02dT%02d:%02d:%02d",
- time_struct->tm_year + 1900, time_struct->tm_mon + 1,
- time_struct->tm_mday, time_struct->tm_hour, time_struct->tm_min,
- time_struct->tm_sec);
-
- fputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", fp);
- fprintf(
- fp,
- "<testsuites tests=\"%zu\" failures=\"%zu\" disabled=\"0\" errors=\"0\"",
- total_test_count, total_failed_count);
- fprintf(fp, " timestamp=\"%s\" time=\"%.3lf\" name=\"AllTests\">\n",
- timestamp, elapsed_time_ns / 1e9);
- for (size_t i = 0; i < testcase_list.size(); ++i) {
- auto& testcase = testcase_list[i];
- fprintf(fp,
- " <testsuite name=\"%s\" tests=\"%zu\" failures=\"%zu\" "
- "disabled=\"0\" errors=\"0\"",
- testcase.GetName().c_str(), testcase.TestCount(),
- failed_count_list[i]);
- fprintf(fp, " time=\"%.3lf\">\n", elapsed_time_list[i] / 1e9);
-
- for (size_t j = 0; j < testcase.TestCount(); ++j) {
- fprintf(fp,
- " <testcase name=\"%s\" status=\"run\" time=\"%.3lf\" "
- "classname=\"%s\"",
- testcase.GetTest(j).GetName().c_str(),
- testcase.GetTestTime(j) / 1e9, testcase.GetName().c_str());
- if (testcase.GetTestResult(j) == TEST_SUCCESS) {
- fputs(" />\n", fp);
- } else {
- fputs(">\n", fp);
- const std::string& test_output = testcase.GetTest(j).GetTestOutput();
- const std::string escaped_test_output = XmlEscape(test_output);
- fprintf(fp, " <failure message=\"%s\" type=\"\">\n",
- escaped_test_output.c_str());
- fputs(" </failure>\n", fp);
- fputs(" </testcase>\n", fp);
- }
- }
-
- fputs(" </testsuite>\n", fp);
- }
- fputs("</testsuites>\n", fp);
- fclose(fp);
-}
-
-static bool sigint_flag;
-static bool sigquit_flag;
-
-static void signal_handler(int sig) {
- if (sig == SIGINT) {
- sigint_flag = true;
- } else if (sig == SIGQUIT) {
- sigquit_flag = true;
- }
-}
-
-static bool RegisterSignalHandler() {
- sigint_flag = false;
- sigquit_flag = false;
- sig_t ret = signal(SIGINT, signal_handler);
- if (ret != SIG_ERR) {
- ret = signal(SIGQUIT, signal_handler);
- }
- if (ret == SIG_ERR) {
- perror("RegisterSignalHandler");
- return false;
- }
- return true;
-}
-
-static bool UnregisterSignalHandler() {
- sig_t ret = signal(SIGINT, SIG_DFL);
- if (ret != SIG_ERR) {
- ret = signal(SIGQUIT, SIG_DFL);
- }
- if (ret == SIG_ERR) {
- perror("UnregisterSignalHandler");
- return false;
- }
- return true;
-}
-
-struct ChildProcInfo {
- pid_t pid;
- int64_t start_time_ns;
- int64_t end_time_ns;
- int64_t
- deadline_end_time_ns; // The time when the test is thought of as timeout.
- size_t testcase_id, test_id;
- bool finished;
- bool timed_out;
- int exit_status;
- int child_read_fd; // File descriptor to read child test failure info.
-};
-
-// Forked Child process, run the single test.
-static void ChildProcessFn(int argc, char** argv,
- const std::string& test_name) {
- char** new_argv = new char*[argc + 2];
- memcpy(new_argv, argv, sizeof(char*) * argc);
-
- char* filter_arg = new char[test_name.size() + 20];
- strcpy(filter_arg, "--gtest_filter=");
- strcat(filter_arg, test_name.c_str());
- new_argv[argc] = filter_arg;
- new_argv[argc + 1] = NULL;
-
- int new_argc = argc + 1;
- testing::InitGoogleTest(&new_argc, new_argv);
- int result = RUN_ALL_TESTS();
- exit(result);
-}
-
-static ChildProcInfo RunChildProcess(const std::string& test_name,
- int testcase_id, int test_id, int argc,
- char** argv) {
- int pipefd[2];
- if (pipe(pipefd) == -1) {
- perror("pipe in RunTestInSeparateProc");
- exit(1);
- }
- if (fcntl(pipefd[0], F_SETFL, O_NONBLOCK) == -1) {
- perror("fcntl in RunTestInSeparateProc");
- exit(1);
- }
- pid_t pid = fork();
- if (pid == -1) {
- perror("fork in RunTestInSeparateProc");
- exit(1);
- } else if (pid == 0) {
- // In child process, run a single test.
- close(pipefd[0]);
- close(STDOUT_FILENO);
- close(STDERR_FILENO);
- dup2(pipefd[1], STDOUT_FILENO);
- dup2(pipefd[1], STDERR_FILENO);
-
- if (!UnregisterSignalHandler()) {
- exit(1);
- }
- ChildProcessFn(argc, argv, test_name);
- // Unreachable.
- }
- // In parent process, initialize child process info.
- close(pipefd[1]);
- ChildProcInfo child_proc;
- child_proc.child_read_fd = pipefd[0];
- child_proc.pid = pid;
- child_proc.start_time_ns = NanoTime();
- child_proc.deadline_end_time_ns =
- child_proc.start_time_ns + GetDeadlineInfo(test_name) * 1000000LL;
- child_proc.testcase_id = testcase_id;
- child_proc.test_id = test_id;
- child_proc.finished = false;
- return child_proc;
-}
-
-static void HandleSignals(std::vector<TestCase>& testcase_list,
- std::vector<ChildProcInfo>& child_proc_list) {
- if (sigquit_flag) {
- sigquit_flag = false;
- // Print current running tests.
- printf("List of current running tests:\n");
- for (const auto& child_proc : child_proc_list) {
- if (child_proc.pid != 0) {
- std::string test_name =
- testcase_list[child_proc.testcase_id].GetTestName(
- child_proc.test_id);
- int64_t current_time_ns = NanoTime();
- int64_t run_time_ms =
- (current_time_ns - child_proc.start_time_ns) / 1000000;
- printf(" %s (%" PRId64 " ms)\n", test_name.c_str(), run_time_ms);
- }
- }
- } else if (sigint_flag) {
- sigint_flag = false;
- // Kill current running tests.
- for (const auto& child_proc : child_proc_list) {
- if (child_proc.pid != 0) {
- // Send SIGKILL to ensure the child process can be killed
- // unconditionally.
- kill(child_proc.pid, SIGKILL);
- }
- }
- // SIGINT kills the parent process as well.
- exit(1);
- }
-}
-
-static bool CheckChildProcExit(pid_t exit_pid, int exit_status,
- std::vector<ChildProcInfo>& child_proc_list) {
- for (size_t i = 0; i < child_proc_list.size(); ++i) {
- if (child_proc_list[i].pid == exit_pid) {
- child_proc_list[i].finished = true;
- child_proc_list[i].timed_out = false;
- child_proc_list[i].exit_status = exit_status;
- child_proc_list[i].end_time_ns = NanoTime();
- return true;
- }
- }
- return false;
-}
-
-static size_t CheckChildProcTimeout(
- std::vector<ChildProcInfo>& child_proc_list) {
- int64_t current_time_ns = NanoTime();
- size_t timeout_child_count = 0;
- for (size_t i = 0; i < child_proc_list.size(); ++i) {
- if (child_proc_list[i].deadline_end_time_ns <= current_time_ns) {
- child_proc_list[i].finished = true;
- child_proc_list[i].timed_out = true;
- child_proc_list[i].end_time_ns = current_time_ns;
- ++timeout_child_count;
- }
- }
- return timeout_child_count;
-}
-
-static void ReadChildProcOutput(std::vector<TestCase>& testcase_list,
- std::vector<ChildProcInfo>& child_proc_list) {
- for (const auto& child_proc : child_proc_list) {
- TestCase& testcase = testcase_list[child_proc.testcase_id];
- int test_id = child_proc.test_id;
- while (true) {
- char buf[1024];
- ssize_t bytes_read = TEMP_FAILURE_RETRY(
- read(child_proc.child_read_fd, buf, sizeof(buf) - 1));
- if (bytes_read > 0) {
- buf[bytes_read] = '\0';
- testcase.GetTest(test_id).AppendTestOutput(buf);
- } else if (bytes_read == 0) {
- break; // Read end.
- } else {
- if (errno == EAGAIN) {
- break;
- }
- perror("failed to read child_read_fd");
- exit(1);
- }
- }
- }
-}
-
-static void WaitChildProcs(std::vector<TestCase>& testcase_list,
- std::vector<ChildProcInfo>& child_proc_list) {
- size_t finished_child_count = 0;
- while (true) {
- int status;
- pid_t result;
- while ((result = TEMP_FAILURE_RETRY(waitpid(-1, &status, WNOHANG))) > 0) {
- if (CheckChildProcExit(result, status, child_proc_list)) {
- ++finished_child_count;
- }
- }
-
- if (result == -1) {
- if (errno == ECHILD) {
- // This happens when we have no running child processes.
- return;
- } else {
- perror("waitpid");
- exit(1);
- }
- } else if (result == 0) {
- finished_child_count += CheckChildProcTimeout(child_proc_list);
- }
-
- ReadChildProcOutput(testcase_list, child_proc_list);
- if (finished_child_count > 0) {
- return;
- }
-
- HandleSignals(testcase_list, child_proc_list);
-
- // sleep 1 ms to avoid busy looping.
- timespec sleep_time;
- sleep_time.tv_sec = 0;
- sleep_time.tv_nsec = 1000000;
- nanosleep(&sleep_time, NULL);
- }
-}
-
-static TestResult WaitForOneChild(pid_t pid) {
- int exit_status;
- pid_t result = TEMP_FAILURE_RETRY(waitpid(pid, &exit_status, 0));
-
- TestResult test_result = TEST_SUCCESS;
- if (result != pid || WEXITSTATUS(exit_status) != 0) {
- test_result = TEST_FAILED;
- }
- return test_result;
-}
-
-static void CollectChildTestResult(const ChildProcInfo& child_proc,
- TestCase& testcase) {
- int test_id = child_proc.test_id;
- testcase.SetTestTime(test_id,
- child_proc.end_time_ns - child_proc.start_time_ns);
- if (child_proc.timed_out) {
- // The child process marked as timed_out has not exited, and we should kill
- // it manually.
- kill(child_proc.pid, SIGKILL);
- WaitForOneChild(child_proc.pid);
- }
- close(child_proc.child_read_fd);
-
- if (child_proc.timed_out) {
- testcase.SetTestResult(test_id, TEST_TIMEOUT);
- char buf[1024];
- snprintf(buf, sizeof(buf),
- "%s killed because of timeout at %" PRId64 " ms.\n",
- testcase.GetTestName(test_id).c_str(),
- testcase.GetTestTime(test_id) / 1000000);
- testcase.GetTest(test_id).AppendTestOutput(buf);
-
- } else if (WIFSIGNALED(child_proc.exit_status)) {
- // Record signal terminated test as failed.
- testcase.SetTestResult(test_id, TEST_FAILED);
- char buf[1024];
- snprintf(buf, sizeof(buf), "%s terminated by signal: %s.\n",
- testcase.GetTestName(test_id).c_str(),
- strsignal(WTERMSIG(child_proc.exit_status)));
- testcase.GetTest(test_id).AppendTestOutput(buf);
-
- } else {
- int exitcode = WEXITSTATUS(child_proc.exit_status);
- testcase.SetTestResult(test_id, exitcode == 0 ? TEST_SUCCESS : TEST_FAILED);
- if (exitcode != 0) {
- char buf[1024];
- snprintf(buf, sizeof(buf), "%s exited with exitcode %d.\n",
- testcase.GetTestName(test_id).c_str(), exitcode);
- testcase.GetTest(test_id).AppendTestOutput(buf);
- }
- }
-}
-
-// We choose to use multi-fork and multi-wait here instead of multi-thread,
-// because it always
-// makes deadlock to use fork in multi-thread.
-// Returns true if all tests run successfully, otherwise return false.
-static bool RunTestInSeparateProc(int argc, char** argv,
- std::vector<TestCase>& testcase_list,
- int iteration_count, size_t job_count,
- const std::string& xml_output_filename) {
- // Stop default result printer to avoid environment setup/teardown information
- // for each test.
- testing::UnitTest::GetInstance()->listeners().Release(
- testing::UnitTest::GetInstance()->listeners().default_result_printer());
- testing::UnitTest::GetInstance()->listeners().Append(new TestResultPrinter);
-
- if (!RegisterSignalHandler()) {
- exit(1);
- }
-
- bool all_tests_passed = true;
-
- for (size_t iteration = 1;
- iteration_count < 0 || iteration <= static_cast<size_t>(iteration_count);
- ++iteration) {
- OnTestIterationStartPrint(testcase_list, iteration, iteration_count);
- int64_t iteration_start_time_ns = NanoTime();
- time_t epoch_iteration_start_time = time(NULL);
-
- // Run up to job_count tests in parallel, each test in a child process.
- std::vector<ChildProcInfo> child_proc_list;
-
- // Next test to run is [next_testcase_id:next_test_id].
- size_t next_testcase_id = 0;
- size_t next_test_id = 0;
-
- // Record how many tests are finished.
- std::vector<size_t> finished_test_count_list(testcase_list.size(), 0);
- size_t finished_testcase_count = 0;
-
- while (finished_testcase_count < testcase_list.size()) {
- // run up to job_count child processes.
- while (child_proc_list.size() < job_count &&
- next_testcase_id < testcase_list.size()) {
- std::string test_name =
- testcase_list[next_testcase_id].GetTestName(next_test_id);
- ChildProcInfo child_proc = RunChildProcess(test_name, next_testcase_id,
- next_test_id, argc, argv);
- child_proc_list.push_back(child_proc);
- if (++next_test_id == testcase_list[next_testcase_id].TestCount()) {
- next_test_id = 0;
- ++next_testcase_id;
- }
- }
-
- // Wait for any child proc finish or timeout.
- WaitChildProcs(testcase_list, child_proc_list);
-
- // Collect result.
- auto it = child_proc_list.begin();
- while (it != child_proc_list.end()) {
- auto& child_proc = *it;
- if (child_proc.finished == true) {
- size_t testcase_id = child_proc.testcase_id;
- size_t test_id = child_proc.test_id;
- TestCase& testcase = testcase_list[testcase_id];
-
- CollectChildTestResult(child_proc, testcase);
- OnTestEndPrint(testcase, test_id);
-
- if (++finished_test_count_list[testcase_id] == testcase.TestCount()) {
- ++finished_testcase_count;
- }
- if (testcase.GetTestResult(test_id) != TEST_SUCCESS) {
- all_tests_passed = false;
- }
-
- it = child_proc_list.erase(it);
- } else {
- ++it;
- }
- }
- }
-
- int64_t elapsed_time_ns = NanoTime() - iteration_start_time_ns;
- OnTestIterationEndPrint(testcase_list, iteration, elapsed_time_ns);
- if (!xml_output_filename.empty()) {
- OnTestIterationEndXmlPrint(xml_output_filename, testcase_list,
- epoch_iteration_start_time, elapsed_time_ns);
- }
- }
-
- if (!UnregisterSignalHandler()) {
- exit(1);
- }
-
- return all_tests_passed;
-}
-
-static size_t GetDefaultJobCount() {
- return static_cast<size_t>(sysconf(_SC_NPROCESSORS_ONLN));
-}
-
-static void AddPathSeparatorInTestProgramPath(std::vector<char*>& args) {
- // To run DeathTest in threadsafe mode, gtest requires that the user must
- // invoke the
- // test program via a valid path that contains at least one path separator.
- // The reason is that gtest uses clone() + execve() to run DeathTest in
- // threadsafe mode,
- // and execve() doesn't read environment variable PATH, so execve() will not
- // success
- // until we specify the absolute path or relative path of the test program
- // directly.
- if (strchr(args[0], '/') == NULL) {
- char path[PATH_MAX];
- ssize_t path_len = readlink("/proc/self/exe", path, sizeof(path));
- if (path_len <= 0 || path_len >= static_cast<ssize_t>(sizeof(path))) {
- perror("readlink");
- exit(1);
- }
- path[path_len] = '\0';
- args[0] = strdup(path);
- }
-}
-
-static void AddGtestFilterSynonym(std::vector<char*>& args) {
- // Support --gtest-filter as a synonym for --gtest_filter.
- for (size_t i = 1; i < args.size(); ++i) {
- if (strncmp(args[i], "--gtest-filter", strlen("--gtest-filter")) == 0) {
- args[i][7] = '_';
- }
- }
-}
-
-struct IsolationTestOptions {
- bool isolate;
- size_t job_count;
- int test_deadline_ms;
- int test_warnline_ms;
- std::string gtest_color;
- bool gtest_print_time;
- int gtest_repeat;
- std::string gtest_output;
-};
-
-// Pick options not for gtest: There are two parts in args, one part is used in
-// isolation test mode
-// as described in PrintHelpInfo(), the other part is handled by
-// testing::InitGoogleTest() in
-// gtest. PickOptions() picks the first part into IsolationTestOptions
-// structure, leaving the second
-// part in args.
-// Arguments:
-// args is used to pass in all command arguments, and pass out only the part
-// of options for gtest.
-// options is used to pass out test options in isolation mode.
-// Return false if there is error in arguments.
-static bool PickOptions(std::vector<char*>& args,
- IsolationTestOptions& options) {
- for (size_t i = 1; i < args.size(); ++i) {
- if (strcmp(args[i], "--help") == 0 || strcmp(args[i], "-h") == 0) {
- PrintHelpInfo();
- options.isolate = false;
- return true;
- }
- }
-
- AddPathSeparatorInTestProgramPath(args);
- AddGtestFilterSynonym(args);
-
- // if --vts-selftest argument is used, only enable self tests, otherwise
- // remove self tests.
- bool enable_selftest = false;
- for (size_t i = 1; i < args.size(); ++i) {
- if (strcmp(args[i], "--vts-selftest") == 0) {
- // This argument is to enable "vts_selftest*" for self test, and is not
- // shown in help info.
- // Don't remove this option from arguments.
- enable_selftest = true;
- }
- }
- std::string gtest_filter_str;
- for (size_t i = args.size() - 1; i >= 1; --i) {
- if (strncmp(args[i], "--gtest_filter=", strlen("--gtest_filter=")) == 0) {
- gtest_filter_str = std::string(args[i]);
- args.erase(args.begin() + i);
- break;
- }
- }
- if (enable_selftest == true) {
- args.push_back(strdup("--gtest_filter=vts_selftest*"));
- } else {
- if (gtest_filter_str == "") {
- gtest_filter_str = "--gtest_filter=-vts_selftest*";
- } else {
- // Find if '-' for NEGATIVE_PATTERNS exists.
- if (gtest_filter_str.find(":-") != std::string::npos) {
- gtest_filter_str += ":vts_selftest*";
- } else {
- gtest_filter_str += ":-vts_selftest*";
- }
- }
- args.push_back(strdup(gtest_filter_str.c_str()));
- }
-
- options.isolate = true;
- // Parse arguments that make us can't run in isolation mode.
- for (size_t i = 1; i < args.size(); ++i) {
- if (strcmp(args[i], "--no-isolate") == 0) {
- options.isolate = false;
- } else if (strcmp(args[i], "--gtest_list_tests") == 0) {
- options.isolate = false;
- }
- }
-
- // Stop parsing if we will not run in isolation mode.
- if (options.isolate == false) {
- return true;
- }
-
- // Init default isolation test options.
- options.job_count = GetDefaultJobCount();
- options.test_deadline_ms = DEFAULT_GLOBAL_TEST_RUN_DEADLINE_MS;
- options.test_warnline_ms = DEFAULT_GLOBAL_TEST_RUN_WARNLINE_MS;
- options.gtest_color = testing::GTEST_FLAG(color);
- options.gtest_print_time = testing::GTEST_FLAG(print_time);
- options.gtest_repeat = testing::GTEST_FLAG(repeat);
- options.gtest_output = testing::GTEST_FLAG(output);
-
- // Parse arguments speficied for isolation mode.
- for (size_t i = 1; i < args.size(); ++i) {
- if (strncmp(args[i], "-j", strlen("-j")) == 0) {
- char* p = args[i] + strlen("-j");
- int count = 0;
- if (*p != '\0') {
- // Argument like -j5.
- count = atoi(p);
- } else if (args.size() > i + 1) {
- // Arguments like -j 5.
- count = atoi(args[i + 1]);
- ++i;
- }
- if (count <= 0) {
- fprintf(stderr, "invalid job count: %d\n", count);
- return false;
- }
- options.job_count = static_cast<size_t>(count);
- } else if (strncmp(args[i], "--deadline=", strlen("--deadline=")) == 0) {
- int time_ms = atoi(args[i] + strlen("--deadline="));
- if (time_ms <= 0) {
- fprintf(stderr, "invalid deadline: %d\n", time_ms);
- return false;
- }
- options.test_deadline_ms = time_ms;
- } else if (strncmp(args[i], "--warnline=", strlen("--warnline=")) == 0) {
- int time_ms = atoi(args[i] + strlen("--warnline="));
- if (time_ms <= 0) {
- fprintf(stderr, "invalid warnline: %d\n", time_ms);
- return false;
- }
- options.test_warnline_ms = time_ms;
- } else if (strncmp(args[i], "--gtest_color=", strlen("--gtest_color=")) ==
- 0) {
- options.gtest_color = args[i] + strlen("--gtest_color=");
- } else if (strcmp(args[i], "--gtest_print_time=0") == 0) {
- options.gtest_print_time = false;
- } else if (strncmp(args[i], "--gtest_repeat=", strlen("--gtest_repeat=")) ==
- 0) {
- // If the value of gtest_repeat is < 0, then it indicates the tests
- // should be repeated forever.
- options.gtest_repeat = atoi(args[i] + strlen("--gtest_repeat="));
- // Remove --gtest_repeat=xx from arguments, so child process only run one
- // iteration for a single test.
- args.erase(args.begin() + i);
- --i;
- } else if (strncmp(args[i], "--gtest_output=", strlen("--gtest_output=")) ==
- 0) {
- std::string output = args[i] + strlen("--gtest_output=");
- // generate output xml file path according to the strategy in gtest.
- bool success = true;
- if (strncmp(output.c_str(), "xml:", strlen("xml:")) == 0) {
- output = output.substr(strlen("xml:"));
- if (output.size() == 0) {
- success = false;
- }
- // Make absolute path.
- if (success && output[0] != '/') {
- char* cwd = getcwd(NULL, 0);
- if (cwd != NULL) {
- output = std::string(cwd) + "/" + output;
- free(cwd);
- } else {
- success = false;
- }
- }
- // Add file name if output is a directory.
- if (success && output.back() == '/') {
- output += "test_details.xml";
- }
- }
- if (success) {
- options.gtest_output = output;
- } else {
- fprintf(stderr, "invalid gtest_output file: %s\n", args[i]);
- return false;
- }
-
- // Remove --gtest_output=xxx from arguments, so child process will not
- // write xml file.
- args.erase(args.begin() + i);
- --i;
- }
- }
-
- // Add --no-isolate in args to prevent child process from running in isolation
- // mode again.
- // As DeathTest will try to call execve(), this argument should always be
- // added.
- args.insert(args.begin() + 1, strdup("--no-isolate"));
- return true;
-}
-
-int main(int argc, char** argv) {
- std::vector<char*> arg_list;
- for (int i = 0; i < argc; ++i) {
- arg_list.push_back(argv[i]);
- }
-
- IsolationTestOptions options;
- if (PickOptions(arg_list, options) == false) {
- return 1;
- }
-
- if (options.isolate == true) {
- // Set global variables.
- global_test_run_deadline_ms = options.test_deadline_ms;
- global_test_run_warnline_ms = options.test_warnline_ms;
- testing::GTEST_FLAG(color) = options.gtest_color.c_str();
- testing::GTEST_FLAG(print_time) = options.gtest_print_time;
- std::vector<TestCase> testcase_list;
-
- argc = static_cast<int>(arg_list.size());
- arg_list.push_back(NULL);
- if (EnumerateTests(argc, arg_list.data(), testcase_list) == false) {
- return 1;
- }
- bool all_test_passed = RunTestInSeparateProc(
- argc, arg_list.data(), testcase_list, options.gtest_repeat,
- options.job_count, options.gtest_output);
- return all_test_passed ? 0 : 1;
- } else {
- argc = static_cast<int>(arg_list.size());
- arg_list.push_back(NULL);
- testing::InitGoogleTest(&argc, arg_list.data());
- return RUN_ALL_TESTS();
- }
-}
-
-//################################################################################
-// VTS Gtest self test, run this by --vts-selftest option.
-
-TEST(vts_selftest, test_success) { ASSERT_EQ(1, 1); }
-
-TEST(vts_selftest, test_fail) { ASSERT_EQ(0, 1); }
-
-TEST(vts_selftest, test_time_warn) { sleep(4); }
-
-TEST(vts_selftest, test_timeout) {
- while (1) {
- }
-}
-
-TEST(vts_selftest, test_signal_SEGV_terminated) {
- char* p = reinterpret_cast<char*>(static_cast<intptr_t>(atoi("0")));
- *p = 3;
-}
-
-class vts_selftest_DeathTest : public ::testing::Test {
- protected:
- virtual void SetUp() {
- ::testing::FLAGS_gtest_death_test_style = "threadsafe";
- }
-};
-
-static void deathtest_helper_success() {
- ASSERT_EQ(1, 1);
- exit(0);
-}
-
-TEST_F(vts_selftest_DeathTest, success) {
- ASSERT_EXIT(deathtest_helper_success(), ::testing::ExitedWithCode(0), "");
-}
-
-static void deathtest_helper_fail() { ASSERT_EQ(1, 0); }
-
-TEST_F(vts_selftest_DeathTest, fail) {
- ASSERT_EXIT(deathtest_helper_fail(), ::testing::ExitedWithCode(0), "");
-}
diff --git a/setup.py b/setup.py
deleted file mode 100644
index 5968c3c..0000000
--- a/setup.py
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/env python
-#
-# 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.
-#
-
-from setuptools import setup
-from setuptools import find_packages
-import sys
-
-install_requires = [
- 'future',
- 'futures',
-]
-
-if sys.version_info < (3,):
- install_requires.append('enum34')
-
-setup(
- name='vts',
- version='0.1',
- description='Android Vendor Test Suite',
- license='Apache2.0',
- packages=find_packages(),
- include_package_data=False,
- install_requires=install_requires,
- url="http://www.android.com/"
-)
diff --git a/specification/Android.bp b/specification/Android.bp
deleted file mode 100644
index 30e3772..0000000
--- a/specification/Android.bp
+++ /dev/null
@@ -1,100 +0,0 @@
-//
-// 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 {
- // See: http://go/android-license-faq
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-cc_library_shared {
- // libvts_interfacespecification does not include or link any HIDL HAL driver.
- // HIDL HAL drivers and profilers are defined as separated shared libraries
- // in a respective hardware/interfaces/<hal name>/<version>/Android.bp file.
- // libvts_interfacespecification is the driver for:
- // legacy HALs,
- // conventional HALs,
- // shared libraries,
- // and so on.
- name: "libvts_interfacespecification",
- generated_sources: ["libvts_interfacespecification_vts.driver_genc++"],
- generated_headers: ["libvts_interfacespecification_vts.driver_genc++_headers"],
- export_generated_headers: ["libvts_interfacespecification_vts.driver_genc++_headers"],
- shared_libs: [
- "libbase",
- "libcutils",
- "liblog",
- "libdl",
- "libandroid_runtime",
- "libcamera_metadata",
- "libvts_datatype",
- "libvts_common",
- "libvts_measurement",
- "libvts_multidevice_proto",
- "libprotobuf-cpp-full",
- ],
- static_libs: [
- "libbluetooth-types",
- ],
- cflags: [
- "-Wall",
- "-Werror",
- // These warnings are in code generated with vtsc
- // b/31362043
- "-Wno-unused-parameter",
- "-Wno-unused-value",
- "-Wno-duplicate-decl-specifier",
- ],
- proto: {
- type: "full",
- },
- compile_multilib: "both",
-}
-
-cc_genrule {
- name: "libvts_interfacespecification_vts.driver_genc++",
- srcs: [
- "lib/**/*",
- ],
- tools: [
- "vtsc",
- ],
- out: [
- "vts/libcutilsV1.vts.cpp",
- "vts/libcV1.vts.cpp",
- "vts/libmV1.vts.cpp",
- ],
- cmd: "mkdir -p $(genDir)/vts && " +
- "cp $(in) $(genDir)/vts/ && " +
- "$(location vtsc) -mDRIVER -tSOURCE -b$(genDir) vts/ $(genDir)/vts/",
-}
-
-cc_genrule {
- name: "libvts_interfacespecification_vts.driver_genc++_headers",
- srcs: [
- "lib/**/*",
- ],
- tools: [
- "vtsc",
- ],
- out: [
- "vts/libcutilsV1.vts.h",
- "vts/libcV1.vts.h",
- "vts/libmV1.vts.h",
- ],
- cmd: "mkdir -p $(genDir)/vts && " +
- "cp $(in) $(genDir)/vts/ && " +
- "$(location vtsc) -mDRIVER -tHEADER -b$(genDir) vts/ $(genDir)/vts/",
-}
diff --git a/specification/kernel/syscalls-arm64.vts b/specification/kernel/syscalls-arm64.vts
deleted file mode 100644
index f3dc0ab..0000000
--- a/specification/kernel/syscalls-arm64.vts
+++ /dev/null
@@ -1,46 +0,0 @@
-component_class: KERNEL
-component_type: SYSCALL
-component_type_version_major: 3
-component_type_version_minor: 10
-
-target_arch: TARGET_ARCH_ARM64
-
-header: "<syscalls.h>"
-
-api: {
- name: "mkdir"
- syscall_number: 1030
- return_type: {
- type: TYPE_SCALAR
- scalar_type: "uint64_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "char_pointer"
- is_const: true
- }
- arg: {
- type: TYPE_PREDEFINED
- predefined_type: "umode_t"
- }
-}
-
-api: {
- name: "rmdir"
- syscall_number: 1031
- return_type: {
- type: TYPE_SCALAR
- scalar_type: "uint64_t"
- }
- arg: {
- type: TYPE_SCALAR
- predefined_type: "char_pointer"
- is_const: true
- }
-}
-
-attribute {
- name: "umode_t"
- type: TYPE_SCALAR
- scalar_type: "uint8_t"
-}
diff --git a/specification/lib/ndk/bionic/1.0/libcV1.vts b/specification/lib/ndk/bionic/1.0/libcV1.vts
deleted file mode 100644
index 5d03fd5..0000000
--- a/specification/lib/ndk/bionic/1.0/libcV1.vts
+++ /dev/null
@@ -1,341 +0,0 @@
-component_class: LIB_SHARED
-component_type: BIONIC_LIBC
-component_type_version_major: 1
-component_type_version_minor: 0
-component_name: "libc"
-
-header: "<unistd.h>"
-header: "<stdint.h>"
-header: "<sys/types.h>"
-header: "<linux/socket.h>"
-
-interface: {
- api: {
- name: "socket"
- return_type: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- }
-
- api: {
- name: "accept"
- return_type: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_PREDEFINED
- scalar_type: "pointer"
- predefined_type: "struct sockaddr*"
- }
- arg: {
- type: TYPE_PREDEFINED
- scalar_type: "pointer"
- predefined_type: "socklen_t*"
- }
- }
-
- api: {
- name: "bind"
- return_type: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_PREDEFINED
- scalar_type: "pointer"
- predefined_type: "struct sockaddr*"
- }
- arg: {
- type: TYPE_PREDEFINED
- scalar_type: "pointer"
- predefined_type: "socklen_t*"
- }
- }
-
- api: {
- name: "connect"
- return_type: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_PREDEFINED
- scalar_type: "pointer"
- predefined_type: "struct sockaddr*"
- }
- arg: {
- type: TYPE_PREDEFINED
- scalar_type: "pointer"
- predefined_type: "socklen_t*"
- }
- }
-
- api: {
- name: "listen"
- return_type: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- }
-
- api: {
- name: "recv"
- return_type: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "void_pointer"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "uint32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- }
-
- api: {
- name: "send"
- return_type: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "void_pointer"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "uint32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- }
-
- api: {
- name: "fopen"
- return_type: {
- type: TYPE_PREDEFINED
- scalar_type: "pointer"
- predefined_type: "FILE*"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "char_pointer"
- name: "filename"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "char_pointer"
- name: "opentype"
- }
- }
-
- api: {
- name: "read"
- return_type: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- name: "filedes"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "void_pointer"
- name: "buffer"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "uint32_t"
- name: "size"
- }
- }
-
- api: {
- name: "write"
- return_type: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- name: "filedes"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "void_pointer"
- name: "buffer"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- name: "size"
- }
- }
-
- api: {
- name: "lseek"
- return_type: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- name: "filedes"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- name: "offset"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- name: "whence"
- }
- }
-
- api: {
- name: "close"
- return_type: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- name: "filedes"
- }
- }
-
- attribute: {
- name: "sockaddr"
- type: TYPE_STRUCT
- struct_value: {
- name: "sa_family"
- type: TYPE_SCALAR
- scalar_type: "uint32_t"
- }
- struct_value: {
- name: "sa_data"
- type: TYPE_ARRAY
- vector_value: {
- type: TYPE_SCALAR
- scalar_type: "char"
- }
- }
- }
-
- attribute: {
- name: "PF_UNIX"
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- scalar_value: {
- int32_t: 1
- }
- is_const: true
- }
-
- attribute: {
- name: "PF_INET"
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- scalar_value: {
- int32_t: 2
- }
- is_const: true
- }
-
- attribute: {
- name: "SOCK_STREAM"
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- scalar_value: {
- int32_t: 1
- }
- is_const: true
- }
-
- attribute: {
- name: "SOCK_DGRAM"
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- scalar_value: {
- int32_t: 2
- }
- is_const: true
- }
-
- attribute: {
- name: "SOCK_RAW"
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- scalar_value: {
- int32_t: 3
- }
- is_const: true
- }
-
- attribute: {
- name: "SOCK_SEQPACKET"
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- scalar_value: {
- int32_t: 5
- }
- is_const: true
- }
-}
diff --git a/specification/lib/ndk/bionic/1.0/libcutilsV1.vts b/specification/lib/ndk/bionic/1.0/libcutilsV1.vts
deleted file mode 100644
index 91ba57c..0000000
--- a/specification/lib/ndk/bionic/1.0/libcutilsV1.vts
+++ /dev/null
@@ -1,87 +0,0 @@
-component_class: LIB_SHARED
-component_type: VNDK_LIBCUTILS
-component_type_version_major: 1
-component_type_version_minor: 0
-component_name: "libcutils"
-
-header: "<unistd.h>"
-header: "<stdint.h>"
-header: "<sys/types.h>"
-
-interface: {
- api: {
- name: "qtaguid_tagSocket"
- return_type: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "uint32_t"
- }
- }
-
- api: {
- name: "qtaguid_untagSocket"
- return_type: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- }
-
- api: {
- name: "qtaguid_setCounterSet"
- return_type: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "uint32_t"
- }
- }
-
- api: {
- name: "qtaguid_deleteTagData"
- return_type: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "uint32_t"
- }
- }
-
- api: {
- name: "qtaguid_setPacifier"
- return_type: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "int32_t"
- }
- }
-}
diff --git a/specification/lib/ndk/bionic/1.0/libmV1.vts b/specification/lib/ndk/bionic/1.0/libmV1.vts
deleted file mode 100644
index 3729613..0000000
--- a/specification/lib/ndk/bionic/1.0/libmV1.vts
+++ /dev/null
@@ -1,33 +0,0 @@
-component_class: LIB_SHARED
-component_type: BIONIC_LIBM
-component_type_version_major: 1
-component_type_version_minor: 0
-component_name: "libm"
-
-header: "<math.h>"
-
-interface: {
- api: {
- name: "fabs"
- return_type: {
- type: TYPE_SCALAR
- scalar_type: "double_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "double_t"
- }
- }
-
- api: {
- name: "fabsf"
- return_type: {
- type: TYPE_SCALAR
- scalar_type: "float_t"
- }
- arg: {
- type: TYPE_SCALAR
- scalar_type: "float_t"
- }
- }
-}
diff --git a/testcases/README.md b/testcases/README.md
deleted file mode 100644
index a838061..0000000
--- a/testcases/README.md
+++ /dev/null
@@ -1,21 +0,0 @@
-In principle, VTS test cases are co-located with their respective projects.
-
-* HIDL HAL Tests: `test/vts-testcase/hal/<hal name>/<version>` and `hardware/interfaces/<hal name>/<version>/vts`
-
-* Kernel Tests: `test/vts-testcase/kernel`
-
- * LTP: `external/ltp`
-
- * Linux Kselftest: `external/linux-kselftest`
-
-* VNDK (Vendor Native Development Kit) Tests: `test/vts-testcase/vndk`
-
-* Performance Tests: `test/vts-testcase/performance`
-
-* Fuzz Tests: `test/vts-testcase/fuzz`
-
-* Security Tests: `test/vts-testcase/security`
-
-The files under this directory (`test/vts/testcases`) are only for:
-VTS codelab, template, tests for legacy components, and tests that are
-under development and do not have any respective projects.
diff --git a/testcases/__init__.py b/testcases/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/testcases/__init__.py
+++ /dev/null
diff --git a/testcases/fuzz/lib_bionic/LibBionicLibmFuzzTest.py b/testcases/fuzz/lib_bionic/LibBionicLibmFuzzTest.py
deleted file mode 100644
index 7242394..0000000
--- a/testcases/fuzz/lib_bionic/LibBionicLibmFuzzTest.py
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/env python
-#
-# 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.
-#
-
-import logging
-
-from vts.runners.host import base_test
-from vts.runners.host import test_runner
-
-
-class LibBionicLibmFuzzTest(base_test.BaseTestClass):
- """A fuzz testcase for a libm shared library of bionic."""
-
- def setUpClass(self):
- self.dut = self.android_devices[0]
- self.dut.lib.InitSharedLib(
- target_type="bionic_libm",
- target_basepaths=["/system/lib64"],
- target_version=1.0,
- target_filename="libm.so",
- bits=64,
- handler_name="libm",
- target_package="lib.ndk.bionic")
-
- def testFabs(self):
- """A simple testcase which just calls the fabs function."""
- # TODO: support ability to test non-instrumented hals.
- logging.info("result %s", self.dut.lib.libm.fabs(5.0))
-
-
-if __name__ == "__main__":
- test_runner.main()
diff --git a/testcases/fuzz/lib_bionic/LibBionicLibmFuzzTest.runner_conf b/testcases/fuzz/lib_bionic/LibBionicLibmFuzzTest.runner_conf
deleted file mode 100644
index 86dc30d..0000000
--- a/testcases/fuzz/lib_bionic/LibBionicLibmFuzzTest.runner_conf
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "gene_pool_size": 10,
- "iteartion_count": 10
-}
diff --git a/testcases/fuzz/lib_bionic/__init__.py b/testcases/fuzz/lib_bionic/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/testcases/fuzz/lib_bionic/__init__.py
+++ /dev/null
diff --git a/testcases/host/__init__.py b/testcases/host/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/testcases/host/__init__.py
+++ /dev/null
diff --git a/testcases/host/firmware_dtbo_test/OWNERS b/testcases/host/firmware_dtbo_test/OWNERS
deleted file mode 100644
index 57b1211..0000000
--- a/testcases/host/firmware_dtbo_test/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-# Bug component: 30545
-smuckle@google.com
diff --git a/testcases/host/kernel_proc_file_api_test/OWNERS b/testcases/host/kernel_proc_file_api_test/OWNERS
deleted file mode 100644
index 57b1211..0000000
--- a/testcases/host/kernel_proc_file_api_test/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-# Bug component: 30545
-smuckle@google.com
diff --git a/testcases/host/selinux_test/OWNERS b/testcases/host/selinux_test/OWNERS
deleted file mode 100644
index 57b1211..0000000
--- a/testcases/host/selinux_test/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-# Bug component: 30545
-smuckle@google.com
diff --git a/testcases/run-on-host.mk b/testcases/run-on-host.mk
deleted file mode 100644
index 70f296e..0000000
--- a/testcases/run-on-host.mk
+++ /dev/null
@@ -1,45 +0,0 @@
-#
-# 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.
-#
-
-# Include once
-ifneq ($(vts_run_on_host_mk_included),true)
-vts_run_on_host_mk_included := true
-
-ifneq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),arm mips x86))
-LINKER = linker64
-else
-LINKER = linker
-endif
-
-ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
-# gtest needs ANDROID_DATA/local/tmp for death test output.
-# Make sure to create ANDROID_DATA/local/tmp if doesn't exist.
-# VTS itself should always work relative to ANDROID_DATA or ANDROID_ROOT.
-vts-prepare-run-on-host: $(TARGET_OUT_EXECUTABLES)/$(LINKER) $(TARGET_OUT)/etc/hosts $(TARGET_OUT_EXECUTABLES)/sh
- if [ ! -d /system ]; then \
- echo "Attempting to create /system"; \
- sudo mkdir -p -m 0777 /system; \
- fi
- echo "Attempting to create $(TARGET_OUT_DATA)/local/tmp if not exists"
- mkdir -p $(TARGET_OUT_DATA)/local/tmp
- ln -fs `realpath $(TARGET_OUT)/bin` /system/
- ln -fs `realpath $(TARGET_OUT)/etc` /system/
- ln -fs `realpath $(TARGET_OUT)/lib` /system/
- if [ -d "$(TARGET_OUT)/lib64" ]; then \
- ln -fs `realpath $(TARGET_OUT)/lib64` /system/; \
- fi
-endif
-endif
\ No newline at end of file
diff --git a/testcases/template/__init__.py b/testcases/template/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/testcases/template/__init__.py
+++ /dev/null
diff --git a/testcases/template/binary_test/__init__.py b/testcases/template/binary_test/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/testcases/template/binary_test/__init__.py
+++ /dev/null
diff --git a/testcases/template/binary_test/binary_test.py b/testcases/template/binary_test/binary_test.py
deleted file mode 100644
index 0224a75..0000000
--- a/testcases/template/binary_test/binary_test.py
+++ /dev/null
@@ -1,501 +0,0 @@
-#
-# 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.
-#
-
-import logging
-import os.path
-import posixpath as targetpath
-import time
-
-from vts.runners.host import asserts
-from vts.runners.host import base_test
-from vts.runners.host import const
-from vts.runners.host import errors
-from vts.runners.host import keys
-from vts.runners.host import test_runner
-from vts.utils.python.common import list_utils
-from vts.utils.python.coverage import coverage_utils
-from vts.utils.python.os import path_utils
-from vts.utils.python.precondition import precondition_utils
-from vts.utils.python.web import feature_utils
-
-from vts.testcases.template.binary_test import binary_test_case
-
-DATA_NATIVETEST = 'data/nativetest'
-DATA_NATIVETEST64 = '%s64' % DATA_NATIVETEST
-
-
-class BinaryTest(base_test.BaseTestClass):
- '''Base class to run binary tests on target.
-
- Attributes:
- _dut: AndroidDevice, the device under test as config
- shell: ShellMirrorObject, shell mirror
- testcases: list of BinaryTestCase objects, list of test cases to run
- tags: all the tags that appeared in binary list
- DEVICE_TMP_DIR: string, temp location for storing binary
- TAG_DELIMITER: string, separator used to separate tag and path
- '''
- DEVICE_TMP_DIR = '/data/local/tmp'
- TAG_DELIMITER = '::'
- PUSH_DELIMITER = '->'
- DEFAULT_TAG_32 = '_%s' % const.SUFFIX_32BIT
- DEFAULT_TAG_64 = '_%s' % const.SUFFIX_64BIT
- DEFAULT_LD_LIBRARY_PATH_32 = '/data/local/tmp/32/'
- DEFAULT_LD_LIBRARY_PATH_64 = '/data/local/tmp/64/'
- DEFAULT_PROFILING_LIBRARY_PATH_32 = '/data/local/tmp/32/'
- DEFAULT_PROFILING_LIBRARY_PATH_64 = '/data/local/tmp/64/'
-
- def setUpClass(self):
- '''Prepare class, push binaries, set permission, create test cases.'''
- required_params = [
- keys.ConfigKeys.IKEY_DATA_FILE_PATH,
- ]
- opt_params = [
- keys.ConfigKeys.IKEY_BINARY_TEST_SOURCE,
- keys.ConfigKeys.IKEY_BINARY_TEST_WORKING_DIRECTORY,
- keys.ConfigKeys.IKEY_BINARY_TEST_ENVP,
- keys.ConfigKeys.IKEY_BINARY_TEST_ARGS,
- keys.ConfigKeys.IKEY_BINARY_TEST_LD_LIBRARY_PATH,
- keys.ConfigKeys.IKEY_BINARY_TEST_PROFILING_LIBRARY_PATH,
- keys.ConfigKeys.IKEY_NATIVE_SERVER_PROCESS_NAME,
- keys.ConfigKeys.IKEY_PRECONDITION_FILE_PATH_PREFIX,
- keys.ConfigKeys.IKEY_PRECONDITION_SYSPROP,
- ]
- self.getUserParams(
- req_param_names=required_params, opt_param_names=opt_params)
-
- # test-module-name is required in binary tests.
- self.getUserParam(
- keys.ConfigKeys.KEY_TESTBED_NAME, error_if_not_found=True)
-
- logging.debug("%s: %s", keys.ConfigKeys.IKEY_DATA_FILE_PATH,
- self.data_file_path)
-
- self.binary_test_source = self.getUserParam(
- keys.ConfigKeys.IKEY_BINARY_TEST_SOURCE, default_value=[])
-
- self.working_directory = {}
- if hasattr(self, keys.ConfigKeys.IKEY_BINARY_TEST_WORKING_DIRECTORY):
- self.binary_test_working_directory = map(
- str, self.binary_test_working_directory)
- for token in self.binary_test_working_directory:
- tag = ''
- path = token
- if self.TAG_DELIMITER in token:
- tag, path = token.split(self.TAG_DELIMITER)
- self.working_directory[tag] = path
-
- self.envp = {}
- if hasattr(self, keys.ConfigKeys.IKEY_BINARY_TEST_ENVP):
- self.binary_test_envp = map(str, self.binary_test_envp)
- for token in self.binary_test_envp:
- tag = ''
- path = token
- split = token.find(self.TAG_DELIMITER)
- if split >= 0:
- tag, path = token[:split], token[
- split + len(self.TAG_DELIMITER):]
- if tag in self.envp:
- self.envp[tag] += ' %s' % path
- else:
- self.envp[tag] = path
-
- self.args = {}
- if hasattr(self, keys.ConfigKeys.IKEY_BINARY_TEST_ARGS):
- self.binary_test_args = map(str, self.binary_test_args)
- for token in self.binary_test_args:
- tag = ''
- arg = token
- split = token.find(self.TAG_DELIMITER)
- if split >= 0:
- tag, arg = token[:split], token[
- split + len(self.TAG_DELIMITER):]
- if tag in self.args:
- self.args[tag] += ' %s' % arg
- else:
- self.args[tag] = arg
-
- if hasattr(self, keys.ConfigKeys.IKEY_PRECONDITION_FILE_PATH_PREFIX):
- self.file_path_prefix = {
- self.DEFAULT_TAG_32: [],
- self.DEFAULT_TAG_64: [],
- }
- self.precondition_file_path_prefix = map(
- str, self.precondition_file_path_prefix)
- for token in self.precondition_file_path_prefix:
- tag = ''
- path = token
- if self.TAG_DELIMITER in token:
- tag, path = token.split(self.TAG_DELIMITER)
- if tag == '':
- self.file_path_prefix[self.DEFAULT_TAG_32].append(path)
- self.file_path_prefix[self.DEFAULT_TAG_64].append(path)
- elif tag in self.file_path_prefix:
- self.file_path_prefix[tag].append(path)
- else:
- logging.warn(
- "Incorrect tag %s in precondition-file-path-prefix",
- tag)
-
- self.ld_library_path = {
- self.DEFAULT_TAG_32: self.DEFAULT_LD_LIBRARY_PATH_32,
- self.DEFAULT_TAG_64: self.DEFAULT_LD_LIBRARY_PATH_64,
- }
- if hasattr(self, keys.ConfigKeys.IKEY_BINARY_TEST_LD_LIBRARY_PATH):
- self.binary_test_ld_library_path = map(
- str, self.binary_test_ld_library_path)
- for token in self.binary_test_ld_library_path:
- tag = ''
- path = token
- if self.TAG_DELIMITER in token:
- tag, path = token.split(self.TAG_DELIMITER)
- if tag in self.ld_library_path:
- self.ld_library_path[tag] = '{}:{}'.format(
- path, self.ld_library_path[tag])
- else:
- self.ld_library_path[tag] = path
-
- self.profiling_library_path = {
- self.DEFAULT_TAG_32: self.DEFAULT_PROFILING_LIBRARY_PATH_32,
- self.DEFAULT_TAG_64: self.DEFAULT_PROFILING_LIBRARY_PATH_64,
- }
- if hasattr(self,
- keys.ConfigKeys.IKEY_BINARY_TEST_PROFILING_LIBRARY_PATH):
- self.binary_test_profiling_library_path = map(
- str, self.binary_test_profiling_library_path)
- for token in self.binary_test_profiling_library_path:
- tag = ''
- path = token
- if self.TAG_DELIMITER in token:
- tag, path = token.split(self.TAG_DELIMITER)
- self.profiling_library_path[tag] = path
-
- self._dut = self.android_devices[0]
- self.shell = self._dut.shell
-
- if self.coverage.enabled and self.coverage.global_coverage:
- self.coverage.InitializeDeviceCoverage(self._dut)
- for tag in [self.DEFAULT_TAG_32, self.DEFAULT_TAG_64]:
- if tag in self.envp:
- self.envp[tag] = '%s %s'.format(
- self.envp[tag], coverage_utils.COVERAGE_TEST_ENV)
- else:
- self.envp[tag] = coverage_utils.COVERAGE_TEST_ENV
-
- self.testcases = []
- if not precondition_utils.CheckSysPropPrecondition(
- self, self._dut, self.shell):
- logging.warn('Precondition sysprop not met; '
- 'all tests skipped.')
- self.skipAllTests('precondition sysprop not met')
-
- self.tags = set()
- self.CreateTestCases()
- cmd = list(
- set('chmod 755 %s' % test_case.path
- for test_case in self.testcases))
- cmd_results = self.shell.Execute(cmd)
- if any(cmd_results[const.EXIT_CODE]):
- logging.error('Failed to set permission to some of the binaries:\n'
- '%s\n%s', cmd, cmd_results)
-
- def CreateTestCases(self):
- '''Push files to device and create test case objects.'''
- source_list = list(map(self.ParseTestSource, self.binary_test_source))
-
- def isValidSource(source):
- '''Checks that the truth value and bitness of source is valid.
-
- Args:
- source: a tuple of (string, string, string or None),
- representing (host side absolute path, device side absolute
- path, tag), is the return value of self.ParseTestSource
-
- Returns:
- False if source has a false truth value or its bitness does
- not match the abi_bitness of the test run.
- '''
- if not source:
- return False
-
- tag = source[2]
- if tag is None:
- return True
-
- tag = str(tag)
- if (tag.endswith(const.SUFFIX_32BIT) and self.abi_bitness == '64'
- ) or (tag.endswith(const.SUFFIX_64BIT) and
- self.abi_bitness == '32'):
- logging.debug('Bitness of test source, %s, does not match the '
- 'abi_bitness, %s, of test run. Skipping',
- str(source[0]),
- self.abi_bitness)
- return False
-
- return True
-
- source_list = filter(isValidSource, source_list)
- logging.debug('Parsed test sources: %s', source_list)
-
- # Push source files first
- for src, dst, tag in source_list:
- if src:
- if os.path.isdir(src):
- src = os.path.join(src, '.')
- logging.debug('Pushing from %s to %s.', src, dst)
- self._dut.adb.push('{src} {dst}'.format(src=src, dst=dst))
- self.shell.Execute('ls %s' % dst)
-
- if not hasattr(self, 'testcases'):
- self.testcases = []
-
- # Then create test cases
- for src, dst, tag in source_list:
- if tag is not None:
- # tag not being None means to create a test case
- self.tags.add(tag)
- logging.debug('Creating test case from %s with tag %s', dst,
- tag)
- testcase = self.CreateTestCase(dst, tag)
- if not testcase:
- continue
-
- if type(testcase) is list:
- self.testcases.extend(testcase)
- else:
- self.testcases.append(testcase)
-
- if not self.testcases:
- logging.warn("No test case is found or generated.")
-
- def PutTag(self, name, tag):
- '''Put tag on name and return the resulting string.
-
- Args:
- name: string, a test name
- tag: string
-
- Returns:
- String, the result string after putting tag on the name
- '''
- return '{}{}'.format(name, tag)
-
- def ExpandListItemTags(self, input_list):
- '''Expand list items with tags.
-
- Since binary test allows a tag to be added in front of the binary
- path, test names are generated with tags attached. This function is
- used to expand the filters correspondingly. If a filter contains
- a tag, only test name with that tag will be included in output.
- Otherwise, all known tags will be paired to the test name in output
- list.
-
- Args:
- input_list: list of string, the list to expand
-
- Returns:
- A list of string
- '''
- result = []
- for item in input_list:
- if self.TAG_DELIMITER in item:
- tag, name = item.split(self.TAG_DELIMITER)
- result.append(self.PutTag(name, tag))
- for tag in self.tags:
- result.append(self.PutTag(item, tag))
- return result
-
- def tearDownClass(self):
- '''Perform clean-up tasks'''
- # Retrieve coverage if applicable
- if self.coverage.enabled and self.coverage.global_coverage:
- if not self.isSkipAllTests():
- self.coverage.SetCoverageData(dut=self._dut, isGlobal=True)
-
- if self.profiling.enabled:
- self.profiling.DisableVTSProfiling(self.shell)
-
- # Clean up the pushed binaries
- logging.debug('Start class cleaning up jobs.')
- # Delete pushed files
-
- sources = [
- self.ParseTestSource(src) for src in self.binary_test_source
- ]
- sources = set(filter(bool, sources))
- paths = [dst for src, dst, tag in sources if src and dst]
- cmd = ['rm -rf %s' % dst for dst in paths]
- cmd_results = self.shell.Execute(cmd, no_except=True)
- if not cmd_results or any(cmd_results[const.EXIT_CODE]):
- logging.warning('Failed to clean up test class: %s', cmd_results)
-
- # Delete empty directories in working directories
- dir_set = set(path_utils.TargetDirName(dst) for dst in paths)
- dir_set.add(self.ParseTestSource('')[1])
- dirs = list(dir_set)
- dirs.sort(lambda x, y: cmp(len(y), len(x)))
- cmd = ['rmdir %s' % d for d in dirs]
- cmd_results = self.shell.Execute(cmd, no_except=True)
- if not cmd_results or any(cmd_results[const.EXIT_CODE]):
- logging.warning('Failed to remove: %s', cmd_results)
-
- if not self.isSkipAllTests() and self.profiling.enabled:
- self.profiling.ProcessAndUploadTraceData()
-
- logging.debug('Finished class cleaning up jobs.')
-
- def ParseTestSource(self, source):
- '''Convert host side binary path to device side path.
-
- Args:
- source: string, binary test source string
-
- Returns:
- A tuple of (string, string, string), representing (host side
- absolute path, device side absolute path, tag). Returned tag
- will be None if the test source is for pushing file to working
- directory only. If source file is specified for adb push but does not
- exist on host, None will be returned.
- '''
- tag = ''
- path = source
- if self.TAG_DELIMITER in source:
- tag, path = source.split(self.TAG_DELIMITER)
-
- src = path
- dst = None
- if self.PUSH_DELIMITER in path:
- src, dst = path.split(self.PUSH_DELIMITER)
-
- if src:
- src = os.path.join(self.data_file_path, src)
- if not os.path.exists(src):
- logging.warning('binary source file is specified '
- 'but does not exist on host: %s', src)
- return None
-
- push_only = dst is not None and dst == ''
-
- if not dst:
- parent = self.working_directory[
- tag] if tag in self.working_directory else self._GetDefaultBinaryPushDstPath(
- src, tag)
- dst = path_utils.JoinTargetPath(parent, os.path.basename(src))
-
- if push_only:
- tag = None
-
- return str(src), str(dst), tag
-
- def _GetDefaultBinaryPushDstPath(self, src, tag):
- '''Get default binary push destination path.
-
- This method is called to get default push destination path when
- it is not specified.
-
- If binary source path contains 'data/nativetest[64]', then the binary
- will be pushed to /data/nativetest[64] instead of /data/local/tmp
-
- Args:
- src: string, source path of binary
- tag: string, tag of binary source
-
- Returns:
- string, default push path
- '''
- src_lower = src.lower()
- if DATA_NATIVETEST64 in src_lower:
- parent_path = targetpath.sep + DATA_NATIVETEST64
- elif DATA_NATIVETEST in src_lower:
- parent_path = targetpath.sep + DATA_NATIVETEST
- else:
- parent_path = self.DEVICE_TMP_DIR
-
- return targetpath.join(
- parent_path, 'vts_binary_test_%s' % self.__class__.__name__, tag)
-
- def CreateTestCase(self, path, tag=''):
- '''Create a list of TestCase objects from a binary path.
-
- Args:
- path: string, absolute path of a binary on device
- tag: string, a tag that will be appended to the end of test name
-
- Returns:
- A list of BinaryTestCase objects
- '''
- working_directory = self.working_directory[
- tag] if tag in self.working_directory else None
- envp = self.envp[tag] if tag in self.envp else ''
- args = self.args[tag] if tag in self.args else ''
- ld_library_path = self.ld_library_path[
- tag] if tag in self.ld_library_path else None
- profiling_library_path = self.profiling_library_path[
- tag] if tag in self.profiling_library_path else None
-
- return binary_test_case.BinaryTestCase(
- '',
- path_utils.TargetBaseName(path),
- path,
- tag,
- self.PutTag,
- working_directory,
- ld_library_path,
- profiling_library_path,
- envp=envp,
- args=args)
-
- def VerifyTestResult(self, test_case, command_results):
- '''Parse test case command result.
-
- Args:
- test_case: BinaryTestCase object, the test case whose command
- command_results: dict of lists, shell command result
- '''
- asserts.assertTrue(command_results, 'Empty command response.')
- asserts.assertFalse(
- any(command_results[const.EXIT_CODE]),
- 'Test {} failed with the following results: {}'.format(
- test_case, command_results))
-
- def RunTestCase(self, test_case):
- '''Runs a test_case.
-
- Args:
- test_case: BinaryTestCase object
- '''
- if self.profiling.enabled:
- self.profiling.EnableVTSProfiling(self.shell,
- test_case.profiling_library_path)
-
- cmd = test_case.GetRunCommand()
- logging.debug("Executing binary test command: %s", cmd)
- command_results = self.shell.Execute(cmd)
-
- self.VerifyTestResult(test_case, command_results)
-
- if self.profiling.enabled:
- self.profiling.ProcessTraceDataForTestCase(self._dut)
- self.profiling.DisableVTSProfiling(self.shell)
-
- def generateAllTests(self):
- '''Runs all binary tests.'''
- self.runGeneratedTests(
- test_func=self.RunTestCase, settings=self.testcases, name_func=str)
-
-
-if __name__ == "__main__":
- test_runner.main()
diff --git a/testcases/template/binary_test/binary_test_case.py b/testcases/template/binary_test/binary_test_case.py
deleted file mode 100644
index 3313191..0000000
--- a/testcases/template/binary_test/binary_test_case.py
+++ /dev/null
@@ -1,237 +0,0 @@
-#
-# 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.
-#
-
-import os
-import operator
-import ntpath
-
-
-def _SafeStrip(value):
- '''Strip string value if value is not None.
-
- Args:
- value: string, value to strip
-
- Returns:
- stripped string; None if input value is None.
- '''
- if value is None:
- return value
- return value.strip()
-
-
-class BinaryTestCase(object):
- '''A class to represent a binary test case.
-
- Attributes:
- test_suite: string, test suite name.
- test_name: string, test case name which does not include test suite.
- path: string, absolute test binary path on device.
- tag: string, test tag.
- put_tag_func: function that takes a name and tag to output a combination.
- working_directory: string, working directory to call the command.
- ld_library_path: string, a path for LD_LIBRARY_PATH environment variable.
- profiling_library_path: string, path to lookup and load VTS profiling libraries.
- cmd: string, a shell command to execute the test case. If empty, path will be used.
- envp: string, environment veriable. shoud be in format 'name1=value1 name2=value2...'
- Will be called using 'env <envp> <cmd> <args>'
- args: string, arguments following cmd.
- name_appendix: string, appendix attached to the test name in display,
- typically contains info of parameters used in the test,
- e.e. service name used for hal hidl test.
- filter_file: string, a path pointing to the file containing the filters.
- '''
-
- def __init__(self,
- test_suite,
- test_name,
- path,
- tag='',
- put_tag_func=operator.add,
- working_directory=None,
- ld_library_path=None,
- profiling_library_path=None,
- cmd='',
- envp='',
- args='',
- name_appendix=''):
- self.test_suite = test_suite
- self.test_name = test_name
- self.path = path
- self.tag = tag
- self.put_tag_func = put_tag_func
- self.working_directory = working_directory
- self.ld_library_path = ld_library_path
- self.profiling_library_path = profiling_library_path
- self.cmd = cmd
- self.envp = envp
- self.args = args
- self.name_appendix = name_appendix
- self.filter_file = None
-
- def __str__(self):
- return self._GenerateDisplayName()
-
- def _GenerateDisplayName(self):
- '''Get a string of test name for display.
-
- The display name contains three parts: the original full test name, the
- name appendix which includes more info about the test run, and the
- tag(s) used by the test.
- '''
- return self.put_tag_func(self.full_name + self.name_appendix, self.tag)
-
- @property
- def name_appendix(self):
- return self._name_appendix
-
- @name_appendix.setter
- def name_appendix(self, name_appendix):
- self._name_appendix = name_appendix
-
- @property
- def full_name(self):
- '''Get a string that represents the test.
-
- Returns:
- A string test name in format '<test suite>.<test name>' if
- test_suite is not empty; '<test name>' otherwise
- '''
- return getattr(self, '_full_name', '{}.{}'.format(
- self.test_suite, self.test_name)
- if self.test_suite else self.test_name)
-
- @full_name.setter
- def full_name(self, full_name):
- self._full_name = full_name
-
- def GetRunCommand(self):
- '''Get the command to run the test.
-
- Returns:
- String, a command to run the test.
- '''
- working_directory = ('cd %s && ' % self.working_directory
- if self.working_directory else '')
-
- envp = 'env %s ' % self.envp if self.envp else ''
- ld_library_path = ('LD_LIBRARY_PATH=%s ' % self.ld_library_path
- if self.ld_library_path else '')
-
- if ld_library_path:
- envp = ('{}{}'.format(envp, ld_library_path)
- if envp else 'env %s ' % ld_library_path)
-
- args = ' %s' % self.args if self.args else ''
-
- return '{working_directory}{envp}{cmd}{args}'.format(
- working_directory=working_directory,
- envp=envp,
- cmd=self.cmd,
- args=args)
-
- @property
- def test_suite(self):
- '''Get test_suite'''
- return self._test_suite
-
- @test_suite.setter
- def test_suite(self, test_suite):
- '''Set test_suite'''
- self._test_suite = _SafeStrip(test_suite)
-
- @property
- def test_name(self):
- '''Get test_name'''
- return self._test_name
-
- @test_name.setter
- def test_name(self, test_name):
- '''Set test_name'''
- self._test_name = _SafeStrip(test_name)
-
- @property
- def path(self):
- '''Get path'''
- return self._path
-
- @path.setter
- def path(self, path):
- '''Set path'''
- self._path = _SafeStrip(path)
-
- @property
- def cmd(self):
- '''Get test command. If command is empty, path is returned.'''
- if not self._cmd:
- return self.path
-
- return self._cmd
-
- @cmd.setter
- def cmd(self, cmd):
- '''Set path'''
- self._cmd = _SafeStrip(cmd)
-
- @property
- def tag(self):
- '''Get tag'''
- return self._tag
-
- @tag.setter
- def tag(self, tag):
- '''Set tag'''
- self._tag = _SafeStrip(tag)
-
- @property
- def working_directory(self):
- '''Get working_directory'''
- return self._working_directory
-
- @working_directory.setter
- def working_directory(self, working_directory):
- '''Set working_directory'''
- self._working_directory = _SafeStrip(working_directory)
-
- @property
- def ld_library_path(self):
- '''Get ld_library_path'''
- return self._ld_library_path
-
- @ld_library_path.setter
- def ld_library_path(self, ld_library_path):
- '''Set ld_library_path'''
- self._ld_library_path = _SafeStrip(ld_library_path)
-
- @property
- def envp(self):
- '''Get envp'''
- return self._envp
-
- @envp.setter
- def envp(self, envp):
- '''Set env'''
- self._envp = _SafeStrip(envp)
-
- @property
- def args(self):
- '''Get args'''
- return self._args
-
- @args.setter
- def args(self, args):
- '''Set args'''
- self._args = _SafeStrip(args)
diff --git a/testcases/template/gtest_binary_test/__init__.py b/testcases/template/gtest_binary_test/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/testcases/template/gtest_binary_test/__init__.py
+++ /dev/null
diff --git a/testcases/template/gtest_binary_test/gtest_binary_test.py b/testcases/template/gtest_binary_test/gtest_binary_test.py
deleted file mode 100644
index ea47011..0000000
--- a/testcases/template/gtest_binary_test/gtest_binary_test.py
+++ /dev/null
@@ -1,319 +0,0 @@
-#
-# 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.
-#
-
-import logging
-import os
-import re
-import tempfile
-import xml.etree.ElementTree
-
-from vts.runners.host import asserts
-from vts.runners.host import const
-from vts.runners.host import keys
-from vts.runners.host import test_runner
-
-from vts.testcases.template.binary_test import binary_test
-from vts.testcases.template.binary_test import binary_test_case
-from vts.testcases.template.gtest_binary_test import gtest_test_case
-
-_GTEST_RESULT_ATTRIBUTE_ALLOW_LIST = ('properties',)
-
-
-class GtestBinaryTest(binary_test.BinaryTest):
- '''Base class to run gtests binary on target.
-
- Attributes:
- DEVICE_TEST_DIR: string, temp location for storing binary
- TAG_PATH_SEPARATOR: string, separator used to separate tag and path
- shell: ShellMirrorObject, shell mirror
- tags: all the tags that appeared in binary list
- testcases: list of GtestTestCase objects, list of test cases to run
- _dut: AndroidDevice, the device under test as config
- _gtest_results: list of GtestResult objects, used during batch mode
- for result storage and parsing
- '''
-
- # @Override
- def setUpClass(self):
- '''Prepare class, push binaries, set permission, create test cases.'''
- self.collect_tests_only = self.getUserParam(
- keys.ConfigKeys.IKEY_COLLECT_TESTS_ONLY, default_value=False)
- self.batch_mode = self.getUserParam(
- keys.ConfigKeys.IKEY_GTEST_BATCH_MODE, default_value=False)
-
- if self.batch_mode:
- if self.collect_tests_only:
- self.batch_mode = False
- logging.debug("Disable batch mode when collecting tests.")
- else:
- self._gtest_results = []
-
- super(GtestBinaryTest, self).setUpClass()
-
- # @Override
- def CreateTestCase(self, path, tag=''):
- '''Create a list of GtestTestCase objects from a binary path.
-
- Args:
- path: string, absolute path of a gtest binary on device
- tag: string, a tag that will be appended to the end of test name
-
- Returns:
- A list of GtestTestCase objects on success; an empty list otherwise.
- In non-batch mode, each object respresents a test case in the
- gtest binary located at the provided path. Usually there are more
- than one object returned.
- In batch mode, each object represents a gtest binary located at
- the provided path; the returned list will always be a one object
- list in batch mode. Test case names are stored in full_name
- property in the object, delimited by ':' according to gtest
- documentation, after being filtered and processed according to
- host configuration.
- '''
- working_directory = self.working_directory[
- tag] if tag in self.working_directory else None
- envp = self.envp[tag] if tag in self.envp else ''
- args = self.args[tag] if tag in self.args else ''
- ld_library_path = self.ld_library_path[
- tag] if tag in self.ld_library_path else None
- profiling_library_path = self.profiling_library_path[
- tag] if tag in self.profiling_library_path else None
-
- gtest_list_args = args + " --gtest_list_tests"
- list_test_case = binary_test_case.BinaryTestCase(
- 'gtest_list_tests',
- path,
- path,
- tag,
- self.PutTag,
- working_directory,
- ld_library_path,
- profiling_library_path,
- envp=envp,
- args=gtest_list_args)
- cmd = ['chmod 755 %s' % path, list_test_case.GetRunCommand()]
- cmd_results = self.shell.Execute(cmd)
- test_cases = []
- asserts.assertFalse(any(cmd_results[const.EXIT_CODE]),
- 'Failed to list test cases from %s. Command: %s, Result: %s.' %
- (path, cmd, cmd_results))
-
- test_suite = ''
- for line in cmd_results[const.STDOUT][1].split('\n'):
- line = str(line)
- if not len(line.strip()):
- continue
- elif line.startswith(' '): # Test case name
- test_name = line.split('#')[0].strip()
- # Skip any test that doesn't instantiate the parameterized gtest
- if re.match('UninstantiatedParamaterizedTestSuite<(.*)>', test_name):
- continue
- test_case = gtest_test_case.GtestTestCase(
- test_suite, test_name, path, tag, self.PutTag,
- working_directory, ld_library_path, profiling_library_path,
- envp=envp, args=args)
- logging.debug('Gtest test case: %s' % test_case)
- test_cases.append(test_case)
- else: # Test suite name
- test_suite = line.strip()
- if test_suite.endswith('.'):
- test_suite = test_suite[:-1]
-
- if not self.batch_mode:
- return test_cases
-
- # Gtest batch mode
- test_names = map(lambda test: test.full_name, test_cases)
-
- gtest_batch = gtest_test_case.GtestTestCase(
- path, '', path, tag, self.PutTag, working_directory,
- ld_library_path, profiling_library_path, envp=envp)
- gtest_batch.full_name = ':'.join(test_names)
- return [gtest_batch]
-
- # @Override
- def VerifyTestResult(self, test_case, command_results):
- '''Parse Gtest xml result output.
-
- Sample
- <testsuites tests="1" failures="1" disabled="0" errors="0"
- timestamp="2017-05-24T18:32:10" time="0.012" name="AllTests">
- <testsuite name="ConsumerIrHidlTest"
- tests="1" failures="1" disabled="0" errors="0" time="0.01">
- <testcase name="TransmitTest" status="run" time="0.01"
- classname="ConsumerIrHidlTest">
- <failure message="hardware/interfaces..." type="">
- <![CDATA[hardware/interfaces...]]>
- </failure>
- </testcase>
- </testsuite>
- </testsuites>
-
- Args:
- test_case: GtestTestCase object, the test being run. This param
- is not currently used in this method.
- command_results: dict of lists, shell command result
- '''
- asserts.assertTrue(command_results, 'Empty command response.')
- asserts.assertEqual(
- len(command_results), 3, 'Abnormal command response.')
- for item in command_results.values():
- asserts.assertEqual(
- len(item), 2,
- 'Abnormal command result length: %s' % command_results)
-
- for stderr in command_results[const.STDERR]:
- if stderr and stderr.strip():
- for line in stderr.split('\n'):
- logging.error(line)
-
- xml_str = command_results[const.STDOUT][1]
-
- if self.batch_mode:
- self._ParseBatchResults(test_case, xml_str)
- return
-
- asserts.assertFalse(
- command_results[const.EXIT_CODE][1],
- 'Failed to show Gtest XML output: %s' % command_results)
-
- root = self._ParseResultXmlString(xml_str)
- asserts.assertEqual(root.get('tests'), '1', 'No tests available')
- success = True
- if root.get('errors') != '0' or root.get('failures') != '0':
- messages = [x.get('message') for x in root.findall('.//failure')]
- success = False
-
- for stdout in command_results[const.STDOUT]:
- if stdout and stdout.strip():
- for line in stdout.split('\n'):
- if success:
- logging.debug(line)
- else:
- logging.error(line)
-
- if not success:
- asserts.fail('\n'.join([x for x in messages if x]))
-
- asserts.skipIf(root.get('disabled') == '1', 'Gtest test case disabled')
-
- def _ParseResultXmlString(self, xml_str):
- """Parses the xml result string into elements.
-
- Args:
- xml_str: string, result xml text content.
-
- Returns:
- xml.etree.ElementTree, parsed xml content.
-
- Raises:
- assertion failure if xml format is not expected.
- """
- asserts.assertTrue(xml_str is not None, 'Test command result not received.')
- xml_str = xml_str.strip()
- asserts.assertTrue(xml_str, 'Test command result is empty.')
-
- try:
- return xml.etree.ElementTree.fromstring(xml_str)
- except:
- asserts.fail('Result xml content is corrupted.')
-
- def _ParseBatchResults(self, test_case_original, xml_str):
- '''Parse batch mode gtest results
-
- Args:
- test_case_original: GtestTestCase object, original batch test case object
- xml_str: string, result xml output content
- '''
- root = self._ParseResultXmlString(xml_str)
-
- for test_suite in root:
- logging.debug('Test tag: %s, attribute: %s',
- test_suite.tag,
- test_suite.attrib)
- for test_case in test_suite:
- result = gtest_test_case.GtestTestCase(
- test_suite.get('name'),
- test_case.get('name'), '', test_case_original.tag,
- self.PutTag, name_appendix=test_case_original.name_appendix)
-
- failure_message = None
- for sub in test_case:
- if sub.tag == 'failure':
- failure_message = sub.get('message')
-
- test_case_filtered = filter(
- lambda sub: sub.tag not in _GTEST_RESULT_ATTRIBUTE_ALLOW_LIST, test_case)
- if len(test_case_filtered) and not failure_message:
- failure_message = 'Error: %s\n' % test_case.attrib
- for sub in test_case_filtered:
- failure_message += '%s: %s\n' % (sub.tag, sub.attrib)
-
- result.failure_message = failure_message
-
- self._gtest_results.append(result)
-
- def _VerifyBatchResult(self, gtest_result):
- '''Check a gtest test case result in batch mode
-
- Args:
- gtest_result: GtestTestCase object, representing gtest result
- '''
- asserts.assertFalse(gtest_result.failure_message,
- gtest_result.failure_message)
-
- # @Override
- def generateAllTests(self):
- '''Runs all binary tests.
-
- If the test cases should run in batch mode, this method executes the
- gtest commands without adding test records, and then parses the XML
- reports to records.
- If the test cases should run in batch mode but be skipped (e.g., HAL is
- not implemented), this method applies the filters in base_test, skips
- the batch test cases, and adds one record for each of them.
- '''
- if self.batch_mode and not self.isSkipAllTests():
- # TODO(b/126412742): Convert filters to --gtest_filter.
- for test_case in self.testcases:
- logging.info('Running %s test cases in batch.',
- len(test_case.full_name.split(':')))
- gtest_filter_flag=('--gtest_filter={test}').format(test = test_case)
- dst = '/data/local/tmp/filter_file'
- temp = tempfile.NamedTemporaryFile()
- try:
- temp.write(gtest_filter_flag)
- self._dut.adb.push('{src} {dst}'.format(src=temp.name, dst=dst))
- finally:
- temp.close()
- test_case.filter_file = dst
- self.RunTestCase(test_case)
-
- self.shell.Execute('rm %s' % dst)
- self.runGeneratedTests(
- test_func=self._VerifyBatchResult,
- settings=self._gtest_results,
- name_func=str)
-
- self._gtest_results = []
- return
-
- self.runGeneratedTests(
- test_func=self.RunTestCase, settings=self.testcases, name_func=str)
-
-
-if __name__ == "__main__":
- test_runner.main()
diff --git a/testcases/template/gtest_binary_test/gtest_test_case.py b/testcases/template/gtest_binary_test/gtest_test_case.py
deleted file mode 100644
index a6be4d8..0000000
--- a/testcases/template/gtest_binary_test/gtest_test_case.py
+++ /dev/null
@@ -1,115 +0,0 @@
-#
-# 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.
-#
-
-import logging
-import re
-import uuid
-
-from vts.runners.host import utils
-from vts.testcases.template.binary_test import binary_test_case
-from vts.utils.python.os import path_utils
-
-
-class GtestTestCase(binary_test_case.BinaryTestCase):
- '''A class to represent a gtest test case.
-
- Attributes:
- test_suite: string, test suite name
- test_name: string, test case name which does not include test suite
- path: string, absolute test binary path on device
- tag: string, test tag
- put_tag_func: function that takes a name and tag to output a combination
- output_file_path: string, gtest output xml path on device
- '''
-
- # @Override
- def GetRunCommand(self,
- output_file_path=None,
- test_name=None,
- raw_command=False):
- '''Get the command to run the test.
-
- Args:
- output_file_path: file to store the gtest results.
- test_name: name of the gtest test case.
- raw_command: whether to return raw command (without gtest_filter
- and gtest_output).
-
- Returns:
- List of strings
- '''
- if raw_command:
- return super(GtestTestCase, self).GetRunCommand()
-
- if output_file_path:
- self.output_file_path = output_file_path
- if not test_name:
- test_name = self.full_name
-
- gtest_filter_flag = ('--gtest_filter={test}').format(test=test_name)
- if self.filter_file:
- gtest_filter_flag='--gtest_flagfile=%s' % self.filter_file
-
- return [('{cmd} {filter_flag} '
- '--gtest_output=xml:{output_file_path}').format(
- cmd=super(GtestTestCase, self).GetRunCommand(),
- filter_flag = gtest_filter_flag,
- output_file_path=self.output_file_path),
- 'cat {output} && rm -rf {output}'.format(
- output=self.output_file_path)]
-
- @property
- def output_file_path(self):
- """Get output_file_path"""
- if not hasattr(self,
- '_output_file_path') or self._output_file_path is None:
- self.output_file_path = '{directory}/gtest_output_{name}.xml'.format(
- directory=path_utils.TargetDirName(self.path),
- name=re.sub(r'\W+', '_', str(self)))
- return self._output_file_path
-
- @output_file_path.setter
- def output_file_path(self, output_file_path):
- """Set output_file_path.
-
- Lengths of both file name and path will be checked. If longer than
- maximum allowance, file name will be set to a random name, and
- directory will be set to relative directory.
-
- Args:
- output_file_path: string, intended path of output xml file
- """
- output_file_path = path_utils.TargetNormPath(output_file_path.strip())
- output_base_name = path_utils.TargetBaseName(output_file_path)
- output_dir_name = path_utils.TargetDirName(output_file_path)
-
- if len(output_base_name) > utils.MAX_FILENAME_LEN:
- logging.warn(
- 'File name of output file "{}" is longer than {}.'.format(
- output_file_path, utils.MAX_FILENAME_LEN))
- output_base_name = '{}.xml'.format(uuid.uuid4())
- output_file_path = path_utils.JoinTargetPath(
- output_dir_name, output_base_name)
- logging.debug('Output file path is set as "%s".', output_file_path)
-
- if len(output_file_path) > utils.MAX_PATH_LEN:
- logging.warn(
- 'File path of output file "{}" is longer than {}.'.format(
- output_file_path, utils.MAX_PATH_LEN))
- output_file_path = output_base_name
- logging.debug('Output file path is set as "%s".', output_file_path)
-
- self._output_file_path = output_file_path
diff --git a/testcases/template/hal_hidl_gtest/__init__.py b/testcases/template/hal_hidl_gtest/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/testcases/template/hal_hidl_gtest/__init__.py
+++ /dev/null
diff --git a/testcases/template/hal_hidl_gtest/hal_hidl_gtest.py b/testcases/template/hal_hidl_gtest/hal_hidl_gtest.py
deleted file mode 100644
index 962414f..0000000
--- a/testcases/template/hal_hidl_gtest/hal_hidl_gtest.py
+++ /dev/null
@@ -1,256 +0,0 @@
-#
-# 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.
-#
-
-import copy
-import logging
-
-from vts.runners.host import const
-from vts.runners.host import keys
-from vts.runners.host import test_runner
-from vts.testcases.template.gtest_binary_test import gtest_binary_test
-from vts.testcases.template.gtest_binary_test import gtest_test_case
-from vts.utils.python.cpu import cpu_frequency_scaling
-from vts.utils.python.hal import hal_service_name_utils
-from vts.utils.python.precondition import precondition_utils
-
-# The pattern indicating a full hal test name including the service name info.
-# e.g. TM.TC(default)_32bit
-_HAL_TEST_NAME_PATTERN = ".*\(.*\).*"
-
-class HidlHalGTest(gtest_binary_test.GtestBinaryTest):
- """Base class to run a VTS target-side HIDL HAL test.
-
- Attributes:
- DEVICE_TEST_DIR: string, temp location for storing binary
- TAG_PATH_SEPARATOR: string, separator used to separate tag and path
- tags: all the tags that appeared in binary list
- testcases: list of GtestTestCase objects, list of test cases to run
- _cpu_freq: CpuFrequencyScalingController instance of a target device.
- _dut: AndroidDevice, the device under test as config
- _initial_test_case_cnt: Number of initial test cases.
- _target_hals: List of String, the targeting hal service of the test.
- e.g (["android.hardware.foo@1.0::IFoo"])
- """
-
- def setUpClass(self):
- """Checks precondition."""
- self._initial_test_case_cnt = 0
- super(HidlHalGTest, self).setUpClass()
- if not hasattr(self, "_target_hals"):
- self._target_hals = []
-
- opt_params = [keys.ConfigKeys.IKEY_SKIP_IF_THERMAL_THROTTLING,
- keys.ConfigKeys.IKEY_DISABLE_CPU_FREQUENCY_SCALING]
- self.getUserParams(opt_param_names=opt_params)
-
- self._skip_if_thermal_throttling = self.getUserParam(
- keys.ConfigKeys.IKEY_SKIP_IF_THERMAL_THROTTLING,
- default_value=False)
- self._disable_cpu_frequency_scaling = self.getUserParam(
- keys.ConfigKeys.IKEY_DISABLE_CPU_FREQUENCY_SCALING,
- default_value=True)
-
- if not self.isSkipAllTests():
- self._cpu_freq = cpu_frequency_scaling.CpuFrequencyScalingController(
- self._dut)
- if self._disable_cpu_frequency_scaling:
- logging.debug("Disabling CPU frequency scaling")
- self._cpu_freq.DisableCpuScaling()
- else:
- self._cpu_freq = None
-
- if not self.isSkipAllTests():
- ret = precondition_utils.CanRunHidlHalTest(
- self, self._dut, self.shell, self.run_as_compliance_test)
- if not ret:
- self.skipAllTests("HIDL HAL precondition check failed.")
-
- # Extend timeout if there are multiple service instance combinations.
- if (not self.isSkipAllTests() and self._initial_test_case_cnt and
- len(self.testcases) > self._initial_test_case_cnt):
- self.resetTimeout(self.timeout * len(self.testcases) /
- float(self._initial_test_case_cnt))
-
- if self.sancov.enabled and self._target_hals:
- self.sancov.InitializeDeviceCoverage(self._dut,
- self._target_hals)
- if self.coverage.enabled and self._target_hals:
- self.coverage.SetHalNames(self._target_hals)
- self.coverage.SetCoverageReportFilePrefix(self.test_module_name + self.abi_bitness)
- self.coverage.InitializeDeviceCoverage(self._dut)
-
- def CreateTestCases(self):
- """Create testcases and conditionally enable passthrough mode.
-
- Create testcases as defined in HidlHalGtest. If the passthrough option
- is provided in the configuration or if coverage is enabled, enable
- passthrough mode on the test environment.
- """
- super(HidlHalGTest, self).CreateTestCases()
-
- passthrough_opt = self.getUserParam(
- keys.ConfigKeys.IKEY_PASSTHROUGH_MODE, default_value=False)
-
- # Enable coverage if specified in the configuration.
- if passthrough_opt:
- self._EnablePassthroughMode()
-
- # @Override
- def CreateTestCase(self, path, tag=''):
- """Create a list of GtestTestCase objects from a binary path.
-
- Support testing against different service names by first executing a
- dummpy test case which lists all the registered hal services. Then
- query the service name(s) for each registered service with lshal.
- For each service name, create a new test case each with the service
- name as an additional argument.
-
- Args:
- path: string, absolute path of a gtest binary on device
- tag: string, a tag that will be appended to the end of test name
-
- Returns:
- A list of GtestTestCase objects.
- """
- initial_test_cases = super(HidlHalGTest, self).CreateTestCase(path,
- tag)
- self._initial_test_case_cnt += len(initial_test_cases)
- if not initial_test_cases:
- return initial_test_cases
- # first, run one test with --list_registered_services.
- list_service_test_case = copy.copy(initial_test_cases[0])
- list_service_test_case.args = " --list_registered_services"
- results = self.shell.Execute(
- list_service_test_case.GetRunCommand(raw_command=True))
- if (results[const.EXIT_CODE][0]):
- logging.error("Failed to list test cases from binary %s",
- list_service_test_case.path)
- # parse the results to get the registered service list.
- registered_services = []
- comb_mode = hal_service_name_utils.CombMode.FULL_PERMUTATION
- # TODO: consider to use a standard data format (e.g. json) instead of
- # parsing the print output.
- for line in results[const.STDOUT][0].split("\n"):
- line = str(line)
- if line.startswith("hal_service: "):
- service = line[len("hal_service: "):]
- registered_services.append(service)
- if line.startswith("service_comb_mode: "):
- comb_mode = int(line[len("service_comb_mode: "):])
-
- # If no service registered, return the initial test cases directly.
- if not registered_services:
- logging.error("No hal service registered.")
- return initial_test_cases
-
- self._target_hals = copy.copy(registered_services)
-
- # find the correponding service name(s) for each registered service and
- # store the mapping in dict service_instances.
- service_instances = {}
- for service in registered_services:
- testable, service_names = hal_service_name_utils.GetHalServiceName(
- self.shell, service, self.abi_bitness,
- self.run_as_compliance_test)
- if not testable:
- self.skipAllTests("Hal: %s is not testable, "
- "skip all tests." % service)
- return initial_test_cases
- if not service_names:
- self.skipAllTests("No service name found for: %s, skip all tests." % service)
- # If any of the test services are not available, return the
- # initial test cases directly.
- return initial_test_cases
- else:
- service_instances[service] = service_names
- logging.debug("registered service instances: %s", service_instances)
- logging.debug("service comb mode: %d", comb_mode)
-
- # If request NO_COMBINATION mode, return the initial test cases directly.
- if comb_mode == hal_service_name_utils.CombMode.NO_COMBINATION:
- return initial_test_cases
-
- # get all the combination of service instances.
- service_instance_combinations = hal_service_name_utils.GetServiceInstancesCombinations(
- registered_services, service_instances, comb_mode);
-
- new_test_cases = []
- appendix_list = []
- for instance_combination in service_instance_combinations:
- for test_case in initial_test_cases:
- new_test_case = copy.copy(test_case)
- service_name_list = []
- for instance in instance_combination:
- new_test_case.args += " --hal_service_instance=" + instance
- service_name_list.append(instance[instance.find('/')+1:])
- name_appendix = "({0})".format(",".join(service_name_list))
- new_test_case.name_appendix = name_appendix
- new_test_cases.append(new_test_case)
- appendix_list.append(name_appendix)
- self.test_filter.ExpandAppendix(appendix_list, _HAL_TEST_NAME_PATTERN)
- return new_test_cases
-
- def _EnablePassthroughMode(self):
- """Enable passthrough mode by setting getStub to true.
-
- This funciton should be called after super class' setupClass method.
- If called before setupClass, user_params will be changed in order to
- trigger setupClass method to invoke this method again.
- """
- if self.testcases:
- for test_case in self.testcases:
- envp = ' %s=true' % const.VTS_HAL_HIDL_GET_STUB
- test_case.envp += envp
- else:
- logging.warn('No test cases are defined yet. Maybe setupClass '
- 'has not been called. Changing user_params to '
- 'enable passthrough mode option.')
- self.user_params[keys.ConfigKeys.IKEY_PASSTHROUGH_MODE] = True
-
- def setUp(self):
- """Skips the test case if thermal throttling lasts for 30 seconds."""
- super(HidlHalGTest, self).setUp()
-
- if (self._skip_if_thermal_throttling and
- getattr(self, "_cpu_freq", None)):
- self._cpu_freq.SkipIfThermalThrottling(retry_delay_secs=30)
-
- def tearDown(self):
- """Skips the test case if there is thermal throttling."""
- if (self._skip_if_thermal_throttling and
- getattr(self, "_cpu_freq", None)):
- self._cpu_freq.SkipIfThermalThrottling()
-
- super(HidlHalGTest, self).tearDown()
-
- def tearDownClass(self):
- """Turns off CPU frequency scaling."""
- if (not self.isSkipAllTests() and getattr(self, "_cpu_freq", None)
- and self._disable_cpu_frequency_scaling):
- logging.debug("Enabling CPU frequency scaling")
- self._cpu_freq.EnableCpuScaling()
-
- if self.sancov.enabled and self._target_hals:
- self.sancov.FlushDeviceCoverage(self._dut, self._target_hals)
- self.sancov.ProcessDeviceCoverage(self._dut,
- self._target_hals)
- self.sancov.Upload()
-
- super(HidlHalGTest, self).tearDownClass()
-
-
-if __name__ == "__main__":
- test_runner.main()
diff --git a/testcases/template/hal_hidl_host_test/__init__.py b/testcases/template/hal_hidl_host_test/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/testcases/template/hal_hidl_host_test/__init__.py
+++ /dev/null
diff --git a/testcases/template/hal_hidl_host_test/hal_hidl_host_test.py b/testcases/template/hal_hidl_host_test/hal_hidl_host_test.py
deleted file mode 100644
index ff91d2b..0000000
--- a/testcases/template/hal_hidl_host_test/hal_hidl_host_test.py
+++ /dev/null
@@ -1,162 +0,0 @@
-#
-# 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.
-#
-import copy
-import logging
-
-from vts.runners.host import base_test
-from vts.testcases.template.param_test import param_test
-from vts.utils.python.controllers import android_device
-from vts.utils.python.hal import hal_service_name_utils
-from vts.utils.python.precondition import precondition_utils
-
-
-class HalHidlHostTest(param_test.ParamTestClass):
- """Base class to run a host-driver hidl hal test.
-
- Attributes:
- dut: AndroidDevice, the device under test as config
- shell: ShellMirrorObject, shell mirror
- TEST_HAL_SERVICES: a set of hal services accessed in the test.
- """
- TEST_HAL_SERVICES = set()
-
- # @Override
- def initParams(self):
- """Get the service combination according to the registered test HAL."""
- self.dut = self.android_devices[0]
- self.shell = self.dut.shell
- service_instance_combinations = self._GetServiceInstanceCombinations()
- self.params = service_instance_combinations
-
- # @Override
- def setUpClass(self):
- """Basic setup process for host-side hidl hal tests.
-
- Test precondition check, prepare for profiling and coverage measurement
- if enabled.
- """
- # Testability check.
- if not precondition_utils.CanRunHidlHalTest(
- self, self.dut, self.shell, self.run_as_compliance_test):
- self.skipAllTests("precondition check for hidl hal tests didn't pass")
- return
-
- # Initialization for coverage measurement.
- if self.coverage.enabled and self.coverage.global_coverage:
- self.coverage.InitializeDeviceCoverage(self.dut)
- if self.TEST_HAL_SERVICES:
- self.coverage.SetHalNames(self.TEST_HAL_SERVICES)
- self.coverage.SetCoverageReportFilePrefix(self.test_module_name + self.abi_bitness)
-
- # Enable profiling.
- if self.profiling.enabled:
- self.profiling.EnableVTSProfiling(self.shell)
-
- # @Override
- def tearDownClass(self):
- """Basic cleanup process for host-side hidl hal tests.
-
- If profiling is enabled for the test, collect the profiling data
- and disable profiling after the test is done.
- If coverage is enabled for the test, collect the coverage data and
- upload it to dashboard.
- """
- if self.isSkipAllTests():
- return
-
- if self.coverage.enabled and self.coverage.global_coverage:
- self.coverage.SetCoverageData(dut=self.dut, isGlobal=True)
-
- if self.profiling.enabled:
- self.profiling.ProcessAndUploadTraceData()
-
- # @Override
- def setUp(self):
- """Setup process for each test case."""
- if self.profiling.enabled:
- self.profiling.EnableVTSProfiling(self.shell)
-
- # @Override
- def tearDown(self):
- """Cleanup process for each test case."""
- if self.profiling.enabled:
- self.profiling.ProcessTraceDataForTestCase(self.dut)
- self.profiling.DisableVTSProfiling(self.shell)
-
- # @Override
- def getParamTag(self, param):
- """Concatenate names for all services passed as the param test tag.
-
- Args:
- param: a list of service instances. e.g [s1/n1, s2/n2]
-
- Returns:
- a string of concatenated service names. e.g. n1/n2
- """
- names = map(lambda instance: instance.split("/")[1], param)
- return "({})".format(",".join(names))
-
- def getHalServiceName(self, hal_service):
- """Get corresponding name for hal_service from the current parameter.
-
- The current parameter should be a list of service instances with the
- format [hal_service/name], e.g [s1/n1, s2/n2]
-
- Args:
- hal_service: string, hal@version e.g. foo@1.0
-
- Returns:
- Name for hal_service, "default" if could not find the hal_service in
- the list of service instances.
- """
- for instance in self.cur_param:
- service, name = instance.split("/")
- if service == hal_service:
- return str(name)
- # In case could not find the name for given hal_service, fall back to
- # use the "default" name.
- logging.warning(
- "Could not find the service name for %s, using default name instead",
- hal_service)
- return "default"
-
- def _GetServiceInstanceCombinations(self):
- """Create combinations of instances for registered HAL services.
-
- Returns:
- A list of instance combination for registered HAL.
- """
- registered_services = copy.copy(self.TEST_HAL_SERVICES)
- service_instances = {}
-
- for service in registered_services:
- testable, service_names = hal_service_name_utils.GetHalServiceName(
- self.shell, service, self.abi_bitness,
- self.run_as_compliance_test)
- if not testable:
- self.skipAllTests("Hal: %s is not testable, "
- "skip all tests." % service)
- return []
- if service_names:
- service_instances[service] = service_names
- else:
- self.skipAllTests("No service name found for: %s, "
- "skip all tests." % service)
- return []
- logging.info("registered service instances: %s", service_instances)
-
- return hal_service_name_utils.GetServiceInstancesCombinations(
- registered_services, service_instances)
diff --git a/testcases/template/hal_hidl_replay_test/__init__.py b/testcases/template/hal_hidl_replay_test/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/testcases/template/hal_hidl_replay_test/__init__.py
+++ /dev/null
diff --git a/testcases/template/hal_hidl_replay_test/hal_hidl_replay_test.py b/testcases/template/hal_hidl_replay_test/hal_hidl_replay_test.py
deleted file mode 100644
index e8575df..0000000
--- a/testcases/template/hal_hidl_replay_test/hal_hidl_replay_test.py
+++ /dev/null
@@ -1,238 +0,0 @@
-#
-# 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.
-#
-
-import logging
-import os
-
-from vts.runners.host import asserts
-from vts.runners.host import const
-from vts.runners.host import keys
-from vts.runners.host import test_runner
-from vts.testcases.template.binary_test import binary_test
-from vts.utils.python.hal import hal_service_name_utils
-from vts.utils.python.os import path_utils
-
-_HAL_TEST_NAME_PATTERN = ".*\(.*\).*"
-
-class HalHidlReplayTest(binary_test.BinaryTest):
- """Base class to run a HAL HIDL replay test on a target device.
-
- Attributes:
- _dut: AndroidDevice, the device under test as config
- DEVICE_TMP_DIR: string, target device's tmp directory path.
- DEVICE_VTS_SPEC_FILE_PATH: string, target device's directory for storing
- HAL spec files.
- """
-
- DEVICE_TMP_DIR = "/data/local/tmp"
- DEVICE_VTS_SPEC_FILE_PATH = "/data/local/tmp/spec"
- DEVICE_VTS_TRACE_FILE_PATH = "/data/local/tmp/vts_replay_trace"
-
- def setUpClass(self):
- """Prepares class and initializes a target device."""
- self._test_hal_services = set()
- super(HalHidlReplayTest, self).setUpClass()
-
- if self.isSkipAllTests():
- return
-
- # Extend timeout if there are multiple service instance combinations.
- if (len(self.trace_paths) and
- len(self.testcases) > len(self.trace_paths)):
- self.resetTimeout(self.timeout * len(self.testcases) /
- float(len(self.trace_paths)))
-
- if self.coverage.enabled and self._test_hal_services is not None:
- self.coverage.SetHalNames(self._test_hal_services)
-
- # @Override
- def CreateTestCases(self):
- """Create a list of HalHidlReplayTestCase objects."""
- required_params = [
- keys.ConfigKeys.IKEY_HAL_HIDL_REPLAY_TEST_TRACE_PATHS,
- keys.ConfigKeys.IKEY_ABI_BITNESS
- ]
- opt_params = [keys.ConfigKeys.IKEY_BINARY_TEST_DISABLE_FRAMEWORK]
- self.getUserParams(
- req_param_names=required_params, opt_param_names=opt_params)
- self.abi_bitness = str(self.abi_bitness)
- self.trace_paths = map(str, self.hal_hidl_replay_test_trace_paths)
-
- self.replayer_binary_path = path_utils.JoinTargetPath(
- self.DEVICE_TMP_DIR, self.abi_bitness,
- "vts_hal_replayer%s" % self.abi_bitness)
- self.custom_ld_library_path = path_utils.JoinTargetPath(
- self.DEVICE_TMP_DIR, self.abi_bitness)
-
- for trace_path in self.trace_paths:
- trace_file_name = str(os.path.basename(trace_path))
- target_trace_path = path_utils.JoinTargetPath(
- self.DEVICE_VTS_TRACE_FILE_PATH, trace_file_name)
- self._dut.adb.push(
- path_utils.JoinTargetPath(self.data_file_path,
- "hal-hidl-trace", trace_path),
- target_trace_path)
- service_instance_combinations = self._GetServiceInstanceCombinations(
- target_trace_path)
-
- appendix_list = []
- if service_instance_combinations:
- for instance_combination in service_instance_combinations:
- test_case = self.CreateReplayTestCase(
- trace_file_name, target_trace_path)
- service_name_list = []
- for instance in instance_combination:
- test_case.args += " --hal_service_instance=" + instance
- service_name_list.append(
- instance[instance.find('/') + 1:])
- name_appendix = "({0})".format(",".join(service_name_list))
- test_case.name_appendix = name_appendix
- self.testcases.append(test_case)
- appendix_list.append(name_appendix)
- self.test_filter.ExpandAppendix(appendix_list, _HAL_TEST_NAME_PATTERN)
- else:
- test_case = self.CreateReplayTestCase(trace_file_name,
- target_trace_path)
- self.testcases.append(test_case)
-
- def CreateReplayTestCase(self, trace_file_name, target_trace_path):
- """Create a replay test case object.
-
- Args:
- trace_file_name: string, name of the trace file used in the test.
- target_trace_path: string, full path of the trace file or the target device.
- """
- test_case = super(HalHidlReplayTest, self).CreateTestCase(
- self.replayer_binary_path, '')
- test_case.envp += "LD_LIBRARY_PATH=%s:$LD_LIBRARY_PATH" % self.custom_ld_library_path
- test_case.args += " --spec_dir_path=" + self.DEVICE_VTS_SPEC_FILE_PATH
- test_case.args += " " + target_trace_path
- test_case.test_name = "replay_test_" + trace_file_name
- return test_case
-
- def VerifyTestResult(self, test_case, command_results):
- """Parse Gtest xml result output.
-
- Args:
- test_case: BinaryTestCase object, the test being run. This param
- is not currently used in this method.
- command_results: dict of lists, shell command result
- """
- asserts.assertTrue(command_results, 'Empty command response.')
- asserts.assertEqual(
- len(command_results), 3, 'Abnormal command response.')
-
- for stdout in command_results[const.STDOUT]:
- if stdout and stdout.strip():
- for line in stdout.split('\n'):
- logging.debug(line)
-
- if any(command_results[const.EXIT_CODE]):
- # print stderr only when test fails.
- for stderr in command_results[const.STDERR]:
- if stderr and stderr.strip():
- for line in stderr.split('\n'):
- logging.error(line)
- asserts.fail(
- 'Test {} failed with the following results: {}'.format(
- test_case, command_results))
-
- def tearDownClass(self):
- """Performs clean-up tasks."""
- # Delete the pushed file.
- if not self.isSkipAllTests():
- for trace_path in self.trace_paths:
- trace_file_name = str(os.path.basename(trace_path))
- target_trace_path = path_utils.JoinTargetPath(
- self.DEVICE_TMP_DIR, "vts_replay_trace", trace_file_name)
- cmd_results = self.shell.Execute(
- "rm -f %s" % target_trace_path)
- if not cmd_results or any(cmd_results[const.EXIT_CODE]):
- logging.warning("Failed to remove: %s", cmd_results)
-
- super(HalHidlReplayTest, self).tearDownClass()
-
- def setUp(self):
- """Setup for code coverage for each test case."""
- super(HalHidlReplayTest, self).setUp()
- if self.coverage.enabled and not self.coverage.global_coverage:
- self.coverage.SetCoverageReportFilePrefix(
- self._current_record.test_name.replace('/', '_'))
- self.coverage.InitializeDeviceCoverage(self._dut)
-
- def tearDown(self):
- """Generate the coverage data for each test case."""
- if self.coverage.enabled and not self.coverage.global_coverage:
- self.coverage.SetCoverageData(dut=self._dut, isGlobal=False)
-
- super(HalHidlReplayTest, self).tearDown()
-
- def _GetServiceInstanceCombinations(self, trace_path):
- """Create all combinations of instances for all services recorded in
- the trace file.
-
- Args:
- trace_path: string, full path of a given trace file
- Returns:
- A list of all service instance combinations.
- """
- registered_services = []
- service_instances = {}
- self.shell.Execute("chmod 755 %s" % self.replayer_binary_path)
- results = self.shell.Execute(
- "LD_LIBRARY_PATH=%s:$LD_LIBRARY_PATH %s --list_service %s" %
- (self.custom_ld_library_path, self.replayer_binary_path,
- trace_path))
-
- asserts.assertFalse(
- results[const.EXIT_CODE][0],
- 'Failed to list test cases. EXIT_CODE: %s\n STDOUT: %s\n STDERR: %s\n'
- % (results[const.EXIT_CODE][0], results[const.STDOUT][0],
- results[const.STDERR][0]))
-
- # parse the results to get the registered service list.
- for line in results[const.STDOUT][0].split('\n'):
- line = str(line)
- if line.startswith('hal_service: '):
- service = line[len('hal_service: '):]
- registered_services.append(service)
-
- for service in registered_services:
- testable, service_names = hal_service_name_utils.GetHalServiceName(
- self.shell, service, self.abi_bitness,
- self.run_as_compliance_test)
- if not testable:
- self.skipAllTests("Hal: %s is not testable, "
- "skip all tests." % service)
- return []
- if service_names:
- service_instances[service] = service_names
- self._test_hal_services.add(service)
- else:
- self.skipAllTests("No service name found for: %s, "
- "skip all tests." % service)
- return []
- logging.info("registered service instances: %s", service_instances)
-
- service_instance_combinations = \
- hal_service_name_utils.GetServiceInstancesCombinations(
- registered_services, service_instances)
-
- return service_instance_combinations
-
-
-if __name__ == "__main__":
- test_runner.main()
diff --git a/testcases/template/host_binary_test/__init__.py b/testcases/template/host_binary_test/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/testcases/template/host_binary_test/__init__.py
+++ /dev/null
diff --git a/testcases/template/host_binary_test/host_binary_test.py b/testcases/template/host_binary_test/host_binary_test.py
deleted file mode 100644
index 4a63bdf..0000000
--- a/testcases/template/host_binary_test/host_binary_test.py
+++ /dev/null
@@ -1,61 +0,0 @@
-#
-# 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.
-#
-
-import logging
-import os
-import subprocess
-
-from vts.runners.host import asserts
-from vts.runners.host import base_test
-from vts.runners.host import keys
-from vts.runners.host import test_runner
-from vts.utils.python.common import cmd_utils
-
-
-class HostBinaryTest(base_test.BaseTestClass):
- """Base class to run a host-side, native binary test.
-
- Note that a host-side binary test is not highly recommended because
- such can be written in Python. Currently, this is used only for legacy
- host-side native tests. And all new host-side native tests should be
- written in Python or Java.
- """
-
- def setUpClass(self):
- """Retrieves the required param."""
- required_params = [keys.ConfigKeys.IKEY_BINARY_TEST_SOURCE]
- self.getUserParams(req_param_names=required_params)
-
- def testHostBinary(self):
- """Tests host-side binaries."""
- android_build_top = os.getenv("ANDROID_BUILD_TOP", "")
- asserts.assertTrue(
- android_build_top,
- "$ANDROID_BUILD_TOP is not set. Please run lunch <build target>")
-
- for binary_test_source in self.binary_test_source:
- binary_test_source = str(binary_test_source)
- binary_path = os.path.join(android_build_top, binary_test_source)
-
- cmd_result = cmd_utils.ExecuteShellCommand(binary_path)
- asserts.assertFalse(
- any(cmd_result[cmd_utils.EXIT_CODE]),
- "Test failed with the following results:\n "
- "command result: %s" % cmd_result)
-
-
-if __name__ == "__main__":
- test_runner.main()
diff --git a/testcases/template/llvmfuzzer_test/__init__.py b/testcases/template/llvmfuzzer_test/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/testcases/template/llvmfuzzer_test/__init__.py
+++ /dev/null
diff --git a/testcases/template/llvmfuzzer_test/llvmfuzzer_test.py b/testcases/template/llvmfuzzer_test/llvmfuzzer_test.py
deleted file mode 100644
index 6216e75..0000000
--- a/testcases/template/llvmfuzzer_test/llvmfuzzer_test.py
+++ /dev/null
@@ -1,259 +0,0 @@
-#
-# 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.
-#
-
-import logging
-import os
-
-from vts.runners.host import asserts
-from vts.runners.host import base_test
-from vts.runners.host import const
-from vts.runners.host import keys
-from vts.runners.host import test_runner
-from vts.utils.python.controllers import adb
-
-from vts.utils.python.common import list_utils
-from vts.utils.python.os import path_utils
-
-from vts.testcases.template.llvmfuzzer_test import llvmfuzzer_test_config as config
-
-
-class LLVMFuzzerTest(base_test.BaseTestClass):
- """Runs fuzzer tests on target.
-
- Attributes:
- _dut: AndroidDevice, the device under test as config
- _testcases: string list, list of testcases to run
- start_vts_agents: whether to start vts agents when registering new
- android devices.
- """
- start_vts_agents = False
-
- def setUpClass(self):
- """Creates a remote shell instance, and copies data files."""
- required_params = [
- keys.ConfigKeys.IKEY_DATA_FILE_PATH,
- config.ConfigKeys.FUZZER_CONFIGS
- ]
- self.getUserParams(required_params)
-
- self._testcases = map(lambda x: str(x), self.fuzzer_configs.keys())
-
- logging.debug("Testcases: %s", self._testcases)
- logging.debug("%s: %s", keys.ConfigKeys.IKEY_DATA_FILE_PATH,
- self.data_file_path)
- logging.debug("%s: %s", config.ConfigKeys.FUZZER_CONFIGS,
- self.fuzzer_configs)
-
- self._dut = self.android_devices[0]
- self._dut.adb.shell("mkdir %s -p" % config.FUZZER_TEST_DIR)
-
- def tearDownClass(self):
- """Deletes all copied data."""
- self._dut.adb.shell("rm -rf %s" % config.FUZZER_TEST_DIR)
-
- def PushFiles(self, testcase):
- """adb pushes testcase file to target.
-
- Args:
- testcase: string, path to executable fuzzer.
- """
- push_src = os.path.join(self.data_file_path, config.FUZZER_SRC_DIR,
- testcase)
- self._dut.adb.push("%s %s" % (push_src, config.FUZZER_TEST_DIR))
- logging.debug("Adb pushed: %s", testcase)
-
- def CreateFuzzerFlags(self, fuzzer_config):
- """Creates flags for the fuzzer executable.
-
- Args:
- fuzzer_config: dict, contains configuration for the fuzzer.
-
- Returns:
- string, command line flags for fuzzer executable.
- """
-
- def _SerializeVTSFuzzerParams(params):
- """Creates VTS command line flags for fuzzer executable.
-
- Args:
- params: dict, contains flags and their values.
-
- Returns:
- string, of form "--<flag0>=<val0> --<flag1>=<val1> ... "
- """
- VTS_SPEC_FILES = "vts_spec_files"
- VTS_EXEC_SIZE = "vts_exec_size"
- DELIMITER = ":"
-
- # vts_spec_files is a string list, will be serialized like this:
- # [a, b, c] -> "a:b:c"
- vts_spec_files = params.get(VTS_SPEC_FILES, {})
- target_vts_spec_files = DELIMITER.join(map(
- lambda x: path_utils.JoinTargetPath(config.FUZZER_SPEC_DIR, x),
- vts_spec_files))
- flags = "--%s=\"%s\" " % (VTS_SPEC_FILES, target_vts_spec_files)
-
- vts_exec_size = params.get(VTS_EXEC_SIZE, {})
- flags += "--%s=%s" % (VTS_EXEC_SIZE, vts_exec_size)
- return flags
-
- def _SerializeLLVMFuzzerParams(params):
- """Creates LLVM libfuzzer command line flags for fuzzer executable.
-
- Args:
- params: dict, contains flags and their values.
-
- Returns:
- string, of form "--<flag0>=<val0> --<flag1>=<val1> ... "
- """
- return " ".join(["-%s=%s" % (k, v) for k, v in params.items()])
-
- vts_fuzzer_params = fuzzer_config.get("vts_fuzzer_params", {})
-
- llvmfuzzer_params = config.FUZZER_PARAMS.copy()
- llvmfuzzer_params.update(fuzzer_config.get("llvmfuzzer_params", {}))
-
- vts_fuzzer_flags = _SerializeVTSFuzzerParams(vts_fuzzer_params)
- llvmfuzzer_flags = _SerializeLLVMFuzzerParams(llvmfuzzer_params)
-
- return vts_fuzzer_flags + " -- " + llvmfuzzer_flags
-
- def CreateCorpus(self, fuzzer, fuzzer_config):
- """Creates a corpus directory on target.
-
- Args:
- fuzzer: string, name of the fuzzer executable.
- fuzzer_config: dict, contains configuration for the fuzzer.
-
- Returns:
- string, path to corpus directory on the target.
- """
- corpus = fuzzer_config.get("corpus", [])
- corpus_dir = path_utils.JoinTargetPath(config.FUZZER_TEST_DIR,
- "%s_corpus" % fuzzer)
-
- self._dut.adb.shell("mkdir %s -p" % corpus_dir)
- for idx, corpus_entry in enumerate(corpus):
- corpus_entry = corpus_entry.replace("x", "\\x")
- corpus_entry_file = path_utils.JoinTargetPath(
- corpus_dir, "input%s" % idx)
- cmd = "echo -ne '%s' > %s" % (str(corpus_entry), corpus_entry_file)
- # Vts shell drive doesn't play nicely with escape characters,
- # so we use adb shell.
- self._dut.adb.shell("\"%s\"" % cmd)
-
- return corpus_dir
-
- def RunTestcase(self, fuzzer):
- """Runs the given testcase and asserts the result.
-
- Args:
- fuzzer: string, name of fuzzer executable.
- """
- self.PushFiles(fuzzer)
-
- fuzzer_config = self.fuzzer_configs.get(fuzzer, {})
- test_flags = self.CreateFuzzerFlags(fuzzer_config)
- corpus_dir = self.CreateCorpus(fuzzer, fuzzer_config)
-
- chmod_cmd = "chmod -R 755 %s" % path_utils.JoinTargetPath(
- config.FUZZER_TEST_DIR, fuzzer)
- self._dut.adb.shell(chmod_cmd)
-
- cd_cmd = "cd %s" % config.FUZZER_TEST_DIR
- ld_path = "LD_LIBRARY_PATH=/data/local/tmp/64:/data/local/tmp/32:$LD_LIBRARY_PATH"
- test_cmd = "./%s" % fuzzer
-
- fuzz_cmd = "%s && %s %s %s %s > /dev/null" % (cd_cmd, ld_path,
- test_cmd, corpus_dir,
- test_flags)
- logging.debug("Executing: %s", fuzz_cmd)
- # TODO(trong): vts shell doesn't handle timeouts properly, change this after it does.
- try:
- stdout = self._dut.adb.shell("'%s'" % fuzz_cmd)
- result = {
- const.STDOUT: stdout,
- const.STDERR: "",
- const.EXIT_CODE: 0
- }
- except adb.AdbError as e:
- result = {
- const.STDOUT: e.stdout,
- const.STDERR: e.stderr,
- const.EXIT_CODE: e.ret_code
- }
- self.AssertTestResult(fuzzer, result)
-
- def LogCrashReport(self, fuzzer):
- """Logs crash-causing fuzzer input.
-
- Reads the crash report file and logs the contents in format:
- "\x01\x23\x45\x67\x89\xab\xcd\xef"
-
- Args:
- fuzzer: string, name of fuzzer executable.
- """
- cmd = "xxd -p %s" % config.FUZZER_TEST_CRASH_REPORT
-
- # output is string of a hexdump from crash report file.
- # From the example above, output would be "0123456789abcdef".
- output = self._dut.adb.shell(cmd)
- remove_chars = ["\r", "\t", "\n", " "]
- for char in remove_chars:
- output = output.replace(char, "")
-
- crash_report = ""
- # output is guaranteed to be even in length since its a hexdump.
- for offset in xrange(0, len(output), 2):
- crash_report += "\\x%s" % output[offset:offset + 2]
-
- logging.debug('FUZZER_TEST_CRASH_REPORT for %s: "%s"', fuzzer,
- crash_report)
-
- # TODO(trong): differentiate between crashes and sanitizer rule violations.
- def AssertTestResult(self, fuzzer, result):
- """Asserts that testcase finished as expected.
-
- Checks that device is in responsive state. If not, waits for boot
- then reports test as failure. If it is, asserts that all test commands
- returned exit code 0.
-
- Args:
- fuzzer: string, name of fuzzer executable.
- result: dict(str, str, int), command results from shell.
- """
- logging.debug("Test result: %s" % result)
- if not self._dut.hasBooted():
- self._dut.waitForBootCompletion()
- asserts.fail("%s left the device in unresponsive state." % fuzzer)
-
- exit_code = result[const.EXIT_CODE]
- if exit_code == config.ExitCode.FUZZER_TEST_FAIL:
- self.LogCrashReport(fuzzer)
- asserts.fail("%s failed normally." % fuzzer)
- elif exit_code != config.ExitCode.FUZZER_TEST_PASS:
- asserts.fail("%s failed abnormally." % fuzzer)
-
- def generateFuzzerTests(self):
- """Runs fuzzer tests."""
- self.runGeneratedTests(
- test_func=self.RunTestcase,
- settings=self._testcases,
- name_func=lambda x: x.split("/")[-1])
-
-
-if __name__ == "__main__":
- test_runner.main()
diff --git a/testcases/template/llvmfuzzer_test/llvmfuzzer_test_config.py b/testcases/template/llvmfuzzer_test/llvmfuzzer_test_config.py
deleted file mode 100644
index a38c5af..0000000
--- a/testcases/template/llvmfuzzer_test/llvmfuzzer_test_config.py
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-# 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.
-#
-
-class ConfigKeys(object):
- FUZZER_CONFIGS = "fuzzer_configs"
-
-class ExitCode(object):
- """Exit codes for test binaries."""
- FUZZER_TEST_PASS = 0
- FUZZER_TEST_FAIL = 77
-
-# Directory on the target where the tests are copied.
-FUZZER_TEST_DIR = "/data/local/tmp/llvmfuzzer_test"
-
-# Directory on the target where VTS specs are copied.
-FUZZER_SPEC_DIR = "/data/local/tmp/spec"
-
-# Directory under data_file_path on the host where fuzzer executables are.
-FUZZER_SRC_DIR = "DATA/bin"
-
-# File used to save crash-causing fuzzer input.
-FUZZER_TEST_CRASH_REPORT = FUZZER_TEST_DIR + "/crash_report"
-
-# Default parameters that will be passed to fuzzer executable.
-FUZZER_PARAMS = {
- "max_len": 100,
- "max_total_time": 60,
- "exact_artifact_path": FUZZER_TEST_CRASH_REPORT
-}
-
diff --git a/testcases/template/param_test/__init__.py b/testcases/template/param_test/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/testcases/template/param_test/__init__.py
+++ /dev/null
diff --git a/testcases/template/param_test/param_test.py b/testcases/template/param_test/param_test.py
deleted file mode 100644
index 9e0e470..0000000
--- a/testcases/template/param_test/param_test.py
+++ /dev/null
@@ -1,105 +0,0 @@
-#
-# Copyright (C) 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.
-#
-
-import logging
-
-from vts.runners.host import base_test
-from vts.runners.host import records
-from vts.runners.host import test_runner
-
-
-class ParamTestClass(base_test.BaseTestClass):
- """Base class to run a parameterized test.
-
- A parameterized test is a test with a set of parameters and the test will be
- run against each parameter. This allows to test logic with different
- parameters without without writing multiple copies of the same test.
-
- An example use case of parameterized test is service name aware HAL testing
- which we expect to run the same test logic against all service instances
- through their corresponding service names. e.g to test graphics.composer HAL
- against two different instance: default and vr.
-
- Attributes:
- params: list, a list of parameters for test run.
- cur_param: the parameter used for the current run.
- """
-
- def __init__(self, configs):
- super(ParamTestClass, self).__init__(configs)
- self.initParams()
-
- def initParams(self):
- """Initialize test parameters. Expected to be overridden by a subclass."""
- self._params = []
-
- def getParamTag(self, param):
- """Get the test tag used to attach with test name from the parameter.
-
- expected to be overridden by a subclass.
-
- Args:
- param: the current test parameter.
- """
- return str(param)
-
- @property
- def params(self):
- """Get params"""
- return self._params
-
- @params.setter
- def params(self, params):
- """Set params"""
- self._params = params
-
- @property
- def cur_param(self):
- """Get cur_param"""
- return self._cur_param
-
- @cur_param.setter
- def cur_param(self, cur_param):
- """Set cur_param"""
- self._cur_param = cur_param
-
- def run(self, test_names=None):
- """Run a parameterized test.
-
- For each parameter initialized for the test, runs test cases within
- this test class against that parameter.
-
- Args:
- test_names: A list of string that are test case names requested in
- cmd line.
-
- Returns:
- The test results object of this class.
- """
- logging.info("==========> %s <==========", self.test_module_name)
- original_tests = self.getTests(test_names)
- # Run the set of original tests against each parameter.
- for param in self.params:
- self.cur_param = param
- tests = [(str(test_name + self.getParamTag(param)), test_func)
- for (test_name, test_func) in original_tests]
- if not self.run_as_vts_self_test:
- self.results.requested = [
- records.TestResultRecord(test_name, self.test_module_name)
- for test_name, _ in tests
- ]
- self.runTestsWithRetry(tests)
- return self.results
diff --git a/testcases/host/fastboot_getvar/Android.bp b/tests/fastboot_getvar/Android.bp
similarity index 100%
rename from testcases/host/fastboot_getvar/Android.bp
rename to tests/fastboot_getvar/Android.bp
diff --git a/testcases/host/fastboot_getvar/AndroidTest.xml b/tests/fastboot_getvar/AndroidTest.xml
similarity index 100%
rename from testcases/host/fastboot_getvar/AndroidTest.xml
rename to tests/fastboot_getvar/AndroidTest.xml
diff --git a/testcases/host/fastboot_getvar/OWNERS b/tests/fastboot_getvar/OWNERS
similarity index 80%
rename from testcases/host/fastboot_getvar/OWNERS
rename to tests/fastboot_getvar/OWNERS
index 0427b50..fd9883a 100644
--- a/testcases/host/fastboot_getvar/OWNERS
+++ b/tests/fastboot_getvar/OWNERS
@@ -2,4 +2,3 @@
dvander@google.com
bowgotsai@google.com
elsk@google.com
-smuckle@google.com
diff --git a/testcases/host/fastboot_getvar/src/com/android/tests/FastbootGetvarUserspaceTest.java b/tests/fastboot_getvar/src/com/android/tests/FastbootGetvarUserspaceTest.java
similarity index 98%
rename from testcases/host/fastboot_getvar/src/com/android/tests/FastbootGetvarUserspaceTest.java
rename to tests/fastboot_getvar/src/com/android/tests/FastbootGetvarUserspaceTest.java
index 806c27d..16d87a3 100644
--- a/testcases/host/fastboot_getvar/src/com/android/tests/FastbootGetvarUserspaceTest.java
+++ b/tests/fastboot_getvar/src/com/android/tests/FastbootGetvarUserspaceTest.java
@@ -114,7 +114,7 @@
@Test
public void testCpuAbiInfo() throws Exception {
final HashSet<String> allCpuAbis = new HashSet<String>(
- Arrays.asList("armeabi-v7a", "arm64-v8a", "mips", "mips64", "x86", "x86_64"));
+ Arrays.asList("armeabi-v7a", "arm64-v8a", "riscv64", "x86", "x86_64"));
String cpuAbi = getTestInformation().getDevice().getFastbootVariable("cpu-abi");
CLog.d("cpuAbi: '%s'", cpuAbi);
assertTrue(allCpuAbis.contains(cpuAbi));
diff --git a/testcases/host/fastboot_test/Android.bp b/tests/fastboot_test/Android.bp
similarity index 100%
rename from testcases/host/fastboot_test/Android.bp
rename to tests/fastboot_test/Android.bp
diff --git a/testcases/host/fastboot_test/AndroidTest.xml b/tests/fastboot_test/AndroidTest.xml
similarity index 100%
rename from testcases/host/fastboot_test/AndroidTest.xml
rename to tests/fastboot_test/AndroidTest.xml
diff --git a/testcases/host/fastboot_test/OWNERS b/tests/fastboot_test/OWNERS
similarity index 75%
rename from testcases/host/fastboot_test/OWNERS
rename to tests/fastboot_test/OWNERS
index d82cb64..6900bb8 100644
--- a/testcases/host/fastboot_test/OWNERS
+++ b/tests/fastboot_test/OWNERS
@@ -1,4 +1,3 @@
# Bug component: 30545
dvander@google.com
elsk@google.com
-smuckle@google.com
diff --git a/testcases/host/fastboot_test/src/com/android/tests/FastbootVerifyUserspaceTest.java b/tests/fastboot_test/src/com/android/tests/FastbootVerifyUserspaceTest.java
similarity index 100%
rename from testcases/host/fastboot_test/src/com/android/tests/FastbootVerifyUserspaceTest.java
rename to tests/fastboot_test/src/com/android/tests/FastbootVerifyUserspaceTest.java
diff --git a/testcases/host/firmware_dtbo_test/Android.bp b/tests/firmware_dtbo_test/Android.bp
similarity index 93%
rename from testcases/host/firmware_dtbo_test/Android.bp
rename to tests/firmware_dtbo_test/Android.bp
index 5a65226..1a6d7ef 100644
--- a/testcases/host/firmware_dtbo_test/Android.bp
+++ b/tests/firmware_dtbo_test/Android.bp
@@ -21,7 +21,6 @@
libs: [
"compatibility-tradefed",
"tradefed",
- "vts-core-tradefed-harness",
],
srcs: ["src/**/*.java"],
test_suites: [
@@ -29,7 +28,7 @@
"vts",
],
data_native_bins: [
- "mkdtboimg.py",
+ "mkdtboimg",
],
target_required: ["ufdt_verify_overlay"],
}
diff --git a/testcases/host/firmware_dtbo_test/AndroidTest.xml b/tests/firmware_dtbo_test/AndroidTest.xml
similarity index 96%
rename from testcases/host/firmware_dtbo_test/AndroidTest.xml
rename to tests/firmware_dtbo_test/AndroidTest.xml
index 86b2681..5451d32 100644
--- a/testcases/host/firmware_dtbo_test/AndroidTest.xml
+++ b/tests/firmware_dtbo_test/AndroidTest.xml
@@ -21,7 +21,6 @@
<target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer" />
<target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
- <option name="cleanup" value="false" />
<option name="push" value="ufdt_verify_overlay->/data/local/tmp/ufdt_verify_overlay" />
</target_preparer>
diff --git a/tests/firmware_dtbo_test/OWNERS b/tests/firmware_dtbo_test/OWNERS
new file mode 100644
index 0000000..245e64e
--- /dev/null
+++ b/tests/firmware_dtbo_test/OWNERS
@@ -0,0 +1,2 @@
+# Bug component: 30545
+vmartensson@google.com
diff --git a/testcases/host/firmware_dtbo_test/src/com/android/tests/firmwaredtbo/FirmwareDtboVerification.java b/tests/firmware_dtbo_test/src/com/android/tests/firmwaredtbo/FirmwareDtboVerification.java
similarity index 98%
rename from testcases/host/firmware_dtbo_test/src/com/android/tests/firmwaredtbo/FirmwareDtboVerification.java
rename to tests/firmware_dtbo_test/src/com/android/tests/firmwaredtbo/FirmwareDtboVerification.java
index 76607f9..de8069a 100644
--- a/testcases/host/firmware_dtbo_test/src/com/android/tests/firmwaredtbo/FirmwareDtboVerification.java
+++ b/tests/firmware_dtbo_test/src/com/android/tests/firmwaredtbo/FirmwareDtboVerification.java
@@ -62,8 +62,8 @@
private static final int COMPRESSION_FLAGS_BIT_MASK = 0x0f;
// FDT Magic.
private static final int FDT_MAGIC = 0xd00dfeed;
- // mkdtboimg.py tool name
- private static final String MKDTBOIMG_TOOL = "mkdtboimg.py";
+ // mkdtboimg tool name
+ private static final String MKDTBOIMG_TOOL = "mkdtboimg";
private static File mTemptFolder = null;
private ITestDevice mDevice;
@@ -91,7 +91,7 @@
mTemptFolder.delete();
}
- /* Validates DTBO partition using mkdtboimg.py */
+ /* Validates DTBO partition using mkdtboimg */
@Test
public void testCheckDTBOPartition() throws Exception {
// Dump dtbo image from device.
@@ -109,7 +109,7 @@
Assert.assertTrue("Pull " + dtboPaths.get(0) + " failed!",
mDevice.pullFile(dtboPaths.get(0), hostDtboImage));
CLog.d("hostDtboImage is %s", hostDtboImage);
- // Using mkdtboimg.py to extract dtbo image.
+ // Using mkdtboimg to extract dtbo image.
File mkdtboimgBin = getTestInformation().getDependencyFile(MKDTBOIMG_TOOL, false);
File unpackedDtbo = new File(mTemptFolder, "dumped_dtbo");
RunUtil runUtil = new RunUtil();
diff --git a/testcases/host/firmware_test/Android.bp b/tests/firmware_test/Android.bp
similarity index 95%
rename from testcases/host/firmware_test/Android.bp
rename to tests/firmware_test/Android.bp
index 0ee6e66..bff7b76 100644
--- a/testcases/host/firmware_test/Android.bp
+++ b/tests/firmware_test/Android.bp
@@ -21,7 +21,6 @@
libs: [
"compatibility-tradefed",
"tradefed",
- "vts-core-tradefed-harness",
],
srcs: ["src/**/*.java"],
test_suites: [
diff --git a/testcases/host/firmware_test/AndroidTest.xml b/tests/firmware_test/AndroidTest.xml
similarity index 100%
rename from testcases/host/firmware_test/AndroidTest.xml
rename to tests/firmware_test/AndroidTest.xml
diff --git a/testcases/host/firmware_test/OWNERS b/tests/firmware_test/OWNERS
similarity index 69%
rename from testcases/host/firmware_test/OWNERS
rename to tests/firmware_test/OWNERS
index 6c6bae8..2f0c279 100644
--- a/testcases/host/firmware_test/OWNERS
+++ b/tests/firmware_test/OWNERS
@@ -1,3 +1,2 @@
# Bug component: 30545
-smuckle@google.com
yochiang@google.com
diff --git a/testcases/host/firmware_test/src/com/android/tests/firmware/BootImageInfo.java b/tests/firmware_test/src/com/android/tests/firmware/BootImageInfo.java
similarity index 100%
rename from testcases/host/firmware_test/src/com/android/tests/firmware/BootImageInfo.java
rename to tests/firmware_test/src/com/android/tests/firmware/BootImageInfo.java
diff --git a/testcases/host/firmware_test/src/com/android/tests/firmware/FirmwareBootHeaderVerification.java b/tests/firmware_test/src/com/android/tests/firmware/FirmwareBootHeaderVerification.java
similarity index 100%
rename from testcases/host/firmware_test/src/com/android/tests/firmware/FirmwareBootHeaderVerification.java
rename to tests/firmware_test/src/com/android/tests/firmware/FirmwareBootHeaderVerification.java
diff --git a/testcases/host/selinux_test/Android.bp b/tests/gpu_test/Android.bp
similarity index 86%
copy from testcases/host/selinux_test/Android.bp
copy to tests/gpu_test/Android.bp
index 69eaa52..47b67be 100644
--- a/testcases/host/selinux_test/Android.bp
+++ b/tests/gpu_test/Android.bp
@@ -1,4 +1,4 @@
-// Copyright (C) 2020 The Android Open Source Project
+// Copyright (C) 2023 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.
@@ -17,11 +17,11 @@
}
java_test_host {
- name: "KernelSelinuxFileApiTest",
+ name: "VtsGpuTests",
libs: [
"compatibility-tradefed",
"tradefed",
- "vts-core-tradefed-harness"
+ "compatibility-host-util",
],
srcs: ["src/**/*.java"],
test_suites: [
diff --git a/testcases/fuzz/lib_bionic/LibBionicLibmFuzzTest.xml b/tests/gpu_test/AndroidTest.xml
similarity index 63%
rename from testcases/fuzz/lib_bionic/LibBionicLibmFuzzTest.xml
rename to tests/gpu_test/AndroidTest.xml
index fd2de7d..ee8d9ae 100644
--- a/testcases/fuzz/lib_bionic/LibBionicLibmFuzzTest.xml
+++ b/tests/gpu_test/AndroidTest.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2016 The Android Open Source Project
+<!-- Copyright (C) 2023 Google LLC.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -13,9 +13,10 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<configuration description="Runs VTS multi device test">
- <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
- <option name="test-case-path" value="vts/testcases/host/sample/SampleLightTest" />
- <option name="test-config-path" value="vts/testcases/host/sample/SampleLightTest.config" />
+<configuration description="Config for VTS GPU test cases">
+ <option name="test-suite-tag" value="vts" />
+ <option name="config-descriptor:metadata" key="component" value="gpu" />
+ <test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
+ <option name="jar" value="VtsGpuTests.jar" />
</test>
</configuration>
diff --git a/tests/gpu_test/OWNERS b/tests/gpu_test/OWNERS
new file mode 100644
index 0000000..d599d91
--- /dev/null
+++ b/tests/gpu_test/OWNERS
@@ -0,0 +1,8 @@
+# Bug template url: https://b.corp.google.com/issues/new?component=122570&template=195524
+cclao@google.com
+chrisforbes@google.com
+cnorthrop@google.com
+ianelliott@google.com
+lpy@google.com
+vantablack@google.com
+chrisglover@google.com
diff --git a/tests/gpu_test/src/com/android/gpu/vts/Build.java b/tests/gpu_test/src/com/android/gpu/vts/Build.java
new file mode 100644
index 0000000..8b6ad52
--- /dev/null
+++ b/tests/gpu_test/src/com/android/gpu/vts/Build.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2023 Google Inc.
+ *
+ * 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 com.android.gpu.vts;
+
+public class Build {
+ public static final int CUR_DEVELOPMENT = 10000;
+ public static final int BASE = 1;
+ public static final int BASE_1_1 = 2;
+ public static final int CUPCAKE = 3;
+ public static final int DONUT = 4;
+ public static final int ECLAIR = 5;
+ public static final int ECLAIR_0_1 = 6;
+ public static final int ECLAIR_MR1 = 7;
+ public static final int FROYO = 8;
+ public static final int GINGERBREAD = 9;
+ public static final int GINGERBREAD_MR1 = 10;
+ public static final int HONEYCOMB = 11;
+ public static final int HONEYCOMB_MR1 = 12;
+ public static final int HONEYCOMB_MR2 = 13;
+ public static final int ICE_CREAM_SANDWICH = 14;
+ public static final int ICE_CREAM_SANDWICH_MR1 = 15;
+ public static final int JELLY_BEAN = 16;
+ public static final int JELLY_BEAN_MR1 = 17;
+ public static final int JELLY_BEAN_MR2 = 18;
+ public static final int KITKAT = 19;
+ public static final int KITKAT_WATCH = 20;
+ public static final int LOLLIPOP = 21;
+ public static final int LOLLIPOP_MR1 = 22;
+ public static final int M = 23;
+ public static final int NYC = 24;
+ public static final int NYC_MR1 = 25;
+ public static final int OC = 26;
+ public static final int OC_MR1 = 27;
+ public static final int PI = 28;
+ public static final int QT = 29; // provisional
+ public static final int RVC = 30; // provisional
+ public static final int SC = 31; // provisional
+ public static final int SC_V2 = 32; // provisional
+ public static final int TM = 33; // provisional
+ public static final int UDC = 34; // provisional
+}
diff --git a/tests/gpu_test/src/com/android/gpu/vts/GpuProfilingTest.java b/tests/gpu_test/src/com/android/gpu/vts/GpuProfilingTest.java
new file mode 100644
index 0000000..b6d5a1d
--- /dev/null
+++ b/tests/gpu_test/src/com/android/gpu/vts/GpuProfilingTest.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2023 Google LLC.
+ *
+ * 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 com.android.gpu.vts;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeFalse;
+import static org.junit.Assume.assumeTrue;
+
+import com.android.compatibility.common.util.ApiLevelUtil;
+import com.android.compatibility.common.util.GmsTest;
+import com.android.compatibility.common.util.PropertyUtil;
+import com.android.compatibility.common.util.VsrTest;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * VTS test for GPU profiling requirements.
+ */
+@RunWith(DeviceJUnit4ClassRunner.class)
+public class GpuProfilingTest extends BaseHostJUnit4Test {
+ private static final int VK_PHYSICAL_DEVICE_TYPE_CPU = 4;
+ private static final int VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU = 3;
+
+ private JSONObject[] mVulkanDevices;
+
+ /**
+ * Test specific setup
+ */
+ @Before
+ public void setUp() throws Exception {
+ final String output = getDevice().executeShellCommand("cmd gpu vkjson");
+ final JSONArray vkjson;
+ // vkjson output in Android N is JSONArray.
+ if (ApiLevelUtil.isBefore(getDevice(), Build.OC)) {
+ vkjson = (new JSONArray(output));
+ } else {
+ vkjson = (new JSONObject(output)).getJSONArray("devices");
+ }
+ mVulkanDevices = new JSONObject[vkjson.length()];
+ for (int i = 0; i < vkjson.length(); i++) {
+ mVulkanDevices[i] = vkjson.getJSONObject(i);
+ }
+ }
+
+ /**
+ * Devices launched in Android 12 and beyond must support GPU profiling.
+ */
+ @VsrTest(requirements = {"VSR-5.1-002"})
+ @Test
+ public void checkGpuProfilingRequirements() throws Exception {
+ final int apiLevel = Util.getVendorApiLevelOrFirstProductApiLevel(getDevice());
+
+ // Only test for 64-bits devices launched in Android 12 and above.
+ assumeTrue("Test does not apply for API level lower than S", apiLevel >= Build.SC);
+ assumeTrue("Test does not apply for 32-bits devices",
+ getDevice().getProperty("ro.product.cpu.abi").contains("64"));
+ assumeTrue("Test does not apply for non-handheld devices", Util.isHandheld(getDevice()));
+ assumeFalse(
+ "Test does not apply for devices with only CPU Vulkan support", hasOnlyCpuDevice());
+ assumeFalse("Test does not apply for devices with only virtual GPU Vulkan support",
+ hasOnlyVirtualGpuDevice());
+
+ assertTrue("API level S must support GPU profiling",
+ PropertyUtil.propertyEquals(getDevice(), "graphics.gpu.profiler.support", "true"));
+ }
+
+ private boolean hasOnlyCpuDevice() throws Exception {
+ for (JSONObject device : mVulkanDevices) {
+ if (device.getJSONObject("properties").getInt("deviceType")
+ != VK_PHYSICAL_DEVICE_TYPE_CPU) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean hasOnlyVirtualGpuDevice() throws Exception {
+ for (JSONObject device : mVulkanDevices) {
+ if (device.getJSONObject("properties").getInt("deviceType")
+ != VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
diff --git a/tests/gpu_test/src/com/android/gpu/vts/OpenGlEsTest.java b/tests/gpu_test/src/com/android/gpu/vts/OpenGlEsTest.java
new file mode 100644
index 0000000..b7cdbf8
--- /dev/null
+++ b/tests/gpu_test/src/com/android/gpu/vts/OpenGlEsTest.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2023 Google LLC.
+ *
+ * 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 com.android.gpu.vts;
+
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
+
+import com.android.compatibility.common.util.VsrTest;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * VTS test for OpenGL ES requirements.
+ */
+@RunWith(DeviceJUnit4ClassRunner.class)
+public class OpenGlEsTest extends BaseHostJUnit4Test {
+ /**
+ * Verify that FEATURE_OPENGLES_DEQP_LEVEL (feature:android.software.opengles.deqp.level) has a
+ * sufficiently high version in relation to the vendor and first product API level.
+ */
+ @VsrTest(requirements = {"VSR-5.1-001", "VSR-5.1-003"})
+ @Test
+ public void checkOpenGlEsDeqpLevelIsHighEnough() throws Exception {
+ final int apiLevel = Util.getVendorApiLevelOrFirstProductApiLevel(getDevice());
+
+ assumeTrue("Test does not apply for API level lower than S", apiLevel >= Build.SC);
+
+ // Map from API level to required dEQP level.
+ final int requiredOpenGlEsDeqpLevel;
+ switch (apiLevel) {
+ case Build.SC:
+ case Build.SC_V2:
+ requiredOpenGlEsDeqpLevel = VulkanTest.DEQP_LEVEL_FOR_S;
+ break;
+ case Build.TM:
+ requiredOpenGlEsDeqpLevel = VulkanTest.DEQP_LEVEL_FOR_T;
+ break;
+ case Build.UDC:
+ requiredOpenGlEsDeqpLevel = VulkanTest.DEQP_LEVEL_FOR_T;
+ break;
+ default:
+ fail("Test should only run for API levels: S, Sv2, T, ...");
+ return;
+ }
+
+ // Check that the feature flag is present and its value is at least the required dEQP level.
+ final String output = getDevice().executeShellCommand(
+ String.format("pm has-feature android.software.opengles.deqp.level %d",
+ requiredOpenGlEsDeqpLevel));
+
+ if (!output.trim().equals("true")) {
+ final String message = String.format(
+ "Advertised GLES dEQP level feature is too low or does not exist.\n"
+ + "Expected:\nfeature:android.software.opengles.deqp.level>=%d\n"
+ + "Actual:\n%s",
+ requiredOpenGlEsDeqpLevel,
+ getDevice().executeShellCommand("pm list features | grep deqp"));
+
+ fail(message);
+ }
+ }
+}
diff --git a/tests/gpu_test/src/com/android/gpu/vts/Util.java b/tests/gpu_test/src/com/android/gpu/vts/Util.java
new file mode 100644
index 0000000..fbd3980
--- /dev/null
+++ b/tests/gpu_test/src/com/android/gpu/vts/Util.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2023 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 com.android.gpu.vts;
+
+import com.android.compatibility.common.util.FeatureUtil;
+import com.android.compatibility.common.util.PropertyUtil;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.log.LogUtil;
+
+public class Util {
+ public static final String FEATURE_PC = "android.hardware.type.pc";
+
+ public static int getVendorApiLevelOrFirstProductApiLevel(final ITestDevice device)
+ throws DeviceNotAvailableException {
+ final int vendorApiLevel = PropertyUtil.getVendorApiLevel(device);
+ final int firstProductApiLevel = PropertyUtil.getFirstApiLevel(device);
+
+ LogUtil.CLog.i("Vendor API level: %d", vendorApiLevel);
+ LogUtil.CLog.i("First product API level: %d", firstProductApiLevel);
+
+ return Math.min(vendorApiLevel, firstProductApiLevel);
+ }
+
+ public static boolean isHandheld(final ITestDevice device) throws DeviceNotAvailableException {
+ return !FeatureUtil.isTV(device) && !FeatureUtil.isWatch(device)
+ && !FeatureUtil.isAutomotive(device)
+ && !FeatureUtil.hasSystemFeature(device, FEATURE_PC);
+ }
+}
diff --git a/tests/gpu_test/src/com/android/gpu/vts/VulkanTest.java b/tests/gpu_test/src/com/android/gpu/vts/VulkanTest.java
new file mode 100644
index 0000000..5bf00a3
--- /dev/null
+++ b/tests/gpu_test/src/com/android/gpu/vts/VulkanTest.java
@@ -0,0 +1,269 @@
+/*
+ * Copyright (C) 2023 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 com.android.gpu.vts;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
+
+import android.platform.test.annotations.RequiresDevice;
+import com.android.compatibility.common.util.ApiLevelUtil;
+import com.android.compatibility.common.util.PropertyUtil;
+import com.android.compatibility.common.util.VsrTest;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
+import com.android.tradefed.testtype.junit4.BaseHostJUnit4Test;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/*
+ * VTS test for Vulkan requirements.
+ */
+@RequiresDevice
+@RunWith(DeviceJUnit4ClassRunner.class)
+public class VulkanTest extends BaseHostJUnit4Test {
+ private static final int VK_PHYSICAL_DEVICE_TYPE_CPU = 4;
+ private static final int VULKAN_1_1_API_VERSION = 0x401000;
+ private static final int VULKAN_1_3_API_VERSION = 0x403000;
+
+ // Feature version corresponding to dEQP level for 2023-03-01.
+ public static final int DEQP_LEVEL_FOR_U = 0x7E70301;
+
+ // Feature version corresponding to dEQP level for 2022-03-01.
+ public static final int DEQP_LEVEL_FOR_T = 0x7E60301;
+
+ // Feature version corresponding to dEQP level for 2021-03-01.
+ public static final int DEQP_LEVEL_FOR_S = 0x7E50301;
+
+ // Feature version corresponding to dEQP level for 2020-03-01.
+ public static final int DEQP_LEVEL_FOR_R = 0x7E40301;
+
+ private static final String VK_EXT_DEVICE_MEMORY_REPORT_EXTENSION_NAME =
+ "VK_EXT_device_memory_report";
+ private static final int VK_EXT_DEVICE_MEMORY_REPORT_SPEC_VERSION = 1;
+
+ private JSONObject[] mVulkanDevices;
+
+ /**
+ * Test specific setup
+ */
+ @Before
+ public void setUp() throws Exception {
+ final String output = getDevice().executeShellCommand("cmd gpu vkjson");
+ final JSONArray vkjson;
+ // vkjson output in Android N is JSONArray.
+ if (ApiLevelUtil.isBefore(getDevice(), Build.OC)) {
+ vkjson = (new JSONArray(output));
+ } else {
+ vkjson = (new JSONObject(output)).getJSONArray("devices");
+ }
+ mVulkanDevices = new JSONObject[vkjson.length()];
+ for (int i = 0; i < vkjson.length(); i++) {
+ mVulkanDevices[i] = vkjson.getJSONObject(i);
+ }
+ }
+
+ /**
+ * 64-bits devices released with Q must support Vulkan 1.1.
+ */
+ @VsrTest(requirements = {"VSR-3.2.1-001.001"})
+ @Test
+ public void checkVulkan1_1Requirements() throws Exception {
+ // Only test for new 64-bits devices that is Q and above.
+ assumeTrue("Test does not apply for devices released before Q",
+ PropertyUtil.getVsrApiLevel(getDevice()) >= Build.QT);
+ assumeTrue("Test does not apply for 32-bits devices",
+ getDevice().getProperty("ro.product.cpu.abi").contains("64"));
+
+ assertTrue(mVulkanDevices.length > 0);
+
+ int bestApiVersion = 0;
+ for (JSONObject device : mVulkanDevices) {
+ final int apiVersion = device.getJSONObject("properties").getInt("apiVersion");
+ if (bestApiVersion < apiVersion) {
+ bestApiVersion = apiVersion;
+ }
+ }
+ assertTrue("Supported Vulkan version must be at least 1.1",
+ bestApiVersion >= VULKAN_1_1_API_VERSION);
+ }
+
+ /**
+ * 64-bits devices released with U must support Vulkan 1.3.
+ */
+ @VsrTest(requirements = {"VSR-3.2.1-001.003"})
+ @Test
+ public void checkVulkan1_3Requirements() throws Exception {
+ // Only test for new 64-bits devices that is U and above.
+ assumeTrue("Test does not apply for devices released before U",
+ PropertyUtil.getVsrApiLevel(getDevice()) >= Build.UDC);
+ assumeTrue("Test does not apply for 32-bits devices",
+ getDevice().getProperty("ro.product.cpu.abi").contains("64"));
+
+ assertTrue(mVulkanDevices.length > 0);
+
+ int bestApiVersion = 0;
+ for (JSONObject device : mVulkanDevices) {
+ final int apiVersion = device.getJSONObject("properties").getInt("apiVersion");
+ if (bestApiVersion < apiVersion) {
+ bestApiVersion = apiVersion;
+ }
+ }
+ assertTrue("Supported Vulkan version must be at least 1.3",
+ bestApiVersion >= VULKAN_1_3_API_VERSION);
+ }
+
+ /**
+ * Devices with only CPU Vulkan must properly set "ro.cpuvulkan.version" property.
+ */
+ @VsrTest(requirements = {"VSR-3.2.1-002"})
+ @Test
+ public void checkCpuVulkanRequirements() throws Exception {
+ // Only test for new devices that is Q and above.
+ assumeTrue("Test does not apply for devices released before Q",
+ PropertyUtil.getVsrApiLevel(getDevice()) >= Build.QT);
+
+ if (mVulkanDevices.length == 0) {
+ return;
+ }
+
+ boolean hasOnlyCpuDevice = true;
+ int bestApiVersion = 0;
+ for (JSONObject device : mVulkanDevices) {
+ if (device.getJSONObject("properties").getInt("deviceType")
+ != VK_PHYSICAL_DEVICE_TYPE_CPU) {
+ hasOnlyCpuDevice = false;
+ } else {
+ final int apiVersion = device.getJSONObject("properties").getInt("apiVersion");
+ if (bestApiVersion < apiVersion) {
+ bestApiVersion = apiVersion;
+ }
+ }
+ }
+
+ if (!hasOnlyCpuDevice) {
+ return;
+ }
+
+ final int advertisedApiVersion =
+ Integer.parseInt(getDevice().getProperty("ro.cpuvulkan.version"));
+ assertEquals("Advertised CPU Vulkan api version " + advertisedApiVersion
+ + " doesn't match the best physical device api version " + bestApiVersion,
+ bestApiVersion, advertisedApiVersion);
+ }
+
+ /**
+ * Verify that FEATURE_VULKAN_DEQP_LEVEL (feature:android.software.vulkan.deqp.level) has a
+ * sufficiently high version in relation to the vendor and first product API level.
+ */
+ @VsrTest(requirements =
+ {"VSR-3.2.2-001/VSR-3.2.2-002/VSR-3.2.2-003/VSR-3.2.2-004/VSR-3.2.2-005"})
+ @Test
+ public void
+ checkVulkanDeqpLevelIsHighEnough() throws Exception {
+ final int apiLevel = Util.getVendorApiLevelOrFirstProductApiLevel(getDevice());
+
+ assumeTrue("Test does not apply for API level lower than R", apiLevel >= Build.RVC);
+ assumeTrue("Test does not apply for devices without Vulkan", mVulkanDevices.length > 0);
+
+ // Map from API level to required dEQP level.
+ final int requiredVulkanDeqpLevel;
+ switch (apiLevel) {
+ case Build.RVC:
+ requiredVulkanDeqpLevel = DEQP_LEVEL_FOR_R;
+ break;
+ case Build.SC:
+ case Build.SC_V2:
+ requiredVulkanDeqpLevel = DEQP_LEVEL_FOR_S;
+ break;
+ case Build.TM:
+ requiredVulkanDeqpLevel = DEQP_LEVEL_FOR_T;
+ break;
+ case Build.UDC:
+ requiredVulkanDeqpLevel = DEQP_LEVEL_FOR_U;
+ break;
+ default:
+ fail("Test should only run for API levels: R, S, Sv2, TM, UDC, ...");
+ return;
+ }
+
+ // Check that the feature flag is present and its value is at least the required dEQP level.
+ final String output = getDevice().executeShellCommand(String.format(
+ "pm has-feature android.software.vulkan.deqp.level %d", requiredVulkanDeqpLevel));
+
+ if (!output.trim().equals("true")) {
+ final String message = String.format(
+ "Advertised Vulkan dEQP level feature is too low or does not exist.\n"
+ + "Expected:\nfeature:android.software.vulkan.deqp.level>=%d\n"
+ + "Actual:\n%s",
+ requiredVulkanDeqpLevel,
+ getDevice().executeShellCommand("pm list features | grep deqp"));
+
+ fail(message);
+ }
+ }
+
+ /**
+ * For devices launching with Android 12 or higher, if the device supports Vulkan 1.1 or higher,
+ * VK_EXT_device_memory_report extension must be supported.
+ */
+ @VsrTest(requirements = {"VSR-3.2.1-006"})
+ @Test
+ public void checkVulkanDeviceMemoryReportSupport() throws Exception {
+ final int apiLevel = Util.getVendorApiLevelOrFirstProductApiLevel(getDevice());
+
+ assumeTrue("Test does not apply for API level lower than S", apiLevel >= Build.SC);
+
+ assumeTrue("Test does not apply for devices without Vulkan support",
+ mVulkanDevices.length > 0);
+
+ for (int i = 0; i < mVulkanDevices.length; ++i) {
+ final JSONObject device = mVulkanDevices[i];
+ // Skip extension check if Vulkan device's API version is < 1.1.
+ if (device.getJSONObject("properties").getInt("apiVersion") < VULKAN_1_1_API_VERSION) {
+ continue;
+ }
+
+ final boolean isSupported =
+ hasExtension(device, VK_EXT_DEVICE_MEMORY_REPORT_EXTENSION_NAME,
+ VK_EXT_DEVICE_MEMORY_REPORT_SPEC_VERSION);
+
+ if (!isSupported) {
+ final String message =
+ String.format("Vulkan devices with API version >= 1.1 must support %s "
+ + "but the device at index %d does not. "
+ + "Check 'adb shell cmd gpu vkjson'.",
+ VK_EXT_DEVICE_MEMORY_REPORT_EXTENSION_NAME, i);
+
+ fail(message);
+ }
+ }
+ }
+
+ private boolean hasExtension(JSONObject device, String name, int minVersion) throws Exception {
+ JSONArray extensions = device.getJSONArray("extensions");
+ for (int i = 0; i < extensions.length(); i++) {
+ JSONObject ext = extensions.getJSONObject(i);
+ if (ext.getString("extensionName").equals(name)
+ && ext.getInt("specVersion") >= minVersion)
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/testcases/host/kernel_proc_file_api_test/Android.bp b/tests/kernel_proc_file_api_test/Android.bp
similarity index 83%
rename from testcases/host/kernel_proc_file_api_test/Android.bp
rename to tests/kernel_proc_file_api_test/Android.bp
index ff7d121..b2f1ae7 100644
--- a/testcases/host/kernel_proc_file_api_test/Android.bp
+++ b/tests/kernel_proc_file_api_test/Android.bp
@@ -31,16 +31,6 @@
"vndk_utils",
"vts_vndk_utils",
],
- version: {
- py2: {
- enabled: false,
- embedded_launcher: false,
- },
- py3: {
- enabled: true,
- embedded_launcher: false,
- },
- },
test_suites: [
"vts",
],
diff --git a/tests/kernel_proc_file_api_test/OWNERS b/tests/kernel_proc_file_api_test/OWNERS
new file mode 100644
index 0000000..245e64e
--- /dev/null
+++ b/tests/kernel_proc_file_api_test/OWNERS
@@ -0,0 +1,2 @@
+# Bug component: 30545
+vmartensson@google.com
diff --git a/tests/kernel_proc_file_api_test/TEST_MAPPING b/tests/kernel_proc_file_api_test/TEST_MAPPING
new file mode 100644
index 0000000..614855b
--- /dev/null
+++ b/tests/kernel_proc_file_api_test/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+ "kernel-presubmit": [
+ {
+ "name": "vts_kernel_proc_file_api_test"
+ }
+ ]
+}
diff --git a/testcases/host/kernel_proc_file_api_test/kernel_proc_file_api_test.xml b/tests/kernel_proc_file_api_test/kernel_proc_file_api_test.xml
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/kernel_proc_file_api_test.xml
rename to tests/kernel_proc_file_api_test/kernel_proc_file_api_test.xml
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/KernelProcFileTestBase.py b/tests/kernel_proc_file_api_test/proc_tests/KernelProcFileTestBase.py
similarity index 99%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/KernelProcFileTestBase.py
rename to tests/kernel_proc_file_api_test/proc_tests/KernelProcFileTestBase.py
index 01c8522..f5d30bd 100644
--- a/testcases/host/kernel_proc_file_api_test/proc_tests/KernelProcFileTestBase.py
+++ b/tests/kernel_proc_file_api_test/proc_tests/KernelProcFileTestBase.py
@@ -94,7 +94,7 @@
t_EQUALS = r'='
t_COMMA = r','
t_PERIOD = r'\.'
- t_STRING = r'[a-zA-Z\(\)_0-9\-@]+'
+ t_STRING = r'[a-zA-Z\(\)_0-9\-.@]+'
t_TAB = r'\t'
t_SPACE = r'[ ]'
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcAsoundTests.py b/tests/kernel_proc_file_api_test/proc_tests/ProcAsoundTests.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcAsoundTests.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcAsoundTests.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcCmdlineTest.py b/tests/kernel_proc_file_api_test/proc_tests/ProcCmdlineTest.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcCmdlineTest.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcCmdlineTest.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcCpuFileTests.py b/tests/kernel_proc_file_api_test/proc_tests/ProcCpuFileTests.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcCpuFileTests.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcCpuFileTests.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcFsFileTests.py b/tests/kernel_proc_file_api_test/proc_tests/ProcFsFileTests.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcFsFileTests.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcFsFileTests.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcKmsgTest.py b/tests/kernel_proc_file_api_test/proc_tests/ProcKmsgTest.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcKmsgTest.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcKmsgTest.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcMapsTest.py b/tests/kernel_proc_file_api_test/proc_tests/ProcMapsTest.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcMapsTest.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcMapsTest.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcMemInfoTest.py b/tests/kernel_proc_file_api_test/proc_tests/ProcMemInfoTest.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcMemInfoTest.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcMemInfoTest.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcMiscTest.py b/tests/kernel_proc_file_api_test/proc_tests/ProcMiscTest.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcMiscTest.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcMiscTest.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcModulesTest.py b/tests/kernel_proc_file_api_test/proc_tests/ProcModulesTest.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcModulesTest.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcModulesTest.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcQtaguidCtrlTest.py b/tests/kernel_proc_file_api_test/proc_tests/ProcQtaguidCtrlTest.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcQtaguidCtrlTest.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcQtaguidCtrlTest.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcRemoveUidRangeTest.py b/tests/kernel_proc_file_api_test/proc_tests/ProcRemoveUidRangeTest.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcRemoveUidRangeTest.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcRemoveUidRangeTest.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcShowUidStatTest.py b/tests/kernel_proc_file_api_test/proc_tests/ProcShowUidStatTest.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcShowUidStatTest.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcShowUidStatTest.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcSimpleFileTests.py b/tests/kernel_proc_file_api_test/proc_tests/ProcSimpleFileTests.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcSimpleFileTests.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcSimpleFileTests.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcStatTest.py b/tests/kernel_proc_file_api_test/proc_tests/ProcStatTest.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcStatTest.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcStatTest.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcUidConcurrentTimeTests.py b/tests/kernel_proc_file_api_test/proc_tests/ProcUidConcurrentTimeTests.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcUidConcurrentTimeTests.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcUidConcurrentTimeTests.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcUidCpuPowerTests.py b/tests/kernel_proc_file_api_test/proc_tests/ProcUidCpuPowerTests.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcUidCpuPowerTests.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcUidCpuPowerTests.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcUidIoStatsTest.py b/tests/kernel_proc_file_api_test/proc_tests/ProcUidIoStatsTest.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcUidIoStatsTest.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcUidIoStatsTest.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcUidTimeInStateTest.py b/tests/kernel_proc_file_api_test/proc_tests/ProcUidTimeInStateTest.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcUidTimeInStateTest.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcUidTimeInStateTest.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcVersionTest.py b/tests/kernel_proc_file_api_test/proc_tests/ProcVersionTest.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcVersionTest.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcVersionTest.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcVmallocInfoTest.py b/tests/kernel_proc_file_api_test/proc_tests/ProcVmallocInfoTest.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcVmallocInfoTest.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcVmallocInfoTest.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcVmstatTest.py b/tests/kernel_proc_file_api_test/proc_tests/ProcVmstatTest.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcVmstatTest.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcVmstatTest.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/ProcZoneInfoTest.py b/tests/kernel_proc_file_api_test/proc_tests/ProcZoneInfoTest.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/ProcZoneInfoTest.py
rename to tests/kernel_proc_file_api_test/proc_tests/ProcZoneInfoTest.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_tests/__init__.py b/tests/kernel_proc_file_api_test/proc_tests/__init__.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_tests/__init__.py
rename to tests/kernel_proc_file_api_test/proc_tests/__init__.py
diff --git a/testcases/host/kernel_proc_file_api_test/proc_utils.py b/tests/kernel_proc_file_api_test/proc_utils.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/proc_utils.py
rename to tests/kernel_proc_file_api_test/proc_utils.py
diff --git a/testcases/host/kernel_proc_file_api_test/target_file_utils.py b/tests/kernel_proc_file_api_test/target_file_utils.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/target_file_utils.py
rename to tests/kernel_proc_file_api_test/target_file_utils.py
diff --git a/testcases/host/kernel_proc_file_api_test/vts_kernel_proc_file_api_test.py b/tests/kernel_proc_file_api_test/vts_kernel_proc_file_api_test.py
similarity index 100%
rename from testcases/host/kernel_proc_file_api_test/vts_kernel_proc_file_api_test.py
rename to tests/kernel_proc_file_api_test/vts_kernel_proc_file_api_test.py
diff --git a/testcases/host/selinux_test/Android.bp b/tests/selinux_test/Android.bp
similarity index 95%
rename from testcases/host/selinux_test/Android.bp
rename to tests/selinux_test/Android.bp
index 69eaa52..0b36523 100644
--- a/testcases/host/selinux_test/Android.bp
+++ b/tests/selinux_test/Android.bp
@@ -21,7 +21,6 @@
libs: [
"compatibility-tradefed",
"tradefed",
- "vts-core-tradefed-harness"
],
srcs: ["src/**/*.java"],
test_suites: [
diff --git a/testcases/host/selinux_test/AndroidTest.xml b/tests/selinux_test/AndroidTest.xml
similarity index 100%
rename from testcases/host/selinux_test/AndroidTest.xml
rename to tests/selinux_test/AndroidTest.xml
diff --git a/tests/selinux_test/OWNERS b/tests/selinux_test/OWNERS
new file mode 100644
index 0000000..245e64e
--- /dev/null
+++ b/tests/selinux_test/OWNERS
@@ -0,0 +1,2 @@
+# Bug component: 30545
+vmartensson@google.com
diff --git a/tests/selinux_test/TEST_MAPPING b/tests/selinux_test/TEST_MAPPING
new file mode 100644
index 0000000..07ba73b
--- /dev/null
+++ b/tests/selinux_test/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+ "kernel-presubmit": [
+ {
+ "name": "KernelSelinuxFileApiTest"
+ }
+ ]
+}
diff --git a/testcases/host/selinux_test/src/com/android/tests/selinux/KernelSelinuxFileApiTest.java b/tests/selinux_test/src/com/android/tests/selinux/KernelSelinuxFileApiTest.java
similarity index 100%
rename from testcases/host/selinux_test/src/com/android/tests/selinux/KernelSelinuxFileApiTest.java
rename to tests/selinux_test/src/com/android/tests/selinux/KernelSelinuxFileApiTest.java
diff --git a/tools/vts-core-tradefed/Android.bp b/tools/vts-core-tradefed/Android.bp
index eaac48f..99af4e2 100644
--- a/tools/vts-core-tradefed/Android.bp
+++ b/tools/vts-core-tradefed/Android.bp
@@ -27,6 +27,7 @@
static_libs: [
"compatibility-tradefed",
],
+ visibility: [":__subpackages__"],
}
tradefed_binary_host {
@@ -34,7 +35,7 @@
wrapper: "etc/vts-tradefed",
short_name: "VTS",
full_name: "Vendor Test Suite",
- version: "13_r8",
+ version: "14_r4",
static_libs: [
"cts-tradefed-harness",
"vts-core-tradefed-harness",
diff --git a/tools/vts-core-tradefed/etc/vts-tradefed b/tools/vts-core-tradefed/etc/vts-tradefed
index de511f2..8e07c6d 100755
--- a/tools/vts-core-tradefed/etc/vts-tradefed
+++ b/tools/vts-core-tradefed/etc/vts-tradefed
@@ -41,9 +41,9 @@
checkPath java
# check java version
-JAVA_VERSION=$(java -version 2>&1 | grep 'version [ "]\(1\.8\|9\|11\).*[ "]' | head -n 1)
+JAVA_VERSION=$(java -version 2>&1 | grep 'version [ "]\(1\.8\|9\|11\|17\).*[ "]' | head -n 1)
if [ "${JAVA_VERSION}" == "" ]; then
- echo "Wrong java version. 1.8, 9, or 11 is required."
+ echo "Wrong java version. 1.8, 9, 11 or 17 is required."
exit
fi
diff --git a/tools/vts-core-tradefed/res/config/vts-ccd.xml b/tools/vts-core-tradefed/res/config/vts-ccd.xml
index 3d394bb..6b94e11 100644
--- a/tools/vts-core-tradefed/res/config/vts-ccd.xml
+++ b/tools/vts-core-tradefed/res/config/vts-ccd.xml
@@ -25,6 +25,16 @@
<option name="enable-experimental-device-baseline-setters" value="disable_os_auto_update" />
</system_checker>
+ <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+ <option name="run-command" value="settings put global verifier_engprod 1" />
+ <option name="teardown-command" value="settings put global verifier_engprod 0"/>
+ </target_preparer>
+
+ <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+ <option name="run-command" value="settings put global verifier_verify_adb_installs 0" />
+ <option name="teardown-command" value="settings put global verifier_verify_adb_installs 1"/>
+ </target_preparer>
+
<target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsDeviceInfoCollector" />
<target_preparer class="com.android.compatibility.common.tradefed.targetprep.DeviceInfoCollector">
<option name="apk" value="CtsDeviceInfo.apk"/>
diff --git a/tools/vts-core-tradefed/res/config/vts-exclude.xml b/tools/vts-core-tradefed/res/config/vts-exclude.xml
index cdbec5f..e64fbd0 100644
--- a/tools/vts-core-tradefed/res/config/vts-exclude.xml
+++ b/tools/vts-core-tradefed/res/config/vts-exclude.xml
@@ -33,4 +33,11 @@
<option name="compatibility:exclude-filter" value="VtsHalConfirmationUIV1_0TargetTest *ConfirmationUIHidlTest.MalformedUTF8Test1/*"/>
<option name="compatibility:exclude-filter" value="VtsHalConfirmationUIV1_0TargetTest *ConfirmationUIHidlTest.MalformedUTF8Test2/*"/>
<option name="compatibility:exclude-filter" value="VtsHalConfirmationUIV1_0TargetTest *ConfirmationUIHidlTest.MalformedUTF8Test3/*"/>
+
+ <!-- b/281630896: Disable tests for UDC as not enough soak time to test the proposed fix in ag/23905225. -->
+ <option name="compatibility:exclude-filter" value="VtsHalUwbTargetTest *UwbAidl.ChipClose/*"/>
+ <option name="compatibility:exclude-filter" value="VtsHalUwbTargetTest *UwbAidl.ChipCoreInit/*"/>
+ <option name="compatibility:exclude-filter" value="VtsHalUwbTargetTest *UwbAidl.ChipOpen/*"/>
+ <option name="compatibility:exclude-filter" value="VtsHalUwbTargetTest *UwbAidl.ChipSessionInit/*"/>
+ <option name="compatibility:exclude-filter" value="VtsHalUwbTargetTest *UwbAidl.ChipGetSupportedAndroidUciVersion/*"/>
</configuration>
diff --git a/tools/vts-core-tradefed/res/config/vts-kernel.xml b/tools/vts-core-tradefed/res/config/vts-kernel.xml
index a5b1567..cedf483 100644
--- a/tools/vts-core-tradefed/res/config/vts-kernel.xml
+++ b/tools/vts-core-tradefed/res/config/vts-kernel.xml
@@ -24,7 +24,6 @@
<option name="compatibility:include-filter" value="binderSafeInterfaceTest " />
<option name="compatibility:include-filter" value="bpf_module_test" />
<option name="compatibility:include-filter" value="drop_caches_test" />
- <option name="compatibility:include-filter" value="ion-unit-tests" />
<option name="compatibility:include-filter" value="KernelApiSysfsTest" />
<option name="compatibility:include-filter" value="KernelDynamicPartitionsTest " />
<option name="compatibility:include-filter" value="KernelLibcutilsTest" />
diff --git a/tools/vts-core-tradefed/src/com/android/tradefed/testtype/binary/KernelTargetTest.java b/tools/vts-core-tradefed/src/com/android/tradefed/testtype/binary/KernelTargetTest.java
index c8101cf..1604972 100644
--- a/tools/vts-core-tradefed/src/com/android/tradefed/testtype/binary/KernelTargetTest.java
+++ b/tools/vts-core-tradefed/src/com/android/tradefed/testtype/binary/KernelTargetTest.java
@@ -35,7 +35,7 @@
@Option(name = "ignore-binary-check", description = "Ignore the binary check in findBinary().")
private boolean mIgnoreBinaryCheck = false;
@Option(name = "exit-code-skip", description = "Exit code for skipped tests.")
- private int mExitCodeSkip = 32;
+ private Integer mExitCodeSkip = null;
@Override
public String findBinary(String binary) throws DeviceNotAvailableException {
@@ -53,7 +53,7 @@
*/
protected void checkCommandResult(
CommandResult result, ITestInvocationListener listener, TestDescription description) {
- if (result.getExitCode() == mExitCodeSkip) {
+ if (mExitCodeSkip != null && result.getExitCode().equals(mExitCodeSkip)) {
listener.testIgnored(description);
} else {
super.checkCommandResult(result, listener, description);
diff --git a/tools/vts-core-tradefed/src/com/android/tradefed/testtype/suite/module/KernelTestModuleController.java b/tools/vts-core-tradefed/src/com/android/tradefed/testtype/suite/module/KernelTestModuleController.java
index cb4135e..abd8ef3 100644
--- a/tools/vts-core-tradefed/src/com/android/tradefed/testtype/suite/module/KernelTestModuleController.java
+++ b/tools/vts-core-tradefed/src/com/android/tradefed/testtype/suite/module/KernelTestModuleController.java
@@ -30,7 +30,7 @@
@Option(name = "arch",
description = "The architecture name that should run for this module."
- + "This should be like arm64, arm, x86_64, x86, mips64, or mips.",
+ + "This should be like arm64, arm, riscv64, x86_64, or x86.",
mandatory = true)
private String mArch = null;
diff --git a/tools/vts-core-tradefed/src/com/android/tradefed/util/TargetFileUtils.java b/tools/vts-core-tradefed/src/com/android/tradefed/util/TargetFileUtils.java
deleted file mode 100644
index a08616c..0000000
--- a/tools/vts-core-tradefed/src/com/android/tradefed/util/TargetFileUtils.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (C) 2020 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.
- */
-
-/* Utils for target file.*/
-package com.android.tradefed.util;
-
-import com.android.ddmlib.Log;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-public class TargetFileUtils {
- // 3 permission groups: owner, group, all users
- private static final int PERMISSION_GROUPS = 3;
-
- public enum FilePermission {
- EXECUTE(1),
- READ(4),
- WRITE(2);
-
- private int mPermissionNum;
-
- FilePermission(int permissionNum) {
- mPermissionNum = permissionNum;
- }
-
- public int getPermissionNum() {
- return mPermissionNum;
- }
- }
-
- /**
- * Determines if the permission bits grant the specify permission to any group.
- *
- * @param permission The specify permissions.
- * @param permissionBits The octal permissions string (e.g. 741).
- * @return True if any owner/group/global has the specify permission.
- */
- public static boolean hasPermission(FilePermission permission, String permissionBits) {
- for (int i = 0; i < PERMISSION_GROUPS; i++) {
- if (hasPermission(permissionBits, i, permission)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Read the file permission bits of a path.
- *
- * @param filepath Path to a file or directory.
- * @param device The test device.
- * @return Octal permission bits for the path.
- */
- public static String getPermission(String filepath, ITestDevice device)
- throws DeviceNotAvailableException {
- CommandResult commandResult = device.executeShellV2Command("stat -c %a " + filepath);
- if (!CommandStatus.SUCCESS.equals(commandResult.getStatus())) {
- CLog.logAndDisplay(Log.LogLevel.ERROR, "Get permission error:\nstdout%s\nstderr",
- commandResult.getStdout(), commandResult.getStderr());
- return "";
- }
- return commandResult.getStdout().trim();
- }
-
- /**
- * Determines if the permission bits grant a permission to a group.
- *
- * @param permissionBits The octal permissions string (e.g. 741).
- * @param groupIndex The index of the group into the permissions string.
- * (e.g. 0 is owner group). If set to -1, then all groups are
- * checked.
- * @param permission The value of the permission.
- * @return True if the group(s) has read permission.
- */
- private static boolean hasPermission(
- String permissionBits, int groupIndex, FilePermission permission) {
- if (groupIndex >= PERMISSION_GROUPS) {
- throw new RuntimeException(String.format("Invalid group: %s", groupIndex));
- }
- if (permissionBits.length() != PERMISSION_GROUPS) {
- throw new RuntimeException(
- String.format("Invalid permission bits: %s", permissionBits.length() + ""));
- }
-
- // Define the start/end group index
- int start = groupIndex;
- int end = groupIndex + 1;
- if (groupIndex < 0) {
- start = 0;
- end = PERMISSION_GROUPS;
- }
-
- for (int i = start; i < end; i++) {
- try {
- int perm = Integer.valueOf(permissionBits.charAt(i) + "");
- if (perm > 7) {
- throw new RuntimeException(String.format("Invalid permission bit: %d", perm));
- }
- if ((perm & permission.getPermissionNum()) == 0) {
- // Return false if any group lacks the permission
- return false;
- }
- } catch (NumberFormatException e) {
- throw new RuntimeException(String.format(
- "Permission bits \"%s\" format error, should be three digital number "
- + "(e.q. 741).",
- permissionBits));
- }
- }
- // Return true if no group lacks the permission
- return true;
- }
-
- /**
- * Helper method which executes a adb shell find command and returns the results as an {@link
- * ArrayList<String>}.
- *
- * @param path The path to search on device.
- * @param namePattern The file name pattern.
- * @param options A {@link List} of {@link String} for other options pass to find.
- * @param device The test device.
- * @return The result in {@link ArrayList<String>}.
- * @throws DeviceNotAvailableException if connection with device is lost and cannot be
- * recovered.
- */
- public static ArrayList<String> findFile(String path, String namePattern, List<String> options,
- ITestDevice device) throws DeviceNotAvailableException {
- ArrayList<String> findedFiles = new ArrayList<>();
- String command = String.format("find %s -name \"%s\"", path, namePattern);
- if (options != null) {
- command += " " + String.join(" ", options);
- }
- CLog.d("command: %s", command);
- CommandResult result = device.executeShellV2Command(command);
- if (!CommandStatus.SUCCESS.equals(result.getStatus())) {
- CLog.e("Find command: '%s' failed, returned:\nstdout:%s\nstderr:%s", command,
- result.getStdout(), result.getStderr());
- return findedFiles;
- }
- findedFiles = new ArrayList<>(Arrays.asList(result.getStdout().split("\n")));
- findedFiles.removeIf(s -> s.contentEquals(""));
- return findedFiles;
- }
-
- /**
- * Check if the permission for a given path is readonly.
- *
- * @param filepath Path to a file or directory.
- * @param device The test device.
- * @return true if the path is readonly, false otherwise.
- */
- public static boolean isReadOnly(String filepath, ITestDevice device)
- throws DeviceNotAvailableException {
- String permissionBits = getPermission(filepath, device);
- return (hasPermission(FilePermission.READ, permissionBits)
- && !hasPermission(FilePermission.WRITE, permissionBits)
- && !hasPermission(FilePermission.EXECUTE, permissionBits));
- }
-
- /**
- * Check if the permission for a given path is readwrite.
- *
- * @param filepath Path to a file or directory.
- * @param device The test device.
- * @return true if the path is readwrite, false otherwise.
- */
- public static boolean isReadWriteOnly(String filepath, ITestDevice device)
- throws DeviceNotAvailableException {
- String permissionBits = getPermission(filepath, device);
- return (hasPermission(FilePermission.READ, permissionBits)
- && hasPermission(FilePermission.WRITE, permissionBits)
- && !hasPermission(FilePermission.EXECUTE, permissionBits));
- }
-}
diff --git a/tools/vts-core-tradefed/tests/Android.bp b/tools/vts-core-tradefed/tests/Android.bp
index a4bda3d..9b30546 100644
--- a/tools/vts-core-tradefed/tests/Android.bp
+++ b/tools/vts-core-tradefed/tests/Android.bp
@@ -27,5 +27,9 @@
"vts-core-tradefed-harness",
],
- static_libs: ["easymock"],
+ static_libs: [
+ "easymock",
+ // Import common validation tests
+ "suite-loading-tests",
+ ],
}
diff --git a/tools/vts-core-tradefed/tests/src/com/android/compatibility/tradefed/VtsUnitTests.java b/tools/vts-core-tradefed/tests/src/com/android/compatibility/tradefed/VtsUnitTests.java
index c478ca9..63c0d4b 100644
--- a/tools/vts-core-tradefed/tests/src/com/android/compatibility/tradefed/VtsUnitTests.java
+++ b/tools/vts-core-tradefed/tests/src/com/android/compatibility/tradefed/VtsUnitTests.java
@@ -16,8 +16,8 @@
package com.android.compatibility.tradefed;
+import com.android.compatibility.common.tradefed.loading.CommonConfigLoadingTest;
import com.android.compatibility.tradefed.VtsCoreTradefedTest;
-import com.android.compatibility.tradefed.util.TargetFileUtilsTest;
import com.android.tradefed.testtype.suite.module.KernelTestModuleControllerTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -32,8 +32,10 @@
@RunWith(Suite.class)
@SuiteClasses({
KernelTestModuleControllerTest.class,
- TargetFileUtilsTest.class,
VtsCoreTradefedTest.class,
+
+ // Loading test
+ CommonConfigLoadingTest.class,
})
public class VtsUnitTests {
// empty on purpose
diff --git a/tools/vts-core-tradefed/tests/src/com/android/compatibility/tradefed/util/TargetFileUtilsTest.java b/tools/vts-core-tradefed/tests/src/com/android/compatibility/tradefed/util/TargetFileUtilsTest.java
deleted file mode 100644
index 4c44f07..0000000
--- a/tools/vts-core-tradefed/tests/src/com/android/compatibility/tradefed/util/TargetFileUtilsTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2020 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 com.android.compatibility.tradefed.util;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.util.CommandResult;
-import com.android.tradefed.util.CommandStatus;
-import com.android.tradefed.util.TargetFileUtils;
-import com.android.tradefed.util.TargetFileUtils.FilePermission;
-import java.util.ArrayList;
-import java.util.Arrays;
-import org.easymock.EasyMock;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-@RunWith(JUnit4.class)
-public class TargetFileUtilsTest {
- private ITestDevice mMockDevice;
-
- /** Test {@link TargetFileUtils#hasPermission()}. */
- @Test
- public void testHasPermission() throws DeviceNotAvailableException {
- for (int x = 0; x <= 7; x++) {
- for (int y = 0; y <= 7; y++) {
- for (int z = 0; z <= 7; z++) {
- String permission = "" + x + y + z;
- // Determines if the permission bits grant read permission to any group.
- if (hasPermission(x, FilePermission.READ)
- || hasPermission(y, FilePermission.READ)
- || hasPermission(z, FilePermission.READ)) {
- assertTrue(TargetFileUtils.hasPermission(FilePermission.READ, permission));
- }
- // Determines if the permission bits grant write permission to any group.
- if (hasPermission(x, FilePermission.WRITE)
- || hasPermission(y, FilePermission.WRITE)
- || hasPermission(z, FilePermission.WRITE)) {
- assertTrue(TargetFileUtils.hasPermission(FilePermission.WRITE, permission));
- }
- // Determines if the permission bits grant EXECUTE permission to any group.
- if (hasPermission(x, FilePermission.EXECUTE)
- || hasPermission(y, FilePermission.EXECUTE)
- || hasPermission(z, FilePermission.EXECUTE)) {
- assertTrue(
- TargetFileUtils.hasPermission(FilePermission.EXECUTE, permission));
- }
- }
- }
- }
- }
-
- private boolean hasPermission(int bit, FilePermission permission) {
- return (bit & permission.getPermissionNum()) != 0;
- }
-
- /** Test {@link TargetFileUtils#findFile()} with NumberFormatException be asserted. */
- @Test
- public void testFindFile() throws DeviceNotAvailableException {
- mMockDevice = EasyMock.createMock(ITestDevice.class);
- CommandResult commandResult = new CommandResult(CommandStatus.SUCCESS);
- commandResult.setStdout("path1\npath2\npath3\n");
- commandResult.setExitCode(0);
- EasyMock.expect(mMockDevice.executeShellV2Command("find findPath -name \"namePattern\" "
- + "option1 option2"))
- .andReturn(commandResult);
- EasyMock.replay(mMockDevice);
- ArrayList<String> findPaths = new ArrayList<>();
- findPaths.add("path1");
- findPaths.add("path2");
- findPaths.add("path3");
- String[] options = {"option1", "option2"};
- assertEquals(findPaths,
- TargetFileUtils.findFile(
- "findPath", "namePattern", Arrays.asList(options), mMockDevice));
- }
-
- /** Test {@link TargetFileUtils#findFile()} with shell command failed. */
- @Test
- public void testFindFile_w_cmd_result_fail() throws DeviceNotAvailableException {
- mMockDevice = EasyMock.createMock(ITestDevice.class);
- CommandResult commandResult = new CommandResult(CommandStatus.FAILED);
- commandResult.setStdout("path1\npath2\npath3\n");
- commandResult.setExitCode(0);
- EasyMock.expect(mMockDevice.executeShellV2Command("find findPath -name \"namePattern\""))
- .andReturn(commandResult);
- EasyMock.replay(mMockDevice);
- ArrayList<String> findPaths = new ArrayList<>();
- assertEquals(
- findPaths, TargetFileUtils.findFile("findPath", "namePattern", null, mMockDevice));
- }
-
- /** Test {@link TargetFileUtils#findFile()} which have stdout with empty line. */
- @Test
- public void testFindFile_w_empty_line_stdout() throws DeviceNotAvailableException {
- mMockDevice = EasyMock.createMock(ITestDevice.class);
- CommandResult commandResult = new CommandResult(CommandStatus.SUCCESS);
- commandResult.setStdout("");
- commandResult.setExitCode(0);
- EasyMock.expect(mMockDevice.executeShellV2Command("find findPath -name \"namePattern\""))
- .andReturn(commandResult);
- EasyMock.replay(mMockDevice);
- ArrayList<String> findPaths = new ArrayList<>();
- assertEquals(
- findPaths, TargetFileUtils.findFile("findPath", "namePattern", null, mMockDevice));
- }
-}
diff --git a/utils/app_engine/__init__.py b/utils/app_engine/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/app_engine/__init__.py
+++ /dev/null
diff --git a/utils/app_engine/bigtable_client.py b/utils/app_engine/bigtable_client.py
deleted file mode 100644
index a33caf6..0000000
--- a/utils/app_engine/bigtable_client.py
+++ /dev/null
@@ -1,126 +0,0 @@
-# Copyright 2016 Google Inc.
-#
-# 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.
-
-import logging
-from google import protobuf
-from gcloud import bigtable
-
-_COLUMN_FAMILY_ID = 'cf1'
-
-
-class BigTableClient(object):
- """Defines the big table client that connects to the big table.
-
- Attributes:
- _column_family_id: A String for family of columns.
- _client: An instance of Client which is project specific.
- _client_instance: Representation of a Google Cloud Bigtable Instance.
- _start_index: Start index for the row key. It gets incremented as we
- dequeue.
- _end_index : End index for row key. This is incremented as we Enqueue.
- _table_name: A string that represents the big table.
- _table_instance: An instance of the Table that represents the big table.
- """
-
- def __init__(self, table, project_id):
- self._column_family_id = _COLUMN_FAMILY_ID
- self._client = bigtable.Client(project=project_id, admin=True)
- self._client_instance = None
- self._start_index = 0
- self._end_index = 0
- self._table_name = table
- self._table_instance = None
- # Start client to enable receiving requests
- self.StartClient()
-
- def StartClient(self, instance_id):
- """Starts client to prepare it to make requests."""
-
- # Start the client
- if not self._client.is_started():
- self._client.start()
- self._client_instance = self._client.instance(instance_id)
- if self._table_instance is None:
- self._table_instance = self._client_instance.table(
- self._table_name)
-
- def StopClient(self):
- """Stop client to close all the open gRPC clients."""
-
- # stop client
- self._client.stop()
-
- def CreateTable(self):
- """Creates a table in which read/write operations are performed.
-
- Raises:
- AbortionError: Error occurred when creating table is not successful.
- This could be due to creating a table with a duplicate name.
- """
-
- # Create a table
- logging.debug('Creating the table %s', self._table_name)
-
- self._table_instance.create()
- cf1 = self._table_instance.column_family(self._column_family_id)
- cf1.create()
-
- def Enqueue(self, messages, column_id):
- """Writes new rows to the given table.
-
- Args:
- messages: An array of strings that represents the message to be
- written to a new row in the table. Each message is writte to a
- new row
- column_id: A string that represents the name of the column to which
- data is to be written.
- """
-
- # Start writing rows
- logging.debug('Writing to the table : %s, column : %s',
- self._table_name, column_id)
- for value in messages:
- row_key = str(self._end_index)
- self._end_index = self._end_index + 1
- row = self._table_instance.row(row_key)
- row.set_cell(self._column_family_id,
- column_id.encode('utf-8'), value.encode('utf-8'))
- row.commit()
- # End writing rows
-
- def Dequeue(self):
- """Removes and returns the first row from the table.
-
- Returns:
- row: A row object that represents the top most row.
- """
-
- if self._end_index < self._start_index:
- return
-
- logging.debug('Getting a single row by row key.')
- key = str(self._start_index)
- row_cond = self._table_instance.row(key)
- top_row = row_cond
- row_cond.delete()
- self._start_index = self._start_index + 1
-
- return top_row
-
- def DeleteTable(self):
- """Performs delete operation for a given table."""
-
- # Delete the table
- logging.debug('Deleting the table : %s', self._table_name)
- self._table_instance.delete()
diff --git a/utils/app_engine/setup.txt b/utils/app_engine/setup.txt
deleted file mode 100644
index cc620f2..0000000
--- a/utils/app_engine/setup.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-Instructions for Setup for writing data to Big table:
-
-1. Make sure gcloud is installed and the project is set to the current project.
- Follow the instructions here to install gcloud:
- https://cloud.google.com/sdk/docs/quickstart-linux
-
- If command gcloud is not recognizable, extract the google-cloud-sdk-116.0.0-linux-x86_64.tar.gz
- from the above link and execute the commands in terminal:
- source google-cloud-sdk/completion.bash.inc
- source google-cloud-sdk/path.bash.inc
-
-2. Upgrade grpcio:
- sudo pip install --upgrade six
- sudo pip install --upgrade grpcio
- sudo pip install gcloud
-
-3. From top level directory:
- cd test/vts
- PYTHONPATH=$PYTHONPATH:.. python -m vts.utils.app_engine.bigtable_client_test
diff --git a/utils/native/libcoverage/Android.bp b/utils/native/libcoverage/Android.bp
deleted file mode 100644
index 828c483..0000000
--- a/utils/native/libcoverage/Android.bp
+++ /dev/null
@@ -1,34 +0,0 @@
-//
-// 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.
-//
-
-package {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-cc_binary {
- name: "vts_coverage_configure",
-
- srcs: ["VtsCoverageConfigureMain.cpp"],
-
- cflags: ["-Wall", "-Werror"],
-
- shared_libs: [
- "libbase",
- "libutils",
- "libcutils",
- "libhidlbase",
- ],
-}
diff --git a/utils/native/libcoverage/VtsCoverageConfigureMain.cpp b/utils/native/libcoverage/VtsCoverageConfigureMain.cpp
deleted file mode 100644
index 49cf0b7..0000000
--- a/utils/native/libcoverage/VtsCoverageConfigureMain.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 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.
- */
-#include <android/hidl/manager/1.0/IServiceManager.h>
-#include <cutils/properties.h>
-#include <hidl/ServiceManagement.h>
-#include <iostream>
-
-using namespace std;
-using namespace android;
-
-const string kSysPropHalCoverage = "hal.coverage.enable";
-
-// Print usage directions.
-void usage() {
- cout << "usage:\n";
- cout << "vts_coverage_configure flush\t\t\t\t: to flush coverage on all "
- "HALs\n";
- cout << "vts_coverage_configure flush <hal name>@<hal version>\t: to flush "
- "coverage on one HAL name/version instance"
- << std::endl;
-}
-
-// Parse the fully-qualified instance name and call the func with the interface
-// name, instance name, and HAL name.
-template <typename Lambda>
-bool parseFqInstaceName(string fqInstanceName, Lambda &&func) {
- string::size_type n = fqInstanceName.find("/");
- if (n == std::string::npos || fqInstanceName.size() == n + 1) return false;
-
- string fqInterfaceName = fqInstanceName.substr(0, n);
- string instanceName = fqInstanceName.substr(n + 1, std::string::npos);
-
- n = fqInstanceName.find("::");
- if (n == std::string::npos || fqInstanceName.size() == n + 1) return false;
- string halName = fqInstanceName.substr(0, n);
- std::forward<Lambda>(func)(fqInterfaceName, instanceName, halName);
- return true;
-}
-
-// Flush coverage on all HAL processes, or just the provided HAL name if
-// provided.
-bool FlushHALCoverage(string flushHal = "") {
- using ::android::hidl::base::V1_0::IBase;
- using ::android::hidl::manager::V1_0::IServiceManager;
- using ::android::hardware::hidl_string;
- using ::android::hardware::Return;
-
- sp<IServiceManager> sm = ::android::hardware::defaultServiceManager();
-
- if (sm == nullptr) {
- cerr << "failed to get IServiceManager to poke HAL services." << std::endl;
- return false;
- }
- property_set(kSysPropHalCoverage.c_str(), "true");
- auto listRet = sm->list([&](const auto &interfaces) {
- for (const string &fqInstanceName : interfaces) {
- hidl_string fqInterfaceName;
- hidl_string instanceName;
- string halName;
-
- auto cb = [&](string fqIface, string instance, string hal) {
- fqInterfaceName = fqIface;
- instanceName = instance;
- halName = hal;
- };
- if (!parseFqInstaceName(fqInstanceName, cb)) continue;
- if (halName.find("android.hidl") == 0) continue;
- if (flushHal == "" || !flushHal.compare(halName)) {
- Return<sp<IBase>> interfaceRet = sm->get(fqInterfaceName, instanceName);
- if (!interfaceRet.isOk()) {
- cerr << "failed to get service " << fqInstanceName << ": "
- << interfaceRet.description() << std::endl;
- continue;
- }
- sp<IBase> interface = interfaceRet;
- auto notifyRet = interface->notifySyspropsChanged();
- if (!notifyRet.isOk()) {
- cerr << "failed to notifySyspropsChanged on service "
- << fqInstanceName << ": " << notifyRet.description()
- << std::endl;
- }
- cout << "- flushed the coverage for HAL " << fqInstanceName
- << std::endl;
- }
- }
- });
- property_set(kSysPropHalCoverage.c_str(), "false");
- if (!listRet.isOk()) {
- cerr << "failed to list services: " << listRet.description() << std::endl;
- return false;
- }
- return true;
-}
-
-// The provided binary can be used to flush coverage on one or all HALs.
-// Usage examples:
-// To flush gcov and/or sancov coverage data on all hals: <binary> flush
-// To flush gcov and/or sancov coverage data on one hal: <binary> flush <hal
-// name>@<hal version>
-int main(int argc, char *argv[]) {
- bool flush_coverage = false;
- if (argc < 2) {
- usage();
- return -1;
- }
- if (!strcmp(argv[1], "flush")) {
- flush_coverage = true;
- string halString = "";
- if (argc == 3) {
- halString = string(argv[2]);
- }
- cout << "* flush coverage" << std::endl;
- if (!FlushHALCoverage(halString)) {
- cerr << "failed to flush coverage" << std::endl;
- }
- } else {
- usage();
- }
- return 0;
-}
diff --git a/utils/native/libprofiling/Android.bp b/utils/native/libprofiling/Android.bp
deleted file mode 100644
index bc72e20..0000000
--- a/utils/native/libprofiling/Android.bp
+++ /dev/null
@@ -1,90 +0,0 @@
-//
-// 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.
-//
-
-package {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-cc_library_shared {
-
- name: "libvts_profiling_utils",
- host_supported: true,
- // TODO(b/153609531): remove when no longer needed.
- native_bridge_supported: true,
-
- srcs: ["VtsProfilingUtil.cpp"],
-
- shared_libs: [
- "libprotobuf-cpp-full",
- ],
-
- cflags: [
- "-Werror",
- "-Wall",
- ],
-
- export_include_dirs: ["."],
-}
-
-cc_library_shared {
-
- name: "libvts_profiling",
-
- // TODO(b/153609531): remove when no longer needed.
- native_bridge_supported: true,
-
- srcs: ["VtsProfilingInterface.cpp"],
-
- shared_libs: [
- "libbase",
- "libcutils",
- "libhidlbase",
- "libprotobuf-cpp-full",
- "libvts_multidevice_proto",
- "libvts_profiling_utils",
- ],
-
- cflags: [
- "-Werror",
- "-Wall",
- ],
-
- multilib: {
- lib32: {
- ldflags: ["-Wl,--rpath,/data/local/tmp/32"],
- },
- lib64: {
- ldflags: ["-Wl,--rpath,/data/local/tmp/64"],
- },
- },
-
- export_include_dirs: ["."],
-}
-
-cc_binary {
- name: "vts_profiling_configure",
-
- srcs: ["VtsProfilingConfigureMain.cpp"],
-
- cflags: ["-Wall", "-Werror"],
-
- shared_libs: [
- "libbase",
- "libutils",
- "libcutils",
- "libhidlbase",
- ],
-}
diff --git a/utils/native/libprofiling/VtsProfilingConfigureMain.cpp b/utils/native/libprofiling/VtsProfilingConfigureMain.cpp
deleted file mode 100644
index 67cd7cc..0000000
--- a/utils/native/libprofiling/VtsProfilingConfigureMain.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 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.
- */
-#include <android/hidl/manager/1.0/IServiceManager.h>
-#include <cutils/properties.h>
-#include <hidl/ServiceManagement.h>
-#include <iostream>
-
-using namespace std;
-using namespace android;
-
-// Turns on the HAL instrumentation feature on all registered HIDL HALs.
-bool SetHALInstrumentation() {
- using ::android::hidl::base::V1_0::IBase;
- using ::android::hidl::manager::V1_0::IServiceManager;
- using ::android::hardware::hidl_string;
- using ::android::hardware::Return;
-
- sp<IServiceManager> sm = ::android::hardware::defaultServiceManager();
-
- if (sm == nullptr) {
- fprintf(stderr, "failed to get IServiceManager to poke HAL services.\n");
- return false;
- }
-
- auto listRet = sm->list([&](const auto &interfaces) {
- for (const string &fqInstanceName : interfaces) {
- string::size_type n = fqInstanceName.find("/");
- if (n == std::string::npos || fqInstanceName.size() == n + 1) continue;
-
- hidl_string fqInterfaceName = fqInstanceName.substr(0, n);
- hidl_string instanceName =
- fqInstanceName.substr(n + 1, std::string::npos);
- Return<sp<IBase>> interfaceRet = sm->get(fqInterfaceName, instanceName);
- if (!interfaceRet.isOk()) {
- fprintf(stderr, "failed to get service %s: %s\n",
- fqInstanceName.c_str(), interfaceRet.description().c_str());
- continue;
- }
- sp<IBase> interface = interfaceRet;
- auto notifyRet = interface->setHALInstrumentation();
- if (!notifyRet.isOk()) {
- fprintf(stderr, "failed to setHALInstrumentation on service %s: %s\n",
- fqInstanceName.c_str(), notifyRet.description().c_str());
- }
- printf("- updated the HAL instrumentation mode setting for %s\n",
- fqInstanceName.c_str());
- }
- });
- if (!listRet.isOk()) {
- fprintf(stderr, "failed to list services: %s\n",
- listRet.description().c_str());
- return false;
- }
- return true;
-}
-
-bool EnableHALProfiling() {
- property_set("hal.instrumentation.enable", "true");
- if (!SetHALInstrumentation()) {
- fprintf(stderr, "failed to set instrumentation on services.\n");
- return false;
- }
- return true;
-}
-
-bool DisableHALProfiling() {
- property_set("hal.instrumentation.enable", "false");
- if (!SetHALInstrumentation()) {
- fprintf(stderr, "failed to set instrumentation on services.\n");
- return false;
- }
- return true;
-}
-
-void PrintUsage() {
- printf(
- "Usage: \n"
- "To enable profiling: <binary> enable <lib path 32> <lib path 64>"
- "To disable profiling <binary> disable");
-}
-
-int main(int argc, char *argv[]) {
- if (argc == 2 && !strcmp(argv[1], "disable")) {
- printf("* disable profiling.\n");
- property_set("hal.instrumentation.lib.path.32", "");
- property_set("hal.instrumentation.lib.path.64", "");
- if (!DisableHALProfiling()) {
- printf("failed to disable profiling.\n");
- return -1;
- }
- } else if (argc >= 2 && !strcmp(argv[1], "enable")) {
- printf("* enable profiling.\n");
- if (argc == 4) {
- property_set("hal.instrumentation.lib.path.32", argv[2]);
- property_set("hal.instrumentation.lib.path.64", argv[3]);
- }
- if (!EnableHALProfiling()) {
- printf("failed to enable profiling.\n");
- return -1;
- }
- } else {
- PrintUsage();
- }
- return 0;
-}
diff --git a/utils/native/libprofiling/VtsProfilingInterface.cpp b/utils/native/libprofiling/VtsProfilingInterface.cpp
deleted file mode 100644
index 6764d77..0000000
--- a/utils/native/libprofiling/VtsProfilingInterface.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright 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.
- */
-#include "VtsProfilingInterface.h"
-
-#include <cutils/properties.h>
-#include <fcntl.h>
-#include <fstream>
-#include <string>
-
-#include <android-base/logging.h>
-#include <google/protobuf/text_format.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include "VtsProfilingUtil.h"
-#include "test/vts/proto/VtsDriverControlMessage.pb.h"
-#include "test/vts/proto/VtsProfilingMessage.pb.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-VtsProfilingInterface::VtsProfilingInterface(
- const string& trace_file_path_prefix)
- : trace_file_path_prefix_(trace_file_path_prefix) {}
-
-VtsProfilingInterface::~VtsProfilingInterface() {
- mutex_.lock();
- for (auto it = trace_map_.begin(); it != trace_map_.end(); ++it) {
- close(it->second);
- }
- mutex_.unlock();
-}
-
-int64_t VtsProfilingInterface::NanoTime() {
- std::chrono::nanoseconds duration(
- std::chrono::steady_clock::now().time_since_epoch());
- return static_cast<int64_t>(duration.count());
-}
-
-VtsProfilingInterface& VtsProfilingInterface::getInstance(
- const string& trace_file_path_prefix) {
- static VtsProfilingInterface instance(trace_file_path_prefix);
- return instance;
-}
-
-int VtsProfilingInterface::GetTraceFile(const string& package,
- const string& version) {
- string fullname = package + "@" + version;
- int fd = -1;
- if (trace_map_.find(fullname) != trace_map_.end()) {
- fd = trace_map_[fullname];
- struct stat statbuf;
- fstat(fd, &statbuf);
- // If file no longer exists or the file descriptor is no longer valid,
- // create a new trace file.
- if (statbuf.st_nlink <= 0 || fcntl(fd, F_GETFD) == -1) {
- fd = CreateTraceFile(package, version);
- trace_map_[fullname] = fd;
- }
- } else {
- // Create trace file for a new HAL.
- fd = CreateTraceFile(package, version);
- trace_map_[fullname] = fd;
- }
- return fd;
-}
-
-int VtsProfilingInterface::CreateTraceFile(const string& package,
- const string& version) {
- // Attach device info and timestamp for the trace file.
- char build_number[PROPERTY_VALUE_MAX];
- char device_id[PROPERTY_VALUE_MAX];
- char product_name[PROPERTY_VALUE_MAX];
- property_get("ro.build.version.incremental", build_number, "unknown_build");
- property_get("ro.serialno", device_id, "unknown_device");
- property_get("ro.build.product", product_name, "unknown_product");
-
- string file_path = trace_file_path_prefix_ + package + "_" + version + "_" +
- string(product_name) + "_" + string(device_id) + "_" +
- string(build_number) + "_" + to_string(NanoTime()) +
- ".vts.trace";
-
- LOG(INFO) << "Creating new trace file: " << file_path;
- int fd = open(file_path.c_str(), O_RDWR | O_CREAT | O_EXCL,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
- if (fd < 0) {
- PLOG(ERROR) << "Can not open trace file: " << file_path;
- return -1;
- }
- return fd;
-}
-
-void VtsProfilingInterface::AddTraceEvent(
- android::hardware::details::HidlInstrumentor::InstrumentationEvent event,
- const char* package, const char* version, const char* interface,
- const FunctionSpecificationMessage& message) {
- std::string version_str = std::string(version);
- int version_major = stoi(version_str.substr(0, version_str.find('.')));
- int version_minor = stoi(version_str.substr(version_str.find('.') + 1));
- // Build the VTSProfilingRecord and print it to string.
- VtsProfilingRecord record;
- record.set_timestamp(NanoTime());
- record.set_event((InstrumentationEventType) static_cast<int>(event));
- record.set_package(package);
- record.set_version_major(version_major);
- record.set_version_minor(version_minor);
- record.set_interface(interface);
- *record.mutable_func_msg() = message;
-
- // Write the record string to trace file.
- mutex_.lock();
- int fd = GetTraceFile(package, version);
- if (fd == -1) {
- LOG(ERROR) << "Failed to get trace file.";
- } else {
- google::protobuf::io::FileOutputStream trace_output(fd);
- if (!writeOneDelimited(record, &trace_output)) {
- LOG(ERROR) << "Failed to write record.";
- }
- if (!trace_output.Flush()) {
- PLOG(ERROR) << "Failed to flush";
- }
- }
- mutex_.unlock();
-}
-
-} // namespace vts
-} // namespace android
diff --git a/utils/native/libprofiling/VtsProfilingInterface.h b/utils/native/libprofiling/VtsProfilingInterface.h
deleted file mode 100644
index 7e177cc..0000000
--- a/utils/native/libprofiling/VtsProfilingInterface.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#ifndef __VTS_DRIVER_PROFILING_INTERFACE_H_
-#define __VTS_DRIVER_PROFILING_INTERFACE_H_
-
-#include <android-base/macros.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
-#include <hidl/HidlSupport.h>
-#include <utils/Condition.h>
-#include <fstream>
-
-#include "test/vts/proto/ComponentSpecificationMessage.pb.h"
-
-using namespace std;
-
-namespace android {
-namespace vts {
-
-// Library class to trace, record and profile a HIDL HAL implementation.
-class VtsProfilingInterface {
- public:
- explicit VtsProfilingInterface(const string& trace_file_path);
-
- virtual ~VtsProfilingInterface();
-
- // Get and create the VtsProfilingInterface singleton.
- static VtsProfilingInterface& getInstance(const string& trace_file_path);
-
- // returns true if the given message is added to the tracing queue.
- void AddTraceEvent(
- android::hardware::details::HidlInstrumentor::InstrumentationEvent event,
- const char* package, const char* version, const char* interface,
- const FunctionSpecificationMessage& message);
-
- private:
- // Internal method to get the corresponding trace file descriptor for a HAL
- // with given package and version.
- int GetTraceFile(const string& package, const string& version);
- // Internal method to create a trace file based on the trace_file_path_prefix_
- // the given package and version, the device info and the current time.
- int CreateTraceFile(const string& package, const string& version);
- // Get the current time in nano seconds.
- int64_t NanoTime();
-
- // Prefix of all trace files.
- string trace_file_path_prefix_; // Prefix of the trace file.
-
- // map between the HAL to the trace file description.
- map<string, int> trace_map_;
- Mutex mutex_; // Mutex used to synchronize the writing to the trace file.
-
- DISALLOW_COPY_AND_ASSIGN(VtsProfilingInterface);
-};
-
-} // namespace vts
-} // namespace android
-
-#endif // __VTS_DRIVER_PROFILING_INTERFACE_H_
diff --git a/utils/native/libprofiling/VtsProfilingUtil.cpp b/utils/native/libprofiling/VtsProfilingUtil.cpp
deleted file mode 100644
index bc13050..0000000
--- a/utils/native/libprofiling/VtsProfilingUtil.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.
- */
-#include "VtsProfilingUtil.h"
-
-#include <stdint.h>
-
-#include "google/protobuf/io/coded_stream.h"
-
-namespace android {
-namespace vts {
-
-bool writeOneDelimited(const google::protobuf::MessageLite& message,
- google::protobuf::io::ZeroCopyOutputStream* out) {
- // We create a new coded stream for each message. This is fast.
- google::protobuf::io::CodedOutputStream output(out);
-
- // Write the size.
- const int size = message.ByteSize();
- output.WriteVarint32(size);
-
- uint8_t* buffer = output.GetDirectBufferForNBytesAndAdvance(size);
- if (buffer) {
- // Optimization: The message fits in one buffer, so use the faster
- // direct-to-array serialization path.
- message.SerializeWithCachedSizesToArray(buffer);
- } else {
- // Slightly-slower path when the message is multiple buffers.
- message.SerializeWithCachedSizes(&output);
- if (output.HadError()) {
- return false;
- }
- }
-
- return true;
-}
-
-bool readOneDelimited(google::protobuf::MessageLite* message,
- google::protobuf::io::ZeroCopyInputStream* in) {
- // We create a new coded stream for each message. This is fast,
- // and it makes sure the 64MB total size limit is imposed per-message rather
- // than on the whole stream (See the CodedInputStream interface for more
- // info on this limit).
- google::protobuf::io::CodedInputStream input(in);
-
- // Read the size.
- uint32_t size;
- if (!input.ReadVarint32(&size)) {
- return false;
- }
- // Tell the stream not to read beyond that size.
- const auto limit = input.PushLimit(size);
-
- // Parse the message.
- if (!message->MergeFromCodedStream(&input)) {
- return false;
- }
- if (!input.ConsumedEntireMessage()) {
- return false;
- }
-
- // Release the limit.
- input.PopLimit(limit);
-
- return true;
-}
-
-} // namespace vts
-} // namespace android
diff --git a/utils/native/libprofiling/VtsProfilingUtil.h b/utils/native/libprofiling/VtsProfilingUtil.h
deleted file mode 100644
index 71881ff..0000000
--- a/utils/native/libprofiling/VtsProfilingUtil.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * * 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.
- *
- */
-#ifndef DRIVERS_HAL_COMMON_UTILS_VTSPROFILINGUTIL_H_
-#define DRIVERS_HAL_COMMON_UTILS_VTSPROFILINGUTIL_H_
-
-#include "google/protobuf/io/zero_copy_stream.h"
-#include "google/protobuf/message_lite.h"
-
-// This file defines methods for serialization of protobuf messages in the same
-// way as Java's writeDelimitedTo()/parseDelimitedFrom().
-namespace android {
-namespace vts {
-
-// Serializes one message to the out file, delimited by message size.
-bool writeOneDelimited(const ::google::protobuf::MessageLite& message,
- google::protobuf::io::ZeroCopyOutputStream* out);
-
-// Deserialize one message from the in file, delimited by message size.
-bool readOneDelimited(::google::protobuf::MessageLite* message,
- google::protobuf::io::ZeroCopyInputStream* in);
-
-} // namespace vts
-} // namespace android
-#endif // DRIVERS_HAL_COMMON_UTILS_VTSPROFILINGUTIL_H_
diff --git a/utils/native/trace_processor/Android.bp b/utils/native/trace_processor/Android.bp
deleted file mode 100644
index 48fe58a..0000000
--- a/utils/native/trace_processor/Android.bp
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-// 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.
-//
-
-package {
- default_applicable_licenses: ["Android-Apache-2.0"],
-}
-
-cc_library_host_shared {
- name: "libvts_traceprocessor",
-
- srcs: ["VtsTraceProcessor.cpp", "VtsCoverageProcessor.cpp"],
-
- shared_libs: [
- "libbase",
- "libcutils",
- "libprotobuf-cpp-full",
- "libvts_multidevice_proto",
- "libvts_profiling_utils",
- ],
- static_libs: [
- "libjsoncpp",
- ],
- cflags: [
- "-Wall",
- "-Werror",
- ],
-}
-
-cc_binary_host {
- name: "trace_processor",
-
- srcs: ["TraceProcessorMain.cpp"],
-
- shared_libs: [
- "libbase",
- "libprotobuf-cpp-full",
- "libvts_multidevice_proto",
- "libvts_traceprocessor",
- ],
- cflags: [
- "-Wall",
- "-Werror",
- ],
-}
diff --git a/utils/native/trace_processor/TraceProcessorMain.cpp b/utils/native/trace_processor/TraceProcessorMain.cpp
deleted file mode 100644
index 8eb821c..0000000
--- a/utils/native/trace_processor/TraceProcessorMain.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * 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.
- */
-#include <getopt.h>
-
-#include "VtsCoverageProcessor.h"
-#include "VtsTraceProcessor.h"
-
-static constexpr const char* kDefaultMode = "noop";
-static constexpr const char* kDefaultOutputFile =
- "/temp/vts_trace_processor_output";
-
-using namespace std;
-
-enum mode_code {
- // Trace related operations.
- CLEANUP_TRACE,
- CONVERT_TRACE,
- DEDUPE_TRACE,
- GET_TEST_LIST_FROM_TRACE,
- PARSE_TRACE,
- PROFILING_TRACE,
- SELECT_TRACE,
- // Coverage related operations.
- COMPARE_COVERAGE,
- GET_COVERGAGE_SUMMARY,
- GET_SUBSET_COVERAGE,
- MERGE_COVERAGE,
-};
-
-mode_code getModeCode(const std::string& str) {
- if (str == "cleanup_trace") return mode_code::CLEANUP_TRACE;
- if (str == "convert_trace") return mode_code::CONVERT_TRACE;
- if (str == "dedup_trace") return mode_code::DEDUPE_TRACE;
- if (str == "get_test_list_from_trace")
- return mode_code::GET_TEST_LIST_FROM_TRACE;
- if (str == "parse_trace") return mode_code::PARSE_TRACE;
- if (str == "profiling_trace") return mode_code::PROFILING_TRACE;
- if (str == "select_trace") return mode_code::SELECT_TRACE;
- if (str == "compare_coverage") return mode_code::COMPARE_COVERAGE;
- if (str == "get_coverage_summary") return mode_code::GET_COVERGAGE_SUMMARY;
- if (str == "get_subset_coverage") return mode_code::GET_SUBSET_COVERAGE;
- if (str == "merge_coverage") return mode_code::MERGE_COVERAGE;
- printf("Unknown operation mode: %s\n", str.c_str());
- exit(-1);
-}
-
-void ShowUsage() {
- printf(
- "Usage: trace_processor [options] <input>\n"
- "--mode: The operation applied to the trace file.\n"
- "\t cleanup_trace: cleanup trace for replay (remove duplicate events "
- "etc.).\n"
- "\t convert_trace: convert a text format trace file into a binary format "
- "trace.\n"
- "\t dedup_trace: remove duplicate trace file in the given directory. A "
- "trace is considered duplicated if there exists a trace that contains "
- "the "
- "same API call sequence as the given trace and the input parameters for "
- "each API call are all the same.\n"
- "\t get_test_list_from_trace: parse all trace files under the given "
- "directory and create a list of test modules for each hal@version that "
- "access all apis covered by the whole test set. (i.e. such list should "
- "be a subset of the whole test list that access the corresponding "
- "hal@version)\n"
- "\t parse_trace: parse the binary format trace file and print the text "
- "format trace. \n"
- "\t profiling_trace: parse the trace file to get the latency of each api "
- "call.\n"
- "\t select_trace: select a subset of trace files from a give trace set "
- "based on their corresponding coverage data, the goal is to pick up the "
- "minimal num of trace files that to maximize the total coverage.\n"
- "\t compare_coverage: compare a coverage report with a reference "
- "coverage report and print the additional file/lines covered.\n"
- "\t get_coverage_summary: print the summary of the coverage file (e.g. "
- "covered lines, total lines, coverage rate.) \n"
- "\t get_subset_coverage: extract coverage measurement from coverage "
- "report for files covered in the reference coverage report. It is used "
- "in cases when we have an aggregated coverage report for all files but "
- "are only interested in the coverage measurement of a subset of files in "
- "that report.\n"
- "\t merge_coverage: merge all coverage reports under the given directory "
- "and generate a merged report.\n"
- "--output: The file path to store the output results.\n"
- "--help: Show help\n");
- exit(-1);
-}
-
-int main(int argc, char** argv) {
- string mode = kDefaultMode;
- string output = kDefaultOutputFile;
- bool verbose_output = false;
-
- android::vts::VtsCoverageProcessor coverage_processor;
- android::vts::VtsTraceProcessor trace_processor(&coverage_processor);
-
- const char* const short_opts = "hm:o:v:";
- const option long_opts[] = {
- {"help", no_argument, nullptr, 'h'},
- {"mode", required_argument, nullptr, 'm'},
- {"output", required_argument, nullptr, 'o'},
- {"verbose", no_argument, nullptr, 'v'},
- {nullptr, 0, nullptr, 0},
- };
-
- while (true) {
- int opt = getopt_long(argc, argv, short_opts, long_opts, nullptr);
- if (opt == -1) {
- break;
- }
- switch (opt) {
- case 'h':
- case '?':
- ShowUsage();
- return 0;
- case 'm': {
- mode = string(optarg);
- break;
- }
- case 'o': {
- output = string(optarg);
- break;
- }
- case 'v': {
- verbose_output = true;
- break;
- }
- default:
- printf("getopt_long returned unexpected value: %d\n", opt);
- return -1;
- }
- }
-
- if (optind == argc - 1) {
- string trace_path = argv[optind];
- switch (getModeCode(mode)) {
- case mode_code::CLEANUP_TRACE:
- trace_processor.CleanupTraces(trace_path);
- break;
- case mode_code::CONVERT_TRACE:
- trace_processor.ConvertTrace(trace_path);
- break;
- case mode_code::DEDUPE_TRACE:
- trace_processor.DedupTraces(trace_path);
- break;
- case mode_code::GET_TEST_LIST_FROM_TRACE:
- trace_processor.GetTestListForHal(trace_path, output, verbose_output);
- break;
- case mode_code::PARSE_TRACE:
- trace_processor.ParseTrace(trace_path);
- break;
- case mode_code::PROFILING_TRACE:
- trace_processor.ProcessTraceForLatencyProfiling(trace_path);
- break;
- case mode_code::GET_COVERGAGE_SUMMARY:
- coverage_processor.GetCoverageSummary(trace_path);
- break;
- case mode_code::MERGE_COVERAGE:
- coverage_processor.MergeCoverage(trace_path, output);
- break;
- default:
- printf("Invalid argument.");
- return -1;
- }
- } else if (optind == argc - 2) {
- switch (getModeCode(mode)) {
- case mode_code::SELECT_TRACE: {
- string coverage_dir = argv[optind];
- string trace_dir = argv[optind + 1];
- trace_processor.SelectTraces(coverage_dir, trace_dir);
- break;
- }
- case mode_code::COMPARE_COVERAGE: {
- string ref_coverage_path = argv[optind];
- string coverage_path = argv[optind + 1];
- coverage_processor.CompareCoverage(ref_coverage_path, coverage_path);
- break;
- }
- case mode_code::GET_SUBSET_COVERAGE: {
- string ref_coverage_path = argv[optind];
- string coverage_path = argv[optind + 1];
- coverage_processor.GetSubsetCoverage(ref_coverage_path, coverage_path,
- output);
- break;
- }
- default:
- printf("Invalid argument.");
- return -1;
- }
- }
- return 0;
-}
diff --git a/utils/native/trace_processor/VtsCoverageProcessor.cpp b/utils/native/trace_processor/VtsCoverageProcessor.cpp
deleted file mode 100644
index afa2c2a..0000000
--- a/utils/native/trace_processor/VtsCoverageProcessor.cpp
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-#include "VtsCoverageProcessor.h"
-
-#include <dirent.h>
-#include <fcntl.h>
-#include <fstream>
-#include <iostream>
-#include <map>
-#include <string>
-#include <vector>
-
-#include <google/protobuf/text_format.h>
-#include <test/vts/proto/VtsReportMessage.pb.h>
-
-using namespace std;
-using google::protobuf::TextFormat;
-
-namespace android {
-namespace vts {
-
-void VtsCoverageProcessor::ParseCoverageData(const string& coverage_file,
- TestReportMessage* report_msg) {
- ifstream in(coverage_file, std::ios::in);
- string msg_str((istreambuf_iterator<char>(in)), istreambuf_iterator<char>());
- if (!TextFormat::MergeFromString(msg_str, report_msg)) {
- cerr << "Can't parse a given coverage report: " << msg_str << endl;
- exit(-1);
- }
-}
-
-void VtsCoverageProcessor::UpdateCoverageData(
- const CoverageReportMessage& ref_msg,
- CoverageReportMessage* msg_to_be_updated) {
- if (ref_msg.file_path() == msg_to_be_updated->file_path()) {
- for (int line = 0; line < ref_msg.line_coverage_vector_size(); line++) {
- if (line < msg_to_be_updated->line_coverage_vector_size()) {
- if (ref_msg.line_coverage_vector(line) > 0 &&
- msg_to_be_updated->line_coverage_vector(line) > 0) {
- msg_to_be_updated->set_line_coverage_vector(line, 0);
- msg_to_be_updated->set_covered_line_count(
- msg_to_be_updated->covered_line_count() - 1);
- }
- } else {
- cout << "Reached the end of line_coverage_vector." << endl;
- break;
- }
- }
- // Validate
- if (msg_to_be_updated->covered_line_count() < 0) {
- cerr << __func__ << ": covered_line_count should not be negative."
- << endl;
- exit(-1);
- }
- }
-}
-
-void VtsCoverageProcessor::MergeCoverage(const string& coverage_file_dir,
- const string& merged_coverage_file) {
- DIR* coverage_dir = opendir(coverage_file_dir.c_str());
- if (coverage_dir == 0) {
- cerr << __func__ << ": " << coverage_file_dir << " does not exist." << endl;
- return;
- }
- TestReportMessage merged_coverage_report;
-
- struct dirent* file;
- while ((file = readdir(coverage_dir)) != NULL) {
- if (file->d_type == DT_REG) {
- string coverage_file = coverage_file_dir;
- if (coverage_file_dir.substr(coverage_file_dir.size() - 1) != "/") {
- coverage_file += "/";
- }
- string coverage_file_base_name = file->d_name;
- coverage_file += coverage_file_base_name;
- TestReportMessage coverage_report;
- ParseCoverageData(coverage_file, &coverage_report);
-
- for (const auto& cov : coverage_report.coverage()) {
- bool seen_cov = false;
- for (int i = 0; i < merged_coverage_report.coverage_size(); i++) {
- if (merged_coverage_report.coverage(i).file_path() ==
- cov.file_path()) {
- MergeCoverageMsg(cov, merged_coverage_report.mutable_coverage(i));
- seen_cov = true;
- break;
- }
- }
- if (!seen_cov) {
- *merged_coverage_report.add_coverage() = cov;
- }
- }
- }
- }
-
- PrintCoverageSummary(merged_coverage_report);
- ofstream fout;
- fout.open(merged_coverage_file);
- fout << merged_coverage_report.DebugString();
- fout.close();
-}
-
-void VtsCoverageProcessor::MergeCoverageMsg(
- const CoverageReportMessage& ref_coverage_msg,
- CoverageReportMessage* merged_coverage_msg) {
- // File path consistency check.
- if (ref_coverage_msg.file_path() != merged_coverage_msg->file_path()) {
- cerr << "Trying to merge coverage data for different files." << endl;
- exit(-1);
- }
- if (ref_coverage_msg.line_coverage_vector_size() !=
- merged_coverage_msg->line_coverage_vector_size()) {
- cerr << "Trying to merge coverage data with different lines."
- << "ref_coverage_msg: " << ref_coverage_msg.DebugString()
- << "merged_coverage_msg: " << merged_coverage_msg->DebugString()
- << endl;
- exit(-1);
- }
- for (int i = 0; i < ref_coverage_msg.line_coverage_vector_size(); i++) {
- if (i > merged_coverage_msg->line_coverage_vector_size() - 1) {
- cerr << "Reach the end of coverage vector" << endl;
- break;
- }
- int ref_line_count = ref_coverage_msg.line_coverage_vector(i);
- int merged_line_count = merged_coverage_msg->line_coverage_vector(i);
- if (ref_line_count > 0) {
- if (merged_line_count == 0) {
- merged_coverage_msg->set_covered_line_count(
- merged_coverage_msg->covered_line_count() + 1);
- }
- merged_coverage_msg->set_line_coverage_vector(
- i, merged_line_count + ref_line_count);
- }
- }
-}
-
-void VtsCoverageProcessor::CompareCoverage(const string& ref_msg_file,
- const string& new_msg_file) {
- TestReportMessage ref_coverage_report;
- TestReportMessage new_coverage_report;
- ParseCoverageData(ref_msg_file, &ref_coverage_report);
- ParseCoverageData(new_msg_file, &new_coverage_report);
- map<string, vector<int>> new_coverage_map;
-
- for (const auto& new_coverage : new_coverage_report.coverage()) {
- bool seen_file = false;
- for (const auto& ref_coverage : ref_coverage_report.coverage()) {
- if (new_coverage.file_path() == ref_coverage.file_path()) {
- int line = 0;
- for (; line < new_coverage.line_coverage_vector_size(); line++) {
- if (new_coverage.line_coverage_vector(line) > 0 &&
- ref_coverage.line_coverage_vector(line) == 0) {
- if (new_coverage_map.find(new_coverage.file_path()) !=
- new_coverage_map.end()) {
- new_coverage_map[new_coverage.file_path()].push_back(line);
- } else {
- new_coverage_map.insert(std::pair<string, vector<int>>(
- new_coverage.file_path(), vector<int>{line}));
- }
- }
- }
- seen_file = true;
- break;
- }
- }
- if (!seen_file) {
- vector<int> new_line;
- for (int line = 0; line < new_coverage.line_coverage_vector_size();
- line++) {
- if (new_coverage.line_coverage_vector(line) > 0) {
- new_line.push_back(line);
- }
- }
- new_coverage_map.insert(
- std::pair<string, vector<int>>(new_coverage.file_path(), new_line));
- }
- }
- for (auto it = new_coverage_map.begin(); it != new_coverage_map.end(); it++) {
- cout << it->first << ": " << endl;
- for (int covered_line : it->second) {
- cout << covered_line << endl;
- }
- }
-}
-
-void VtsCoverageProcessor::GetSubsetCoverage(const string& ref_msg_file,
- const string& full_msg_file,
- const string& result_msg_file) {
- TestReportMessage ref_coverage_report;
- TestReportMessage full_coverage_report;
- TestReportMessage result_coverage_report;
- ParseCoverageData(ref_msg_file, &ref_coverage_report);
- ParseCoverageData(full_msg_file, &full_coverage_report);
-
- for (const auto& ref_coverage : ref_coverage_report.coverage()) {
- bool seen_file = false;
- for (const auto& coverage : full_coverage_report.coverage()) {
- if (coverage.file_path() == ref_coverage.file_path()) {
- *result_coverage_report.add_coverage() = coverage;
- seen_file = true;
- break;
- }
- }
- if (!seen_file) {
- cout << ": missing coverage for file " << ref_coverage.file_path()
- << endl;
- CoverageReportMessage* empty_coverage =
- result_coverage_report.add_coverage();
- *empty_coverage = ref_coverage;
- for (int line = 0; line < empty_coverage->line_coverage_vector_size();
- line++) {
- if (empty_coverage->line_coverage_vector(line) > 0) {
- empty_coverage->set_line_coverage_vector(line, 0);
- }
- }
- empty_coverage->set_covered_line_count(0);
- }
- }
- PrintCoverageSummary(result_coverage_report);
- ofstream fout;
- fout.open(result_msg_file);
- fout << result_coverage_report.DebugString();
- fout.close();
-}
-
-void VtsCoverageProcessor::GetCoverageSummary(const string& coverage_msg_file) {
- TestReportMessage coverage_report;
- ParseCoverageData(coverage_msg_file, &coverage_report);
- PrintCoverageSummary(coverage_report);
-}
-
-void VtsCoverageProcessor::PrintCoverageSummary(
- const TestReportMessage& coverage_report) {
- long total_lines_covered = GetTotalCoverageLine(coverage_report);
- long total_code_lines = GetTotalCodeLine(coverage_report);
- double coverage_rate = (double)total_lines_covered / total_code_lines;
- cout << "total lines covered: " << total_lines_covered << endl;
- cout << "total lines: " << total_code_lines << endl;
- cout << "coverage rate: " << coverage_rate << endl;
-}
-
-long VtsCoverageProcessor::GetTotalCoverageLine(
- const TestReportMessage& msg) const {
- long total_coverage_line = 0;
- for (const auto& coverage : msg.coverage()) {
- total_coverage_line += coverage.covered_line_count();
- }
- return total_coverage_line;
-}
-
-long VtsCoverageProcessor::GetTotalCodeLine(
- const TestReportMessage& msg) const {
- long total_line = 0;
- for (const auto& coverage : msg.coverage()) {
- total_line += coverage.total_line_count();
- }
- return total_line;
-}
-
-} // namespace vts
-} // namespace android
diff --git a/utils/native/trace_processor/VtsCoverageProcessor.h b/utils/native/trace_processor/VtsCoverageProcessor.h
deleted file mode 100644
index e1eb70a..0000000
--- a/utils/native/trace_processor/VtsCoverageProcessor.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 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.
- */
-
-#ifndef TOOLS_TRACE_PROCESSOR_VTSCOVERAGEPROCESSOR_H_
-#define TOOLS_TRACE_PROCESSOR_VTSCOVERAGEPROCESSOR_H_
-
-#include <android-base/macros.h>
-#include <test/vts/proto/VtsReportMessage.pb.h>
-
-namespace android {
-namespace vts {
-// A class used for processing coverage report data, such as parse the
-// coverage report file, merge multiple coverage reports, and compare
-// two coverage reports.
-class VtsCoverageProcessor {
- public:
- VtsCoverageProcessor(){};
- virtual ~VtsCoverageProcessor(){};
-
- // Merge the coverage files under coverage_file_dir and output the merged
- // coverage data to merged_coverage_file.
- void MergeCoverage(const std::string& coverage_file_dir,
- const std::string& merged_coverage_file);
-
- // Compare coverage data contained in new_msg_file with ref_msg_file and
- // print the additional file/lines covered by the new_msg_file.
- void CompareCoverage(const std::string& ref_msg_file,
- const std::string& new_msg_file);
-
- // Parse the given coverage_file into a coverage report.
- void ParseCoverageData(const std::string& coverage_file,
- TestReportMessage* coverage_report);
-
- // Updates msg_to_be_updated by removing all the covered lines in ref_msg
- // and recalculates the count of covered lines accordingly.
- void UpdateCoverageData(const CoverageReportMessage& ref_msg,
- CoverageReportMessage* msg_to_be_updated);
-
- // Extract the files covered in ref_msg_file from full_msg_file and store
- // the result in result_msg_file.
- void GetSubsetCoverage(const std::string& ref_msg_file,
- const std::string& full_msg_file,
- const std::string& result_msg_file);
-
- // Parse the coverage report and print the coverage summary.
- void GetCoverageSummary(const std::string& coverage_msg_file);
-
- // Calculate total coverage line in the given report message.
- long GetTotalCoverageLine(const TestReportMessage& msg) const;
- // Calculate total code line in the given report message.
- long GetTotalCodeLine(const TestReportMessage& msg) const;
-
- private:
- // Internal method to merge the ref_coverage_msg into merged_covergae_msg.
- void MergeCoverageMsg(const CoverageReportMessage& ref_coverage_msg,
- CoverageReportMessage* merged_covergae_msg);
-
- // Help method to print the coverage summary.
- void PrintCoverageSummary(const TestReportMessage& coverage_report);
-
- DISALLOW_COPY_AND_ASSIGN(VtsCoverageProcessor);
-};
-
-} // namespace vts
-} // namespace android
-#endif // TOOLS_TRACE_PROCESSOR_VTSCOVERAGEPROCESSOR_H_
diff --git a/utils/native/trace_processor/VtsTraceProcessor.cpp b/utils/native/trace_processor/VtsTraceProcessor.cpp
deleted file mode 100644
index c77a535..0000000
--- a/utils/native/trace_processor/VtsTraceProcessor.cpp
+++ /dev/null
@@ -1,704 +0,0 @@
-/*
- * 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.
- */
-#include "VtsTraceProcessor.h"
-
-#include <dirent.h>
-#include <fcntl.h>
-#include <json/json.h>
-#include <fstream>
-#include <iomanip>
-#include <iostream>
-#include <map>
-#include <sstream>
-#include <string>
-#include <vector>
-
-#include <google/protobuf/io/zero_copy_stream_impl.h>
-#include <google/protobuf/text_format.h>
-#include <sys/stat.h>
-#include <test/vts/proto/ComponentSpecificationMessage.pb.h>
-#include <test/vts/proto/VtsReportMessage.pb.h>
-
-#include "VtsProfilingUtil.h"
-
-using namespace std;
-using google::protobuf::TextFormat;
-
-namespace android {
-namespace vts {
-
-bool VtsTraceProcessor::ParseBinaryTrace(const string& trace_file,
- bool ignore_timestamp, bool entry_only,
- bool ignore_func_params,
- VtsProfilingMessage* profiling_msg) {
- int fd =
- open(trace_file.c_str(), O_RDONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
- if (fd < 0) {
- cerr << "Can not open trace file: " << trace_file
- << "error: " << std::strerror(errno);
- return false;
- }
- google::protobuf::io::FileInputStream input(fd);
- VtsProfilingRecord record;
- while (readOneDelimited(&record, &input)) {
- if (ignore_timestamp) {
- record.clear_timestamp();
- }
- if (ignore_func_params) {
- record.mutable_func_msg()->clear_arg();
- record.mutable_func_msg()->clear_return_type_hidl();
- }
- if (entry_only) {
- if (isEntryEvent(record.event())) {
- *profiling_msg->add_records() = record;
- }
- } else {
- *profiling_msg->add_records() = record;
- }
- record.Clear();
- }
- input.Close();
- return true;
-}
-
-bool VtsTraceProcessor::ParseTextTrace(const string& trace_file,
- VtsProfilingMessage* profiling_msg) {
- ifstream in(trace_file, std::ios::in);
- bool new_record = true;
- string record_str, line;
-
- while (getline(in, line)) {
- // Assume records are separated by '\n'.
- if (line.empty()) {
- new_record = false;
- }
- if (new_record) {
- record_str += line + "\n";
- } else {
- VtsProfilingRecord record;
- if (!TextFormat::MergeFromString(record_str, &record)) {
- cerr << "Can't parse a given record: " << record_str << endl;
- return false;
- }
- *profiling_msg->add_records() = record;
- new_record = true;
- record_str.clear();
- }
- }
- in.close();
- return true;
-}
-
-void VtsTraceProcessor::ParseTrace(const string& trace_file) {
- VtsProfilingMessage profiling_msg;
- if (!ParseBinaryTrace(trace_file, false, false, false, &profiling_msg)) {
- cerr << __func__ << ": Failed to parse trace file: " << trace_file << endl;
- return;
- }
- for (const auto& record : profiling_msg.records()) {
- cout << record.DebugString() << endl;
- }
-}
-
-bool VtsTraceProcessor::WriteProfilingMsg(
- const string& output_file, const VtsProfilingMessage& profiling_msg) {
- int fd = open(output_file.c_str(), O_WRONLY | O_CREAT | O_EXCL,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
- if (fd < 0) {
- cerr << "Can not open trace file: " << output_file
- << "error: " << std::strerror(errno);
- return false;
- }
- google::protobuf::io::FileOutputStream output(fd);
- for (const auto& record : profiling_msg.records()) {
- if (!writeOneDelimited(record, &output)) {
- cerr << "Failed to write record";
- }
- }
- output.Close();
- return true;
-}
-
-void VtsTraceProcessor::ConvertTrace(const string& trace_file) {
- VtsProfilingMessage profiling_msg;
- if (!ParseTextTrace(trace_file, &profiling_msg)) {
- cerr << __func__ << ": Failed to parse trace file: " << trace_file << endl;
- return;
- }
- string tmp_file = trace_file + "_binary";
- if (!WriteProfilingMsg(tmp_file, profiling_msg)) {
- cerr << __func__ << ": Failed to write new trace file: " << tmp_file
- << endl;
- return;
- }
-}
-
-void VtsTraceProcessor::CleanupTraceFile(const string& trace_file) {
- VtsProfilingMessage profiling_msg;
- if (!ParseBinaryTrace(trace_file, false, false, true, &profiling_msg)) {
- cerr << __func__ << ": Failed to parse trace file: " << trace_file << endl;
- return;
- }
- VtsProfilingMessage clean_profiling_msg;
- bool first_record = true;
- enum TRACE_TYPE { server_trace, client_trace, passthrough_trace };
- string package;
- int version_major;
- int version_minor;
- TRACE_TYPE trace_type;
- for (const auto& record : profiling_msg.records()) {
- if (first_record) {
- package = record.package();
- version_major = record.version_major();
- version_minor = record.version_minor();
- // determine trace type based on the event of the first record.
- switch (record.event()) {
- case InstrumentationEventType::SERVER_API_ENTRY:
- trace_type = TRACE_TYPE::server_trace;
- break;
- case InstrumentationEventType::CLIENT_API_ENTRY:
- trace_type = TRACE_TYPE::client_trace;
- break;
- case InstrumentationEventType::PASSTHROUGH_ENTRY:
- trace_type = TRACE_TYPE::passthrough_trace;
- break;
- default:
- cerr << "Unexpected record: " << record.DebugString() << endl;
- return;
- }
- first_record = false;
- }
- // If trace contains records for a different hal, remove it.
- if (record.package() != package ||
- record.version_major() != version_major ||
- record.version_minor() != version_minor) {
- cerr << "Unexpected record: " << record.DebugString() << endl;
- continue;
- }
- switch (trace_type) {
- case TRACE_TYPE::server_trace: {
- if (record.event() == InstrumentationEventType::SERVER_API_ENTRY ||
- record.event() == InstrumentationEventType::SERVER_API_EXIT) {
- *clean_profiling_msg.add_records() = record;
- }
- break;
- }
- case TRACE_TYPE::client_trace: {
- if (record.event() == InstrumentationEventType::CLIENT_API_ENTRY ||
- record.event() == InstrumentationEventType::CLIENT_API_EXIT) {
- *clean_profiling_msg.add_records() = record;
- }
- break;
- }
- case TRACE_TYPE::passthrough_trace: {
- if (record.event() == InstrumentationEventType::PASSTHROUGH_ENTRY ||
- record.event() == InstrumentationEventType::PASSTHROUGH_EXIT) {
- *clean_profiling_msg.add_records() = record;
- }
- break;
- }
- default:
- cerr << "Unknow trace type: " << trace_type << endl;
- return;
- }
- }
- string tmp_file = trace_file + "_tmp";
- if (!WriteProfilingMsg(tmp_file, clean_profiling_msg)) {
- cerr << __func__ << ": Failed to write new trace file: " << tmp_file
- << endl;
- return;
- }
- if (rename(tmp_file.c_str(), trace_file.c_str())) {
- cerr << __func__ << ": Failed to replace old trace file: " << trace_file
- << endl;
- return;
- }
-}
-
-void VtsTraceProcessor::CleanupTraces(const string& path) {
- struct stat path_stat;
- stat(path.c_str(), &path_stat);
- if (S_ISREG(path_stat.st_mode)) {
- CleanupTraceFile(path);
- } else if (S_ISDIR(path_stat.st_mode)) {
- DIR* dir = opendir(path.c_str());
- struct dirent* file;
- while ((file = readdir(dir)) != NULL) {
- if (file->d_type == DT_REG) {
- string trace_file = path;
- if (path.substr(path.size() - 1) != "/") {
- trace_file += "/";
- }
- trace_file += file->d_name;
- CleanupTraceFile(trace_file);
- }
- }
- }
-}
-
-void VtsTraceProcessor::ProcessTraceForLatencyProfiling(
- const string& trace_file) {
- VtsProfilingMessage profiling_msg;
- if (!ParseBinaryTrace(trace_file, false, false, true, &profiling_msg)) {
- cerr << __func__ << ": Failed to parse trace file: " << trace_file << endl;
- return;
- }
- if (!profiling_msg.records_size()) return;
- if (profiling_msg.records(0).event() ==
- InstrumentationEventType::PASSTHROUGH_ENTRY ||
- profiling_msg.records(0).event() ==
- InstrumentationEventType::PASSTHROUGH_EXIT) {
- cout << "hidl_hal_mode:passthrough" << endl;
- } else {
- cout << "hidl_hal_mode:binder" << endl;
- }
-
- // stack to store all seen records.
- vector<VtsProfilingRecord> seen_records;
- // stack to store temp records that not processed.
- vector<VtsProfilingRecord> pending_records;
- for (const auto& record : profiling_msg.records()) {
- if (isEntryEvent(record.event())) {
- seen_records.emplace_back(record);
- } else {
- while (!seen_records.empty() &&
- !isPairedRecord(seen_records.back(), record)) {
- pending_records.emplace_back(seen_records.back());
- seen_records.pop_back();
- }
- if (seen_records.empty()) {
- cerr << "Could not found entry record for record: "
- << record.DebugString() << endl;
- continue;
- } else {
- // Found the paired entry record, calculate the latency.
- VtsProfilingRecord entry_record = seen_records.back();
- seen_records.pop_back();
- string full_api_name = GetFullApiStr(record);
- int64_t start_timestamp = entry_record.timestamp();
- int64_t end_timestamp = record.timestamp();
- int64_t latency = end_timestamp - start_timestamp;
- // Negative latency check.
- if (latency < 0) {
- cerr << __func__ << ": got negative latency for " << full_api_name
- << endl;
- exit(-1);
- }
- cout << full_api_name << ":" << latency << endl;
- while (!pending_records.empty()) {
- seen_records.emplace_back(pending_records.back());
- pending_records.pop_back();
- }
- }
- }
- }
-}
-
-void VtsTraceProcessor::DedupTraces(const string& trace_dir) {
- DIR* dir = opendir(trace_dir.c_str());
- if (dir == 0) {
- cerr << trace_dir << "does not exist." << endl;
- return;
- }
- vector<VtsProfilingMessage> seen_msgs;
- vector<string> duplicate_trace_files;
- struct dirent* file;
- long total_trace_num = 0;
- long duplicat_trace_num = 0;
- while ((file = readdir(dir)) != NULL) {
- if (file->d_type == DT_REG) {
- total_trace_num++;
- string trace_file = trace_dir;
- if (trace_dir.substr(trace_dir.size() - 1) != "/") {
- trace_file += "/";
- }
- trace_file += file->d_name;
- VtsProfilingMessage profiling_msg;
- if (!ParseBinaryTrace(trace_file, true, true, false, &profiling_msg)) {
- cerr << "Failed to parse trace file: " << trace_file << endl;
- return;
- }
- if (!profiling_msg.records_size()) { // empty trace file
- duplicate_trace_files.push_back(trace_file);
- duplicat_trace_num++;
- continue;
- }
- auto found =
- find_if(seen_msgs.begin(), seen_msgs.end(),
- [&profiling_msg](const VtsProfilingMessage& seen_msg) {
- std::string str_profiling_msg;
- std::string str_seen_msg;
- profiling_msg.SerializeToString(&str_profiling_msg);
- seen_msg.SerializeToString(&str_seen_msg);
- return (str_profiling_msg == str_seen_msg);
- });
- if (found == seen_msgs.end()) {
- seen_msgs.push_back(profiling_msg);
- } else {
- duplicate_trace_files.push_back(trace_file);
- duplicat_trace_num++;
- }
- }
- }
- for (const string& duplicate_trace : duplicate_trace_files) {
- cout << "deleting duplicate trace file: " << duplicate_trace << endl;
- remove(duplicate_trace.c_str());
- }
- cout << "Num of traces processed: " << total_trace_num << endl;
- cout << "Num of duplicate trace deleted: " << duplicat_trace_num << endl;
- cout << "Duplicate percentage: "
- << float(duplicat_trace_num) / total_trace_num << endl;
-}
-
-void VtsTraceProcessor::SelectTraces(const string& coverage_file_dir,
- const string& trace_file_dir,
- TraceSelectionMetric metric) {
- DIR* coverage_dir = opendir(coverage_file_dir.c_str());
- if (coverage_dir == 0) {
- cerr << __func__ << ": " << coverage_file_dir << " does not exist." << endl;
- return;
- }
- DIR* trace_dir = opendir(trace_file_dir.c_str());
- if (trace_dir == 0) {
- cerr << __func__ << ": " << trace_file_dir << " does not exist." << endl;
- return;
- }
- map<string, CoverageInfo> original_coverages;
- map<string, CoverageInfo> selected_coverages;
-
- // Parse all the coverage files and store them into original_coverage_msgs.
- struct dirent* file;
- while ((file = readdir(coverage_dir)) != NULL) {
- if (file->d_type == DT_REG) {
- string coverage_file = coverage_file_dir;
- if (coverage_file_dir.substr(coverage_file_dir.size() - 1) != "/") {
- coverage_file += "/";
- }
- string coverage_file_base_name = file->d_name;
- coverage_file += coverage_file_base_name;
- TestReportMessage coverage_msg;
- coverage_processor_->ParseCoverageData(coverage_file, &coverage_msg);
-
- string trace_file = trace_file_dir;
- if (trace_file_dir.substr(trace_file_dir.size() - 1) != "/") {
- trace_file += "/";
- }
- string trace_file_base_name = GetTraceFileName(coverage_file_base_name);
- trace_file += trace_file_base_name;
- ifstream in(trace_file, ifstream::binary | ifstream::ate);
- if (!in.good()) {
- cerr << "trace file: " << trace_file << " does not exists." << endl;
- continue;
- }
- long trace_file_size = in.tellg();
-
- CoverageInfo coverage_info;
- coverage_info.coverage_msg = coverage_msg;
- coverage_info.trace_file_name = trace_file;
- coverage_info.trace_file_size = trace_file_size;
-
- original_coverages[coverage_file] = coverage_info;
- }
- }
- // Greedy algorithm that selects coverage files with the maximal code
- // coverage delta at each iteration. Note: Not guaranteed to generate the
- // optimal set. Example (*: covered, -: not_covered) line#\coverage_file
- // cov1 cov2 cov3
- // 1 * - -
- // 2 * * -
- // 3 - * *
- // 4 - * *
- // 5 - - *
- // This algorithm will select cov2, cov1, cov3 while optimal solution is:
- // cov1, cov3.
- // double max_coverage_size_ratio = 0.0;
- TestReportMessage selected_coverage_msg;
- while (true) {
- double max_selection_metric = 0.0;
- string selected_coverage_file = "";
- // Update the remaining coverage file in original_coverage_msgs.
- for (auto it = original_coverages.begin(); it != original_coverages.end();
- ++it) {
- TestReportMessage cur_coverage_msg = it->second.coverage_msg;
- for (const auto& ref_coverage : selected_coverage_msg.coverage()) {
- for (int i = 0; i < cur_coverage_msg.coverage_size(); i++) {
- CoverageReportMessage* coverage_to_be_updated =
- cur_coverage_msg.mutable_coverage(i);
- coverage_processor_->UpdateCoverageData(ref_coverage,
- coverage_to_be_updated);
- }
- }
- it->second.coverage_msg = cur_coverage_msg;
- long total_coverage_line =
- coverage_processor_->GetTotalCoverageLine(cur_coverage_msg);
- long trace_file_size = it->second.trace_file_size;
- double coverage_size_ratio =
- (double)total_coverage_line / trace_file_size;
- if (metric == TraceSelectionMetric::MAX_COVERAGE) {
- if (coverage_size_ratio > max_selection_metric) {
- max_selection_metric = coverage_size_ratio;
- selected_coverage_file = it->first;
- }
- } else if (metric == TraceSelectionMetric::MAX_COVERAGE_SIZE_RATIO) {
- if (total_coverage_line > max_selection_metric) {
- max_selection_metric = total_coverage_line;
- selected_coverage_file = it->first;
- }
- }
- }
- if (!max_selection_metric) {
- break;
- } else {
- CoverageInfo selected_coverage =
- original_coverages[selected_coverage_file];
- selected_coverages[selected_coverage_file] = selected_coverage;
- // Remove the coverage file from original_coverage_msgs.
- original_coverages.erase(selected_coverage_file);
- selected_coverage_msg = selected_coverage.coverage_msg;
- }
- }
- // Calculate the total code lines and total line covered.
- long total_lines = 0;
- long total_lines_covered = 0;
- for (auto it = selected_coverages.begin(); it != selected_coverages.end();
- ++it) {
- cout << "select trace file: " << it->second.trace_file_name << endl;
- TestReportMessage coverage_msg = it->second.coverage_msg;
- total_lines_covered +=
- coverage_processor_->GetTotalCoverageLine(coverage_msg);
- if (coverage_processor_->GetTotalCodeLine(coverage_msg) > total_lines) {
- total_lines = coverage_processor_->GetTotalCodeLine(coverage_msg);
- }
- }
- double coverage_rate = (double)total_lines_covered / total_lines;
- cout << "total lines covered: " << total_lines_covered << endl;
- cout << "total lines: " << total_lines << endl;
- cout << "coverage rate: " << coverage_rate << endl;
-}
-
-string VtsTraceProcessor::GetTraceFileName(const string& coverage_file_name) {
- std::size_t start = coverage_file_name.find("android.hardware");
- std::size_t end = coverage_file_name.find("vts.trace") + sizeof("vts.trace");
- return coverage_file_name.substr(start, end - start - 1);
-}
-
-bool VtsTraceProcessor::isEntryEvent(const InstrumentationEventType& event) {
- if (event == InstrumentationEventType::SERVER_API_ENTRY ||
- event == InstrumentationEventType::CLIENT_API_ENTRY ||
- event == InstrumentationEventType::PASSTHROUGH_ENTRY) {
- return true;
- }
- return false;
-}
-
-bool VtsTraceProcessor::isPairedRecord(const VtsProfilingRecord& entry_record,
- const VtsProfilingRecord& exit_record) {
- if (entry_record.package() != exit_record.package() ||
- entry_record.version_major() != exit_record.version_major() ||
- entry_record.version_minor() != exit_record.version_minor() ||
- entry_record.interface() != exit_record.interface() ||
- entry_record.func_msg().name() != exit_record.func_msg().name()) {
- return false;
- }
- switch (entry_record.event()) {
- case InstrumentationEventType::SERVER_API_ENTRY: {
- if (exit_record.event() == InstrumentationEventType::SERVER_API_EXIT) {
- return true;
- }
- break;
- }
- case InstrumentationEventType::CLIENT_API_ENTRY: {
- if (exit_record.event() == InstrumentationEventType::CLIENT_API_EXIT)
- return true;
- break;
- }
- case InstrumentationEventType::PASSTHROUGH_ENTRY: {
- if (exit_record.event() == InstrumentationEventType::PASSTHROUGH_EXIT)
- return true;
- break;
- }
- default:
- cout << "Unsupported event: " << entry_record.event() << endl;
- return false;
- }
- return false;
-}
-
-void VtsTraceProcessor::GetTestListForHal(const string& test_trace_dir,
- const string& output_file,
- bool verbose_output) {
- // Mapping from hal name to the list of test that access that hal.
- map<string, vector<TraceSummary>> hal_trace_mapping;
- GetHalTraceMapping(test_trace_dir, &hal_trace_mapping);
-
- map<string, set<string>> test_list;
- for (auto it = hal_trace_mapping.begin(); it != hal_trace_mapping.end();
- it++) {
- test_list[it->first] = set<string>();
- vector<TraceSummary> trace_summaries = it->second;
- vector<string> covered_apis;
- for (const auto& summary : trace_summaries) {
- for (auto const& api_stat_it : summary.api_stats) {
- if (std::find(covered_apis.begin(), covered_apis.end(),
- api_stat_it.first) == covered_apis.end()) {
- covered_apis.push_back(api_stat_it.first);
- test_list[it->first].insert(summary.test_name);
- }
- }
- }
- for (const auto& api : covered_apis) {
- cout << "covered api: " << api << endl;
- }
- }
-
- ofstream fout;
- fout.open(output_file);
- for (auto it = hal_trace_mapping.begin(); it != hal_trace_mapping.end();
- it++) {
- if (verbose_output) {
- Json::Value root(Json::objectValue);
- root["Hal_name"] = Json::Value(it->first);
- Json::Value arr(Json::arrayValue);
- for (const TraceSummary& summary : it->second) {
- Json::Value obj;
- obj["Test_name"] = summary.test_name;
- obj["Unique_Api_Count"] = std::to_string(summary.unique_api_count);
- obj["Total_Api_Count"] = std::to_string(summary.total_api_count);
- arr.append(obj);
- }
- root["Test_list"] = arr;
- fout << root.toStyledString();
- } else {
- fout << it->first << ",";
- for (auto test : test_list[it->first]) {
- auto found = find_if(it->second.begin(), it->second.end(),
- [&](const TraceSummary& trace_summary) {
- return (trace_summary.test_name == test);
- });
- if (found != it->second.end()) {
- fout << found->test_name << "(" << found->unique_api_count << "/"
- << found->total_api_count << "),";
- }
- }
- fout << endl;
- }
- }
- fout.close();
-}
-
-void VtsTraceProcessor::GetHalTraceMapping(
- const string& test_trace_dir,
- map<string, vector<TraceSummary>>* hal_trace_mapping) {
- DIR* trace_dir = opendir(test_trace_dir.c_str());
- if (trace_dir == 0) {
- cerr << __func__ << ": " << trace_dir << " does not exist." << endl;
- return;
- }
- vector<TraceSummary> trace_summaries;
- struct dirent* test_dir;
- while ((test_dir = readdir(trace_dir)) != NULL) {
- if (test_dir->d_type == DT_DIR) {
- string test_name = test_dir->d_name;
- cout << "Processing test: " << test_name << endl;
- string trace_file_dir_name = test_trace_dir;
- if (test_trace_dir.substr(test_trace_dir.size() - 1) != "/") {
- trace_file_dir_name += "/";
- }
- trace_file_dir_name += test_name;
- DIR* trace_file_dir = opendir(trace_file_dir_name.c_str());
- struct dirent* trace_file;
- while ((trace_file = readdir(trace_file_dir)) != NULL) {
- if (trace_file->d_type == DT_REG) {
- string trace_file_name =
- trace_file_dir_name + "/" + trace_file->d_name;
- GetHalTraceSummary(trace_file_name, test_name, &trace_summaries);
- }
- }
- }
- }
-
- // Generate hal_trace_mapping mappings.
- for (const TraceSummary& trace_summary : trace_summaries) {
- string test_name = trace_summary.test_name;
- stringstream stream;
- stream << trace_summary.version_major << "." << trace_summary.version_minor;
- string hal_name = trace_summary.package + "@" + stream.str();
- if (hal_trace_mapping->find(hal_name) != hal_trace_mapping->end()) {
- (*hal_trace_mapping)[hal_name].push_back(trace_summary);
- } else {
- (*hal_trace_mapping)[hal_name] = vector<TraceSummary>{trace_summary};
- }
- }
- for (auto it = hal_trace_mapping->begin(); it != hal_trace_mapping->end();
- it++) {
- // Sort the tests according to unique_api_count and break tie with
- // total_api_count.
- std::sort(it->second.begin(), it->second.end(),
- [](const TraceSummary& lhs, const TraceSummary& rhs) {
- return (lhs.unique_api_count > rhs.unique_api_count) ||
- (lhs.unique_api_count == rhs.unique_api_count &&
- lhs.total_api_count > rhs.total_api_count);
- });
- }
-}
-
-void VtsTraceProcessor::GetHalTraceSummary(
- const string& trace_file, const string& test_name,
- vector<TraceSummary>* trace_summaries) {
- VtsProfilingMessage profiling_msg;
- if (!ParseBinaryTrace(trace_file, true, true, true, &profiling_msg)) {
- cerr << __func__ << ": Failed to parse trace file: " << trace_file << endl;
- return;
- }
- for (const auto& record : profiling_msg.records()) {
- string package = record.package();
- int version_major = record.version_major();
- int version_minor = record.version_minor();
- string func_name = record.func_msg().name();
- auto found =
- find_if(trace_summaries->begin(), trace_summaries->end(),
- [&](const TraceSummary& trace_summary) {
- return (test_name == trace_summary.test_name &&
- package == trace_summary.package &&
- version_major == trace_summary.version_major &&
- version_minor == trace_summary.version_minor);
- });
- if (found != trace_summaries->end()) {
- found->total_api_count++;
- if (found->api_stats.find(func_name) != found->api_stats.end()) {
- found->api_stats[func_name]++;
- } else {
- found->unique_api_count++;
- found->api_stats[func_name] = 1;
- }
- } else {
- map<string, long> api_stats;
- api_stats[func_name] = 1;
- TraceSummary trace_summary(test_name, package, version_major,
- version_minor, 1, 1, api_stats);
- trace_summaries->push_back(trace_summary);
- }
- }
-}
-
-string VtsTraceProcessor::GetFullApiStr(const VtsProfilingRecord& record) {
- return record.package() + '@' + std::to_string(record.version_major()) + '.' +
- std::to_string(record.version_minor()) + "::" + record.interface() +
- "::" + record.func_msg().name();
-}
-
-} // namespace vts
-} // namespace android
diff --git a/utils/native/trace_processor/VtsTraceProcessor.h b/utils/native/trace_processor/VtsTraceProcessor.h
deleted file mode 100644
index 145156d..0000000
--- a/utils/native/trace_processor/VtsTraceProcessor.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef TOOLS_TRACE_PROCESSOR_VTSTRACEPROCESSOR_H_
-#define TOOLS_TRACE_PROCESSOR_VTSTRACEPROCESSOR_H_
-
-#include <android-base/macros.h>
-#include <test/vts/proto/VtsProfilingMessage.pb.h>
-#include <test/vts/proto/VtsReportMessage.pb.h>
-#include "VtsCoverageProcessor.h"
-
-namespace android {
-namespace vts {
-
-class VtsTraceProcessor {
- public:
- explicit VtsTraceProcessor(VtsCoverageProcessor* coverage_processor)
- : coverage_processor_(coverage_processor){};
- virtual ~VtsTraceProcessor(){};
-
- enum TraceSelectionMetric {
- MAX_COVERAGE,
- MAX_COVERAGE_SIZE_RATIO,
- };
- // Cleanups the given trace file/all trace files under the given directory to
- // be used for replaying. Current cleanup depends on the trace type:
- // 1. For sever side trace, remove client side and passthrough records.
- // 2. For client side trace, remove server side and passthrough records.
- // 3. For passthrough trace, remove server and client side records.
- void CleanupTraces(const std::string& path);
- // Parses the given trace file and outputs the latency for each API call.
- void ProcessTraceForLatencyProfiling(const std::string& trace_file);
- // Parses all trace files under the the given trace directory and remove
- // duplicate trace file.
- void DedupTraces(const std::string& trace_dir);
- // Selects a subset of trace files from a give trace set based on their
- // corresponding coverage data that maximize the total coverage.
- // coverage_file_dir: directory that stores all the coverage data files.
- // trace_file_dir: directory that stores the corresponding trace files.
- // metric: metric used to select traces, currently support two metrics:
- // 1. MAX_COVERAGE: select trace that leads to the maximum coverage lines.
- // 2. MAX_COVERAGE_SIZE_RATIO: select trace that has the maximum coverage
- // lines/trace size.
- void SelectTraces(
- const std::string& coverage_file_dir, const std::string& trace_file_dir,
- TraceSelectionMetric metric = TraceSelectionMetric::MAX_COVERAGE);
- // Reads a binary trace file, parse each trace event and print the proto.
- void ParseTrace(const std::string& trace_file);
- // Reads a text trace file, parse each trace event and convert it into a
- // binary trace file.
- void ConvertTrace(const std::string& trace_file);
- // Parse all trace files under test_trace_dir and create a list of test
- // modules for each hal@version that access all apis covered by the whole test
- // set. (i.e. such list should be a subset of the whole test list that access
- // the corresponding hal@version)
- void GetTestListForHal(const std::string& test_trace_dir,
- const std::string& output_file,
- bool verbose_output = false);
-
- private:
- // Reads a binary trace file and parse each trace event into
- // VtsProfilingRecord.
- bool ParseBinaryTrace(const std::string& trace_file, bool ignore_timestamp,
- bool entry_only, bool summary_only,
- VtsProfilingMessage* profiling_msg);
-
- // Reads a text trace file and parse each trace event into
- // VtsProfilingRecord.
- bool ParseTextTrace(const std::string& trace_file,
- VtsProfilingMessage* profiling_msg);
-
- // Writes the given VtsProfilingMessage into an output file.
- bool WriteProfilingMsg(const std::string& output_file,
- const VtsProfilingMessage& profiling_msg);
-
- // Internal method to cleanup a trace file.
- void CleanupTraceFile(const std::string& trace_file);
- // Reads a test report file that contains the coverage data and parse it into
- // TestReportMessage.
- bool ParseCoverageData(const std::string& coverage_file,
- TestReportMessage* report_msg);
- // Updates msg_to_be_updated by removing all the covered lines in ref_msg
- // and recalculates the count of covered lines accordingly.
- void UpdateCoverageData(const CoverageReportMessage& ref_msg,
- CoverageReportMessage* msg_to_be_updated);
- // Helper method to calculate total coverage line in the given report message.
- long GetTotalCoverageLine(const TestReportMessage& msg);
- // Helper method to calculate total code line in the given report message.
- long GetTotalLine(const TestReportMessage& msg);
- // Helper method to extract the trace file name from the given file name.
- std::string GetTraceFileName(const std::string& coverage_file_name);
- // Helper method to check whether the given event is an entry event.
- bool isEntryEvent(const InstrumentationEventType& event);
- // Helper method to check whether the given two records are paired records.
- // Paired records means the two records are for the same hal interface, and
- // have corresponding entry/exit events.
- bool isPairedRecord(const VtsProfilingRecord& entry_record,
- const VtsProfilingRecord& exit_record);
- // Util method to get the string representing the full API name, e.g.
- // android.hardware.foo@1.0::IFoo:open
- std::string GetFullApiStr(const VtsProfilingRecord& record);
-
- // Struct to store the coverage data.
- struct CoverageInfo {
- TestReportMessage coverage_msg;
- std::string trace_file_name;
- long trace_file_size;
- };
-
- // Struct to store the trace summary data.
- struct TraceSummary {
- // Name of test module that generates the trace. e.g. CtsUsbTests.
- std::string test_name;
- // Hal package name. e.g. android.hardware.light
- std::string package;
- // Hal major version, e.g. 1.0 -> 1
- int version_major;
- // Hal minor version, e.g. 1.0 -> 0
- int version_minor;
- // Total number of API calls recorded in the trace.
- long total_api_count;
- // Total number of different APIs recorded in the trace.
- long unique_api_count;
- // Call statistics for each API: <API_name, number_called>
- std::map<std::string, long> api_stats;
-
- TraceSummary(std::string test_name, std::string package, int version_major,
- int version_minor, long total_api_count, long unique_api_count,
- std::map<std::string, long> api_stats)
- : test_name(test_name),
- package(package),
- version_major(version_major),
- version_minor(version_minor),
- total_api_count(total_api_count),
- unique_api_count(unique_api_count),
- api_stats(api_stats){};
- };
-
- // Internal method to parse all trace files under test_trace_dir and create
- // the mapping from each hal@version to the list of test that access it.
- void GetHalTraceMapping(
- const std::string& test_trace_dir,
- std::map<std::string, std::vector<TraceSummary>>* hal_trace_mapping);
-
- // Internal method to parse a trace file and create the corresponding
- // TraceSummary from it.
- void GetHalTraceSummary(const std::string& trace_file,
- const std::string& test_name,
- std::vector<TraceSummary>* trace_summaries);
-
- // A class to process coverage reports. Not owned.
- VtsCoverageProcessor* coverage_processor_;
-
- DISALLOW_COPY_AND_ASSIGN(VtsTraceProcessor);
-};
-
-} // namespace vts
-} // namespace android
-#endif // TOOLS_TRACE_PROCESSOR_VTSTRACEPROCESSOR_H_
diff --git a/utils/python/__init__.py b/utils/python/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/__init__.py
+++ /dev/null
diff --git a/utils/python/archive/Android.mk b/utils/python/archive/Android.mk
deleted file mode 100644
index 88f5735..0000000
--- a/utils/python/archive/Android.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright 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.
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := vts_archive_test
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_MODULE_CLASS := FAKE
-LOCAL_IS_HOST_MODULE := true
-
-include $(BUILD_SYSTEM)/base_rules.mk
-
-py_scripts := \
- $(LOCAL_PATH)/archive_parser_test.py
-
-$(LOCAL_BUILT_MODULE): PRIVATE_PY_SCRIPTS := $(py_scripts)
-$(LOCAL_BUILT_MODULE): $(py_scripts)
- @echo "Regression test (build time): $(PRIVATE_MODULE)"
- $(foreach py, $(PRIVATE_PY_SCRIPTS), (PYTHONPATH=$$PYTHONPATH:test python $(py)) &&) true
- $(hide) touch $@
diff --git a/utils/python/archive/__init__.py b/utils/python/archive/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/archive/__init__.py
+++ /dev/null
diff --git a/utils/python/archive/archive_parser.py b/utils/python/archive/archive_parser.py
deleted file mode 100644
index fb48774..0000000
--- a/utils/python/archive/archive_parser.py
+++ /dev/null
@@ -1,130 +0,0 @@
-#
-# 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.
-#
-"""Parses the contents of a Unix archive file generated using the 'ar' command.
-
-The constructor returns an Archive object, which contains dictionary from
-file name to file content.
-
-
- Typical usage example:
-
- archive = Archive(content)
- archive.Parse()
-"""
-
-import io
-
-class Archive(object):
- """Archive object parses and stores Unix archive contents.
-
- Stores the file names and contents as it parses the archive.
-
- Attributes:
- files: a dictionary from file name (string) to file content (binary)
- """
-
- GLOBAL_SIG = '!<arch>\n' # Unix global signature
- STRING_TABLE_ID = '//'
- STRING_TABLE_TERMINATOR = '/\n'
- SYM_TABLE_ID = '__.SYMDEF'
- FILE_ID_LENGTH = 16 # Number of bytes to store file identifier
- FILE_ID_TERMINATOR = '/'
- FILE_TIMESTAMP_LENGTH = 12 # Number of bytes to store file mod timestamp
- OWNER_ID_LENGTH = 6 # Number of bytes to store file owner ID
- GROUP_ID_LENGTH = 6 # Number of bytes to store file group ID
- FILE_MODE_LENGTH = 8 # Number of bytes to store file mode
- CONTENT_SIZE_LENGTH = 10 # Number of bytes to store content size
- END_TAG = '`\n' # Header end tag
-
- def __init__(self, file_content):
- """Initialize and parse the archive contents.
-
- Args:
- file_content: Binary contents of the archive file.
- """
-
- self.files = {}
- self._content = file_content
- self._cursor = 0
- self._string_table = dict()
-
- def ReadBytes(self, n):
- """Reads n bytes from the content stream.
-
- Args:
- n: The integer number of bytes to read.
-
- Returns:
- The n-bit string (binary) of data from the content stream.
-
- Raises:
- ValueError: invalid file format.
- """
- if self._cursor + n > len(self._content):
- raise ValueError('Invalid file. EOF reached unexpectedly.')
-
- content = self._content[self._cursor : self._cursor + n]
- self._cursor += n
- return content
-
- def Parse(self):
- """Verifies the archive header and arses the contents of the archive.
-
- Raises:
- ValueError: invalid file format.
- """
- # Check global header
- sig = self.ReadBytes(len(self.GLOBAL_SIG))
- if sig != self.GLOBAL_SIG:
- raise ValueError('File is not a valid Unix archive.')
-
- # Read files in archive
- while self._cursor < len(self._content):
- self.ReadFile()
-
- def ReadFile(self):
- """Reads a file from the archive content stream.
-
- Raises:
- ValueError: invalid file format.
- """
- name = self.ReadBytes(self.FILE_ID_LENGTH).strip()
- self.ReadBytes(self.FILE_TIMESTAMP_LENGTH)
- self.ReadBytes(self.OWNER_ID_LENGTH)
- self.ReadBytes(self.GROUP_ID_LENGTH)
- self.ReadBytes(self.FILE_MODE_LENGTH)
- size = self.ReadBytes(self.CONTENT_SIZE_LENGTH)
- content_size = int(size)
-
- if self.ReadBytes(len(self.END_TAG)) != self.END_TAG:
- raise ValueError('File is not a valid Unix archive. Missing end tag.')
-
- content = self.ReadBytes(content_size)
- if name == self.STRING_TABLE_ID:
- acc = 0
- names = content.split(self.STRING_TABLE_TERMINATOR)
- for string in names:
- self._string_table[acc] = string
- acc += len(string) + len(self.STRING_TABLE_TERMINATOR)
- elif name != self.SYM_TABLE_ID:
- if name.endswith(self.FILE_ID_TERMINATOR):
- name = name[:-len(self.FILE_ID_TERMINATOR)]
- elif name.startswith(self.FILE_ID_TERMINATOR):
- offset = int(name[len(self.FILE_ID_TERMINATOR):])
- if offset not in self._string_table:
- raise ValueError('Offset %s not in string table.', offset)
- name = self._string_table[offset]
- self.files[name] = content
diff --git a/utils/python/archive/archive_parser_test.py b/utils/python/archive/archive_parser_test.py
deleted file mode 100644
index 68b13a4..0000000
--- a/utils/python/archive/archive_parser_test.py
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/usr/bin/env python
-#
-# 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.
-#
-
-import os
-import unittest
-
-from vts.utils.python.archive import archive_parser
-
-
-class ArchiveParserTest(unittest.TestCase):
- """Unit tests for archive_parser of vts.utils.python.archive.
- """
-
- def testReadHeaderPass(self):
- """Tests that archive is read when header is correct.
-
- Parses archive content containing only the signature.
- """
- try:
- archive = archive_parser.Archive(archive_parser.Archive.GLOBAL_SIG)
- archive.Parse()
- except ValueError:
- self.fail('Archive reader read improperly.')
-
- def testReadHeaderFail(self):
- """Tests that parser throws error when header is invalid.
-
- Parses archive content lacking the correct signature.
- """
- archive = archive_parser.Archive('Fail.')
- self.assertRaises(ValueError, archive.Parse)
-
- def testReadFile(self):
- """Tests that file is read correctly.
-
- Tests that correctly formatted file in archive is read correctly.
- """
- content = archive_parser.Archive.GLOBAL_SIG
- file_name = 'test_file'
- content += file_name + ' ' * (archive_parser.Archive.FILE_ID_LENGTH -
- len(file_name))
- content += ' ' * archive_parser.Archive.FILE_TIMESTAMP_LENGTH
- content += ' ' * archive_parser.Archive.OWNER_ID_LENGTH
- content += ' ' * archive_parser.Archive.GROUP_ID_LENGTH
- content += ' ' * archive_parser.Archive.FILE_MODE_LENGTH
-
- message = 'test file contents'
- message_size = str(len(message))
- content += message_size + ' ' * (archive_parser.Archive.CONTENT_SIZE_LENGTH -
- len(message_size))
- content += archive_parser.Archive.END_TAG
- content += message
- archive = archive_parser.Archive(content)
- archive.Parse()
- self.assertIn(file_name, archive.files)
- self.assertEquals(archive.files[file_name], message)
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/utils/python/build/__init__.py b/utils/python/build/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/build/__init__.py
+++ /dev/null
diff --git a/utils/python/build/api/__init__.py b/utils/python/build/api/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/build/api/__init__.py
+++ /dev/null
diff --git a/utils/python/build/api/artifact_fetcher.py b/utils/python/build/api/artifact_fetcher.py
deleted file mode 100644
index 2224038..0000000
--- a/utils/python/build/api/artifact_fetcher.py
+++ /dev/null
@@ -1,265 +0,0 @@
-#
-# 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.
-#
-"""Class to fetch artifacts from internal build server.
-"""
-
-import googleapiclient
-import httplib2
-import io
-import json
-import logging
-import re
-import time
-from googleapiclient.discovery import build
-from oauth2client import client as oauth2_client
-from oauth2client.service_account import ServiceAccountCredentials
-
-logger = logging.getLogger('artifact_fetcher')
-
-
-class DriverError(Exception):
- """Base Android GCE driver exception."""
-
-
-class AndroidBuildClient(object):
- """Client that manages Android Build.
-
- Attributes:
- service: object, initialized and authorized service object for the
- androidbuildinternal API.
- API_NAME: string, name of internal API accessed by the client.
- API_VERSION: string, version of the internal API accessed by the client.
- SCOPE: string, URL for which to request access via oauth2.
- DEFAULT_RESOURCE_ID: string, default artifact name to request.
- DEFAULT_ATTEMPT_ID: string, default attempt to request for the artifact.
- DEFAULT_CHUNK_SIZE: int, number of bytes to download at a time.
- RETRY_COUNT: int, max number of retries.
- RETRY_DELAY_IN_SECS: int, time delays between retries in seconds.
- """
-
- API_NAME = "androidbuildinternal"
- API_VERSION = "v2beta1"
- SCOPE = "https://www.googleapis.com/auth/androidbuild.internal"
-
- # other variables.
- BUILDS_KEY = "builds"
- BUILD_ID_KEY = "buildId"
- DEFAULT_ATTEMPT_ID = "latest"
- DEFAULT_BUILD_ATTEMPT_STATUS = "complete"
- DEFAULT_BUILD_TYPE = "submitted"
- DEFAULT_CHUNK_SIZE = 20 * 1024 * 1024
- DEFAULT_RESOURCE_ID = "0"
-
- # Defaults for retry.
- RETRY_COUNT = 5
- RETRY_DELAY_IN_SECS = 3
-
- def __init__(self, oauth2_service_json):
- """Initialize.
-
- Args:
- oauth2_service_json: Path to service account json file.
- """
- authToken = ServiceAccountCredentials.from_json_keyfile_name(
- oauth2_service_json, [self.SCOPE])
- http_auth = authToken.authorize(httplib2.Http())
- for _ in xrange(self.RETRY_COUNT):
- try:
- self.service = build(
- serviceName=self.API_NAME,
- version=self.API_VERSION,
- http=http_auth)
- break
- except oauth2_client.AccessTokenRefreshError as e:
- # The following HTTP code typically indicates transient errors:
- # 500 (Internal Server Error)
- # 502 (Bad Gateway)
- # 503 (Service Unavailable)
- logging.exception(e)
- logging.info("Retrying to connect to %s", self.API_NAME)
- time.sleep(self.RETRY_DELAY_IN_SECS)
-
- def DownloadArtifactToFile(self,
- branch,
- build_target,
- build_id,
- resource_id,
- dest_filepath,
- attempt_id=None):
- """Get artifact from android build server.
-
- Args:
- branch: Branch from which the code was built, e.g. "master"
- build_target: Target name, e.g. "gce_x86-userdebug"
- build_id: Build id, a string, e.g. "2263051", "P2804227"
- resource_id: Name of resource to be downloaded, a string.
- attempt_id: string, attempt id, will default to DEFAULT_ATTEMPT_ID.
- dest_filepath: string, set a file path to store to a file.
-
- Returns:
- Contents of the requested resource as a string if dest_filepath is None;
- None otherwise.
- """
- return self.GetArtifact(branch, build_target, build_id, resource_id,
- attempt_id=attempt_id, dest_filepath=dest_filepath)
-
- def GetArtifact(self,
- branch,
- build_target,
- build_id,
- resource_id,
- attempt_id=None,
- dest_filepath=None):
- """Get artifact from android build server.
-
- Args:
- branch: Branch from which the code was built, e.g. "master"
- build_target: Target name, e.g. "gce_x86-userdebug"
- build_id: Build id, a string, e.g. "2263051", "P2804227"
- resource_id: Name of resource to be downloaded, a string.
- attempt_id: string, attempt id, will default to DEFAULT_ATTEMPT_ID.
- dest_filepath: string, set a file path to store to a file.
-
- Returns:
- Contents of the requested resource as a string if dest_filepath is None;
- None otherwise.
- """
- attempt_id = attempt_id or self.DEFAULT_ATTEMPT_ID
- api = self.service.buildartifact().get_media(
- buildId=build_id,
- target=build_target,
- attemptId=attempt_id,
- resourceId=resource_id)
- logger.info("Downloading artifact: target: %s, build_id: %s, "
- "resource_id: %s", build_target, build_id, resource_id)
- fh = None
- try:
- if dest_filepath:
- fh = io.FileIO(dest_filepath, mode='wb')
- else:
- fh = io.BytesIO()
-
- downloader = googleapiclient.http.MediaIoBaseDownload(
- fh, api, chunksize=self.DEFAULT_CHUNK_SIZE)
- done = False
- while not done:
- _, done = downloader.next_chunk()
- logger.info("Downloaded artifact %s" % resource_id)
-
- if not dest_filepath:
- return fh.getvalue()
- except OSError as e:
- logger.error("Downloading artifact failed: %s", str(e))
- raise DriverError(str(e))
- finally:
- if fh:
- fh.close()
-
- def GetManifest(self, branch, build_target, build_id, attempt_id=None):
- """Get Android build manifest XML file.
-
- Args:
- branch: Branch from which the code was built, e.g. "master"
- build_target: Target name, e.g. "gce_x86-userdebug"
- build_id: Build id, a string, e.g. "2263051", "P2804227"
- attempt_id: String, attempt id, will default to DEFAULT_ATTEMPT_ID.
-
-
- Returns:
- Contents of the requested XML file as a string.
- """
- resource_id = "manifest_%s.xml" % build_id
- return self.GetArtifact(branch, build_target, build_id, resource_id,
- attempt_id)
-
- def GetRepoDictionary(self,
- branch,
- build_target,
- build_id,
- attempt_id=None):
- """Get dictionary of repositories and git revision IDs
-
- Args:
- branch: Branch from which the code was built, e.g. "master"
- build_target: Target name, e.g. "gce_x86-userdebug"
- build_id: Build id, a string, e.g. "2263051", "P2804227"
- attempt_id: String, attempt id, will default to DEFAULT_ATTEMPT_ID.
-
-
- Returns:
- Dictionary of project names (string) to commit ID (string)
- """
- resource_id = "BUILD_INFO"
- build_info = self.GetArtifact(branch, build_target, build_id,
- resource_id, attempt_id)
- try:
- return json.loads(build_info)["repo-dict"]
- except (ValueError, KeyError):
- logger.warn("Could not find repo dictionary.")
- return {}
-
- def GetCoverage(self,
- branch,
- build_target,
- build_id,
- product,
- attempt_id=None):
- """Get Android build coverage zip file.
-
- Args:
- branch: Branch from which the code was built, e.g. "master"
- build_target: Target name, e.g. "gce_x86-userdebug"
- build_id: Build id, a string, e.g. "2263051", "P2804227"
- product: Name of product for build target, e.g. "bullhead", "angler"
- attempt_id: String, attempt id, will default to DEFAULT_ATTEMPT_ID.
-
-
- Returns:
- Contents of the requested zip file as a string.
- """
- resource_id = ("%s-coverage-%s.zip" % (product, build_id))
- return self.GetArtifact(branch, build_target, build_id, resource_id,
- attempt_id)
-
- def ListBuildIds(self,
- branch,
- build_target,
- limit=1,
- build_type=DEFAULT_BUILD_TYPE,
- build_attempt_status=DEFAULT_BUILD_ATTEMPT_STATUS):
- """Get a list of most recent build IDs.
-
- Args:
- branch: Branch from which the code was built, e.g. "master"
- build_target: Target name, e.g. "gce_x86-userdebug"
- limit: (optional) an int, max number of build IDs to fetch,
- default of 1
- build_type: (optional) a string, the build type to filter, default
- of "submitted"
- build_attempt_status: (optional) a string, the build attempt status
- to filter, default of "completed"
-
- Returns:
- A list of build ID strings in reverse time order.
- """
- builds = self.service.build().list(
- branch=branch,
- target=build_target,
- maxResults=limit,
- buildType=build_type,
- buildAttemptStatus=build_attempt_status).execute()
- return [str(build.get(self.BUILD_ID_KEY))
- for build in builds.get(self.BUILDS_KEY)]
diff --git a/utils/python/common/__init__.py b/utils/python/common/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/common/__init__.py
+++ /dev/null
diff --git a/utils/python/common/cmd_result.py b/utils/python/common/cmd_result.py
deleted file mode 100644
index a0451bc..0000000
--- a/utils/python/common/cmd_result.py
+++ /dev/null
@@ -1,132 +0,0 @@
-# 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.
-
-import vts.utils.python.common.cmd_utils as cmd_utils
-
-
-class CmdResult(object):
- """Shell command result object.
-
- Attributes:
- stdout: string, command stdout output.
- If multiple command results are included in the object,
- only the last one is returned.
- stdouts: list of string, a list of command stdout outputs.
- stderr: string, command stderr output.
- If multiple command results are included in the object,
- only the last one is returned.
- stderrs: list of string, a list of command stderr outputs
- returncode: int, command returncode output.
- If multiple command results are included in the object,
- only the last one is returned.
- returncodes: list of int, a list of command returncode outputs.
- cmd: string, original command that generates the result.
- If multiple commands are included in the object,
- only the last one is returned.
- original command may not always be included (is None).
- cmds: a list of string, original commands that generate the results.
- exception: Exception or string, the exception that prevented the command
- from generating result.
- If multiple commands are included in the object,
- only the last one is returned.
- execptions: a list of Exception or string, the exceptions that
- prevented the command from generating result.
- """
-
- def __init__(self, stdout, stderr, returncode, cmd=None, exception=None):
- self.stdouts = []
- self.stderrs = []
- self.returncodes = []
- self.cmds = []
- self.exceptions = []
- self.AddResult(stdout, stderr, returncode, cmd=cmd, exception=exception)
-
- @property
- def stdout(self):
- """Returns command stdout output.
-
- If multiple command results are included in the object, only the last one is returned.
- """
- return self.stdouts[-1]
-
- @property
- def stderr(self):
- """Returns command stderr output.
-
- If multiple command results are included in the object, only the last one is returned.
- """
- return self.stderrs[-1]
-
- @property
- def returncode(self):
- """Returns command returncode output.
-
- If multiple command results are included in the object, only the last one is returned.
- """
- return self.returncodes[-1]
-
- @property
- def cmd(self):
- """Returns original command that generates the result.
-
- If multiple commands are included in the object, only the last one is returned.
- """
- return self.cmds[-1]
-
- @property
- def exception(self):
- """Returns the exception that prevented the command from generating result.
-
- If multiple commands are included in the object, only the last one is returned.
- """
- return self.exceptions[-1]
-
- def AddResult(self, stdout, stderr, returncode, cmd=None, exception=None):
- """Adds additional command result data to the object.
-
- Args:
- stdout: string, command stdout output.
- stderr: string, command stderr output.
- returncode: int, command returncode output.
- cmd: string, original command that generates the result.
- Defaults to None.
- exception: Exception or string, the exception that prevented the command
- from generating result.
- """
- self.stdouts.append(stdout)
- self.stderrs.append(stderr)
- self.returncodes.append(returncode)
- self.cmds.append(cmd)
- self.exceptions.append(exception)
-
- def __getitem__(self, key):
- """Legacy code support for getting results as a dictionary.
-
- Args:
- key: string, commend result type.
-
- Returns:
- list of string or int, command results corresponding to provided key.
-
- Raises:
- KeyError if key is not specified in const.
- """
- if key == cmd_utils.STDOUT:
- return self.stdouts
- elif key == cmd_utils.STDERR:
- return self.stderrs
- elif key == cmd_utils.EXIT_CODE:
- return self.returncodes
- else:
- raise KeyError(key)
\ No newline at end of file
diff --git a/utils/python/common/cmd_result_test.py b/utils/python/common/cmd_result_test.py
deleted file mode 100644
index 365e378..0000000
--- a/utils/python/common/cmd_result_test.py
+++ /dev/null
@@ -1,111 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 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.
-#
-
-import unittest
-import vts.utils.python.common.cmd_utils as cmd_utils
-import vts.utils.python.common.cmd_result as cmd_result
-
-
-class CmdResultTest(unittest.TestCase):
- '''Test methods for cmd_result module.'''
-
- def setUp(self):
- """SetUp tasks"""
- self.res_single_no_error = cmd_result.CmdResult('stdout', '', 0)
-
- self.res_multiple_no_error = cmd_result.CmdResult('stdout1', '', 0)
- self.res_multiple_no_error.AddResult('stdout2', '', 0)
-
- self.res_multiple_one_error = cmd_result.CmdResult('stdout1', '', 0)
- self.res_multiple_one_error.AddResult('stdout2', 'stderr2', 1)
-
- self.res_multiple_one_stderr_only = cmd_result.CmdResult('stdout1', '', 0)
- self.res_multiple_one_stderr_only.AddResult('stdout2', 'stderr2', 0)
-
- self.res_multiple_with_cmd_and_exception = cmd_result.CmdResult(
- 'stdout1', '', 0, cmd='cmd1')
- self.res_multiple_with_cmd_and_exception.AddResult(
- None, None, None, cmd='cmd2', exception='TCP connection lost')
-
- def tearDown(self):
- """TearDown tasks"""
-
- def test_single_result_data(self):
- """Tests the functionally of getting data from single command result."""
- self.assertEqual(self.res_single_no_error.stdout, 'stdout')
- self.assertEqual(self.res_single_no_error.stderr, '')
- self.assertEqual(self.res_single_no_error.returncode, 0)
- self.assertEqual(self.res_single_no_error.stdouts[-1], 'stdout')
- self.assertEqual(self.res_single_no_error.stderrs[-1], '')
- self.assertEqual(self.res_single_no_error.returncodes[-1], 0)
-
- def test_multiple_result_data(self):
- """Tests the functionally of getting data from multiple command result."""
- self.assertEqual(self.res_multiple_no_error.stdout, 'stdout2')
- self.assertEqual(self.res_multiple_no_error.stderr, '')
- self.assertEqual(self.res_multiple_no_error.returncode, 0)
- self.assertEqual(self.res_multiple_no_error.stdouts, ['stdout1', 'stdout2'])
- self.assertEqual(self.res_multiple_no_error.stderrs, ['', ''])
- self.assertEqual(self.res_multiple_no_error.returncodes, [0, 0])
-
- def test_legacy_single_result_dictionary_support_no_error(self):
- """Tests legacy dictionary getting method for single command result."""
- self.assertEqual(self.res_single_no_error[cmd_utils.STDOUT][0], 'stdout')
- self.assertFalse(self.res_single_no_error[cmd_utils.STDERR][0])
- self.assertFalse(any(self.res_single_no_error[cmd_utils.STDERR]))
- self.assertFalse(self.res_single_no_error[cmd_utils.EXIT_CODE][0])
- self.assertFalse(any(self.res_single_no_error[cmd_utils.EXIT_CODE]))
-
- def test_legacy_single_result_dictionary_support_no_error_wrong_key(self):
- """Tests legacy dictionary getting method for single command result."""
- try:
- self.res_single_no_error["wrong key"]
- except KeyError as e:
- return # test pass, end test case
- except:
- pass # wrong exception, proceed to end of test function
-
- self.assertFalse(True, "wrong key should raise KeyError exception")
-
- def test_legacy_multiple_result_dictionary_support_no_error(self):
- """Tests legacy dictionary getting method for multiple command results."""
- self.assertEqual(self.res_multiple_no_error[cmd_utils.STDOUT][0], 'stdout1')
- self.assertEqual(self.res_multiple_no_error[cmd_utils.STDOUT][1], 'stdout2')
- self.assertFalse(any(self.res_multiple_no_error[cmd_utils.STDERR]))
- self.assertFalse(any(self.res_multiple_no_error[cmd_utils.EXIT_CODE]))
-
- def test_legacy_multiple_result_dictionary_support_one_error(self):
- """Tests legacy dictionary getting method for multiple command results."""
- self.assertTrue(any(self.res_multiple_one_error[cmd_utils.STDERR]))
- self.assertTrue(any(self.res_multiple_one_error[cmd_utils.EXIT_CODE]))
-
- def test_legacy_multiple_result_dictionary_support_one_stderr_only(self):
- """Tests legacy dictionary getting method for multiple command results."""
- self.assertTrue(any(self.res_multiple_one_stderr_only[cmd_utils.STDERR]))
- self.assertFalse(any(self.res_multiple_one_stderr_only[cmd_utils.EXIT_CODE]))
-
- def test_multiple_result_with_cmd_and_exception(self):
- """Tests getting original command strings and exceptions"""
- self.assertEqual(self.res_multiple_with_cmd_and_exception.cmd, 'cmd2')
- self.assertEqual(self.res_multiple_with_cmd_and_exception.cmds, ['cmd1', 'cmd2'])
- self.assertEqual(self.res_multiple_with_cmd_and_exception.exception, 'TCP connection lost')
- self.assertEqual(self.res_multiple_with_cmd_and_exception.exceptions,
- [None, 'TCP connection lost'])
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/utils/python/common/cmd_utils.py b/utils/python/common/cmd_utils.py
deleted file mode 100644
index e47fedd..0000000
--- a/utils/python/common/cmd_utils.py
+++ /dev/null
@@ -1,145 +0,0 @@
-#
-# Copyright 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.
-
-import logging
-import subprocess
-import threading
-
-from vts.runners.host import utils
-
-STDOUT = 'stdouts'
-STDERR = 'stderrs'
-EXIT_CODE = 'return_codes'
-
-# Exit code returned from the sub-process when timed out on Linux systems.
-EXIT_CODE_TIMEOUT_ON_LINUX = -15
-
-# Same as EXIT_CODE_TIMEOUT_ON_LINUX but on Windows systems.
-EXIT_CODE_TIMEOUT_ON_WINDOWS = -1073741510
-
-
-def _ExecuteOneShellCommandWithTimeout(cmd,
- timeout,
- callback_on_timeout=None,
- *args):
- """Executes a command with timeout.
-
- If the process times out, this function terminates it and continues
- waiting.
-
- Args:
- proc: Popen object, the process to wait for.
- timeout: float, timeout in seconds.
- callback_on_timeout: callable, callback function for the case
- when the command times out.
- args: arguments for the callback_on_timeout.
-
- Returns:
- tuple(string, string, int) which are stdout, stderr and return code.
- """
- # On Windows, subprocess.Popen(shell=True) starts two processes, cmd.exe
- # and the command. The Popen object represents the cmd.exe process, so
- # calling Popen.kill() does not terminate the command.
- # This function uses process group to ensure command termination.
- proc = utils.start_standing_subprocess(cmd)
- result = []
-
- def WaitForProcess():
- out, err = proc.communicate()
- result.append((out, err, proc.returncode))
-
- wait_thread = threading.Thread(target=WaitForProcess)
- wait_thread.daemon = True
- wait_thread.start()
- try:
- wait_thread.join(timeout)
- finally:
- if proc.poll() is None:
- utils.kill_process_group(proc)
- if callback_on_timeout is not None:
- if ((utils.is_on_windows()
- and proc.returncode == EXIT_CODE_TIMEOUT_ON_WINDOWS)
- or proc.returncode == EXIT_CODE_TIMEOUT_ON_LINUX):
- callback_on_timeout(*args)
- wait_thread.join()
-
- if len(result) != 1:
- logging.error("Unexpected command result: %s", result)
- return "", "", proc.returncode
- return result[0]
-
-
-def RunCommand(command):
- """Runs a unix command and stashes the result.
-
- Args:
- command: the command to run.
-
- Returns:
- code of the subprocess.
- """
- proc = subprocess.Popen(
- command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- (stdout, stderr) = proc.communicate()
- if proc.returncode != 0:
- logging.error('Fail to execute command: %s '
- '(stdout: %s\n stderr: %s\n)' % (command, stdout,
- stderr))
- return proc.returncode
-
-
-def ExecuteOneShellCommand(cmd, timeout=None, callback_on_timeout=None, *args):
- """Executes one shell command and returns (stdout, stderr, exit_code).
-
- Args:
- cmd: string, a shell command.
- timeout: float, timeout in seconds.
- callback_on_timeout: callable, callback function for the case
- when the command times out.
- args: arguments for the callback_on_timeout.
-
- Returns:
- tuple(string, string, int), containing stdout, stderr, exit_code of
- the shell command.
- If timeout, exit_code is -15 on Unix; -1073741510 on Windows.
- """
- if timeout is None:
- p = subprocess.Popen(
- str(cmd),
- shell=True,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- stdout, stderr = p.communicate()
- return (stdout, stderr, p.returncode)
- else:
- return _ExecuteOneShellCommandWithTimeout(
- str(cmd), timeout, callback_on_timeout, *args)
-
-
-def ExecuteShellCommand(cmd):
- """Execute one shell cmd or a list of shell commands.
-
- Args:
- cmd: string or a list of strings, shell command(s)
-
- Returns:
- dict{int->string}, containing stdout, stderr, exit_code of the shell command(s)
- """
- if not isinstance(cmd, list):
- cmd = [cmd]
-
- results = [ExecuteOneShellCommand(command) for command in cmd]
- stdout, stderr, exit_code = zip(*results)
- return {STDOUT: stdout, STDERR: stderr, EXIT_CODE: exit_code}
diff --git a/utils/python/common/filter_utils.py b/utils/python/common/filter_utils.py
deleted file mode 100644
index df5121e..0000000
--- a/utils/python/common/filter_utils.py
+++ /dev/null
@@ -1,570 +0,0 @@
-#
-# 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.
-#
-
-import copy
-import logging
-import re
-from sre_constants import error as regex_error
-import types
-
-from vts.runners.host import const
-from vts.utils.python.common import list_utils
-
-REGEX_PREFIX = 'r('
-REGEX_SUFFIX = ')'
-REGEX_PREFIX_ESCAPE = '\\r('
-NEGATIVE_PATTERN_PREFIX = '-'
-_INCLUDE_FILTER = '_include_filter'
-_EXCLUDE_FILTER = '_exclude_filter'
-DEFAULT_EXCLUDE_OVER_INCLUDE = False
-_MODULE_NAME_PATTERN = '{module}.{test}'
-
-
-def ExpandBitness(input_list):
- '''Expand filter items with bitness suffix.
-
- If a filter item contains bitness suffix, only test name with that tag
- will be included in output.
- Otherwise, 2 more item with 32bit and 64bit suffix will be added to the output list.
-
- This method removes duplicated item while keeping item order before returning output.
-
- Examples of input -> output are:
- [a_32bit] -> [a_32bit]
- [a] -> [a, a_32bit, a_64bit]
- [a_32bit, a] -> [a_32bit, a, a_64bit]
-
- Args:
- input_list: list of string, the list to expand
-
- Returns:
- A list of string
- '''
- result = []
- for item in input_list:
- result.append(str(item))
- if (not item.endswith(const.SUFFIX_32BIT) and
- not item.endswith(const.SUFFIX_64BIT)):
- result.append("%s_%s" % (item, const.SUFFIX_32BIT))
- result.append("%s_%s" % (item, const.SUFFIX_64BIT))
- return list_utils.DeduplicateKeepOrder(result)
-
-
-def ExpandAppendix(input_list, appendix_list, filter_pattern):
- '''Expand each item in input_list with appendix in the appendix_list
-
- For each item in input_list, expand it to N items (N=size of appendix_list)
- by attaching it with each appendix form appendix_list.
- Note, for items end with bitness info (e.g 32bit/63bit/_32bit/_64bit),
- attach the appendix before the bitness info. (This is to make sure the
- bitness info is always at the end of each item since the system rely on this
- assumption to check the bitness info)
- There are two cases when an item will not be expanded: 1) it is a Regex
- filter item and 2) it has the pattern described by filter_pattern.
-
- Examples of input -> output are:
- [a] [_default] -> [a_default]
- [a, b] [_default] -> [a_default, b_default]
- [a] [_default, _test] -> [a_default, a_test]
- [a, b_32bit] [_default, _test]
- -> [a_default, a_test, b_default_32bit, b_test_32bit]
-
- Args:
- input_list: list of string, the list to expand
- appendix_list: list of string, the appendix to be append.
- filter_pattern: string, a Regex pattern to filter out the items that
- should not expand.
-
- Returns:
- A list of string with expanded result.
- '''
- result = []
- for item in input_list:
- if IsRegexFilter(item) or re.compile(filter_pattern).match(item):
- result.append(item)
- continue
- pos = len(item)
- if (item.endswith(const.SUFFIX_32BIT) or
- item.endswith(const.SUFFIX_64BIT)):
- pos = len(item) - len(const.SUFFIX_32BIT)
- if item[pos - 1] == "_":
- pos = pos - 1
- for appendix in appendix_list:
- result.append(item[:pos] + appendix + item[pos:])
- return result
-
-
-def SplitFilterList(input_list):
- '''Split filter items into exact and regex lists.
-
- To specify a regex filter, the syntax is:
- 'r(suite.test)' for regex matching of 'suite.test', where '.' means
- one of any char.
- See Filter class docstring for details.
-
- Args:
- input_list: list of string, the list to split
-
- Returns:
- A tuple of lists: two lists where the first one is exact matching
- list and second one is regex list where the wrapping
- syntax 'r(..)' is removed.
- '''
- exact = []
- regex = []
- for item in input_list:
- if IsRegexFilter(item):
- regex_item = item[len(REGEX_PREFIX):-len(REGEX_SUFFIX)]
- try:
- re.compile(regex_item)
- regex.append(regex_item)
- except regex_error:
- logging.error('Invalid regex %s, ignored. Please refer to '
- 'python re syntax documentation.' % regex_item)
- elif item.startswith(REGEX_PREFIX_ESCAPE) and item.endswith(
- REGEX_SUFFIX):
- exact.append(REGEX_PREFIX + item[len(REGEX_PREFIX_ESCAPE):])
- else:
- exact.append(item)
-
- return (exact, regex)
-
-
-def SplitNegativePattern(input_list):
- '''Split negative items out from an input filter list.
-
- Items starting with the negative sign will be moved to the second returning
- list.
-
- Args:
- input_list: list of string, the list to split
-
- Returns:
- A tuple of lists: two lists where the first one is positive patterns
- and second one is negative items whose negative sign
- is removed.
- '''
- positive = []
- negative = []
- for item in input_list:
- if item.startswith(NEGATIVE_PATTERN_PREFIX):
- negative.append(item[len(NEGATIVE_PATTERN_PREFIX):])
- else:
- positive.append(item)
- return (positive, negative)
-
-
-def InRegexList(item, regex_list):
- '''Checks whether a given string matches an item in the given regex list.
-
- Args:
- item: string, given string
- regex_list: regex list
-
- Returns:
- bool, True if there is a match; False otherwise.
- '''
- for regex in regex_list:
- p = re.compile(regex)
- m = p.match(item)
- if m and m.start() == 0 and m.end() == len(item):
- return True
-
- return False
-
-
-def IsRegexFilter(item):
- '''Checks whether the given item is a regex filter.
-
- Args:
- item: string, given string
-
- Returns:
- bool: true if the given item is a regex filter.
- '''
- return item.startswith(REGEX_PREFIX) and item.endswith(REGEX_SUFFIX)
-
-
-class Filter(object):
- '''A class to hold test filter rules and filter test names.
-
- Regex matching is supported. Regex syntax is python re package syntax.
- To specify a regex filter, the syntax is:
- 'suite.test' for exact matching
- 'r(suite.test)' for regex matching of 'suite.test', where '.' means
- one of any char.
- '\r(suite.test)' for exact matching of name 'r(suite.test)', where
- '\r' is a two char string ('\\r' in code).
- Since test name is not expected to start with backslash, the exact
- string matching of name '\r(suite.test)' is not supported here.
-
- Negative pattern is supported. If a test name starts with the negative
- sign in include_filter, the negative sign will be removed and item will
- be moved from include_filter to exclude_filter. Negative sign should
- be added before regex prefix, i.e., '-r(negative.pattern)'
-
- Attributes:
- enable_regex: bool, whether regex is enabled.
- include_filter: list of string, input include filter
- exclude_filter: list of string, input exclude filter
- include_filter_exact: list of string, exact include filter
- include_filter_regex: list of string, exact include filter
- exclude_filter_exact: list of string, exact exclude filter
- exclude_filter_regex: list of string, exact exclude filter
- exclude_over_include: bool, False for include over exclude;
- True for exclude over include.
- enable_native_pattern: bool, whether to enable negative pattern
- processing in include_filter
- enable_module_name_prefix_matching: bool, whether to perform auto
- module name prefix matching
- module_name: string, test module name for auto module name prefix
- matching
- expand_bitness: bool, whether to append bitness to filter items.
- Default is False. When set to True, bitness will
- be added to test name for filtering process, but
- the original filter list will not be changed.
- '''
- include_filter_exact = []
- include_filter_regex = []
- exclude_filter_exact = []
- exclude_filter_regex = []
-
- def __init__(self,
- include_filter=[],
- exclude_filter=[],
- enable_regex=True,
- exclude_over_include=None,
- enable_negative_pattern=True,
- enable_module_name_prefix_matching=False,
- module_name=None,
- expand_bitness=False):
- self.enable_regex = enable_regex
- self.expand_bitness = expand_bitness
-
- self.enable_negative_pattern = enable_negative_pattern
- self.include_filter = include_filter
- self.exclude_filter = exclude_filter
- if exclude_over_include is None:
- exclude_over_include = DEFAULT_EXCLUDE_OVER_INCLUDE
- self.exclude_over_include = exclude_over_include
- self.enable_module_name_prefix_matching = enable_module_name_prefix_matching
- self.module_name = module_name
-
- # @Deprecated. Use expand_bitness parameter in construction method instead.
- # This method will be removed after all legacy usage has been cleaned up
- def ExpandBitness(self):
- '''Expand bitness from filter.
-
- Items in the filter that doesn't contain bitness suffix will be expended
- to 3 items, 2 of which ending with bitness. This method is safe if
- called multiple times. Regex items will not be expanded
- '''
- self.include_filter_exact = ExpandBitness(self.include_filter_exact)
- self.exclude_filter_exact = ExpandBitness(self.exclude_filter_exact)
- self.expand_bitness = True
-
- def IsIncludeFilterEmpty(self):
- '''Check whether actual include filter is specified.
-
- Since the input include filter may contain negative patterns,
- checking self.include_filter is not always correct.
-
- This method checks include_filter_exact and include_filter_regex.
- '''
- return not self.include_filter_exact and not self.include_filter_regex
-
- def ExpandAppendix(self, appendix_list, filter_pattern):
- '''Expand filter with appendix from appendix_list.
-
- Reset both include_filter and exclude_filter by expanding the filters
- with appendix in appendix_list.
-
- Args:
- appendix_list: list of string to be append to the filters.
- filter_pattern: string, a Regex pattern to filter out the items that
- should not be expanded.
- '''
- self.include_filter = ExpandAppendix(self.include_filter,
- appendix_list, filter_pattern)
- self.exclude_filter = ExpandAppendix(self.exclude_filter,
- appendix_list, filter_pattern)
-
- def Filter(self, item):
- '''Filter a given string using the internal filters.
-
- Rule:
- By default, include_filter overrides exclude_filter. This means:
- If include_filter is empty, only exclude_filter is checked.
- Otherwise, only include_filter is checked
- If exclude_over_include is set to True, exclude filter will first
- be checked.
-
- Args:
- item: string, the string for filter check
-
- Returns:
- bool. True if it passed the filter; False otherwise
- '''
- if self.exclude_over_include:
- if self.IsInExcludeFilter(item):
- return False
-
- if not self.IsIncludeFilterEmpty():
- return self.IsInIncludeFilter(item)
-
- return True
- else:
- if not self.IsIncludeFilterEmpty():
- return self.IsInIncludeFilter(item)
-
- return not self.IsInExcludeFilter(item)
-
- def IsInIncludeFilter(self, item):
- '''Check if item is in include filter.
-
- If enable_module_name_prefix_matching is set to True, module name
- added to item as prefix will also be check from the include filter.
-
- Args:
- item: string, item to check filter
-
- Returns:
- bool, True if in include filter.
- '''
- return self._ModuleNamePrefixMatchingCheck(item,
- self._IsInIncludeFilter)
-
- def IsInExcludeFilter(self, item):
- '''Check if item is in exclude filter.
-
- If enable_module_name_prefix_matching is set to True, module name
- added to item as prefix will also be check from the exclude filter.
-
- Args:
- item: string, item to check filter
-
- Returns:
- bool, True if in exclude filter.
- '''
- return self._ModuleNamePrefixMatchingCheck(item,
- self._IsInExcludeFilter)
-
- def _ModuleNamePrefixMatchingCheck(self, item, check_function):
- '''Check item from filter after appending module name as prefix.
-
- This function will first check whether enable_module_name_prefix_matching
- is True and module_name is not empty. Then, the check_function will
- be applied to the item. If the result is False and
- enable_module_name_prefix_matching is True, module name will be added
- as the prefix to the item, in format of '<module_name>.<item>', and
- call the check_function again with the new resulting name.
-
- This is mainly used for retry command where test module name are
- automatically added to test case name.
-
- Args:
- item: string, test name for checking.
- check_function: function to check item in filters.
-
- Return:
- bool, True if item pass the filter from the given check_function.
- '''
- res = check_function(item)
-
- if (not res and self.enable_module_name_prefix_matching and
- self.module_name):
- res = check_function(
- _MODULE_NAME_PATTERN.format(
- module=self.module_name, test=item))
-
- return res
-
- def _IsInIncludeFilter(self, item):
- '''Internal function to check if item is in include filter.
-
- Args:
- item: string, item to check filter
-
- Returns:
- bool, True if in include filter.
- '''
- return item in self.include_filter_exact or InRegexList(
- item, self.include_filter_regex)
-
- def _IsInExcludeFilter(self, item):
- '''Internal function to check if item is in exclude filter.
-
- Args:
- item: string, item to check filter
-
- Returns:
- bool, True if in exclude filter.
- '''
- return item in self.exclude_filter_exact or InRegexList(
- item, self.exclude_filter_regex)
-
- @property
- def include_filter(self):
- '''Getter method for include_filter.
-
- Use this method to print include_filter only.
-
- If the items needed to be added, use add_to_exclude_filter method.
-
- E.g.
- self.add_to_exclude_filter('pattern1')
-
- If the filter needs to be modified without using add_to_exclude_filter,
- call refresh_filter() after modification. Otherwise, the change will
- not take effect.
-
- E.g.
- Get and modify filter:
- filter = Filter()
- filter.include_filter.append('pattern1')
- Refresh the filter:
- filter.refresh_filter()
- '''
- return getattr(self, _INCLUDE_FILTER, [])
-
- @include_filter.setter
- def include_filter(self, include_filter):
- '''Setter method for include_filter'''
- setattr(self, _INCLUDE_FILTER, include_filter)
- self.refresh_filter()
-
- @property
- def exclude_filter(self):
- '''Getter method for exclude_filter.
-
- Use this method to print exclude_filter only.
-
- If the items needed to be added, use add_to_exclude_filter method.
-
- E.g.
- self.add_to_exclude_filter('pattern1')
-
- If the filter needs to be modified without using add_to_exclude_filter,
- call refresh_filter() after modification. Otherwise, the change will
- not take effect.
-
- E.g.
- Get and modify filter:
- filter = Filter()
- filter.exclude_filter.append('pattern1')
- Refresh the filter:
- filter.refresh_filter()
- '''
- return getattr(self, _EXCLUDE_FILTER, [])
-
- @exclude_filter.setter
- def exclude_filter(self, exclude_filter):
- '''Setter method for exclude_filter'''
- setattr(self, _EXCLUDE_FILTER, exclude_filter)
- self.refresh_filter()
-
- def add_to_include_filter(self, pattern, auto_refresh=True):
- '''Add an item to include_filter.
-
- Args:
- pattern: string or list of string. Item(s) to add
- auto_refresh: bool, whether to automatically call refresh_filter().
- Default is True. Use False only if a large number of
- items are added one by one in a sequence call.
- In that case, call refresh_filter() at the end of the
- sequence.
- '''
- if not isinstance(pattern, types.ListType):
- pattern = [pattern]
-
- self.include_filter.extend(pattern)
-
- if auto_refresh:
- self.refresh_filter()
-
- def add_to_exclude_filter(self, pattern, auto_refresh=True):
- '''Add an item to exclude_filter.
-
- Args:
- pattern: string or list of string. Item(s) to add
- auto_refresh: bool, whether to automatically call refresh_filter().
- Default is True. Use False only if a large number of
- items are added one by one in a sequence call.
- In that case, call refresh_filter() at the end of the
- sequence.
- '''
- if not isinstance(pattern, types.ListType):
- pattern = [pattern]
-
- self.exclude_filter.extend(pattern)
-
- if auto_refresh:
- self.refresh_filter()
-
- def refresh_filter(self):
- '''Process the filter patterns.
-
- This method splits filter into exact and regex patterns.
- Bitness will also be appended if expand_bitness is True.
- '''
- include_filter = copy.copy(self.include_filter)
- exclude_filter = copy.copy(self.exclude_filter)
-
- if self.enable_negative_pattern:
- include_filter, include_filter_negative = SplitNegativePattern(
- include_filter)
- exclude_filter.extend(include_filter_negative)
-
- if self.enable_regex:
- self.include_filter_exact, self.include_filter_regex = SplitFilterList(
- include_filter)
- self.exclude_filter_exact, self.exclude_filter_regex = SplitFilterList(
- exclude_filter)
- else:
- self.include_filter_exact = include_filter
- self.exclude_filter_exact = exclude_filter
-
- if self.expand_bitness:
- self.include_filter_exact = ExpandBitness(
- self.include_filter_exact)
- self.exclude_filter_exact = ExpandBitness(
- self.exclude_filter_exact)
-
- def __str__(self):
- return ('Filter:\nenable_regex: {enable_regex}\n'
- 'enable_negative_pattern: {enable_negative_pattern}\n'
- 'enable_module_name_prefix_matching: '
- '{enable_module_name_prefix_matching}\n'
- 'module_name: {module_name}\n'
- 'include_filter: {include_filter}\n'
- 'exclude_filter: {exclude_filter}\n'
- 'include_filter_exact: {include_filter_exact}\n'
- 'include_filter_regex: {include_filter_regex}\n'
- 'exclude_filter_exact: {exclude_filter_exact}\n'
- 'exclude_filter_regex: {exclude_filter_regex}\n'
- 'expand_bitness: {expand_bitness}'.format(
- enable_regex=self.enable_regex,
- enable_negative_pattern=self.enable_negative_pattern,
- enable_module_name_prefix_matching=
- self.enable_module_name_prefix_matching,
- module_name=self.module_name,
- include_filter=self.include_filter,
- exclude_filter=self.exclude_filter,
- include_filter_exact=self.include_filter_exact,
- include_filter_regex=self.include_filter_regex,
- exclude_filter_exact=self.exclude_filter_exact,
- exclude_filter_regex=self.exclude_filter_regex,
- expand_bitness=self.expand_bitness))
diff --git a/utils/python/common/list_utils.py b/utils/python/common/list_utils.py
deleted file mode 100644
index 8bdce9d..0000000
--- a/utils/python/common/list_utils.py
+++ /dev/null
@@ -1,224 +0,0 @@
-#
-# 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.
-#
-
-import itertools
-import os
-
-DEFAULT_COMMENT_CHAR = '#'
-
-
-def ItemsToStr(input_list):
- '''Convert item in a list to string.
-
- Args:
- input_list: list of objects, the list to convert
-
- Return:
- A list of string where objects were converted to string using str function.
- None if input list is None.
- '''
- if not input_list:
- return input_list
- return list(map(str, input_list))
-
-
-def ExpandItemDelimiters(input_list,
- delimiter,
- strip=False,
- to_str=False,
- remove_empty=True):
- '''Expand list items that contain the given delimiter.
-
- Args:
- input_list: list of string, a list whose item may contain a delimiter
- delimiter: string
- strip: bool, whether to strip items after expanding. Default is False
- to_str: bool, whether to convert output items in string.
- Default is False
- remove_empty: bool, whether to remove empty string in result list.
- Will not remove None items. Default: True
-
- Returns:
- The expended list, which may be the same with input list
- if no delimiter found; None if input list is None
- '''
- if input_list is None:
- return None
-
- do_strip = lambda s: s.strip() if strip else s
- do_str = lambda s: str(s) if to_str else s
-
- expended_list_generator = (item.split(delimiter) for item in input_list)
- result = [
- do_strip(do_str(s))
- for s in itertools.chain.from_iterable(expended_list_generator)
- ]
- return filter(lambda s: str(s) != '', result) if remove_empty else result
-
-
-def DeduplicateKeepOrder(input):
- '''Remove duplicate items from a sequence while keeping the item order.
-
- Args:
- input: a sequence that might have duplicated items.
-
- Returns:
- A deduplicated list where item order is kept.
- '''
- return MergeUniqueKeepOrder(input)
-
-
-def MergeUniqueKeepOrder(*lists):
- '''Merge two list, remove duplicate items, and order.
-
- Args:
- lists: any number of lists
-
- Returns:
- A merged list where items are unique and original order is kept.
- '''
- seen = set()
- return [
- x for x in itertools.chain(*lists) if not (x in seen or seen.add(x))
- ]
-
-
-def LoadListFromCommentedTextFile(file_path,
- to_str=True,
- to_strip=True,
- exclude_empty_line=True,
- exclude_comment_line=True,
- exclude_trailing_comment=True,
- remove_duplicates=False,
- remove_line_breaks=True,
- comment_char=DEFAULT_COMMENT_CHAR):
- '''Read commented text file into a list of lines.
-
- Comments or empty lines will be excluded by default.
-
- Args:
- file_path: string, path to file
- to_str: bool, whether to convert lines to string in result list.
- Default value is True.
- to_strip: bool, whether to strip lines in result list.
- Default value is True.
- exclude_empty_line: bool, whether to exclude empty items in result list
- Default value is True.
- exclude_comment_line: bool, whether to exclude lines that only contains comments.
- If a line starts with spaces and ends with comments it
- will still be excluded even if to_trim is False.
- Default value is True.
- exclude_trailing_comment: bool, whether to remove trailing comments
- from result items.
- Default value is True.
- remove_duplicates: bool, whether to remove duplicate items in output list.
- Default value is False.
- remove_line_breaks: bool, whether to remove trailing trailing
- new line characters from result items.
- Default value is True.
- comment_char: string, character to denote comment.
- Default value is pound (#).
-
- Returns:
- a list of string. None if file does not exist.
- '''
- if not os.path.isfile(file_path):
- logging.error('The path provided is not a file or does not exist: %s',
- file_path)
- return None
-
- with open(file_path, 'r') as f:
- return LoadListFromCommentedText(
- f.read(),
- to_str,
- to_strip,
- exclude_empty_line,
- exclude_comment_line,
- exclude_trailing_comment,
- remove_duplicates,
- remove_line_breaks,
- comment_char=DEFAULT_COMMENT_CHAR)
-
-
-def LoadListFromCommentedText(text,
- to_str=True,
- to_strip=True,
- exclude_empty_line=True,
- exclude_comment_line=True,
- exclude_trailing_comment=True,
- remove_duplicates=False,
- remove_line_breaks=True,
- comment_char=DEFAULT_COMMENT_CHAR):
- '''Read commented text into a list of lines.
-
- Comments or empty lines will be excluded by default.
-
- Args:
- text: string, text to parse
- to_str: bool, whether to convert lines to string in result list.
- Default value is True.
- to_strip: bool, whether to strip lines in result list.
- Default value is True.
- exclude_empty_line: bool, whether to exclude empty items in result list
- Default value is True.
- exclude_comment_line: bool, whether to exclude lines that only contains comments.
- If a line starts with spaces and ends with comments it
- will still be excluded even if to_trim is False.
- Default value is True.
- exclude_trailing_comment: bool, whether to remove trailing comments
- from result items.
- Default value is True.
- remove_duplicates: bool, whether to remove duplicate items in output list.
- Default value is False.
- remove_line_breaks: bool, whether to remove trailing trailing
- new line characters from result items.
- Default value is True.
- comment_char: string, character to denote comment.
- Default value is pound (#).
-
- Returns:
- a list of string.
- '''
- lines = text.splitlines(not remove_line_breaks)
-
- if to_str:
- lines = map(str, lines)
-
- if exclude_trailing_comment:
-
- def RemoveComment(line):
- idx = line.find(comment_char)
- if idx < 0:
- return line
- else:
- return line[:idx]
-
- lines = map(RemoveComment, lines)
-
- if to_strip:
- lines = map(lambda line: line.strip(), lines)
-
- if exclude_comment_line:
- lines = filter(lambda line: not line.strip().startswith(comment_char),
- lines)
-
- if exclude_empty_line:
- lines = filter(bool, lines)
-
- if remove_duplicates:
- lines = DeduplicateKeepOrder(lines)
-
- return lines
diff --git a/utils/python/common/timeout_utils.py b/utils/python/common/timeout_utils.py
deleted file mode 100644
index f9ae009..0000000
--- a/utils/python/common/timeout_utils.py
+++ /dev/null
@@ -1,70 +0,0 @@
-#
-# Copyright (C) 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.
-#
-
-import errno
-import logging
-import os
-import signal
-
-from functools import wraps
-from vts.runners.host import errors
-
-
-class TimeoutError(errors.VtsError):
- """Timeout exception class to throw when a function times out."""
-
-
-def timeout(seconds, message=os.strerror(errno.ETIME), no_exception=False):
- """Timeout decorator for functions.
-
- Args:
- seconds: int, number of seconds before timing out the decorated function.
- message: string, error message when the decorated function times out.
- no_exception: bool, whether to raise exception when decorated function times out.
- If set to False, the function will stop execution and return None.
-
- Returns:
- Decorated function returns if no timeout, or None if timeout but no_exception is True.
-
- Raises:
- TimeoutError if decorated function times out.
- TypeError if seconds is not integer
- """
- def _handler_timeout(signum, frame):
- raise TimeoutError(message)
-
- def decorator(func):
- def wrapper(*args, **kwargs):
- if seconds > 0:
- signal.signal(signal.SIGALRM, _handler_timeout)
- signal.alarm(seconds)
-
- try:
- result = func(*args, **kwargs)
- except TimeoutError as e:
- if no_exception:
- logging.error(message)
- return None
- else:
- raise e
- finally:
- signal.alarm(0)
-
- return result
-
- return wraps(func)(wrapper)
-
- return decorator
diff --git a/utils/python/common/timeout_utils_test.py b/utils/python/common/timeout_utils_test.py
deleted file mode 100644
index 89604d3..0000000
--- a/utils/python/common/timeout_utils_test.py
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 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.
-#
-
-import unittest
-import time
-
-import vts.utils.python.common.timeout_utils as timeout_utils
-
-#TODO use milliseconds after float number timeout is implemented in timeout_utils
-
-
-class TimeoutUtilsTest(unittest.TestCase):
- '''Test methods for timeout_util module.'''
-
- def setUp(self):
- """SetUp tasks"""
- self.count = 0
-
- def test_timeout_no_except_no_timeout(self):
- """Tests the functionality of timeout decorator function."""
- @timeout_utils.timeout(1, no_exception=True)
- def increase(self):
- self.count += 1;
-
- increase(self)
- self.assertEqual(self.count, 1)
-
- def test_timeout_no_except_with_timeout(self):
- """Tests the functionality of timeout decorator function."""
- @timeout_utils.timeout(1, no_exception=True)
- def increase(self):
- time.sleep(2)
- self.count += 1;
-
- increase(self)
- self.assertEqual(self.count, 0)
-
- def test_timeout_with_except_with_timeout(self):
- """Tests the functionality of timeout decorator function."""
- @timeout_utils.timeout(1)
- def increase(self):
- time.sleep(2)
- self.count += 1;
-
- try:
- increase(self)
- except timeout_utils.TimeoutError:
- pass
-
- self.assertEqual(self.count, 0)
-
- def test_timeout_with_except_no_timeout(self):
- """Tests the functionality of timeout decorator function."""
- @timeout_utils.timeout(1)
- def increase(self):
- self.count += 1;
-
- increase(self)
-
- self.assertEqual(self.count, 1)
\ No newline at end of file
diff --git a/utils/python/common/vts_spec_utils.py b/utils/python/common/vts_spec_utils.py
deleted file mode 100644
index 3f51ee8..0000000
--- a/utils/python/common/vts_spec_utils.py
+++ /dev/null
@@ -1,175 +0,0 @@
-#
-# 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.
-#
-
-import logging
-import os
-
-from google.protobuf import text_format
-from vts.proto import ComponentSpecificationMessage_pb2 as CompSpecMsg
-
-
-def HalPackageToNameAndVersion(hal_package):
- """Returns hal name and version given hal package name.
-
- Args:
- hal_package: string, e.g. 'android.hardware.vibrator@1.0'
-
- Return:
- tuple, hal name and version e.g. ('vibrator', '1.0')
- """
- # TODO(trong): check if proper package name.
- prefix = 'android.hardware.'
- if not hal_package.startswith(prefix):
- logging.error("Invalid hal package name: %s" % hal_package)
- [hal_name, hal_version] = hal_package[len(prefix):].split('@')
- return (hal_name, hal_version)
-
-
-def HalNameDir(hal_name):
- """Returns directory name corresponding to hal name."""
- return hal_name.replace('.', '/')
-
-
-def HalVerDir(hal_version):
- """Returns directory name corresponding to hal version."""
- return "V" + hal_version.replace('.', '_')
-
-
-class VtsSpecParser(object):
- """Provides an API to parse .vts spec files.
-
- Attributes:
- data_file_path: string, path to vts data directory on target.
- """
-
- def __init__(self, data_file_path):
- """VtsSpecParser constructor.
-
- Args:
- data_file_path: string, path to vts data directory on target.
- """
- self._data_file_path = data_file_path
-
- def _VtsSpecDir(self, hal_name, hal_version):
- """Returns directory path to .vts spec files.
-
- Args:
- hal_name: string, name of the hal, e.g. 'vibrator'.
- hal_version: string, version of the hal, e.g '7.4'
-
- Returns:
- string, directory path to .vts spec files.
- """
- return os.path.join(
- self._data_file_path, 'spec', 'hardware', 'interfaces',
- hal_name.replace('.', '/'), hal_version, 'vts')
-
- def IndirectImportedHals(self, hal_name, hal_version):
- """Returns a list of imported HALs.
-
- Includes indirectly imported ones and excludes the given one.
-
- Args:
- hal_name: string, name of the hal, e.g. 'vibrator'.
- hal_version: string, version of the hal, e.g '7.4'
-
- Returns:
- list of string tuples. For example,
- [('vibrator', '1.3'), ('sensors', '3.2')]
- """
-
- this_hal = (hal_name, hal_version)
- imported_hals = [this_hal]
-
- for hal_name, hal_version in imported_hals:
- for discovery in self.ImportedHals(hal_name, hal_version):
- if discovery not in imported_hals:
- imported_hals.append(discovery)
-
- imported_hals.remove(this_hal)
- return sorted(imported_hals)
-
- def ImportedHals(self, hal_name, hal_version):
- """Returns a list of imported HALs.
-
- Args:
- hal_name: string, name of the hal, e.g. 'vibrator'.
- hal_version: string, version of the hal, e.g '7.4'
-
- Returns:
- list of string tuples. For example,
- [('vibrator', '1.3'), ('sensors', '3.2')]
- """
-
- vts_spec_protos = self.VtsSpecProto(hal_name, hal_version)
- imported_hals = set()
- for vts_spec in vts_spec_protos:
- for package in getattr(vts_spec, 'import', []):
- if package.startswith('android.hardware.'):
- package = package.split('::')[0]
- imported_hals.add(HalPackageToNameAndVersion(package))
-
- this_hal = (hal_name, hal_version)
- if this_hal in imported_hals:
- imported_hals.remove(this_hal)
- return sorted(imported_hals)
-
- def VtsSpecNames(self, hal_name, hal_version):
- """Returns list of .vts file names for given hal name and version.
-
- Args:
- hal_name: string, name of the hal, e.g. 'vibrator'.
- hal_version: string, version of the hal, e.g '7.4'
-
- Returns:
- list of string, .vts files for given hal name and version,
- e.g. ['Vibrator.vts', 'types.vts']
- """
- vts_spec_names = filter(
- lambda x: x.endswith('.vts'),
- os.listdir(self._VtsSpecDir(hal_name, hal_version)))
- return sorted(vts_spec_names)
-
- def VtsSpecProto(self, hal_name, hal_version, vts_spec_name=''):
- """Returns list of .vts protos for given hal name and version.
-
- Args:
- hal_name: string, name of the hal, e.g. 'vibrator'.
- hal_version: string, version of the hal, e.g '7.4'
- vts_spec:
-
- Returns:
- list with all vts spec protos for a given hal and version if
- vts_spec_name is not given. If vts_spec_name is not empty, then
- returns ComponentSpecificationMessage matching vts_spec_name.
- If no such vts_spec_name, return None.
- """
- if not vts_spec_name:
- vts_spec_protos = []
- for vts_spec in self.VtsSpecNames(hal_name, hal_version):
- vts_spec_proto = self.VtsSpecProto(hal_name, hal_version,
- vts_spec)
- vts_spec_protos.append(vts_spec_proto)
- return vts_spec_protos
- else:
- if vts_spec_name in self.VtsSpecNames(hal_name, hal_version):
- vts_spec_proto = CompSpecMsg.ComponentSpecificationMessage()
- vts_spec_path = os.path.join(
- self._VtsSpecDir(hal_name, hal_version), vts_spec_name)
- with open(vts_spec_path, 'r') as vts_spec_file:
- vts_spec_string = vts_spec_file.read()
- text_format.Merge(vts_spec_string, vts_spec_proto)
- return vts_spec_proto
diff --git a/utils/python/controllers/__init__.py b/utils/python/controllers/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/controllers/__init__.py
+++ /dev/null
diff --git a/utils/python/controllers/adb.py b/utils/python/controllers/adb.py
deleted file mode 100644
index 6211c6d..0000000
--- a/utils/python/controllers/adb.py
+++ /dev/null
@@ -1,208 +0,0 @@
-#
-# Copyright 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.
-
-from builtins import str
-
-import logging
-import random
-import socket
-import subprocess
-import time
-
-from vts.runners.host import const
-from vts.utils.python.common import cmd_utils
-
-
-# Default adb timeout 10 minutes
-DEFAULT_ADB_TIMEOUT = 600
-# Adb long timeout (10 minutes) for adb push/pull/bugreport/bugreportz
-DEFAULT_ADB_LONG_TIMEOUT = 600
-# Adb short timeout (30 seconds)
-DEFAULT_ADB_SHORT_TIMEOUT = 30
-
-class AdbError(Exception):
- """Raised when there is an error in adb operations."""
-
- def __init__(self, cmd, stdout, stderr, ret_code):
- self.cmd = cmd
- self.stdout = stdout
- self.stderr = stderr
- self.ret_code = ret_code
-
- def __str__(self):
- return ("Error executing adb cmd '%s'. ret: %d, stdout: %s, stderr: %s"
- ) % (self.cmd, self.ret_code, self.stdout, self.stderr)
-
-
-def get_available_host_port():
- """Gets a host port number available for adb forward.
-
- Returns:
- An integer representing a port number on the host available for adb
- forward.
- """
- while True:
- port = random.randint(1024, 9900)
- if is_port_available(port):
- return port
-
-
-def is_port_available(port):
- """Checks if a given port number is available on the system.
-
- Args:
- port: An integer which is the port number to check.
-
- Returns:
- True if the port is available; False otherwise.
- """
- # Make sure adb is not using this port so we don't accidentally interrupt
- # ongoing runs by trying to bind to the port.
- if port in list_occupied_adb_ports():
- return False
- s = None
- try:
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- s.bind(('localhost', port))
- return True
- except socket.error:
- return False
- finally:
- if s:
- s.close()
-
-
-def list_occupied_adb_ports():
- """Lists all the host ports occupied by adb forward.
-
- This is useful because adb will silently override the binding if an attempt
- to bind to a port already used by adb was made, instead of throwing binding
- error. So one should always check what ports adb is using before trying to
- bind to a port with adb.
-
- Returns:
- A list of integers representing occupied host ports.
- """
- out = AdbProxy().forward("--list")
- clean_lines = str(out, 'utf-8').strip().split('\n')
- used_ports = []
- for line in clean_lines:
- tokens = line.split(" tcp:")
- if len(tokens) != 3:
- continue
- used_ports.append(int(tokens[1]))
- return used_ports
-
-
-class AdbProxy():
- """Proxy class for ADB.
-
- For syntactic reasons, the '-' in adb commands need to be replaced with
- '_'. Can directly execute adb commands on an object:
- >> adb = AdbProxy(<serial>)
- >> adb.start_server()
- >> adb.devices() # will return the console output of "adb devices".
- """
-
- def __init__(self, serial="", log=None):
- self.serial = serial
- if serial:
- self.adb_str = "adb -s {}".format(serial)
- else:
- self.adb_str = "adb"
- self.log = log
-
- def _exec_cmd(self, cmd, no_except=False, timeout=DEFAULT_ADB_TIMEOUT):
- """Executes adb commands in a new shell.
-
- This is specific to executing adb binary because stderr is not a good
- indicator of cmd execution status.
-
- Args:
- cmd: string, the adb command to execute.
- no_except: bool, controls whether exception can be thrown.
- timeout: float, timeout in seconds. If the command times out, the
- exit code is not 0.
-
- Returns:
- The output of the adb command run if the exit code is 0 and if
- exceptions are allowed. Otherwise, returns a dictionary containing
- stdout, stderr, and exit code.
-
- Raises:
- AdbError if the adb command exit code is not 0 and exceptions are
- allowed.
- """
- out, err, ret = cmd_utils.ExecuteOneShellCommand(cmd, timeout)
- logging.debug("cmd: %s, stdout: %s, stderr: %s, ret: %s", cmd, out,
- err, ret)
- if no_except:
- return {
- const.STDOUT: out,
- const.STDERR: err,
- const.EXIT_CODE: ret,
- }
- else:
- if ret == 0:
- return out
- else:
- raise AdbError(cmd=cmd, stdout=out, stderr=err, ret_code=ret)
-
- def tcp_forward(self, host_port, device_port):
- """Starts TCP forwarding.
-
- Args:
- host_port: Port number to use on the computer.
- device_port: Port number to use on the android device.
- """
- self.forward("tcp:{} tcp:{}".format(host_port, device_port))
-
- def reverse_tcp_forward(self, device_port, host_port):
- """Starts reverse TCP forwarding.
-
- Args:
- device_port: Port number to use on the android device.
- host_port: Port number to use on the computer.
- """
- self.reverse("tcp:{} tcp:{}".format(device_port, host_port))
-
- def __getattr__(self, name):
-
- def adb_call(*args, **kwargs):
- clean_name = name.replace('_', '-')
- arg_str = ' '.join(str(elem) for elem in args)
- if clean_name == 'shell':
- arg_str = self._quote_wrap_shell_command(arg_str)
- elif "timeout" not in kwargs.keys():
- # for non-shell command like adb pull/push/bugreport, set longer default timeout
- kwargs["timeout"] = DEFAULT_ADB_LONG_TIMEOUT
- return self._exec_cmd(' '.join((self.adb_str, clean_name, arg_str)),
- **kwargs)
-
- return adb_call
-
- def _quote_wrap_shell_command(self, cmd):
- """Wraps adb shell command with double quotes.
-
- Double quotes inside the command will be replaced with \".
-
- Args:
- cmd: string, command string.
-
- Returns:
- string, quote wrapped command.
- """
- return '"%s"' % cmd.replace('"', '\\"')
\ No newline at end of file
diff --git a/utils/python/controllers/android.py b/utils/python/controllers/android.py
deleted file mode 100644
index 531ae06..0000000
--- a/utils/python/controllers/android.py
+++ /dev/null
@@ -1,134 +0,0 @@
-#/usr/bin/env python3.4
-#
-# Copyright (C) 2009 Google Inc.
-#
-# 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.
-"""
-JSON RPC interface to android scripting engine.
-"""
-
-from builtins import str
-
-import json
-import os
-import socket
-import threading
-import time
-
-HOST = os.environ.get('AP_HOST', None)
-PORT = os.environ.get('AP_PORT', 9999)
-
-
-class SL4AException(Exception):
- pass
-
-
-class SL4AAPIError(SL4AException):
- """Raised when remote API reports an error."""
-
-
-class SL4AProtocolError(SL4AException):
- """Raised when there is some error in exchanging data with server on device."""
- NO_RESPONSE_FROM_HANDSHAKE = "No response from handshake."
- NO_RESPONSE_FROM_SERVER = "No response from server."
- MISMATCHED_API_ID = "Mismatched API id."
-
-
-def IDCounter():
- i = 0
- while True:
- yield i
- i += 1
-
-
-class Android(object):
- COUNTER = IDCounter()
-
- _SOCKET_CONNECT_TIMEOUT = 60
-
- def __init__(self,
- cmd='initiate',
- uid=-1,
- port=PORT,
- addr=HOST,
- timeout=None):
- self.lock = threading.RLock()
- self.client = None # prevent close errors on connect failure
- self.uid = None
- timeout_time = time.time() + self._SOCKET_CONNECT_TIMEOUT
- while True:
- try:
- self.conn = socket.create_connection(
- (addr, port), max(1, timeout_time - time.time()))
- self.conn.settimeout(timeout)
- break
- except (TimeoutError, socket.timeout):
- print("Failed to create socket connection!")
- raise
- except (socket.error, IOError):
- # TODO: optimize to only forgive some errors here
- # error values are OS-specific so this will require
- # additional tuning to fail faster
- if time.time() + 1 >= timeout_time:
- print("Failed to create socket connection!")
- raise
- time.sleep(1)
-
- self.client = self.conn.makefile(mode="brw")
-
- resp = self._cmd(cmd, uid)
- if not resp:
- raise SL4AProtocolError(
- SL4AProtocolError.NO_RESPONSE_FROM_HANDSHAKE)
- result = json.loads(str(resp, encoding="utf8"))
- if result['status']:
- self.uid = result['uid']
- else:
- self.uid = -1
-
- def close(self):
- if self.conn is not None:
- self.conn.close()
- self.conn = None
-
- def _cmd(self, command, uid=None):
- if not uid:
- uid = self.uid
- self.client.write(json.dumps({'cmd': command,
- 'uid': uid}).encode("utf8") + b'\n')
- self.client.flush()
- return self.client.readline()
-
- def _rpc(self, method, *args):
- self.lock.acquire()
- apiid = next(Android.COUNTER)
- self.lock.release()
- data = {'id': apiid, 'method': method, 'params': args}
- request = json.dumps(data)
- self.client.write(request.encode("utf8") + b'\n')
- self.client.flush()
- response = self.client.readline()
- if not response:
- raise SL4AProtocolError(SL4AProtocolError.NO_RESPONSE_FROM_SERVER)
- result = json.loads(str(response, encoding="utf8"))
- if result['error']:
- raise SL4AAPIError(result['error'])
- if result['id'] != apiid:
- raise SL4AProtocolError(SL4AProtocolError.MISMATCHED_API_ID)
- return result['result']
-
- def __getattr__(self, name):
- def rpc_call(*args):
- return self._rpc(name, *args)
-
- return rpc_call
diff --git a/utils/python/controllers/android_device.py b/utils/python/controllers/android_device.py
deleted file mode 100644
index e5dd1cb..0000000
--- a/utils/python/controllers/android_device.py
+++ /dev/null
@@ -1,1409 +0,0 @@
-#
-# Copyright 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.
-
-# TODO(b/147454897): Keep the logic in sync with
-# test/vts-testcase/vndk/utils.py until this file is
-# removed.
-from builtins import str
-from builtins import open
-
-import gzip
-import logging
-import os
-import re
-import socket
-import subprocess
-import tempfile
-import threading
-import time
-import traceback
-
-from vts.runners.host import asserts
-from vts.runners.host import const
-from vts.runners.host import errors
-from vts.runners.host import keys
-from vts.runners.host import logger as vts_logger
-from vts.runners.host import signals
-from vts.runners.host import utils
-from vts.runners.host.tcp_client import vts_tcp_client
-from vts.utils.python.controllers import adb
-from vts.utils.python.controllers import fastboot
-from vts.utils.python.instrumentation import test_framework_instrumentation as tfi
-from vts.utils.python.mirror import mirror_tracker
-
-VTS_CONTROLLER_CONFIG_NAME = "AndroidDevice"
-VTS_CONTROLLER_REFERENCE_NAME = "android_devices"
-
-ANDROID_DEVICE_PICK_ALL_TOKEN = "*"
-# Key name for adb logcat extra params in config file.
-ANDROID_DEVICE_ADB_LOGCAT_PARAM_KEY = "adb_logcat_param"
-ANDROID_DEVICE_EMPTY_CONFIG_MSG = "Configuration is empty, abort!"
-ANDROID_DEVICE_NOT_LIST_CONFIG_MSG = "Configuration should be a list, abort!"
-PORT_RETRY_COUNT = 3
-SL4A_APK_NAME = "com.googlecode.android_scripting"
-
-ANDROID_PRODUCT_TYPE_UNKNOWN = "unknown"
-
-# Target-side directory where the VTS binaries are uploaded
-DEFAULT_AGENT_BASE_DIR = "/data/local/tmp"
-# Name of llkd
-LLKD = 'llkd-1'
-# Time for which the current is put on sleep when the client is unable to
-# make a connection.
-THREAD_SLEEP_TIME = 1
-# Max number of attempts that the client can make to connect to the agent
-MAX_AGENT_CONNECT_RETRIES = 10
-# System property for product sku.
-PROPERTY_PRODUCT_SKU = "ro.boot.product.hardware.sku"
-
-# The argument to fastboot getvar command to determine whether the device has
-# the slot for vbmeta.img
-_FASTBOOT_VAR_HAS_VBMETA = "has-slot:vbmeta"
-
-SYSPROP_DEV_BOOTCOMPLETE = "dev.bootcomplete"
-SYSPROP_SYS_BOOT_COMPLETED = "sys.boot_completed"
-# the name of a system property which tells whether to stop properly configured
-# native servers where properly configured means a server's init.rc is
-# configured to stop when that property's value is 1.
-SYSPROP_VTS_NATIVE_SERVER = "vts.native_server.on"
-# Maximum time in seconds to wait for process/system status change.
-WAIT_TIMEOUT_SEC = 120
-
-class AndroidDeviceError(signals.ControllerError):
- pass
-
-
-def create(configs, start_services=True):
- """Creates AndroidDevice controller objects.
-
- Args:
- configs: A list of dicts, each representing a configuration for an
- Android device.
- start_services: boolean, controls whether services will be started.
-
- Returns:
- A list of AndroidDevice objects.
- """
- if not configs:
- raise AndroidDeviceError(ANDROID_DEVICE_EMPTY_CONFIG_MSG)
- elif configs == ANDROID_DEVICE_PICK_ALL_TOKEN:
- ads = get_all_instances()
- elif not isinstance(configs, list):
- raise AndroidDeviceError(ANDROID_DEVICE_NOT_LIST_CONFIG_MSG)
- elif isinstance(configs[0], str):
- # Configs is a list of serials.
- ads = get_instances(configs)
- else:
- # Configs is a list of dicts.
- ads = get_instances_with_configs(configs)
- connected_ads = list_adb_devices()
- for ad in ads:
- ad.enable_vts_agent = start_services
- if ad.serial not in connected_ads:
- raise DoesNotExistError(("Android device %s is specified in config"
- " but is not attached.") % ad.serial)
- if start_services:
- _startServicesOnAds(ads)
- return ads
-
-
-def destroy(ads):
- """Cleans up AndroidDevice objects.
-
- Args:
- ads: A list of AndroidDevice objects.
- """
- for ad in ads:
- try:
- ad.cleanUp()
- except:
- ad.log.exception("Failed to clean up properly.")
-
-
-def _startServicesOnAds(ads):
- """Starts long running services on multiple AndroidDevice objects.
-
- If any one AndroidDevice object fails to start services, cleans up all
- existing AndroidDevice objects and their services.
-
- Args:
- ads: A list of AndroidDevice objects whose services to start.
- """
- running_ads = []
- for ad in ads:
- running_ads.append(ad)
- try:
- ad.startServices()
- except:
- ad.log.exception("Failed to start some services, abort!")
- destroy(running_ads)
- raise
-
-
-def _parse_device_list(device_list_str, key):
- """Parses a byte string representing a list of devices. The string is
- generated by calling either adb or fastboot.
-
- Args:
- device_list_str: Output of adb or fastboot.
- key: The token that signifies a device in device_list_str.
-
- Returns:
- A list of android device serial numbers.
- """
- clean_lines = str(device_list_str, 'utf-8').strip().split('\n')
- results = []
- for line in clean_lines:
- tokens = line.strip().split('\t')
- if len(tokens) == 2 and tokens[1] == key:
- results.append(tokens[0])
- return results
-
-
-def list_adb_devices():
- """List all target devices connected to the host and detected by adb.
-
- Returns:
- A list of android device serials. Empty if there's none.
- """
- out = adb.AdbProxy().devices()
- return _parse_device_list(out, "device")
-
-
-def list_fastboot_devices():
- """List all android devices connected to the computer that are in in
- fastboot mode. These are detected by fastboot.
-
- Returns:
- A list of android device serials. Empty if there's none.
- """
- out = fastboot.FastbootProxy().devices()
- return _parse_device_list(out, "fastboot")
-
-
-def list_unauthorized_devices():
- """List all unauthorized devices connected to the host and detected by adb.
-
- Returns:
- A list of unauthorized device serials. Empty if there's none.
- """
- out = adb.AdbProxy().devices()
- return _parse_device_list(out, "unauthorized")
-
-
-def get_instances(serials):
- """Create AndroidDevice instances from a list of serials.
-
- Args:
- serials: A list of android device serials.
-
- Returns:
- A list of AndroidDevice objects.
- """
- results = []
- for s in serials:
- results.append(AndroidDevice(s))
- return results
-
-
-def get_instances_with_configs(configs):
- """Create AndroidDevice instances from a list of json configs.
-
- Each config should have the required key-value pair "serial".
-
- Args:
- configs: A list of dicts each representing the configuration of one
- android device.
-
- Returns:
- A list of AndroidDevice objects.
- """
- results = []
- for c in configs:
- try:
- serial = c.pop(keys.ConfigKeys.IKEY_SERIAL)
- except KeyError:
- raise AndroidDeviceError(('Required value %s is missing in '
- 'AndroidDevice config %s.') %
- (keys.ConfigKeys.IKEY_SERIAL, c))
- try:
- product_type = c.pop(keys.ConfigKeys.IKEY_PRODUCT_TYPE)
- except KeyError:
- logging.error('Required value %s is missing in '
- 'AndroidDevice config %s.',
- keys.ConfigKeys.IKEY_PRODUCT_TYPE, c)
- product_type = ANDROID_PRODUCT_TYPE_UNKNOWN
-
- ad = AndroidDevice(serial, product_type)
- ad.loadConfig(c)
- results.append(ad)
- return results
-
-
-def get_all_instances(include_fastboot=False):
- """Create AndroidDevice instances for all attached android devices.
-
- Args:
- include_fastboot: Whether to include devices in bootloader mode or not.
-
- Returns:
- A list of AndroidDevice objects each representing an android device
- attached to the computer.
- """
- if include_fastboot:
- serial_list = list_adb_devices() + list_fastboot_devices()
- return get_instances(serial_list)
- return get_instances(list_adb_devices())
-
-
-def filter_devices(ads, func):
- """Finds the AndroidDevice instances from a list that match certain
- conditions.
-
- Args:
- ads: A list of AndroidDevice instances.
- func: A function that takes an AndroidDevice object and returns True
- if the device satisfies the filter condition.
-
- Returns:
- A list of AndroidDevice instances that satisfy the filter condition.
- """
- results = []
- for ad in ads:
- if func(ad):
- results.append(ad)
- return results
-
-
-def get_device(ads, **kwargs):
- """Finds a unique AndroidDevice instance from a list that has specific
- attributes of certain values.
-
- Example:
- get_device(android_devices, label="foo", phone_number="1234567890")
- get_device(android_devices, model="angler")
-
- Args:
- ads: A list of AndroidDevice instances.
- kwargs: keyword arguments used to filter AndroidDevice instances.
-
- Returns:
- The target AndroidDevice instance.
-
- Raises:
- AndroidDeviceError is raised if none or more than one device is
- matched.
- """
-
- def _get_device_filter(ad):
- for k, v in kwargs.items():
- if not hasattr(ad, k):
- return False
- elif getattr(ad, k) != v:
- return False
- return True
-
- filtered = filter_devices(ads, _get_device_filter)
- if not filtered:
- raise AndroidDeviceError(("Could not find a target device that matches"
- " condition: %s.") % kwargs)
- elif len(filtered) == 1:
- return filtered[0]
- else:
- serials = [ad.serial for ad in filtered]
- raise AndroidDeviceError("More than one device matched: %s" % serials)
-
-
-def takeBugReports(ads, test_name, begin_time):
- """Takes bug reports on a list of android devices.
-
- If you want to take a bug report, call this function with a list of
- android_device objects in on_fail. But reports will be taken on all the
- devices in the list concurrently. Bug report takes a relative long
- time to take, so use this cautiously.
-
- Args:
- ads: A list of AndroidDevice instances.
- test_name: Name of the test case that triggered this bug report.
- begin_time: Logline format timestamp taken when the test started.
- """
- begin_time = vts_logger.normalizeLogLineTimestamp(begin_time)
-
- def take_br(test_name, begin_time, ad):
- ad.takeBugReport(test_name, begin_time)
-
- args = [(test_name, begin_time, ad) for ad in ads]
- utils.concurrent_exec(take_br, args)
-
-
-class AndroidDevice(object):
- """Class representing an android device.
-
- Each object of this class represents one Android device. The object holds
- handles to adb, fastboot, and various RPC clients.
-
- Attributes:
- serial: A string that's the serial number of the Android device.
- device_command_port: int, the port number used on the Android device
- for adb port forwarding (for command-response sessions).
- device_callback_port: int, the port number used on the Android device
- for adb port reverse forwarding (for callback sessions).
- Set -1 if callback is not needed (e.g., when this class is used
- as an adb library).
- log: A logger project with a device-specific prefix for each line -
- [AndroidDevice|<serial>]
- log_path: A string that is the path where all logs collected on this
- android device should be stored.
- adb_logcat_process: A process that collects the adb logcat.
- adb_logcat_file_path: A string that's the full path to the adb logcat
- file collected, if any.
- vts_agent_process: A process that runs the HAL agent.
- adb: An AdbProxy object used for interacting with the device via adb.
- fastboot: A FastbootProxy object used for interacting with the device
- via fastboot.
- enable_vts_agent: bool, whether VTS agent is used.
- enable_sl4a: bool, whether SL4A is used. (unsupported)
- enable_sl4a_ed: bool, whether SL4A Event Dispatcher is used. (unsupported)
- host_command_port: the host-side port for runner to agent sessions
- (to send commands and receive responses).
- host_callback_port: the host-side port for agent to runner sessions
- (to get callbacks from agent).
- hal: HalMirror, in charge of all communications with the HAL layer.
- lib: LibMirror, in charge of all communications with static and shared
- native libs.
- shell: ShellMirror, in charge of all communications with shell.
- shell_default_nohup: bool, whether to use nohup by default in shell commands.
- _product_type: A string, the device product type (e.g., bullhead) if
- known, ANDROID_PRODUCT_TYPE_UNKNOWN otherwise.
- """
-
- def __init__(self,
- serial="",
- product_type=ANDROID_PRODUCT_TYPE_UNKNOWN,
- device_callback_port=5010,
- shell_default_nohup=False):
- self.serial = serial
- self._product_type = product_type
- self.device_command_port = None
- self.device_callback_port = device_callback_port
- self.log = AndroidDeviceLoggerAdapter(logging.getLogger(),
- {"serial": self.serial})
- base_log_path = getattr(logging, "log_path", "/tmp/logs/")
- self.log_path = os.path.join(base_log_path, "AndroidDevice%s" % serial)
- self.adb_logcat_process = None
- self.adb_logcat_file_path = None
- self.vts_agent_process = None
- self.adb = adb.AdbProxy(serial)
- self.fastboot = fastboot.FastbootProxy(serial)
- if not self.isBootloaderMode:
- self.rootAdb()
- self.host_command_port = None
- self.host_callback_port = adb.get_available_host_port()
- if self.device_callback_port >= 0:
- self.adb.reverse_tcp_forward(self.device_callback_port,
- self.host_callback_port)
- self.hal = None
- self.lib = None
- self.shell = None
- self.shell_default_nohup = shell_default_nohup
- self.fatal_error = False
-
- def __del__(self):
- self.cleanUp()
-
- def cleanUp(self):
- """Cleans up the AndroidDevice object and releases any resources it
- claimed.
- """
- self.stopServices()
- self._StartLLKD()
- if self.host_command_port:
- self.adb.forward("--remove tcp:%s" % self.host_command_port,
- timeout=adb.DEFAULT_ADB_SHORT_TIMEOUT)
- self.host_command_port = None
-
- @property
- def shell_default_nohup(self):
- """Gets default value for shell nohup option."""
- if not getattr(self, '_shell_default_nohup'):
- self._shell_default_nohup = False
- return self._shell_default_nohup
-
- @shell_default_nohup.setter
- def shell_default_nohup(self, value):
- """Sets default value for shell nohup option."""
- self._shell_default_nohup = value
- if self.shell:
- self.shell.shell_default_nohup = value
-
- @property
- def hasVbmetaSlot(self):
- """True if the device has the slot for vbmeta."""
- if not self.isBootloaderMode:
- self.adb.reboot_bootloader()
-
- out = self.fastboot.getvar(_FASTBOOT_VAR_HAS_VBMETA).strip()
- if ("%s: yes" % _FASTBOOT_VAR_HAS_VBMETA) in out:
- return True
- return False
-
- @property
- def isBootloaderMode(self):
- """True if the device is in bootloader mode."""
- return self.serial in list_fastboot_devices()
-
- @property
- def isTcpFastbootdMode(self):
- """True if the device is in tcp fastbootd mode."""
- if self.serial in list_unauthorized_devices():
- if self.fastboot.isFastbootOverTcp(self.serial):
- out = self.fastboot.getvar("is-userspace").strip()
- if ("is-userspace: yes") in out:
- return True
- return False
-
- @property
- def isAdbRoot(self):
- """True if adb is running as root for this device."""
- id_str = self.adb.shell("id -un").strip().decode("utf-8")
- return id_str == "root"
-
- @property
- def verityEnabled(self):
- """True if verity is enabled for this device."""
- try:
- verified = self.getProp("partition.system.verified")
- if not verified:
- return False
- except adb.AdbError:
- # If verity is disabled, there is no property 'partition.system.verified'
- return False
- return True
-
- @property
- def model(self):
- """The Android code name for the device."""
- # If device is in bootloader mode, get mode name from fastboot.
- if self.isBootloaderMode:
- out = self.fastboot.getvar("product").strip()
- # "out" is never empty because of the "total time" message fastboot
- # writes to stderr.
- lines = out.decode("utf-8").split('\n', 1)
- if lines:
- tokens = lines[0].split(' ')
- if len(tokens) > 1:
- return tokens[1].lower()
- return None
- model = self.getProp("ro.build.product").lower()
- if model == "sprout":
- return model
- else:
- model = self.getProp("ro.product.name").lower()
- return model
-
- @property
- def first_api_level(self):
- """Gets the API level that the device was initially launched with."""
- return self.getProp("ro.product.first_api_level")
-
- @property
- def sdk_version(self):
- """Gets the SDK version that the device is running with."""
- return self.getProp("ro.build.version.sdk")
-
- def getLaunchApiLevel(self, strict=True):
- """Gets the API level that the device was initially launched with.
-
- This method reads ro.product.first_api_level from the device. If the
- value is 0, it then reads ro.build.version.sdk.
-
- Args:
- strict: A boolean, whether to fail the test if the property is
- not an integer or not defined.
-
- Returns:
- An integer, the API level.
- 0 if the property is not an integer or not defined.
- """
- level_str = self.first_api_level
- try:
- level = int(level_str)
- except ValueError:
- error_msg = "Cannot parse first_api_level: %s" % level_str
- if strict:
- asserts.fail(error_msg)
- logging.error(error_msg)
- return 0
-
- if level != 0:
- return level
-
- level_str = self.sdk_version
- try:
- return int(level_str)
- except ValueError:
- error_msg = "Cannot parse version.sdk: %s" % level_str
- if strict:
- asserts.fail(error_msg)
- logging.error(error_msg)
- return 0
-
- @property
- def kernel_version(self):
- """Gets the kernel verison from the device.
-
- This method reads the output of command "uname -r" from the device.
-
- Returns:
- A tuple of kernel version information
- in the format of (version, patchlevel, sublevel).
-
- It will fail if failed to get the output or correct format
- from the output of "uname -r" command
- """
- cmd = 'uname -r'
- out = self.adb.shell(cmd)
- out = out.strip()
-
- match = re.match(r"(\d+)\.(\d+)\.(\d+)", out)
- if match is None:
- asserts.fail("Failed to detect kernel version of device. out:%s", out)
-
- version = int(match.group(1))
- patchlevel = int(match.group(2))
- sublevel = int(match.group(3))
- logging.info("Detected kernel version: %s", match.group(0))
- return (version, patchlevel, sublevel)
-
- @property
- def vndk_version(self):
- """Gets the VNDK version that the vendor partition is using."""
- return self.getProp("ro.vndk.version")
-
- @property
- def vndk_lite(self):
- """Checks whether the vendor partition requests lite VNDK
- enforcement.
-
- Returns:
- bool, True for lite vndk enforcement.
- """
- vndk_lite_str = self.getProp("ro.vndk.lite")
- if vndk_lite_str is None:
- logging.debug('ro.vndk.lite: %s' % vndk_lite_str)
- return False
- return vndk_lite_str.lower() == "true"
-
- @property
- def cpu_abi(self):
- """CPU ABI (Application Binary Interface) of the device."""
- out = self.getProp("ro.product.cpu.abi")
- if not out:
- return "unknown"
-
- cpu_abi = out.lower()
- return cpu_abi
-
- def getCpuAbiList(self, bitness=""):
- """Gets list of supported ABIs from property.
-
- Args:
- bitness: 32 or 64. If the argument is not specified, this method
- returns both 32 and 64-bit ABIs.
-
- Returns:
- A list of strings, the supported ABIs.
- """
- out = self.getProp("ro.product.cpu.abilist" + str(bitness))
- return out.lower().split(",") if out else []
-
- @property
- def is64Bit(self):
- """True if device is 64 bit."""
- out = self.adb.shell('uname -m')
- return "64" in out
-
- @property
- def total_memory(self):
- """Total memory on device.
-
- Returns:
- long, total memory in bytes. -1 if cannot get memory information.
- """
- total_memory_command = 'cat /proc/meminfo | grep MemTotal'
- out = self.adb.shell(total_memory_command)
- value_unit = out.split(':')[-1].strip().split(' ')
-
- if len(value_unit) != 2:
- logging.error('Cannot get memory information. %s', out)
- return -1
-
- value, unit = value_unit
-
- try:
- value = int(value)
- except ValueError:
- logging.error('Unrecognized total memory value: %s', value_unit)
- return -1
-
- unit = unit.lower()
- if unit == 'kb':
- value *= 1024
- elif unit == 'mb':
- value *= 1024 * 1024
- elif unit == 'b':
- pass
- else:
- logging.error('Unrecognized total memory unit: %s', value_unit)
- return -1
-
- return value
-
- @property
- def libPaths(self):
- """List of strings representing the paths to the native library directories."""
- paths_32 = ["/system/lib", "/vendor/lib"]
- if self.is64Bit:
- paths_64 = ["/system/lib64", "/vendor/lib64"]
- paths_64.extend(paths_32)
- return paths_64
- return paths_32
-
- @property
- def isAdbLogcatOn(self):
- """Whether there is an ongoing adb logcat collection.
- """
- if self.adb_logcat_process:
- return True
- return False
-
- @property
- def mac_address(self):
- """The MAC address of the device.
- """
- try:
- command = 'cat /sys/class/net/wlan0/address'
- response = self.adb.shell(command)
- return response.strip()
- except adb.AdbError as e:
- logging.exception(e)
- return "unknown"
-
- @property
- def sim_state(self):
- """The SIM state of the device.
- """
- return self.getProp('gsm.sim.state')
-
- @property
- def sim_operator(self):
- """The SIM operator of the device.
- """
- return self.getProp('gsm.operator.alpha')
-
- def getKernelConfig(self, config_name):
- """Gets kernel config from the device.
-
- Args:
- config_name: A string, the name of the configuration.
-
- Returns:
- "y" or "m" if the config is set.
- "" if the config is not set.
- None if fails to read config.
- """
- line_prefix = config_name + "="
- with tempfile.NamedTemporaryFile(delete=False) as temp_file:
- config_path = temp_file.name
- try:
- logging.debug("Pull config.gz to %s", config_path)
- self.adb.pull("/proc/config.gz", config_path)
- with gzip.GzipFile(config_path, "rb") as config_file:
- for line in config_file:
- if line.strip().startswith(line_prefix):
- logging.debug("Found config: %s", line)
- return line.strip()[len(line_prefix):]
- logging.debug("%s is not set.", config_name)
- return ""
- except (adb.AdbError, IOError) as e:
- logging.exception("Cannot read kernel config.", e)
- return None
- finally:
- os.remove(config_path)
-
- def getBinderBitness(self):
- """Returns the value of BINDER_IPC_32BIT in kernel config.
-
- Returns:
- 32 or 64, binder bitness of the device.
- None if fails to read config.
- """
- config_value = self.getKernelConfig("CONFIG_ANDROID_BINDER_IPC_32BIT")
- if config_value is None:
- return None
- elif config_value:
- return 32
- else:
- return 64
-
- def loadConfig(self, config):
- """Add attributes to the AndroidDevice object based on json config.
-
- Args:
- config: A dictionary representing the configs.
-
- Raises:
- AndroidDeviceError is raised if the config is trying to overwrite
- an existing attribute.
- """
- for k, v in config.items():
- if hasattr(self, k):
- raise AndroidDeviceError(
- "Attempting to set existing attribute %s on %s" %
- (k, self.serial))
- setattr(self, k, v)
-
- def rootAdb(self):
- """Changes adb to root mode for this device."""
- if not self.isAdbRoot:
- try:
- self.adb.root()
- self.adb.wait_for_device()
- except adb.AdbError as e:
- # adb wait-for-device is not always possible in the lab
- # continue with an assumption it's done by the harness.
- logging.exception(e)
-
- def startAdbLogcat(self):
- """Starts a standing adb logcat collection in separate subprocesses and
- save the logcat in a file.
- """
- if self.isAdbLogcatOn:
- raise AndroidDeviceError(("Android device %s already has an adb "
- "logcat thread going on. Cannot start "
- "another one.") % self.serial)
- event = tfi.Begin("start adb logcat from android_device",
- tfi.categories.FRAMEWORK_SETUP)
-
- f_name = "adblog_%s_%s.txt" % (self.model, self.serial)
- utils.create_dir(self.log_path)
- logcat_file_path = os.path.join(self.log_path, f_name)
- try:
- extra_params = self.adb_logcat_param
- except AttributeError:
- extra_params = "-b all"
- cmd = "adb -s %s logcat -v threadtime %s >> %s" % (self.serial,
- extra_params,
- logcat_file_path)
- self.adb_logcat_process = utils.start_standing_subprocess(cmd)
- self.adb_logcat_file_path = logcat_file_path
- event.End()
-
- def stopAdbLogcat(self):
- """Stops the adb logcat collection subprocess.
- """
- if not self.isAdbLogcatOn:
- raise AndroidDeviceError(
- "Android device %s does not have an ongoing adb logcat collection."
- % self.serial)
-
- event = tfi.Begin("stop adb logcat from android_device",
- tfi.categories.FRAMEWORK_TEARDOWN)
- try:
- utils.stop_standing_subprocess(self.adb_logcat_process)
- except utils.VTSUtilsError as e:
- event.Remove("Cannot stop adb logcat. %s" % e)
- logging.error("Cannot stop adb logcat. %s", e)
- self.adb_logcat_process = None
- event.End()
-
- def takeBugReport(self, test_name, begin_time):
- """Takes a bug report on the device and stores it in a file.
-
- Args:
- test_name: Name of the test case that triggered this bug report.
- begin_time: Logline format timestamp taken when the test started.
- """
- br_path = os.path.join(self.log_path, "BugReports")
- utils.create_dir(br_path)
- base_name = ",%s,%s.txt" % (begin_time, self.serial)
- test_name_len = utils.MAX_FILENAME_LEN - len(base_name)
- out_name = test_name[:test_name_len] + base_name
- full_out_path = os.path.join(br_path, out_name.replace(' ', '\ '))
- self.log.info("Taking bugreport for %s on %s", test_name, self.serial)
- self.adb.bugreport(" > %s" % full_out_path)
- self.log.info("Bugreport for %s taken at %s", test_name, full_out_path)
-
- def waitForBootCompletion(self, timeout=900):
- """Waits for Android framework to broadcast ACTION_BOOT_COMPLETED.
-
- Args:
- timeout: int, seconds to wait for boot completion. Default is
- 15 minutes.
-
- Returns:
- bool, True if boot completed. False if any error or timeout
- """
- start = time.time()
- try:
- self.adb.wait_for_device(timeout=timeout)
- except adb.AdbError as e:
- # adb wait-for-device is not always possible in the lab
- logging.exception(e)
- return False
-
- while not self.isBootCompleted():
- if time.time() - start >= timeout:
- logging.error("Timeout while waiting for boot completion.")
- return False
- time.sleep(1)
-
- return True
-
- # Deprecated. Use isBootCompleted instead
- def hasBooted(self):
- """Checks whether the device has booted.
-
- Returns:
- True if booted, False otherwise.
- """
- return self.isBootCompleted()
-
- def isBootCompleted(self):
- """Checks whether the device has booted.
-
- Returns:
- True if booted, False otherwise.
- """
- try:
- if (self.getProp(SYSPROP_SYS_BOOT_COMPLETED) == '1' and
- self.getProp(SYSPROP_DEV_BOOTCOMPLETE) == '1'):
- return True
- except adb.AdbError:
- # adb shell calls may fail during certain period of booting
- # process, which is normal. Ignoring these errors.
- pass
-
- return False
-
- def isFrameworkRunning(self, check_boot_completion=True):
- """Checks whether Android framework is started.
-
- This function will first check boot_completed prop. If boot_completed
- is 0, then return False meaning framework not started.
- Then this function will check whether system_server process is running.
- If yes, then return True meaning framework is started.
-
- The assumption here is if prop boot_completed is 0 then framework
- is stopped.
-
- There are still cases which can make this function return wrong
- result. For example, boot_completed is set to 0 manually without
- without stopping framework.
-
- Args:
- check_boot_completion: bool, whether to check boot completion
- before checking framework status. This is an
- important step for ensuring framework is
- started. Under most circumstances this value
- should be set to True.
- Default True.
-
- Returns:
- True if started, False otherwise.
- """
- # First, check whether boot has completed.
- if check_boot_completion and not self.isBootCompleted():
- return False
-
- cmd = 'ps -g system | grep system_server'
- res = self.adb.shell(cmd, no_except=True)
-
- return 'system_server' in res[const.STDOUT]
-
- def startFramework(self,
- wait_for_completion=True,
- wait_for_completion_timeout=WAIT_TIMEOUT_SEC):
- """Starts Android framework.
-
- By default this function will wait for framework starting process to
- finish before returning.
-
- Args:
- wait_for_completion: bool, whether to wait for framework to complete
- starting. Default: True
- wait_for_completion_timeout: timeout in seconds for waiting framework
- to start. Default: 2 minutes
-
- Returns:
- bool, True if framework start success. False otherwise.
- """
- logging.debug("starting Android framework")
- self.adb.shell("start")
-
- if wait_for_completion:
- if not self.waitForFrameworkStartComplete(
- wait_for_completion_timeout):
- return False
-
- logging.info("Android framework started.")
- return True
-
- def start(self, start_native_server=True):
- """Starts Android framework and waits for ACTION_BOOT_COMPLETED.
-
- Args:
- start_native_server: bool, whether to start the native server.
- Returns:
- bool, True if framework start success. False otherwise.
- """
- if start_native_server:
- self.startNativeServer()
- return self.startFramework()
-
- def stopFramework(self):
- """Stops Android framework.
-
- Method will block until stop is complete.
- """
- logging.debug("stopping Android framework")
- self.adb.shell("stop")
- self.setProp(SYSPROP_SYS_BOOT_COMPLETED, 0)
- logging.info("Android framework stopped")
-
- def stop(self, stop_native_server=False):
- """Stops Android framework.
-
- Method will block until stop is complete.
-
- Args:
- stop_native_server: bool, whether to stop the native server.
- """
- self.stopFramework()
- if stop_native_server:
- self.stopNativeServer()
-
- def waitForFrameworkStartComplete(self, timeout_secs=WAIT_TIMEOUT_SEC):
- """Wait for Android framework to complete starting.
-
- Args:
- timeout_secs: int, seconds to wait for boot completion. Default is
- 2 minutes.
-
- Returns:
- bool, True if framework is started. False otherwise or timeout
- """
- start = time.time()
-
- # First, wait for boot completion and checks
- if not self.waitForBootCompletion(timeout_secs):
- return False
-
- while not self.isFrameworkRunning(check_boot_completion=False):
- if time.time() - start >= timeout_secs:
- logging.error("Timeout while waiting for framework to start.")
- return False
- time.sleep(1)
- return True
-
- def startNativeServer(self):
- """Starts all native servers."""
- self.setProp(SYSPROP_VTS_NATIVE_SERVER, "0")
-
- def stopNativeServer(self):
- """Stops all native servers."""
- self.setProp(SYSPROP_VTS_NATIVE_SERVER, "1")
-
- def isProcessRunning(self, process_name):
- """Check whether the given process is running.
- Args:
- process_name: string, name of the process.
-
- Returns:
- bool, True if the process is running.
-
- Raises:
- AndroidDeviceError, if ps command failed.
- """
- logging.debug("Checking process %s", process_name)
- cmd_result = self.adb.shell.Execute("ps -A")
- if cmd_result[const.EXIT_CODE][0] != 0:
- logging.error("ps command failed (exit code: %s",
- cmd_result[const.EXIT_CODE][0])
- raise AndroidDeviceError("ps command failed.")
- if (process_name not in cmd_result[const.STDOUT][0]):
- logging.debug("Process %s not running", process_name)
- return False
- return True
-
- def waitForProcessStop(self, process_names, timeout_secs=WAIT_TIMEOUT_SEC):
- """Wait until the given process is stopped or timeout.
-
- Args:
- process_names: list of string, name of the processes.
- timeout_secs: int, timeout in secs.
-
- Returns:
- bool, True if the process stopped within timeout.
- """
- if process_names:
- for process_name in process_names:
- start = time.time()
- while self.isProcessRunning(process_name):
- if time.time() - start >= timeout_secs:
- logging.error(
- "Timeout while waiting for process %s stop.",
- process_name)
- return False
- time.sleep(1)
-
- return True
-
- def setProp(self, name, value):
- """Calls setprop shell command.
-
- Args:
- name: string, the name of a system property to set
- value: any type, value will be converted to string. Quotes in value
- is not supported at this time; if value contains a quote,
- this method will log an error and return.
-
- Raises:
- AdbError, if name contains invalid character
- """
- if name is None or value is None:
- logging.error("name or value of system property "
- "should not be None. No property is set.")
- return
-
- value = str(value)
-
- if "'" in value or "\"" in value:
- logging.error("Quotes in value of system property "
- "is not yet supported. No property is set.")
- return
-
- self.adb.shell("setprop %s \"%s\"" % (name, value))
-
- def getProp(self, name, timeout=adb.DEFAULT_ADB_SHORT_TIMEOUT):
- """Calls getprop shell command.
-
- Args:
- name: string, the name of a system property to get
-
- Returns:
- string, value of the property. If name does not exist; an empty
- string will be returned. decode("utf-8") and strip() will be called
- on the output before returning; None will be returned if input
- name is None
-
- Raises:
- AdbError, if name contains invalid character
- """
- if name is None:
- logging.error("name of system property should not be None.")
- return None
-
- out = self.adb.shell("getprop %s" % name, timeout=timeout)
- return out.decode("utf-8").strip()
-
- def reboot(self, restart_services=True):
- """Reboots the device and wait for device to complete booting.
-
- This is probably going to print some error messages in console. Only
- use if there's no other option.
-
- Raises:
- AndroidDeviceError is raised if waiting for completion timed
- out.
- """
- if self.isBootloaderMode:
- self.fastboot.reboot()
- return
-
- if self.isTcpFastbootdMode:
- self.fastboot.reboot()
- return
-
- if restart_services:
- has_adb_log = self.isAdbLogcatOn
- has_vts_agent = True if self.vts_agent_process else False
- if has_adb_log:
- self.stopAdbLogcat()
- if has_vts_agent:
- self.stopVtsAgent()
-
- self.adb.reboot()
- self.waitForBootCompletion()
- self.rootAdb()
-
- if restart_services:
- if has_adb_log:
- self.startAdbLogcat()
- if has_vts_agent:
- self.startVtsAgent()
-
- def startServices(self):
- """Starts long running services on the android device.
-
- 1. Start adb logcat capture.
- 2. Start VtsAgent and create HalMirror unless disabled in config.
- """
- event = tfi.Begin("start vts services",
- tfi.categories.FRAMEWORK_SETUP)
-
- self.enable_vts_agent = getattr(self, "enable_vts_agent", True)
- try:
- self.startAdbLogcat()
- except Exception as e:
- msg = "Failed to start adb logcat!"
- event.Remove(msg)
- self.log.error(msg)
- self.log.exception(e)
- raise
- if self.enable_vts_agent:
- self.startVtsAgent()
- self.device_command_port = int(
- self.adb.shell("cat /data/local/tmp/vts_tcp_server_port"))
- logging.debug("device_command_port: %s", self.device_command_port)
- if not self.host_command_port:
- self.host_command_port = adb.get_available_host_port()
- self.adb.tcp_forward(self.host_command_port,
- self.device_command_port)
- self.hal = mirror_tracker.MirrorTracker(
- self.host_command_port, self.host_callback_port, True)
- self.lib = mirror_tracker.MirrorTracker(self.host_command_port)
- self.shell = mirror_tracker.MirrorTracker(
- host_command_port=self.host_command_port, adb=self.adb)
- self.shell.shell_default_nohup = self.shell_default_nohup
- self.resource = mirror_tracker.MirrorTracker(self.host_command_port)
- event.End()
-
- def Heal(self):
- """Performs a self healing.
-
- Includes self diagnosis that looks for any framework errors.
-
- Returns:
- bool, True if everything is ok; False otherwise.
- """
- res = True
-
- if self.shell:
- res &= self.shell.Heal()
-
- try:
- self.getProp("ro.build.version.sdk")
- except adb.AdbError:
- if self.serial in list_adb_devices():
- self.log.error(
- "Device is in adb devices, but is not responding!")
- elif self.isBootloaderMode:
- self.log.info("Device is in bootloader/fastbootd mode")
- return True
- elif self.isTcpFastbootdMode:
- self.log.info("Device is in tcp fastbootd mode")
- return True
- else:
- self.log.error("Device is not in adb devices!")
- self.fatal_error = True
- res = False
- else:
- self.fatal_error = False
- if not res:
- self.log.error('Self diagnosis found problem')
-
- return res
-
- def stopServices(self):
- """Stops long running services on the android device."""
- if self.adb_logcat_process:
- self.stopAdbLogcat()
- if getattr(self, "enable_vts_agent", True):
- self.stopVtsAgent()
- if self.hal:
- self.hal.CleanUp()
-
- def _StartLLKD(self):
- """Starts LLKD"""
- if self.fatal_error:
- self.log.error("Device in fatal error state, skip starting llkd")
- return
- try:
- self.adb.shell('start %s' % LLKD)
- except adb.AdbError as e:
- logging.warn('Failed to start llkd')
-
- def _StopLLKD(self):
- """Stops LLKD"""
- if self.fatal_error:
- self.log.error("Device in fatal error state, skip stop llkd")
- return
- try:
- self.adb.shell('stop %s' % LLKD)
- except adb.AdbError as e:
- logging.warn('Failed to stop llkd')
-
- def startVtsAgent(self):
- """Start HAL agent on the AndroidDevice.
-
- This function starts the target side native agent and is persisted
- throughout the test run.
- """
- self.log.info("Starting VTS agent")
- if self.vts_agent_process:
- raise AndroidDeviceError(
- "HAL agent is already running on %s." % self.serial)
-
- event = tfi.Begin("start vts agent", tfi.categories.FRAMEWORK_SETUP)
-
- self._StopLLKD()
-
- event_cleanup = tfi.Begin("start vts agent -- cleanup", tfi.categories.FRAMEWORK_SETUP)
- cleanup_commands = [
- "rm -f /data/local/tmp/vts_driver_*",
- "rm -f /data/local/tmp/vts_agent_callback*"
- ]
-
- kill_command = "pgrep 'vts_*' | xargs kill"
- cleanup_commands.append(kill_command)
- try:
- self.adb.shell("\"" + " ; ".join(cleanup_commands) + "\"")
- except adb.AdbError as e:
- self.log.warning(
- "A command to setup the env to start the VTS Agent failed %s",
- e)
- event_cleanup.End()
-
- log_severity = getattr(self, keys.ConfigKeys.KEY_LOG_SEVERITY, "INFO")
- bits = ['64', '32'] if self.is64Bit else ['32']
- file_names = ['vts_hal_agent', 'vts_hal_driver', 'vts_shell_driver']
- for bitness in bits:
- vts_agent_log_path = os.path.join(
- self.log_path, 'vts_agent_%s_%s.log' % (bitness, self.serial))
-
- chmod_cmd = ' '.join(
- map(lambda file_name: 'chmod 755 {path}/{bit}/{file_name}{bit};'.format(
- path=DEFAULT_AGENT_BASE_DIR,
- bit=bitness,
- file_name=file_name),
- file_names))
-
- cmd = ('adb -s {s} shell "{chmod} LD_LIBRARY_PATH={path}/{bitness} '
- '{path}/{bitness}/vts_hal_agent{bitness} '
- '--hal_driver_path_32={path}/32/vts_hal_driver32 '
- '--hal_driver_path_64={path}/64/vts_hal_driver64 '
- '--spec_dir={path}/spec '
- '--shell_driver_path_32={path}/32/vts_shell_driver32 '
- '--shell_driver_path_64={path}/64/vts_shell_driver64 '
- '-l {severity}" >> {log} 2>&1').format(
- s=self.serial,
- chmod=chmod_cmd,
- bitness=bitness,
- path=DEFAULT_AGENT_BASE_DIR,
- log=vts_agent_log_path,
- severity=log_severity)
- try:
- self.vts_agent_process = utils.start_standing_subprocess(
- cmd, check_health_delay=1)
- break
- except utils.VTSUtilsError as e:
- logging.exception(e)
- with open(vts_agent_log_path, 'r') as log_file:
- logging.error("VTS agent output:\n")
- logging.error(log_file.read())
- # one common cause is that 64-bit executable is not supported
- # in low API level devices.
- if bitness == '32':
- msg = "unrecognized bitness"
- event.Remove(msg)
- logging.error(msg)
- raise
- else:
- logging.error('retrying using a 32-bit binary.')
- event.End()
-
- def stopVtsAgent(self):
- """Stop the HAL agent running on the AndroidDevice.
- """
- if not self.vts_agent_process:
- return
- try:
- utils.stop_standing_subprocess(self.vts_agent_process)
- except utils.VTSUtilsError as e:
- logging.error("Cannot stop VTS agent. %s", e)
- self.vts_agent_process = None
-
- @property
- def product_type(self):
- """Gets the product type name."""
- return self._product_type
-
- def getPackagePid(self, package_name):
- """Gets the pid for a given package. Returns None if not running.
-
- Args:
- package_name: The name of the package.
-
- Returns:
- The first pid found under a given package name. None if no process
- was found running the package.
-
- Raises:
- AndroidDeviceError if the output of the phone's process list was
- in an unexpected format.
- """
- for cmd in ("ps -A", "ps"):
- try:
- out = self.adb.shell('%s | grep "S %s"' % (cmd, package_name))
- if package_name not in out:
- continue
- try:
- pid = int(out.split()[1])
- self.log.info('apk %s has pid %s.', package_name, pid)
- return pid
- except (IndexError, ValueError) as e:
- # Possible ValueError from string to int cast.
- # Possible IndexError from split.
- self.log.warn('Command \"%s\" returned output line: '
- '\"%s\".\nError: %s', cmd, out, e)
- except Exception as e:
- self.log.warn(
- 'Device fails to check if %s running with \"%s\"\n'
- 'Exception %s', package_name, cmd, e)
- self.log.debug("apk %s is not running", package_name)
- return None
-
-class AndroidDeviceLoggerAdapter(logging.LoggerAdapter):
- """A wrapper class that attaches a prefix to all log lines from an
- AndroidDevice object.
- """
-
- def process(self, msg, kwargs):
- """Process every log message written via the wrapped logger object.
-
- We are adding the prefix "[AndroidDevice|<serial>]" to all log lines.
-
- Args:
- msg: string, the original log message.
- kwargs: dict, the key value pairs that can be used to modify the
- original log message.
- """
- msg = "[AndroidDevice|%s] %s" % (self.extra["serial"], msg)
- return (msg, kwargs)
-
- def warn(self, msg, *args, **kwargs):
- """Function call warper for warn() to warning()."""
- super(AndroidDeviceLoggerAdapter, self).warning(msg, *args, **kwargs)
diff --git a/utils/python/controllers/android_device_test.py b/utils/python/controllers/android_device_test.py
deleted file mode 100644
index cbe6711..0000000
--- a/utils/python/controllers/android_device_test.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 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.
-#
-
-import unittest
-import vts.utils.python.controllers.android_device as android_device
-
-
-class AndroidDeviceTest(unittest.TestCase):
- '''Test methods inside android_device module.'''
-
- def setUp(self):
- """SetUp tasks"""
- available_serials = android_device.list_adb_devices()
- self.assertGreater(len(available_serials), 0, 'no device available.')
- self.dut = android_device.AndroidDevice(available_serials[0])
-
- def tearDown(self):
- """TearDown tasks"""
- pass
-
- def testFrameworkStatusChange(self):
- '''Test AndroidDevice class startRuntime related functions.'''
- err_msg = 'Runtime status is wrong'
- print('step 1 start runtime')
- self.dut.start()
-
- print('step 2 check runtime status')
- self.assertTrue(self.dut.isFrameworkRunning(), err_msg)
-
- print('step 3 stop runtime')
- self.dut.stop()
-
- print('step 4 check runtime status')
- self.assertFalse(self.dut.isFrameworkRunning(), err_msg)
-
- print('step 5 start runtime')
- self.dut.start()
-
- print('step 6 check runtime status')
- self.assertTrue(self.dut.isFrameworkRunning(), err_msg)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/utils/python/controllers/fastboot.py b/utils/python/controllers/fastboot.py
deleted file mode 100644
index 2d8313a..0000000
--- a/utils/python/controllers/fastboot.py
+++ /dev/null
@@ -1,88 +0,0 @@
-#
-# Copyright 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.
-
-from subprocess import Popen, PIPE
-
-import socket
-
-
-def exe_cmd(*cmds):
- """Executes commands in a new shell. Directing stderr to PIPE.
-
- This is fastboot's own exe_cmd because of its peculiar way of writing
- non-error info to stderr.
-
- Args:
- cmds: A sequence of commands and arguments.
-
- Returns:
- The output of the command run.
-
- Raises:
- Exception is raised if an error occurred during the command execution.
- """
- cmd = ' '.join(cmds)
- proc = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
- (out, err) = proc.communicate()
- if not err:
- return out
- return err
-
-def isFastbootOverTcp(serial):
- token = serial.split(':')
- if len(token) == 2:
- try:
- socket.inet_aton(token[0])
- return True
- except socket.error:
- return False
- return False
-
-class FastbootError(Exception):
- """Raised when there is an error in fastboot operations."""
-
-
-class FastbootProxy():
- """Proxy class for fastboot.
-
- For syntactic reasons, the '-' in fastboot commands need to be replaced
- with '_'. Can directly execute fastboot commands on an object:
- >> fb = FastbootProxy(<serial>)
- >> fb.devices() # will return the console output of "fastboot devices".
- """
-
- def __init__(self, serial=""):
- self.serial = serial
- if serial:
- if isFastbootOverTcp(serial):
- self.fastboot_str = "fastboot -s tcp:{}".format(serial[:serial.index(':')])
- else:
- self.fastboot_str = "fastboot -s {}".format(serial)
- else:
- self.fastboot_str = "fastboot"
-
- def _exec_fastboot_cmd(self, name, arg_str):
- return exe_cmd(' '.join((self.fastboot_str, name, arg_str)))
-
- def args(self, *args):
- return exe_cmd(' '.join((self.fastboot_str, ) + args))
-
- def __getattr__(self, name):
- def fastboot_call(*args):
- clean_name = name.replace('_', '-')
- arg_str = ' '.join(str(elem) for elem in args)
- return self._exec_fastboot_cmd(clean_name, arg_str)
-
- return fastboot_call
diff --git a/utils/python/cpu/__init__.py b/utils/python/cpu/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/cpu/__init__.py
+++ /dev/null
diff --git a/utils/python/cpu/cpu_frequency_scaling.py b/utils/python/cpu/cpu_frequency_scaling.py
deleted file mode 100644
index f132fc8..0000000
--- a/utils/python/cpu/cpu_frequency_scaling.py
+++ /dev/null
@@ -1,246 +0,0 @@
-#
-# 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.
-#
-
-import logging
-import time
-
-from vts.runners.host import asserts
-from vts.runners.host import const
-
-
-class CpuFrequencyScalingController(object):
- """CPU Frequency Scaling Controller.
-
- The implementation is based on the special files in
- /sys/devices/system/cpu/. CPU availability is shown in multiple files,
- including online, present, and possible. This class assumes that a present
- CPU may dynamically switch its online status. If a CPU is online, its
- frequency scaling can be adjusted by reading/writing the files in
- cpuX/cpufreq/ where X is the CPU number.
-
- Attributes:
- _dut: the target device DUT instance.
- _shell: Shell mirror object for communication with a target.
- _min_cpu_number: integer, the min CPU number.
- _max_cpu_number; integer, the max CPU number.
- _theoretical_max_frequency: a dict where its key is the CPU number and
- its value is an integer containing the
- theoretical max CPU frequency.
- _perf_override: boolean, true if this module has switched the device from
- its normal cpufreq governor to the performance
- governor.
- _saved_governors: list of strings, the saved cpufreq governor for each
- CPU on the device.
- """
-
- def __init__(self, dut):
- self._dut = dut
- self._init = False
-
- def Init(self):
- """Creates a shell mirror object and reads the configuration values."""
- if self._init:
- return
- self._shell = self._dut.shell
- self._min_cpu_number, self._max_cpu_number = self._LoadMinAndMaxCpuNo()
- self._theoretical_max_frequency = {}
- self._perf_override = False
- self._saved_governors = None
- self._init = True
-
- def _LoadMinAndMaxCpuNo(self):
- """Reads the min and max CPU numbers from sysfs.
-
- Returns:
- integer: min CPU number (inclusive)
- integer: max CPU number (exclusive)
- """
- results = self._shell.Execute("cat /sys/devices/system/cpu/present")
- asserts.assertEqual(len(results[const.STDOUT]), 1)
- stdout_lines = results[const.STDOUT][0].split("\n")
- stdout_split = stdout_lines[0].split('-')
- asserts.assertLess(len(stdout_split), 3)
- low = stdout_split[0]
- high = stdout_split[1] if len(stdout_split) == 2 else low
- logging.debug("present cpus: %s : %s" % (low, high))
- return int(low), int(high) + 1
-
- def GetMinAndMaxCpuNo(self):
- """Returns the min and max CPU numbers.
-
- Returns:
- integer: min CPU number (inclusive)
- integer: max CPU number (exclusive)
- """
- return self._min_cpu_number, self._max_cpu_number
-
- def _GetTheoreticalMaxFrequency(self, cpu_no):
- """Reads max value from cpufreq/scaling_available_frequencies.
-
- If the read operation is successful, the return value is kept in
- _theoretical_max_frequency as a cache.
-
- Args:
- cpu_no: integer, the CPU number.
-
- Returns:
- An integer which is the max frequency read from the file.
- None if the file cannot be read.
- """
- if cpu_no in self._theoretical_max_frequency:
- return self._theoretical_max_frequency[cpu_no]
- results = self._shell.Execute(
- "cat /sys/devices/system/cpu/cpu%s/"
- "cpufreq/scaling_available_frequencies" % cpu_no)
- asserts.assertEqual(1, len(results[const.EXIT_CODE]))
- if not results[const.EXIT_CODE][0]:
- freq = [int(x) for x in results[const.STDOUT][0].split()]
- self._theoretical_max_frequency[cpu_no] = max(freq)
- return self._theoretical_max_frequency[cpu_no]
- else:
- logging.warn("cpufreq/scaling_available_frequencies for cpu %s"
- " not set.", cpu_no)
- return None
-
- def ChangeCpuGovernor(self, modes):
- """Changes the CPU governor mode of all the CPUs on the device.
-
- Args:
- modes: list of expected CPU governor modes, e.g., 'performance'
- or 'schedutil'. The length of the list must be equal to
- the number of CPUs on the device.
-
- Returns:
- A list of the previous governor modes if successful, None otherwise.
- """
- self.Init()
- asserts.assertEqual(self._max_cpu_number - self._min_cpu_number,
- len(modes))
- # save current governor settings
- target_cmd = []
- prev_govs = []
- for cpu_no in range(self._min_cpu_number, self._max_cpu_number):
- target_cmd.append("cat /sys/devices/system/cpu/cpu%s/cpufreq/"
- "scaling_governor" % cpu_no)
- results = self._shell.Execute(target_cmd)
- asserts.assertEqual(self._max_cpu_number - self._min_cpu_number,
- len(results[const.STDOUT]))
- if any(results[const.EXIT_CODE]):
- logging.warn("Unable to save governors")
- logging.warn("Stderr for saving scaling_governor: %s",
- results[const.STDERR])
- return
- for cpu_no in range(self._min_cpu_number, self._max_cpu_number):
- prev_govs.append(results[const.STDOUT][cpu_no].rstrip())
- # set new governor
- target_cmd = []
- for cpu_no in range(self._min_cpu_number, self._max_cpu_number):
- target_cmd.append(
- "echo %s > /sys/devices/system/cpu/cpu%s/cpufreq/"
- "scaling_governor" % (modes[cpu_no], cpu_no))
- results = self._shell.Execute(target_cmd)
- asserts.assertEqual(self._max_cpu_number - self._min_cpu_number,
- len(results[const.STDOUT]))
- if any(results[const.EXIT_CODE]):
- logging.warn("Can't change CPU governor.")
- logging.warn("Stderr for changing scaling_governor: %s",
- results[const.STDERR])
- return
- return prev_govs
-
- def DisableCpuScaling(self):
- """Disable CPU frequency scaling on the device."""
- self.Init()
- if self._perf_override:
- logging.warn(
- "DisableCpuScaling called while scaling already disabled.")
- return
- new_govs = []
- for cpu_no in range(self._min_cpu_number, self._max_cpu_number):
- new_govs.append("performance")
- prev_govs = self.ChangeCpuGovernor(new_govs)
- if prev_govs is not None:
- self._saved_governors = prev_govs
- self._perf_override = True
-
- def EnableCpuScaling(self):
- """Enable CPU frequency scaling on the device."""
- self.Init()
- if not self._perf_override:
- logging.warn(
- "EnableCpuScaling called while scaling already enabled.")
- return
- if self._saved_governors is None:
- logging.warn(
- "EnableCpuScaling called and _saved_governors is None.")
- return
- self.ChangeCpuGovernor(self._saved_governors)
- self._perf_override = False
-
- def IsUnderThermalThrottling(self):
- """Checks whether a target device is under thermal throttling.
-
- Returns:
- True if the current CPU frequency is not the theoretical max,
- False otherwise.
- """
- self.Init()
- for cpu_no in range(self._min_cpu_number, self._max_cpu_number):
- results = self._shell.Execute([
- "cat /sys/devices/system/cpu/cpu%s/cpufreq/scaling_max_freq" %
- cpu_no,
- "cat /sys/devices/system/cpu/cpu%s/cpufreq/scaling_cur_freq" %
- cpu_no
- ])
- asserts.assertEqual(2, len(results[const.STDOUT]))
- if any(results[const.EXIT_CODE]):
- logging.warn(
- "Can't check the current and/or max CPU frequency.")
- logging.warn("Stderr for scaling_max_freq: %s",
- results[const.STDERR][0])
- logging.warn("Stderr for scaling_cur_freq: %s",
- results[const.STDERR][1])
- return False
- configurable_max_frequency = results[const.STDOUT][0].strip()
- current_frequency = results[const.STDOUT][1].strip()
- if configurable_max_frequency > current_frequency:
- logging.error(
- "CPU%s: Configurable max frequency %s > current frequency %s",
- cpu_no, configurable_max_frequency, current_frequency)
- return True
- theoretical_max_frequency = self._GetTheoreticalMaxFrequency(
- cpu_no)
- if (theoretical_max_frequency is not None
- and theoretical_max_frequency > int(current_frequency)):
- logging.error(
- "CPU%s, Theoretical max frequency %d > scaling current frequency %s",
- cpu_no, theoretical_max_frequency, current_frequency)
- return True
- return False
-
- def SkipIfThermalThrottling(self, retry_delay_secs=0):
- """Skips the current test case if a target device is under thermal throttling.
-
- Args:
- retry_delay_secs: integer, if not 0, retry after the specified seconds.
- """
- throttling = self.IsUnderThermalThrottling()
- if throttling and retry_delay_secs > 0:
- logging.info("Waiting %s seconds for the target CPU to cool down.",
- retry_delay_secs)
- time.sleep(retry_delay_secs)
- throttling = self.IsUnderThermalThrottling()
- asserts.skipIf(throttling, "Thermal throttling")
diff --git a/utils/python/file/__init__.py b/utils/python/file/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/file/__init__.py
+++ /dev/null
diff --git a/utils/python/file/target_file_utils.py b/utils/python/file/target_file_utils.py
deleted file mode 100644
index cac3036..0000000
--- a/utils/python/file/target_file_utils.py
+++ /dev/null
@@ -1,314 +0,0 @@
-#
-# Copyright 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.
-
-import logging
-from vts.runners.host import asserts
-from vts.runners.host import const
-
-_PERMISSION_GROUPS = 3 # 3 permission groups: owner, group, all users
-_READ_PERMISSION = 4
-_WRITE_PERMISSION = 2
-_EXECUTE_PERMISSION = 1
-
-
-def _Test(shell, *args):
- """Executes test command on device.
-
- Args:
- shell: an instance of the VTS shell.
- *args: strings, the command line arguments.
-
- Returns:
- boolean, whether the condition is true.
- """
- cmd = "test %s" % " ".join(args)
- results = shell.Execute(cmd)
- return results[const.EXIT_CODE][0] == 0
-
-
-def Exists(filepath, shell):
- """Determines if a file or directory exists.
-
- Args:
- filepath: string, the path to a file or a directory.
- shell: an instance of the VTS shell.
-
- Returns:
- True if exists, False otherwise.
- """
- return _Test(shell, "-e", filepath)
-
-
-def IsDirectory(path, shell):
- """Determines if a path is a directory.
-
- Args:
- path: string, a path on device.
- shell: an instance of the VTS shell.
-
- Returns:
- True if the path is a directory, False otherwise.
- """
- return _Test(shell, "-d", path)
-
-
-def FindFiles(shell, path, name_pattern, options=None):
- """Searches a path for files on device.
-
- Args:
- shell: the ShellMirrorObject.
- path: string, the path to search on device.
- name_pattern: string, the file name pattern.
- options: string, other options passed to find command.
-
- Returns:
- list of strings, the paths to the found files.
-
- Raises:
- IOError if the pattern contains quotes, or the path does not exist.
- """
- if '"' in name_pattern or "'" in name_pattern:
- raise IOError("File name pattern contains quotes")
- cmd = "find %s -name \"%s\"" % (path, name_pattern)
- if options is not None:
- cmd += " " + options
- results = shell.Execute(cmd)
- logging.debug("%s: Shell command '%s' results: %s", path, cmd, results)
-
- if results[const.EXIT_CODE][0] != 0:
- raise IOError(results[const.STDERR][0])
-
- stdout = str(results[const.STDOUT][0])
- # Filter out empty strings before return.
- return filter(None, stdout.strip().split("\n"))
-
-
-def ReadFileContent(filepath, shell):
- """Read the content of a file and perform assertions.
-
- Args:
- filepath: string, path to file
- shell: an instance of the VTS shell
-
- Returns:
- string, content of file
-
- Raises:
- IOError if the file does not exist.
- """
- cmd = "cat %s" % filepath
- results = shell.Execute(cmd)
- logging.debug("%s: Shell command '%s' results: %s", filepath, cmd, results)
-
- # checks the exit code
- if results[const.EXIT_CODE][0] != 0:
- raise IOError(results[const.STDERR][0])
-
- return results[const.STDOUT][0]
-
-
-def GetPermission(path, shell):
- """Read the file permission bits of a path.
-
- Args:
- filepath: string, path to a file or directory
- shell: an instance of the VTS shell
-
- Returns:
- String, octal permission bits for the path
-
- Raises:
- IOError if the path does not exist or has invalid permission bits.
- """
- cmd = "stat -c %%a %s" % path
- results = shell.Execute(cmd)
- logging.debug("%s: Shell command '%s' results: %s", path, cmd, results)
-
- # checks the exit code
- if results[const.EXIT_CODE][0] != 0:
- raise IOError(results[const.STDERR][0])
-
- accessBits = results[const.STDOUT][0].strip()
- if len(accessBits) != 3:
- raise IOError("%s: Wrong number of access bits (%s)" % (path,
- accessBits))
- return accessBits
-
-
-def _HasPermission(permission_bits, groupIndex, permission):
- """Determines if the permission bits grant a permission to a group.
-
- Args:
- permission_bits: string, the octal permissions string (e.g. 741)
- groupIndex: int, the index of the group into the permissions string.
- (e.g. 0 is owner group). If set to -1, then all groups are
- checked.
- permission: the value of the permission.
-
- Returns:
- True if the group(s) has read permission.
-
- Raises:
- ValueError if the group or permission bits are invalid
- """
- if groupIndex >= _PERMISSION_GROUPS:
- raise ValueError("Invalid group: %s" % str(groupIndex))
-
- if len(permission_bits) != _PERMISSION_GROUPS:
- raise ValueError("Invalid permission bits: %s" % str(permission_bits))
-
- # Define the start/end group index
- start = groupIndex
- end = groupIndex + 1
- if groupIndex < 0:
- start = 0
- end = _PERMISSION_GROUPS
-
- for i in range(start, end):
- perm = int(permission_bits[i]) # throws ValueError if not an integer
- if perm > 7:
- raise ValueError("Invalid permission bit: %s" % str(perm))
- if perm & permission == 0:
- # Return false if any group lacks the permission
- return False
- # Return true if no group lacks the permission
- return True
-
-
-def IsReadable(permission_bits):
- """Determines if the permission bits grant read permission to any group.
-
- Args:
- permission_bits: string, the octal permissions string (e.g. 741)
-
- Returns:
- True if any group has read permission.
-
- Raises:
- ValueError if the group or permission bits are invalid
- """
- return any([
- _HasPermission(permission_bits, i, _READ_PERMISSION)
- for i in range(_PERMISSION_GROUPS)
- ])
-
-
-def IsWritable(permission_bits):
- """Determines if the permission bits grant write permission to any group.
-
- Args:
- permission_bits: string, the octal permissions string (e.g. 741)
-
- Returns:
- True if any group has write permission.
-
- Raises:
- ValueError if the group or permission bits are invalid
- """
- return any([
- _HasPermission(permission_bits, i, _WRITE_PERMISSION)
- for i in range(_PERMISSION_GROUPS)
- ])
-
-
-def IsExecutable(permission_bits):
- """Determines if the permission bits grant execute permission to any group.
-
- Args:
- permission_bits: string, the octal permissions string (e.g. 741)
-
- Returns:
- True if any group has execute permission.
-
- Raises:
- ValueError if the group or permission bits are invalid
- """
- return any([
- _HasPermission(permission_bits, i, _EXECUTE_PERMISSION)
- for i in range(_PERMISSION_GROUPS)
- ])
-
-
-def IsReadOnly(permission_bits):
- """Determines if the permission bits grant read-only permission.
-
- Read-only permission is granted if some group has read access but no group
- has write access.
-
- Args:
- permission_bits: string, the octal permissions string (e.g. 741)
-
- Returns:
- True if any group has read permission, none have write.
-
- Raises:
- ValueError if the group or permission bits are invalid
- """
- return IsReadable(permission_bits) and not IsWritable(permission_bits)
-
-
-def IsWriteOnly(permission_bits):
- """Determines if the permission bits grant write-only permission.
-
- Write-only permission is granted if some group has write access but no group
- has read access.
-
- Args:
- permission_bits: string, the octal permissions string (e.g. 741)
-
- Returns:
- True if any group has write permission, none have read.
-
- Raises:
- ValueError if the group or permission bits are invalid
- """
- return IsWritable(permission_bits) and not IsReadable(permission_bits)
-
-
-def IsReadWrite(permission_bits):
- """Determines if the permission bits grant read/write permissions.
-
- Read-write permission is granted if some group has read access and some has
- write access. The groups may be different.
-
- Args:
- permission_bits: string, the octal permissions string (e.g. 741)
-
- Returns:
- True if read and write permissions are granted to any group(s).
-
- Raises:
- ValueError if the group or permission bits are invalid
- """
- return IsReadable(permission_bits) and IsWritable(permission_bits)
-
-
-def assertPermissionsAndExistence(shell, path, check_permission):
- """Asserts that the specified path exists and has the correct permission.
-
- Args:
- path: string, path to validate existence and permissions
- check_permission: function which takes unix permissions in octal
- format and returns True if the permissions are
- correct, False otherwise.
- """
- asserts.assertTrue(Exists(path, shell), "%s: File does not exist." % path)
- try:
- permission = GetPermission(path, shell)
- asserts.assertTrue(
- check_permission(permission),
- "%s: File has invalid permissions (%s)" % (path, permission))
- except (ValueError, IOError) as e:
- asserts.fail("Failed to assert permissions: %s" % str(e))
diff --git a/utils/python/fuzzer/FuzzerUtils.py b/utils/python/fuzzer/FuzzerUtils.py
deleted file mode 100644
index a15f520..0000000
--- a/utils/python/fuzzer/FuzzerUtils.py
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# 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.
-#
-
-import random
-
-def mask_uint32_t():
- shifter = random.randint(0, 31)
- return 1 << shifter
-
-
-def mask_int32_t():
- return mask_uint32_t()
-
diff --git a/utils/python/fuzzer/GenePool.py b/utils/python/fuzzer/GenePool.py
deleted file mode 100644
index 8e3034a..0000000
--- a/utils/python/fuzzer/GenePool.py
+++ /dev/null
@@ -1,104 +0,0 @@
-#
-# 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.
-#
-
-import random
-
-REPLICATION_COUNT_IF_NEW_COVERAGE_IS_SEEN = 5
-REPLICATION_PARAM_IF_NO_COVERAGE_IS_SEEN = 10
-
-
-def CreateGenePool(count, generator, fuzzer, **kwargs):
- """Creates a gene pool, a set of test input data.
-
- Args:
- count: integer, the size of the pool.
- generator: function pointer, which can generate the data.
- fuzzer: function pointer, which can mutate the data.
- **kwargs: the args to the generator function pointer.
-
- Returns:
- a list of generated data.
- """
- genes = []
- for index in range(count):
- gene = generator(**kwargs)
- genes.append(fuzzer(gene))
- return genes
-
-
-class Evolution(object):
- """Evolution class
-
- Attributes:
- _coverages_database: a list of coverage entities seen previously.
- _alpha: replication count if new coverage is seen.
- _beta: replication parameter if no coverage is seen.
- """
-
- def __init__(self, alpha=REPLICATION_COUNT_IF_NEW_COVERAGE_IS_SEEN,
- beta=REPLICATION_PARAM_IF_NO_COVERAGE_IS_SEEN):
- self._coverages_database = []
- self._alpha = alpha
- self._beta = beta
-
- def _IsNewCoverage(self, coverage, add=False):
- """Returns True iff the 'coverage' is new.
-
- Args:
- coverage: int, a coverage entity
- add: boolean, true to add coverage to the db if it's new.
-
- Returns:
- True if new, False otherwise
- """
- is_new_coverage = False
- new_coverage_entities_to_add = []
- for entity in coverage:
- if entity not in self._coverages_database:
- is_new_coverage = True
- if add:
- new_coverage_entities_to_add.append(entity)
- else:
- return True
- if add:
- self._coverages_database.extend(new_coverage_entities_to_add)
- return is_new_coverage
-
- def Evolve(self, genes, fuzzer, coverages=None):
- """Evolves a gene pool.
-
- Args:
- genes: a list of input data.
- fuzzer: function pointer, which can mutate the data.
- coverages: a list of the coverage data where coverage data is a list which
- contains IDs of the covered entities (e.g., basic blocks).
-
- Returns:
- a list of evolved data.
- """
- new_genes = []
- if not coverages:
- for gene in genes:
- # TODO: consider cross over
- new_genes.append(fuzzer(gene))
- else:
- for gene, coverage in zip(genes, coverages):
- if self._IsNewCoverage(coverage, add=True):
- for _ in range(self._alpha):
- new_genes.append(fuzzer(gene))
- elif random.randint(0, self._beta) == 1:
- new_genes.append(fuzzer(gene))
- return new_genes
diff --git a/utils/python/fuzzer/__init__.py b/utils/python/fuzzer/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/fuzzer/__init__.py
+++ /dev/null
diff --git a/utils/python/fuzzer/corpus_manager.py b/utils/python/fuzzer/corpus_manager.py
deleted file mode 100644
index a78bc02..0000000
--- a/utils/python/fuzzer/corpus_manager.py
+++ /dev/null
@@ -1,689 +0,0 @@
-#
-# Copyright (C) 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.
-#
-
-import logging
-import os
-import random
-import re
-import time
-import uuid
-
-from vts.runners.host import keys
-from vts.utils.python.gcs import gcs_api_utils
-from vts.utils.python.web import feature_utils
-"""
-Stage 1: FETCH_ONE_AND_FEED
-The stage 1 algorithm collects the corpus output generated from the fuzz test.
-Then, the algorithm chooses by random one of the generated seeds in the
-next round as input.
-
-Stage 2: FETCH_CRASH_AND_FEED
-The stage 2 algorithm classifies generated corpus output into two priorities:
-high priority and regular priority. Corpus strings created during a fuzz test
-run that revealed a crash will be given a high priority.
-On the other hand, corpus strings created during a fuzz test run that did
-not lead to a crash will be given the regular priority.
-
-Stage 3: FETCH_ALL_AND_REPEAT
-The stage 3 algorithm feeds the entire corpus body generated from the
-previous run as corpus seed input directory. This process will
-repeat {REPEAT_TIMES} times. After executing {REPEAT_TIMES},
-the scheduling algorithm will start a new session with an empty corpus seed
-and reset the counter to 0.
-"""
-FETCH_ONE_AND_FEED = 1
-FETCH_CRASH_AND_FEED = 2
-FETCH_ALL_AND_REPEAT = 3
-REPEAT_TIMES = 5
-
-SCHEDULING_ALGORITHM = FETCH_ALL_AND_REPEAT
-MEASURE_CORPUS = True
-CORPUS_STATES = [
- 'corpus_seed_high', 'corpus_seed', 'corpus_seed_low', 'corpus_inuse',
- 'corpus_complete', 'corpus_crash', 'corpus_error', 'corpus_trigger'
-]
-CORPUS_PRIORITIES = ['corpus_seed_high', 'corpus_seed', 'corpus_seed_low']
-
-
-class CorpusManager(feature_utils.Feature):
- """Manages corpus for fuzzing.
-
- Features include:
- Fetching corpus input from GCS to host.
- Uploading corpus output from host to GCS.
- Classifying corpus output into different priorities.
- Moving corpus between different states (seed, inuse, complete).
-
- Attributes:
- _TOGGLE_PARAM: String, the name of the parameter used to toggle the feature.
- _REQUIRED_PARAMS: list, the list of parameter names that are required.
- _OPTIONAL_PARAMS: list, the list of parameter names that are optional.
- _key_path: string, path to the json path.
- _bucket_name: string, name of the Google Cloud Storage bucket used.
- _gcs_api_utils: GcsApiUtils object, used to communicate with GCS.
- _gcs_path: string, path to the upper most level corpus directory in GCS.
- _device_serial: string, serial number of the current target device.
- """
-
- _TOGGLE_PARAM = keys.ConfigKeys.IKEY_ENABLE_LOG_UPLOADING
- _REQUIRED_PARAMS = [
- keys.ConfigKeys.IKEY_SERVICE_JSON_PATH,
- keys.ConfigKeys.IKEY_FUZZING_GCS_BUCKET_NAME
- ]
- _OPTIONAL_PARAMS = []
-
- def __init__(self, user_params, dut):
- """Initializes the gcs util provider.
-
- Args:
- user_params: A dictionary from parameter name (String) to parameter value.
- dut: The Android device we are testing against.
- """
- self.ParseParameters(
- toggle_param_name=self._TOGGLE_PARAM,
- required_param_names=self._REQUIRED_PARAMS,
- optional_param_names=self._OPTIONAL_PARAMS,
- user_params=user_params)
-
- if self.enabled:
- self._key_path = self.service_key_json_path
- self._bucket_name = self.fuzzing_gcs_bucket_name
- self._gcs_api_utils = gcs_api_utils.GcsApiUtils(
- self._key_path, self._bucket_name)
- self.enabled = self._gcs_api_utils.Enabled
-
- branch = dut.build_alias.split('.')[0]
- model = dut.product_type
- self._gcs_path = os.path.join('corpus', branch, model)
- self._device_serial = dut.serial
-
- def FetchCorpusSeed(self, test_name, local_temp_dir):
- """Fetches seed corpus of the corresponding test from the GCS directory.
-
- Args:
- test_name: string, name of the current fuzzing test.
- local_temp_dir: string, path to temporary directory for this test
- on the host machine.
-
- Returns:
- inuse_seed, GCS file path of the seed in use for test case
- if fetch was successful.
- None otherwise.
- """
- if self.enabled:
- logging.debug('Attempting to fetch corpus seed for %s.', test_name)
- else:
- return None
-
- if SCHEDULING_ALGORITHM == FETCH_ONE_AND_FEED:
- inuse_seed = self._FetchCorpusSeedFromPriority(
- test_name, local_temp_dir, 'corpus_seed')
- return inuse_seed
- elif SCHEDULING_ALGORITHM == FETCH_CRASH_AND_FEED:
- for CORPUS_PRIORITY in CORPUS_PRIORITIES:
- inuse_seed = self._FetchCorpusSeedFromPriority(
- test_name, local_temp_dir, CORPUS_PRIORITY)
- if inuse_seed is not None:
- return inuse_seed
- return None
- elif SCHEDULING_ALGORITHM == FETCH_ALL_AND_REPEAT:
- if self._gcs_api_utils.PrefixExists(
- self._GetDirPaths('corpus_lock', test_name)):
- logging.error('test locked. skipping.')
- return 'locked'
- else:
- self.add_lock(test_name, local_temp_dir)
- self._FetchCorpusSeedDirectory(test_name, local_temp_dir)
- return 'directory'
-
- def _FetchCorpusSeedFromPriority(self, test_name, local_temp_dir,
- CORPUS_PRIORITY):
- """Fetches 1 seed corpus from a corpus seed directory with the given priority.
-
- In GCS, moves the seed from corpus_seed directory to corpus_inuse directory.
- From GCS to host, downloads 1 corpus seed from corpus_inuse directory
- to {temp_dir}_{test_name}_corpus_seed in host machine.
-
- Args:
- test_name: string, name of the current fuzzing test.
- local_temp_dir: string, path to temporary directory for this test
- on the host machine.
- CORPUS_PRIORITY: string, priority of the given directory.
-
- Returns:
- inuse_seed, GCS file path of the seed in use for test case
- if fetch was successful.
- None otherwise.
- """
- corpus_seed_dir = self._GetDirPaths(CORPUS_PRIORITY, test_name)
- num_try = 0
- while num_try < 10:
- seed_list = self._gcs_api_utils.ListFilesWithPrefix(
- corpus_seed_dir)
-
- if len(seed_list) == 0:
- logging.info('No corpus available to fetch from %s.',
- corpus_seed_dir)
- return None
-
- target_seed = seed_list[random.randint(0, len(seed_list) - 1)]
- inuse_seed = self._GetFilePaths('corpus_inuse', test_name,
- target_seed)
- move_successful = self._gcs_api_utils.MoveFile(
- target_seed, inuse_seed, False)
-
- if move_successful:
- local_dest_folder = self._gcs_api_utils.PrepareDownloadDestination(
- corpus_seed_dir, local_temp_dir)
- dest_file_path = os.path.join(local_dest_folder,
- os.path.basename(target_seed))
- try:
- self._gcs_api_utils.DownloadFile(inuse_seed,
- dest_file_path)
- logging.info('Successfully fetched corpus seed from %s.',
- corpus_seed_dir)
- except:
- logging.error('Download failed, retrying.')
- continue
- return inuse_seed
- else:
- num_try += 1
- logging.debug('move try %d failed, retrying.', num_try)
- continue
-
- def _FetchCorpusSeedDirectory(self, test_name, local_temp_dir):
- """Fetches an entire corpus directory generated from the previous run.
-
- From GCS to host, downloads corpus seed from corpus_seed directory
- to {temp_dir}_{test_name}_corpus_seed in host machine.
-
- Args:
- test_name: string, name of the current fuzzing test.
- local_temp_dir: string, path to temporary directory for this test
- on the host machine.
-
- Returns:
- corpus_seed_dir, GCS directory of the seed directory for test case
- if fetch was successful.
- None otherwise.
- """
- corpus_seed_dir = self._GetDirPaths('corpus_seed', test_name)
- seed_count = self._gcs_api_utils.CountFiles(corpus_seed_dir)
- if seed_count == 0:
- logging.info('No corpus available to fetch from %s.',
- corpus_seed_dir)
- return None
-
- logging.info('Fetching %d corpus strings from %s', seed_count,
- corpus_seed_dir)
- local_dest_folder = self._gcs_api_utils.PrepareDownloadDestination(
- corpus_seed_dir, local_temp_dir)
- for target_seed in self._gcs_api_utils.ListFilesWithPrefix(
- corpus_seed_dir):
- dest_file_path = os.path.join(local_dest_folder,
- os.path.basename(target_seed))
- self._gcs_api_utils.DownloadFile(target_seed, dest_file_path)
- return corpus_seed_dir
-
- def UploadCorpusOutDir(self, test_name, local_temp_dir):
- """Uploads the corpus output source directory in host to GCS.
-
- First, uploads the corpus output sorce directory in host to
- its corresponding incoming directory in GCS.
- Then, calls _ClassifyPriority function to classify each of
- newly generated corpus by its priority.
- Empty directory can be handled in the case no interesting corpus
- was generated.
-
- Args:
- test_name: string, name of the current fuzzing test.
- local_temp_dir: string, path to temporary directory for this test
- on the host machine.
-
- Returns:
- True if successfully uploaded.
- False otherwise.
- """
- if self.enabled:
- logging.debug('Attempting to upload corpus output for %s.',
- test_name)
- else:
- return False
-
- local_corpus_out_dir = self._GetDirPaths('local_corpus_out', test_name,
- local_temp_dir)
- incoming_parent_dir = self._GetDirPaths('incoming_parent', test_name,
- local_temp_dir)
- if self._gcs_api_utils.UploadDir(local_corpus_out_dir,
- incoming_parent_dir):
- logging.info('Successfully uploaded corpus output to %s.',
- incoming_parent_dir)
- num_unique_corpus = self._ClassifyPriority(test_name,
- local_temp_dir)
- if MEASURE_CORPUS:
- self._UploadCorpusMeasure(test_name, local_temp_dir,
- num_unique_corpus)
- return True
- else:
- logging.error('Failed to upload corpus output for %s.', test_name)
- return False
-
- def _UploadCorpusMeasure(self, test_name, local_temp_dir,
- num_unique_corpus):
- """Uploads the corpus measurement file to GCS.
-
- Args:
- test_name: string, name of the current fuzzing test.
- local_temp_dir: string, path to temporary directory for this test
- on the host machine.
- num_unique_corpus: integer, number of unique corpus generated.
- """
- local_measure_file = os.path.join(
- local_temp_dir,
- '%s_%s.txt' % (test_name, time.strftime('%Y-%m-%d-%H%M')))
- with open(local_measure_file, 'w') as f:
- f.write(str(num_unique_corpus))
- remote_measure_file = os.path.join(
- self._GetDirPaths('corpus_measure', test_name),
- os.path.basename(local_measure_file))
- self._gcs_api_utils.UploadFile(local_measure_file, remote_measure_file)
-
- def InuseToDest(self, test_name, inuse_seed, destination):
- """Moves a corpus from corpus_inuse to destination.
-
- Destinations are as follows:
- corpus_seed directory is the directory for corpus that are ready
- to be used as input corpus seed.
- corpus_complete directory is the directory for corpus that have
- been used as an input, succeeded, and the test exited normally.
- corpus_crash directory is the directory for corpus whose mutant have
- caused a fuzz test crash.
- corpus_error directory is the directory for corpus that have
- caused an error in executing the fuzz test.
-
- Args:
- test_name: string, name of the current test.
- inuse_seed: string, path to corpus seed currently in use.
- destination: string, destination of the seed.
-
- Returns:
- True if move was successful.
- False otherwise.
- """
- if not self.enabled:
- return False
-
- if self._gcs_api_utils.FileExists(inuse_seed):
- if destination in CORPUS_STATES:
- corpus_destination = self._GetFilePaths(
- destination, test_name, inuse_seed)
- return self._gcs_api_utils.MoveFile(inuse_seed,
- corpus_destination, True)
- else:
- logging.error(
- 'destination is not one of the predefined states')
- return False
- else:
- logging.error('seed in use %s does not exist', inuse_seed)
- return False
-
- def _CorpusIsDuplicate(self, test_name, incoming_seed):
- """Checks if the newly generated corpus is a duplicate corpus.
-
- Args:
- test_name: string, name of the current test.
- incoming_seed: string, path to the incoming seed in GCS.
-
- Returns:
- True if the incoming corpus already exists in the GCS bucket.
- False otherwise.
- """
- for file_type in CORPUS_STATES:
- remote_corpus = self._GetFilePaths(file_type, test_name,
- incoming_seed)
- logging.debug(remote_corpus)
- if self._gcs_api_utils.FileExists(remote_corpus):
- logging.info('Corpus %s already exists.', remote_corpus)
- return True
- return False
-
- def _ClassifyPriority(self, test_name, local_temp_dir):
- """Calls the appropriate classification algorithm.
-
- Args:
- test_name: string, name of the current test.
- local_temp_dir: string, path to temporary directory for this
- test on the host machine.
-
- Returns:
- num_unique_corpus: integer, number of unique corpus generated.
- """
- if SCHEDULING_ALGORITHM == FETCH_ONE_AND_FEED:
- return self._ClassifyPriority1(test_name, local_temp_dir)
- elif SCHEDULING_ALGORITHM == FETCH_CRASH_AND_FEED:
- return self._ClassifyPriority2(test_name, local_temp_dir)
- elif SCHEDULING_ALGORITHM == FETCH_ALL_AND_REPEAT:
- num_unique_corpus = self._ClassifyPriority3(
- test_name, local_temp_dir)
- self.remove_lock(test_name)
- return num_unique_corpus
-
- def _ClassifyPriority1(self, test_name, local_temp_dir):
- """Classifies each of newly genereated corpus into different priorities.
-
- Uses 1 priority level: corpus_seed.
- This algorithm is a naive implementation.
-
- Args:
- test_name: string, name of the current test.
- local_temp_dir: string, path to temporary directory for this
- test on the host machine.
-
- Returns:
- num_unique_corpus: integer, number of unique corpus generated.
- """
- incoming_child_dir = self._GetDirPaths('incoming_child', test_name,
- local_temp_dir)
- num_unique_corpus = 0
- for incoming_seed in self._gcs_api_utils.ListFilesWithPrefix(
- incoming_child_dir):
- if self._CorpusIsDuplicate(test_name, incoming_seed):
- logging.info('Deleting duplicate corpus.')
- self._gcs_api_utils.DeleteFile(incoming_seed)
- continue
- num_unique_corpus += 1
- logging.info(
- 'Corpus string %s was classified as regular priority.',
- incoming_seed)
- corpus_destination = self._GetFilePaths('corpus_seed', test_name,
- incoming_seed)
- self._gcs_api_utils.MoveFile(incoming_seed, corpus_destination,
- True)
-
- return num_unique_corpus
-
- def _ClassifyPriority2(self, test_name, local_temp_dir):
- """Classifies each of newly genereated corpus into different priorities.
-
- Uses 2 priority levels: corpus_seed_high, corpus_seed.
- This algorithm uses crash occurrence as its classification criteria.
-
- Args:
- test_name: string, name of the current test.
- local_temp_dir: string, path to temporary directory for this
- test on the host machine.
-
- Returns:
- num_unique_corpus: integer, number of unique corpus generated.
- """
- triggered_corpus = os.path.join(
- self._GetDirPaths('local_corpus_trigger', test_name,
- local_temp_dir), 'crash_report')
- high_priority = os.path.exists(triggered_corpus)
- incoming_child_dir = self._GetDirPaths('incoming_child', test_name,
- local_temp_dir)
- num_unique_corpus = 0
- for incoming_seed in self._gcs_api_utils.ListFilesWithPrefix(
- incoming_child_dir):
- if self._CorpusIsDuplicate(test_name, incoming_seed):
- logging.info('Deleting duplicate corpus.')
- self._gcs_api_utils.DeleteFile(incoming_seed)
- continue
-
- num_unique_corpus += 1
- if high_priority:
- logging.info(
- 'corpus string %s was classified as high priority.',
- incoming_seed)
- corpus_destination = self._GetFilePaths(
- 'corpus_seed_high', test_name, incoming_seed)
- else:
- logging.info(
- 'corpus string %s was classified as regular priority.',
- incoming_seed)
- corpus_destination = self._GetFilePaths(
- 'corpus_seed', test_name, incoming_seed)
- self._gcs_api_utils.MoveFile(incoming_seed, corpus_destination,
- True)
-
- self._UploadTriggeredCorpus(test_name, local_temp_dir)
-
- return num_unique_corpus
-
- def _ClassifyPriority3(self, test_name, local_temp_dir):
- """Classifies the newly genereated corpus body into priorities.
-
- The stage 3 algorithm collects the corpus output generated
- from the fuzz test. Then it will perform one of the following:
-
- If we are still in the same fuzzing session:
- - Move the seed generated from the previous run (ILight_corpus_seed)
- to the corresponding (ILight_corpus_seed##) directiry.
- - Move the seed generated from the current run (incoming/)
- to the seed (ILight_corpus_seed) directory.
- If we have reached the maximum number of runs within a session,
- start a new session:
- - Move the seed generated from the previous runs of this fuzz session
- (ILight_corpus_seed, ILight_corpus_seed##)
- to the completed (ILight_corpus_completed) directory.
- - Move the seed generated from the current run (incoming/)
- to the completed (ILight_corpus_completed) directory.
-
- Args:
- test_name: string, name of the current test.
- local_temp_dir: string, path to temporary directory for this
- test on the host machine.
-
- Returns:
- num_unique_corpus: integer, number of unique corpus generated.
- """
- # check if directories seed_01, seed_02, ..., seed_{REPEAT_TIMES - 1} exist.
- for i in range(1, REPEAT_TIMES):
- last_corpus_dir = '%s_%02d' % (self._GetDirPaths(
- 'corpus_seed', test_name), i)
- if not self._gcs_api_utils.PrefixExists(last_corpus_dir):
- break
-
- num_unique_corpus = 0
- # if seed_01, ..., seed_{REPEAT_TIMES-2}
- if i < REPEAT_TIMES - 1:
- self._MoveCorpusDirectory(
- test_name, local_temp_dir, 'corpus_seed', 'corpus_seed_%02d' % i)
- num_unique_corpus = self._MoveCorpusDirectory(
- test_name, local_temp_dir, 'incoming_child', 'corpus_seed')
-
- # if seed_{REPEAT_TIMES-1}
- else:
- self._MoveCorpusDirectory(
- test_name, local_temp_dir, 'corpus_seed', 'corpus_complete', False)
- num_unique_corpus = self._MoveCorpusDirectory(
- test_name, local_temp_dir, 'incoming_child', 'corpus_complete')
-
- self._UploadTriggeredCorpus(test_name, local_temp_dir)
-
- return num_unique_corpus
-
- def _UploadTriggeredCorpus(self, test_name, local_temp_dir):
- """Uploades the corpus that tiggered crash to GCS.
-
- Args:
- test_name: string, name of the current test.
- local_temp_dir: string, path to temporary directory for this
- test on the host machine.
- """
- triggered_corpus = os.path.join(
- self._GetDirPaths('local_corpus_trigger', test_name,
- local_temp_dir), 'crash_report')
-
- if os.path.exists(triggered_corpus):
- corpus_destination = self._GetFilePaths(
- 'corpus_trigger', test_name, triggered_corpus)
- corpus_destination += str(uuid.uuid4())
- self._gcs_api_utils.UploadFile(triggered_corpus,
- corpus_destination)
-
- def _MoveCorpusDirectory(self,
- test_name,
- local_temp_dir,
- src_dir,
- dest_dir,
- strict=True):
- """Moves every corpus in the given src_dir to dest_dir.
-
- Args:
- test_name: string, name of the current test.
- local_temp_dir: string, path to temporary directory for this
- test on the host machine.
- src_dir: string, source directory of corpus strings in GCS.
- dest_dir: string, destination directory of corpus strings in GCS.
- strict: boolean, whether to use strict when calling ListFilesWithPrefix.
-
- Returns:
- num_unique_corpus: int, blah.
- """
- if strict:
- logging.info('Moving %s to %s', src_dir, dest_dir)
- else:
- logging.info('Moving %s* to %s', src_dir, dest_dir)
-
- num_unique_corpus = 0
- src_corpus_dir = self._GetDirPaths(src_dir, test_name, local_temp_dir)
- for src_corpus in self._gcs_api_utils.ListFilesWithPrefix(
- src_corpus_dir, strict=strict):
- dest_corpus = self._GetFilePaths(dest_dir, test_name, src_corpus)
- self._gcs_api_utils.MoveFile(src_corpus, dest_corpus, True)
- num_unique_corpus += 1
-
- return num_unique_corpus
-
- def add_lock(self, test_name, local_temp_dir):
- """Adds a locking mechanism to the GCS directory.
-
- Args:
- test_name: string, name of the current test.
- local_temp_dir: string, path to temporary directory for this
- test on the host machine.
- """
- if self.enabled:
- logging.info('adding a lock.')
- else:
- return None
-
- # write empty file /tmp/tmpV1oPTp/HT7BF1A01613
- local_lock_file = os.path.join(local_temp_dir, self._device_serial)
- open(local_lock_file, 'a').close()
- # move to corpus/PPR1/walleye/ILight/ILight_corpus_lock/HT7BF1A01613
- self._gcs_api_utils.UploadFile(
- local_lock_file, self._GetFilePaths('corpus_lock', test_name))
-
- def remove_lock(self, test_name):
- """Removes locking mechanism from the GCS directory.
-
- Args:
- test_name: string, name of the current test.
- """
- if self.enabled:
- logging.info('removing a lock.')
- else:
- return None
-
- # delete corpus/PPR1/walleye/ILight/ILight_corpus_lock/HT7BF1A01613
- self._gcs_api_utils.DeleteFile(
- self._GetFilePaths('corpus_lock', test_name))
-
- def _GetDirPaths(self, dir_type, test_name, local_temp_dir=None):
- """Generates the required directory path name for the given information.
-
- Args:
- dir_type: string, type of the directory requested.
- test_name: string, name of the current test.
- local_temp_dir: string, path to temporary directory for this
- test on the host machine.
-
- Returns:
- dir_path, generated directory path if dir_type supported.
- Empty string if dir_type not supported.
- """
- dir_path = ''
-
- # ex: corpus/[build tag]/[device]/ILight/ILight_corpus_seed
- if dir_type in CORPUS_STATES:
- dir_path = os.path.join(self._gcs_path, test_name,
- '%s_%s' % (test_name, dir_type))
- # ex: corpus/[build tag]/[device]/ILight/ILight_corpus_seed_01
- elif re.match('corpus_seed_[0-9][0-9]$', dir_type):
- dir_path = os.path.join(self._gcs_path, test_name,
- '%s_%s' % (test_name, dir_type))
- # ex: corpus/[build tag]/[device]/ILight/ILight_corpus_measure
- elif dir_type == 'corpus_measure':
- dir_path = os.path.join(self._gcs_path, test_name,
- '%s_%s' % (test_name, dir_type))
- # ex: corpus/[build tag]/[device]/ILight/ILight_corpus_lock
- elif dir_type == 'corpus_lock':
- dir_path = os.path.join(self._gcs_path, test_name,
- '%s_%s' % (test_name, dir_type))
- # ex: corpus/[build tag]/[device]/ILight/incoming/tmpV1oPTp
- elif dir_type == 'incoming_parent':
- dir_path = os.path.join(self._gcs_path, test_name, 'incoming',
- os.path.basename(local_temp_dir))
- # ex: corpus/[build tag]/[device]/ILight/incoming/tmpV1oPTp/ILight_corpus_out
- elif dir_type == 'incoming_child':
- dir_path = os.path.join(self._gcs_path, test_name, 'incoming',
- os.path.basename(local_temp_dir),
- '%s_corpus_out' % test_name)
- # ex: /tmp/tmpV1oPTp/ILight_corpus_out
- elif dir_type == 'local_corpus_out':
- dir_path = os.path.join(local_temp_dir,
- '%s_corpus_out' % test_name)
- # ex: /tmp/tmpV1oPTp/ILight_corpus_trigger
- elif dir_type == 'local_corpus_trigger':
- dir_path = os.path.join(local_temp_dir,
- '%s_corpus_trigger' % test_name)
-
- return dir_path
-
- def _GetFilePaths(self, file_type, test_name, seed=None):
- """Generates the required file path name for the given information.
-
- Args:
- file_type: string, type of the file requested.
- test_name: string, name of the current test.
- seed: string, seed to base new file path name upon.
-
- Returns:
- file_path, generated file path if file_type supported.
- Empty string if file_type not supported.
- """
- # ex: corpus/[build tag]/[device]/ILight/ILight_corpus_seed/20f5d9b8cd53881c9ff0205c9fdc5d283dc9fc68
- if file_type in CORPUS_STATES:
- file_path = os.path.join(
- self._GetDirPaths(file_type, test_name),
- os.path.basename(seed))
- return file_path
- # ex: corpus/[build tag]/[device]/ILight/ILight_corpus_seed_01/20f5d9b8cd53881c9ff0205c9fdc5d283dc9fc68
- elif re.match('corpus_seed_[0-9][0-9]$', file_type):
- file_path = os.path.join(
- self._GetDirPaths(file_type, test_name),
- os.path.basename(seed))
- return file_path
- # ex: corpus/[build tag]/[device]/ILight/ILight_corpus_lock/HT7BF1A01613
- elif file_type == 'corpus_lock':
- file_path = os.path.join(
- self._GetDirPaths(file_type, test_name), self._device_serial)
- return file_path
- else:
- logging.error('invalid file_type argument entered.')
- return ''
diff --git a/utils/python/fuzzer/corpus_manager_test.py b/utils/python/fuzzer/corpus_manager_test.py
deleted file mode 100644
index 5ab38b8..0000000
--- a/utils/python/fuzzer/corpus_manager_test.py
+++ /dev/null
@@ -1,335 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 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.
-
-import mock
-import os
-import unittest
-
-from vts.utils.python.fuzzer import corpus_manager
-
-dut = mock.Mock()
-dut.build_alias = 'Pie.118.wj12e'
-dut.product_type = 'Pixel3_XL'
-dut.serial = 'HT1178BBZWQ'
-
-
-class CorpusManagerTest(unittest.TestCase):
- """Unit tests for corpus_manager module."""
-
- def SetUp(self):
- """Setup tasks."""
- self.category = "category_default"
- self.name = "name_default"
-
- def testInitializationDisabled(self):
- """Tests the disabled initilization of a CorpusManager object."""
- _corpus_manager = corpus_manager.CorpusManager({}, dut)
- self.assertEqual(_corpus_manager.enabled, False)
-
- def testInitializationEnabled(self):
- """Tests the enabled initilization of a CorpusManager object.
-
- If we initially begin with enabled=True, it will automatically
- attempt to connect GCS API.
- """
- _corpus_manager = corpus_manager.CorpusManager({}, dut)
- _corpus_manager.enabled = True
- self.assertEqual(_corpus_manager.enabled, True)
- self.assertEqual(_corpus_manager._gcs_path, 'corpus/Pie/Pixel3_XL')
- self.assertEqual(_corpus_manager._device_serial, 'HT1178BBZWQ')
-
- def testFetchCorpusSeedEmpty_STAGE_1(self):
- """Tests the FetchCorpusSeed function of a CorpusManager object.
-
- This is tested with an empty seed directory for stage 1 algorithm.
- """
- corpus_manager.SCHEDULING_ALGORITHM = 1
- _corpus_manager = corpus_manager.CorpusManager({}, dut)
- _corpus_manager.enabled = True
- _corpus_manager._gcs_api_utils = mock.MagicMock()
- _corpus_manager._FetchCorpusSeedFromPriority = mock.MagicMock()
- _corpus_manager.FetchCorpusSeed('ILight', '/tmp/tmpDir1')
- _corpus_manager._FetchCorpusSeedFromPriority.assert_called_with(
- 'ILight', '/tmp/tmpDir1', 'corpus_seed')
-
- def testFetchCorpusSeedEmpty_STAGE_2(self):
- """Tests the FetchCorpusSeed function of a CorpusManager object.
-
- This is tested with an empty seed directory for stage 2 algorithm.
- """
- corpus_manager.SCHEDULING_ALGORITHM = 2
- _corpus_manager = corpus_manager.CorpusManager({}, dut)
- _corpus_manager.enabled = True
- _corpus_manager._gcs_api_utils = mock.MagicMock()
- _corpus_manager._gcs_api_utils.ListFilesWithPrefix.return_value = []
- _corpus_manager.FetchCorpusSeed('ILight', '/tmp/tmpDir1')
- self.assertEquals(
- _corpus_manager._gcs_api_utils.ListFilesWithPrefix.call_count, 3)
-
- def testFetchCorpusSeedEmpty_STAGE_3_LOCKED(self):
- """Tests the FetchCorpusSeed function of a CorpusManager object.
-
- This is tested with an empty seed directory for stage 3 algorithm.
- """
- corpus_manager.SCHEDULING_ALGORITHM = 3
- _corpus_manager = corpus_manager.CorpusManager({}, dut)
- _corpus_manager.enabled = True
- _corpus_manager._gcs_api_utils = mock.MagicMock()
- _corpus_manager._gcs_api_utils.PrefixExists_return_value = True
- _corpus_manager._gcs_api_utils.ListFilesWithPrefix.return_value = []
- res = _corpus_manager.FetchCorpusSeed('ILight', '/tmp/tmpDir1')
- self.assertEquals(res, 'locked')
-
- def testFetchCorpusSeedEmpty_STAGE_3_NOT_LOCKED(self):
- """Tests the FetchCorpusSeed function of a CorpusManager object.
-
- This is tested with an empty seed directory for stage 3 algorithm.
- """
- corpus_manager.SCHEDULING_ALGORITHM = 3
- _corpus_manager = corpus_manager.CorpusManager({}, dut)
- _corpus_manager.enabled = True
- _corpus_manager._gcs_api_utils = mock.MagicMock()
- _corpus_manager._gcs_api_utils.PrefixExists.return_value = False
- _corpus_manager._gcs_api_utils.ContFiles.return_value = 0
- _corpus_manager.add_lock = mock.MagicMock()
- _corpus_manager._FetchCorpusSeedDirectory = mock.MagicMock()
- res = _corpus_manager.FetchCorpusSeed('ILight', '/tmp/tmpDir1')
- self.assertEquals(res, 'directory')
-
- def testFetchCorpusSeedValid_STAGE_1(self):
- """Tests the FetchCorpusSeed function of a CorpusManager object.
-
- This is tested with a valid seed directory for stage 1 algorithm.
- """
- corpus_manager.SCHEDULING_ALGORITHM = 1
- _corpus_manager = corpus_manager.CorpusManager({}, dut)
- _corpus_manager.enabled = True
- _corpus_manager._gcs_api_utils = mock.MagicMock()
- _corpus_manager._gcs_api_utils.ListFilesWithPrefix.return_value = [
- 'dir/file1', 'dir/file2', 'dir/file3', 'dir/file4', 'dir/file5'
- ]
- _corpus_manager._gcs_api_utils.MoveFile.return_value = True
- _corpus_manager.FetchCorpusSeed('ILight', '/tmp/tmpDir1')
- _corpus_manager._gcs_api_utils.ListFilesWithPrefix.assert_called_with(
- 'corpus/Pie/Pixel3_XL/ILight/ILight_corpus_seed')
- _corpus_manager._gcs_api_utils.MoveFile.assert_called()
- _corpus_manager._gcs_api_utils.PrepareDownloadDestination.assert_called(
- )
- _corpus_manager._gcs_api_utils.DownloadFile.assert_called()
-
- def testFetchCorpusSeedValid_STAGE_2(self):
- """Tests the FetchCorpusSeed function of a CorpusManager object.
-
- This is tested with a valid seed directory for stage 2 algorithm.
- """
- corpus_manager.SCHEDULING_ALGORITHM = 2
- _corpus_manager = corpus_manager.CorpusManager({}, dut)
- _corpus_manager.enabled = True
- _corpus_manager._gcs_api_utils = mock.MagicMock()
- _corpus_manager._gcs_api_utils.ListFilesWithPrefix.return_value = [
- 'dir/file1', 'dir/file2', 'dir/file3', 'dir/file4', 'dir/file5'
- ]
- _corpus_manager._gcs_api_utils.MoveFile.return_value = True
- _corpus_manager.FetchCorpusSeed('ILight', '/tmp/tmpDir1')
- _corpus_manager._gcs_api_utils.ListFilesWithPrefix.assert_called_with(
- 'corpus/Pie/Pixel3_XL/ILight/ILight_corpus_seed_high')
- _corpus_manager._gcs_api_utils.MoveFile.assert_called()
- _corpus_manager._gcs_api_utils.PrepareDownloadDestination.assert_called(
- )
- _corpus_manager._gcs_api_utils.DownloadFile.assert_called()
-
- def testFetchCorpusSeedValid_STAGE_3(self):
- """Tests the FetchCorpusSeed function of a CorpusManager object.
-
- This is tested with a valid seed directory for stage 3 algorithm.
- """
- corpus_manager.SCHEDULING_ALGORITHM = 3
- _corpus_manager = corpus_manager.CorpusManager({}, dut)
- _corpus_manager.enabled = True
- _corpus_manager._gcs_api_utils = mock.MagicMock()
- _corpus_manager._gcs_api_utils.ListFilesWithPrefix.return_value = [
- 'dir/file1', 'dir/file2', 'dir/file3', 'dir/file4', 'dir/file5'
- ]
- _corpus_manager._gcs_api_utils.PrefixExists.return_value = False
- _corpus_manager.add_lock = mock.MagicMock()
- res = _corpus_manager.FetchCorpusSeed('ILight', '/tmp/tmpDir1')
- self.assertEquals(res, 'directory')
- _corpus_manager._gcs_api_utils.PrepareDownloadDestination.assert_called(
- )
- _corpus_manager._gcs_api_utils.ListFilesWithPrefix.assert_called_with(
- 'corpus/Pie/Pixel3_XL/ILight/ILight_corpus_seed')
- _corpus_manager._gcs_api_utils.DownloadFile.assert_called()
-
- def testUploadCorpusOutDir(self):
- """Tests the UploadCorpusOutDir function of a CorpusManager object."""
- corpus_manager.MEASURE_CORPUS = False
- _corpus_manager = corpus_manager.CorpusManager({}, dut)
- _corpus_manager.enabled = True
- _corpus_manager._gcs_api_utils = mock.MagicMock()
- _corpus_manager._gcs_api_utils.UploadDir.return_value = True
- _corpus_manager._ClassifyPriority = mock.MagicMock()
- _corpus_manager.UploadCorpusOutDir('ILight', '/tmp/tmpDir1')
- _corpus_manager._gcs_api_utils.UploadDir.assert_called_with(
- '/tmp/tmpDir1/ILight_corpus_out',
- 'corpus/Pie/Pixel3_XL/ILight/incoming/tmpDir1')
- _corpus_manager._ClassifyPriority.assert_called_with(
- 'ILight', '/tmp/tmpDir1')
-
- def testInuseToDestSeed(self):
- """Tests the InuseToDest function of a CorpusManager object."""
- _corpus_manager = corpus_manager.CorpusManager({}, dut)
- _corpus_manager.enabled = True
- _corpus_manager._gcs_api_utils = mock.MagicMock()
-
- _corpus_manager.InuseToDest(
- 'ILight',
- 'corpus/Pie/Pixel3_XL/ILight/ILight_corpus_inuse/corpus_number_1',
- 'corpus_seed')
- _corpus_manager._gcs_api_utils.MoveFile.assert_called_with(
- 'corpus/Pie/Pixel3_XL/ILight/ILight_corpus_inuse/corpus_number_1',
- 'corpus/Pie/Pixel3_XL/ILight/ILight_corpus_seed/corpus_number_1',
- True)
-
- _corpus_manager.InuseToDest(
- 'ILight',
- 'corpus/Pie/Pixel3_XL/ILight/ILight_corpus_inuse/corpus_number_1',
- 'corpus_complete')
- _corpus_manager._gcs_api_utils.MoveFile.assert_called_with(
- 'corpus/Pie/Pixel3_XL/ILight/ILight_corpus_inuse/corpus_number_1',
- 'corpus/Pie/Pixel3_XL/ILight/ILight_corpus_complete/corpus_number_1',
- True)
-
- _corpus_manager.InuseToDest(
- 'ILight',
- 'corpus/Pie/Pixel3_XL/ILight/ILight_corpus_inuse/corpus_number_1',
- 'corpus_crash')
- _corpus_manager._gcs_api_utils.MoveFile.assert_called_with(
- 'corpus/Pie/Pixel3_XL/ILight/ILight_corpus_inuse/corpus_number_1',
- 'corpus/Pie/Pixel3_XL/ILight/ILight_corpus_crash/corpus_number_1',
- True)
-
- def test_ClassifyPriority1(self):
- """Tests the _ClassifyPriority1 function of a CorpusManager object."""
- corpus_manager.SCHEDULING_ALGORITHM = 1
- _corpus_manager = corpus_manager.CorpusManager({}, dut)
- _corpus_manager.enabled = True
- _corpus_manager._gcs_api_utils = mock.MagicMock()
- _corpus_manager._gcs_api_utils.ListFilesWithPrefix.return_value = [
- 'dir/file1', 'dir/file2', 'dir/file3', 'dir/file4', 'dir/file5'
- ]
- _corpus_manager._CorpusIsDuplicate = mock.MagicMock()
- _corpus_manager._CorpusIsDuplicate.return_value = False
- _corpus_manager._ClassifyPriority1('ILight', '/tmp/tmpDir1')
- _corpus_manager._gcs_api_utils.ListFilesWithPrefix.assert_called_with(
- 'corpus/Pie/Pixel3_XL/ILight/incoming/tmpDir1/ILight_corpus_out')
- self.assertEquals(_corpus_manager._gcs_api_utils.MoveFile.call_count,
- 5)
-
- def test_ClassifyPriority2(self):
- """Tests the _ClassifyPriority2 function of a CorpusManager object."""
- corpus_manager.SCHEDULING_ALGORITHM = 2
- corpus_manager.os.path.exists = mock.MagicMock()
- corpus_manager.os.path.exists.return_value = True
- _corpus_manager = corpus_manager.CorpusManager({}, dut)
- _corpus_manager.enabled = True
- _corpus_manager._gcs_api_utils = mock.MagicMock()
- _corpus_manager._gcs_api_utils.ListFilesWithPrefix.return_value = [
- 'dir/file1', 'dir/file2', 'dir/file3', 'dir/file4', 'dir/file5'
- ]
- _corpus_manager._CorpusIsDuplicate = mock.MagicMock()
- _corpus_manager._CorpusIsDuplicate.return_value = False
- _corpus_manager._ClassifyPriority2('ILight', '/tmp/tmpDir1')
- _corpus_manager._gcs_api_utils.ListFilesWithPrefix.assert_called_with(
- 'corpus/Pie/Pixel3_XL/ILight/incoming/tmpDir1/ILight_corpus_out')
- self.assertEquals(_corpus_manager._gcs_api_utils.MoveFile.call_count,
- 5)
-
- def test_ClassifyPriority3(self):
- """Tests the _ClassifyPriority3 function of a CorpusManager object."""
- corpus_manager.SCHEDULING_ALGORITHM = 3
- corpus_manager.REPEAT_TIMES = 5
- corpus_manager.os.path.exists = mock.MagicMock()
- corpus_manager.os.path.exists.return_value = True
- _corpus_manager = corpus_manager.CorpusManager({}, dut)
- _corpus_manager.enabled = True
- _corpus_manager._gcs_api_utils = mock.MagicMock()
- _corpus_manager._gcs_api_utils.ListFilesWithPrefix.return_value = [
- 'dir/file1', 'dir/file2', 'dir/file3', 'dir/file4', 'dir/file5'
- ]
- _corpus_manager._gcs_api_utils.PrefixExists.return_value = True
- _corpus_manager._MoveCorpusDirectory = mock.MagicMock()
- _corpus_manager._ClassifyPriority3('ILight', '/tmp/tmpDir1')
- self.assertEquals(_corpus_manager._MoveCorpusDirectory.call_count, 2)
- _corpus_manager._MoveCorpusDirectory.assert_called_with(
- 'ILight', '/tmp/tmpDir1', 'incoming_child', 'corpus_complete')
-
- def test_MoveCorpusDirectory(self):
- """Tests the _MoveCorpusDirectory function of a CorpusManager object."""
- _corpus_manager = corpus_manager.CorpusManager({}, dut)
- _corpus_manager.enabled = True
- _corpus_manager._gcs_api_utils = mock.MagicMock()
- _corpus_manager._gcs_api_utils.ListFilesWithPrefix.return_value = [
- 'dir/file1', 'dir/file2', 'dir/file3', 'dir/file4', 'dir/file5'
- ]
- _corpus_manager._MoveCorpusDirectory('ILight', '/tmp/tmpDir1',
- 'corpus_seed', 'corpus_complete')
- _corpus_manager._gcs_api_utils.ListFilesWithPrefix.assert_called_with(
- 'corpus/Pie/Pixel3_XL/ILight/ILight_corpus_seed', strict=True)
- self.assertEquals(_corpus_manager._gcs_api_utils.MoveFile.call_count,
- 5)
-
- def test_GetDirPaths(self):
- """Tests the _GetDirPaths function of a CorpusManager object."""
- _corpus_manager = corpus_manager.CorpusManager({}, dut)
- self.assertEqual(
- _corpus_manager._GetDirPaths('corpus_seed', 'ILight'),
- 'corpus/Pie/Pixel3_XL/ILight/ILight_corpus_seed')
- self.assertEqual(
- _corpus_manager._GetDirPaths('incoming_parent', 'ILight',
- '/tmp/tmpDir1'),
- 'corpus/Pie/Pixel3_XL/ILight/incoming/tmpDir1')
- self.assertEqual(
- _corpus_manager._GetDirPaths('incoming_child', 'ILight',
- '/tmp/tmpDir1'),
- 'corpus/Pie/Pixel3_XL/ILight/incoming/tmpDir1/ILight_corpus_out')
- self.assertEqual(
- _corpus_manager._GetDirPaths('corpus_seed', 'ILight'),
- 'corpus/Pie/Pixel3_XL/ILight/ILight_corpus_seed')
-
- def test_GetFilePaths(self):
- """Tests the _GetFilePaths function of a CorpusManager object."""
- _corpus_manager = corpus_manager.CorpusManager({}, dut)
- self.assertEqual(
- _corpus_manager._GetFilePaths('corpus_seed', 'ILight',
- 'some_dir/corpus_number_1'),
- 'corpus/Pie/Pixel3_XL/ILight/ILight_corpus_seed/corpus_number_1')
- self.assertEqual(
- _corpus_manager._GetFilePaths('corpus_inuse', 'ILight',
- 'some_dir/corpus_number_1'),
- 'corpus/Pie/Pixel3_XL/ILight/ILight_corpus_inuse/corpus_number_1')
- self.assertEqual(
- _corpus_manager._GetFilePaths('corpus_complete', 'ILight',
- 'somedir/corpus_number_1'),
- 'corpus/Pie/Pixel3_XL/ILight/ILight_corpus_complete/corpus_number_1'
- )
- self.assertEqual(
- _corpus_manager._GetFilePaths('corpus_crash', 'ILight',
- 'somedir/corpus_number_1'),
- 'corpus/Pie/Pixel3_XL/ILight/ILight_corpus_crash/corpus_number_1')
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/utils/python/gcs/__init__.py b/utils/python/gcs/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/gcs/__init__.py
+++ /dev/null
diff --git a/utils/python/gcs/gcs_api_utils.py b/utils/python/gcs/gcs_api_utils.py
deleted file mode 100644
index 7834c22..0000000
--- a/utils/python/gcs/gcs_api_utils.py
+++ /dev/null
@@ -1,340 +0,0 @@
-#
-# Copyright (C) 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.
-#
-
-import google.auth
-import logging
-import os
-
-from google.cloud import exceptions
-from google.cloud import storage
-
-# OS environment variable name for google application credentials.
-_GOOGLE_CRED_ENV_VAR = 'GOOGLE_APPLICATION_CREDENTIALS'
-# URL to the Google Cloud storage authentication.
-_READ_WRITE_SCOPE_URL = 'https://www.googleapis.com/auth/devstorage.read_write'
-
-
-class GcsApiUtils(object):
- """GCS (Google Cloud Storage) API utility provider.
-
- Attributes:
- _key_path: string, path to the JSON key file of the service account.
- _bucket_name: string, Google Cloud Storage bucket name.
- _credentials: credentials object for the service account.
- _project: string, Google Cloud project name of the service account.
- _enabled: boolean, whether this GcsApiUtils object is enabled.
- """
-
- def __init__(self, key_path, bucket_name):
- self._key_path = key_path
- self._bucket_name = bucket_name
- os.environ[_GOOGLE_CRED_ENV_VAR] = key_path
- self._enabled = True
- try:
- self._credentials, self._project = google.auth.default()
- if self._credentials.requires_scopes:
- self._credentials = self._credentials.with_scopes(
- [_READ_WRITE_SCOPE_URL])
- except google.auth.exceptions.DefaultCredentialsError as e:
- logging.exception(e)
- self._enabled = False
-
- @property
- def Enabled(self):
- """Gets private variable _enabled.
-
- Returns:
- self._enabled: boolean, whether this GcsApiUtils object is enabled.
- """
- return self._enabled
-
- @Enabled.setter
- def Enabled(self, enabled):
- """Sets private variable _enabled."""
- self._enabled = enabled
-
- def ListFilesWithPrefix(self, dir_path, strict=True):
- """Returns a list of files under a given GCS prefix.
-
- GCS uses prefixes to resemble the concept of directories.
-
- For instance, if we have a directory called 'corpus,'
- then we have a file named corpus.
-
- Then we can have files like 'corpus/ILight/ILight_corpus_seed/132,'
- which may appear that the file named '132' is inside the directory
- ILight_corpus_seed, whose parent directory is ILight, whose parent
- directory is corpus.
-
- However, we only have 1 explicit file that resembles a directory
- role here: 'corpus.' We do not have directories 'corpus/ILight' or
- 'corpus/ILight/ILight_corpus.'
-
- Here, we have only 2 files:
- 'corpus/'
- 'corpus/ILight/ILight_corpus_seed/132'
-
- Given the two prefixes (directories),
- corpus/ILight/ILight_corpus_seed
- corpus/ILight/ILight_corpus_seed_01
-
- ListFilesWithPrefix(corpus/ILight/ILight_corpus_seed, strict=True)
- will only list files in corpus/ILight/ILight_corpus_seed,
- not in corpus/ILight/ILight_corpus_seed_01.
-
- ListFilesWithPrefix(corpus/ILight/ILight_corpus_seed, strict=False)
- will list files in both corpus/ILight/ILight_corpus_seed,
- and corpus/ILight/ILight_corpus_seed_01.
-
- Args:
- dir_path: path to the GCS directory of interest.
-
- Returns:
- a list of absolute path filenames of the content of the given GCS directory.
- """
- if not self._enabled:
- logging.error('This GcsApiUtils object is not enabled.')
- return []
-
- if strict and not dir_path.endswith('/'):
- dir_path += '/'
- client = storage.Client(credentials=self._credentials)
- bucket = client.get_bucket(self._bucket_name)
- dir_list = list(bucket.list_blobs(prefix=dir_path))
- return [file.name for file in dir_list]
-
- def CountFiles(self, dir_path):
- """Counts the number of files under a given GCS prefix.
-
- Args:
- dir_path: path to the GCS prefix of interest.
-
- Returns:
- number of files, if files exist under the prefix.
- 0, if prefix doesnt exist.
- """
- if not self._enabled:
- logging.error('This GcsApiUtils object is not enabled.')
- return 0
-
- return len(self.ListFilesWithPrefix(dir_path))
-
- def PrefixExists(self, dir_path):
- """Checks if a file containing the prefix exists in the GCS bucket.
-
- This is effectively "counting" the number of files
- inside the directory. Depending on whether the prefix/directory
- file exist or not, this function may return the number of files
- in the diretory or the number + 1 (the prefix/directory file).
-
- Returns:
- True, if such prefix exists in the GCS bucket.
- False, otherwise.
- """
- if not self._enabled:
- logging.error('This GcsApiUtils object is not enabled.')
- return False
-
- return self.CountFiles(dir_path) is not 0
-
- def FileExists(self, file_path):
- """Checks if a file exists in the GCS bucket.
-
- Returns:
- True, if the specific file exists in the GCS bucket.
- False, otherwise.
- """
- if not self._enabled:
- logging.error('This GcsApiUtils object is not enabled.')
- return False
-
- client = storage.Client(credentials=self._credentials)
- bucket = client.get_bucket(self._bucket_name)
- blob = bucket.blob(file_path)
- return blob.exists()
-
- def DownloadFile(self, src_file_path, dest_file_path):
- """Downloads a file to a local destination directory.
-
- Args:
- src_file_path: source file path, directory/filename in GCS.
- dest_file_path: destination file path, directory/filename in local.
-
- Raises:
- exception when the source file does not exist in GCS.
- """
- if not self._enabled:
- logging.error('This GcsApiUtils object is not enabled.')
- return
-
- client = storage.Client(credentials=self._credentials)
- bucket = client.get_bucket(self._bucket_name)
- blob = bucket.blob(src_file_path)
- blob.download_to_filename(dest_file_path)
- logging.info('File %s downloaded to %s.', src_file_path,
- dest_file_path)
-
- def PrepareDownloadDestination(self, src_dir, dest_dir):
- """Makes prerequisite directories in the local destination.
-
- Args:
- src_dir: source directory, in GCS.
- dest_dir: destination directory, in local.
-
- Returns:
- local_dest_folder, path to the local folder created (or had already existed).
- """
- if not self._enabled:
- logging.error('This GcsApiUtils object is not enabled.')
- return
-
- local_dest_folder = os.path.join(dest_dir, os.path.basename(src_dir))
- if not os.path.exists(local_dest_folder):
- os.makedirs(local_dest_folder)
- return local_dest_folder
-
- def DownloadDir(self, src_dir, dest_dir):
- """Downloads a GCS src directory to a local dest dir.
-
- Args:
- src_dir: source directory, directory in GCS.
- dest_dir: destination directory, directory in local.
-
- Raises:
- exception when a source file does not exist in GCS.
-
- Returns:
- True, if the source directory exists and files successfully downloaded.
- False, if the source directory does not exist.
- """
- if not self._enabled:
- logging.error('This GcsApiUtils object is not enabled.')
- return False
-
- if self.PrefixExists(src_dir):
- logging.info('successfully found the GCS directory.')
- self.PrepareDownloadDestination(src_dir, dest_dir)
- filelist = self.ListFilesWithPrefix(src_dir)
- for src_file_path in filelist:
- dest_file_path = os.path.join(
- dest_dir,
- os.path.join(
- os.path.basename(src_dir),
- os.path.basename(src_file_path)))
- try:
- self.DownloadFile(src_file_path, dest_file_path)
- except exceptions.NotFound as e:
- logging.error('download failed for file: %s',
- src_file_path)
- return True
- else:
- logging.error('requested GCS directory does not exist.')
- return False
-
- def UploadFile(self, src_file_path, dest_file_path):
- """Uploads a file to a GCS bucket.
-
- Args:
- src_file_path: source file path, directory/filename in local.
- dest_file_path: destination file path, directory/filename in GCS.
- """
- if not self._enabled:
- logging.error('This GcsApiUtils object is not enabled.')
- return
-
- client = storage.Client(credentials=self._credentials)
- bucket = client.get_bucket(self._bucket_name)
- blob = bucket.blob(dest_file_path)
- blob.upload_from_filename(src_file_path)
- logging.info('File %s uploaded to %s.', src_file_path, dest_file_path)
-
- def UploadDir(self, src_dir, dest_dir):
- """Uploads a local src dir to a GCS dest dir.
-
- Args:
- src_dir: source directory, directory in local.
- dest_dir: destination directory, directory in GCS.
-
- Returns:
- True, if the source directory exists and files successfully uploaded.
- False, if the source directory does not exist.
- """
- if not self._enabled:
- logging.error('This GcsApiUtils object is not enabled.')
- return False
-
- if os.path.exists(src_dir):
- logging.info('successfully found the local directory.')
- src_basedir = os.path.basename(src_dir)
- for dirpath, _, filenames in os.walk(src_dir):
- for filename in filenames:
- src_file_path = os.path.join(dirpath, filename)
- dest_file_path = os.path.join(
- dest_dir, src_file_path.replace(src_dir, src_basedir))
- self.UploadFile(src_file_path, dest_file_path)
- return True
- else:
- logging.error('requested local directory does not exist.')
- return False
-
- def MoveFile(self, src_file_path, dest_file_path, log_error=True):
- """Renames a blob, which effectively changes its path.
-
- Args:
- src_file_path: source file path in GCS.
- dest_dest_path: destination file path in GCS.
-
- Returns:
- True if susccessful, False otherwise.
- """
- if not self._enabled:
- logging.error('This GcsApiUtils object is not enabled.')
- return False
-
- client = storage.Client(credentials=self._credentials)
- bucket = client.get_bucket(self._bucket_name)
- blob = bucket.blob(src_file_path)
- try:
- new_blob = bucket.rename_blob(blob, dest_file_path)
- except exceptions.NotFound as e:
- if log_error:
- logging.exception('file move was unsuccessful with error %s.',
- e)
- return False
- return True
-
- def DeleteFile(self, file_path):
- """Deletes a blob, which effectively deletes its corresponding file.
-
- Args:
- file_path: string, path to the file to remove.
-
- Returns:
- True if successful, False otherwise.
- """
- if not self._enabled:
- logging.error('This GcsApiUtils object is not enabled.')
- return False
-
- client = storage.Client(credentials=self._credentials)
- bucket = client.get_bucket(self._bucket_name)
- blob = bucket.blob(file_path)
- try:
- blob.delete()
- except exceptions.NotFound as e:
- logging.exception('file delete was unsuccessful with error %s.', e)
- return False
- return True
diff --git a/utils/python/gcs/gcs_api_utils_test.py b/utils/python/gcs/gcs_api_utils_test.py
deleted file mode 100644
index 334a605..0000000
--- a/utils/python/gcs/gcs_api_utils_test.py
+++ /dev/null
@@ -1,168 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 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.
-#
-
-import os
-import unittest
-
-try:
- from unittest import mock
-except ImportError:
- # TODO: Remove when we stop supporting Python 2
- import mock
-
-from google.auth import exceptions as auth_exceptions
-
-from vts.utils.python.gcs import gcs_api_utils
-
-
-def simple_ListFilesWithPrefix(dir_path):
- return [
- '%s/file1' % dir_path,
- '%s/file2' % dir_path,
- '%s/file3' % dir_path,
- '%s/file4' % dir_path
- ]
-
-
-def simple_DownloadFile(src_file_path, dest_file_path):
- return None
-
-
-def simple_UploadFile(src_file_path, dest_file_path):
- return None
-
-
-def simple_PrefixExists(dir_path):
- if dir_path is 'valid_source_dir':
- return True
- else:
- return False
-
-
-def simple_os_path_exists(path):
- return True
-
-
-def simple__init__(key_path, bucket_name):
- return None
-
-
-def simple_PrepareDownloadDestination(src_dir, dest_dir):
- return os.path.join(dest_dir, os.path.basename(src_dir))
-
-
-class GcsApiUtilsTest(unittest.TestCase):
- """Unit tests for gcs_utils module."""
-
- def SetUp(self):
- """Setup tasks."""
- self.category = "category_default"
- self.name = "name_default"
-
- @mock.patch(
- 'vts.utils.python.gcs.gcs_api_utils.GcsApiUtils.ListFilesWithPrefix',
- side_effect=simple_ListFilesWithPrefix)
- @mock.patch(
- 'vts.utils.python.gcs.gcs_api_utils.GcsApiUtils.__init__',
- side_effect=simple__init__)
- def testCountFiles(self, simple__init__, simple_ListFilesWithPrefix):
- """Tests the CountFiles function."""
- _gcs_api_utils = gcs_api_utils.GcsApiUtils('key/path', 'vts-fuzz')
- length = _gcs_api_utils.CountFiles('corpus/ILight/ILight_corpus_seed')
- simple_ListFilesWithPrefix.assert_called()
- self.assertEqual(length, 4)
-
- @mock.patch(
- 'vts.utils.python.gcs.gcs_api_utils.GcsApiUtils.ListFilesWithPrefix',
- side_effect=simple_ListFilesWithPrefix)
- @mock.patch(
- 'vts.utils.python.gcs.gcs_api_utils.GcsApiUtils.__init__',
- side_effect=simple__init__)
- def testPrefixExists(self, simple__init__, simple_ListFilesWithPrefix):
- """Tests the PrefixExists function."""
- _gcs_api_utils = gcs_api_utils.GcsApiUtils('key/path', 'vts-fuzz')
- dir_exist = _gcs_api_utils.PrefixExists(
- 'corpus/ILight/ILight_corpus_seed')
- simple_ListFilesWithPrefix.assert_called()
- self.assertEqual(dir_exist, True)
-
- @mock.patch('os.path.exists', side_effect=simple_os_path_exists)
- @mock.patch(
- 'vts.utils.python.gcs.gcs_api_utils.GcsApiUtils.__init__',
- side_effect=simple__init__)
- def testPrepareDownloadDestination(self, simple__init__,
- simple_os_path_exists):
- """Tests the PrepareDownloadDestination function."""
- _gcs_api_utils = gcs_api_utils.GcsApiUtils('key/path', 'vts-fuzz')
- local_dest_folder = _gcs_api_utils.PrepareDownloadDestination(
- 'corpus/ILight/ILight_corpus_seed', 'tmp/tmp4772')
- self.assertEqual(local_dest_folder, 'tmp/tmp4772/ILight_corpus_seed')
-
- @mock.patch(
- 'vts.utils.python.gcs.gcs_api_utils.GcsApiUtils.DownloadFile',
- side_effect=simple_DownloadFile)
- @mock.patch(
- 'vts.utils.python.gcs.gcs_api_utils.GcsApiUtils.PrefixExists',
- side_effect=simple_PrefixExists)
- @mock.patch(
- 'vts.utils.python.gcs.gcs_api_utils.GcsApiUtils.ListFilesWithPrefix',
- side_effect=simple_ListFilesWithPrefix)
- @mock.patch(
- 'vts.utils.python.gcs.gcs_api_utils.GcsApiUtils.PrepareDownloadDestination',
- side_effect=simple_PrepareDownloadDestination)
- @mock.patch(
- 'vts.utils.python.gcs.gcs_api_utils.GcsApiUtils.__init__',
- side_effect=simple__init__)
- def testDownloadDir(self, simple__init__,
- simple_PrepareDownloadDestination,
- simple_ListFilesWithPrefix, simple_PrefixExists,
- simple_DownloadFile):
- """Tests the DownloadDir function"""
- _gcs_api_utils = gcs_api_utils.GcsApiUtils('key/path', 'vts-fuzz')
- _gcs_api_utils.DownloadDir('valid_source_dir',
- 'local_destination/dest')
- num_DownloadFile_called = simple_DownloadFile.call_count
- self.assertEqual(num_DownloadFile_called, 4)
- local_dest_folder = simple_PrepareDownloadDestination.return_value
-
- @mock.patch(
- 'vts.utils.python.gcs.gcs_api_utils.GcsApiUtils.UploadFile',
- side_effect=simple_UploadFile)
- @mock.patch('os.path.exists', side_effect=simple_os_path_exists)
- @mock.patch('os.listdir', side_effect=simple_ListFilesWithPrefix)
- @mock.patch(
- 'vts.utils.python.gcs.gcs_api_utils.GcsApiUtils.__init__',
- side_effect=simple__init__)
- def testUploadDir(self, simple__init__, simple_ListFilesWithPrefix,
- simple_os_path_exists, simple_UploadFile):
- _gcs_api_utils = gcs_api_utils.GcsApiUtils('key/path', 'vts-fuzz')
- _gcs_api_utils.UploadDir('valid_source_dir', 'GCS_destination/dest')
- num_UploadFile_called = simple_UploadFile.call_count
- self.assertEqual(num_UploadFile_called, 4)
-
- @mock.patch(
- 'vts.utils.python.gcs.gcs_api_utils.google.auth.default',
- side_effect=auth_exceptions.DefaultCredentialsError('unit test'))
- def testCredentialsError(self, mock_default):
- """Tests authentication failure in __init__."""
- _gcs_api_utils = gcs_api_utils.GcsApiUtils('key/path', 'vts-fuzz')
- self.assertFalse(_gcs_api_utils.Enabled)
- mock_default.assert_called()
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/utils/python/gcs/gcs_utils.py b/utils/python/gcs/gcs_utils.py
deleted file mode 100644
index 943fdc7..0000000
--- a/utils/python/gcs/gcs_utils.py
+++ /dev/null
@@ -1,87 +0,0 @@
-#
-# Copyright (C) 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.
-
-import logging
-import os
-import re
-import zipfile
-
-from vts.proto import VtsReportMessage_pb2 as ReportMsg
-from vts.runners.host import keys
-from vts.utils.python.common import cmd_utils
-from vts.utils.python.web import feature_utils
-
-
-class GcsUtils(feature_utils.Feature):
- """GCS (Google Cloud Storage) utility provider.
-
- Attributes:
- _TOGGLE_PARAM: String, the name of the parameter used to toggle the feature
- _REQUIRED_PARAMS: list, the list of parameter names that are required
- _OPTIONAL_PARAMS: list, the list of parameter names that are optional
- """
-
- _TOGGLE_PARAM = None
- _REQUIRED_PARAMS = [keys.ConfigKeys.IKEY_SERVICE_JSON_PATH]
- _OPTIONAL_PARAMS = []
-
- def __init__(self, user_params):
- """Initializes the gcs util provider.
-
- Args:
- user_params: A dictionary from parameter name (String) to parameter value.
- """
- self.ParseParameters(
- toggle_param_name=self._TOGGLE_PARAM,
- required_param_names=self._REQUIRED_PARAMS,
- optional_param_names=self._OPTIONAL_PARAMS,
- user_params=user_params)
-
- def GetGcloudAuth(self):
- """Connects to a service account with access to the gcloud bucket."""
- gcloud_path = GcsUtils.GetGcloudPath()
- gcloud_key = getattr(self, keys.ConfigKeys.IKEY_SERVICE_JSON_PATH)
- if gcloud_path is not None:
- auth_cmd = "%s auth activate-service-account --key-file %s" % (
- gcloud_path, gcloud_key)
- _, stderr, ret_code = cmd_utils.ExecuteOneShellCommand(auth_cmd)
- if ret_code == 0:
- logging.info(stderr)
- else:
- logging.error(stderr)
-
- @staticmethod
- def GetGcloudPath():
- """Returns the gcloud file path if found; None otherwise."""
- sh_stdout, _, ret_code = cmd_utils.ExecuteOneShellCommand(
- "which gcloud")
- if ret_code == 0:
- return sh_stdout.strip()
- else:
- logging.error("`gcloud` doesn't exist on the host; "
- "please install Google Cloud SDK before retrying.")
- return None
-
- @staticmethod
- def GetGsutilPath():
- """Returns the gsutil file path if found; None otherwise."""
- sh_stdout, sh_stderr, ret_code = cmd_utils.ExecuteOneShellCommand(
- "which gsutil")
- if ret_code == 0:
- return sh_stdout.strip()
- else:
- logging.error("`gsutil` doesn't exist on the host; "
- "please install Google Cloud SDK before retrying.")
- return None
diff --git a/utils/python/gcs/gcs_utils_test.py b/utils/python/gcs/gcs_utils_test.py
deleted file mode 100644
index 0ce00c0..0000000
--- a/utils/python/gcs/gcs_utils_test.py
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 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.
-
-import mock
-import unittest
-
-from vts.utils.python.gcs import gcs_utils
-
-
-def simple_GetGcloudPath():
- """mock function created for _GetGcloudPath"""
- return "gcloud"
-
-
-def simple_ExecuteOneShellCommand(input_string):
- """mock function created for ExecuteOneShellCommand"""
- std_out = "this is standard output"
- std_err = "this is standard error"
- return_code = 0
- return std_out, std_err, return_code
-
-
-class GcsUtilsTest(unittest.TestCase):
- """Unit tests for gcs_utils module"""
-
- def SetUp(self):
- """Setup tasks"""
- self.category = "category_default"
- self.name = "name_default"
-
- def testInitialization(self):
- """Tests the initilization of a GcsUtils object"""
- user_params = {"service_key_json_path": "key.json"}
- _gcs_utils = gcs_utils.GcsUtils(user_params)
- self.assertEqual(_gcs_utils.service_key_json_path, "key.json")
-
- @mock.patch(
- 'vts.utils.python.gcs.gcs_utils.GcsUtils.GetGcloudPath',
- side_effect=simple_GetGcloudPath)
- @mock.patch(
- 'vts.utils.python.common.cmd_utils.ExecuteOneShellCommand',
- side_effect=simple_ExecuteOneShellCommand)
- def testGetGcloudAuth(self, simple_ExecuteOneShellCommand,
- simeple_GetGCloudPath):
- """Tests the GetGcloudAuth function"""
- user_params = {"service_key_json_path": "key.json"}
- _gcs_utils = gcs_utils.GcsUtils(user_params)
- _gcs_utils.GetGcloudAuth()
- simple_ExecuteOneShellCommand.assert_called_with(
- "gcloud auth activate-service-account --key-file key.json")
-
- @mock.patch(
- 'vts.utils.python.common.cmd_utils.ExecuteOneShellCommand',
- side_effect=simple_ExecuteOneShellCommand)
- def testGetGcloudPath(self, simple_ExecuteOneShellCommand):
- """Tests the GetGcloudPath static function"""
- result = gcs_utils.GcsUtils.GetGcloudPath()
- simple_ExecuteOneShellCommand.assert_called_with("which gcloud")
- self.assertEqual(result, "this is standard output")
-
- @mock.patch(
- 'vts.utils.python.common.cmd_utils.ExecuteOneShellCommand',
- side_effect=simple_ExecuteOneShellCommand)
- def testGetGsutilPath(self, simple_ExecuteOneShellCommand):
- """Tests the GetGsutilPath static function"""
- result = gcs_utils.GcsUtils.GetGsutilPath()
- simple_ExecuteOneShellCommand.assert_called_with("which gsutil")
- self.assertEqual(result, "this is standard output")
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/utils/python/instrumentation/__init__.py b/utils/python/instrumentation/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/instrumentation/__init__.py
+++ /dev/null
diff --git a/utils/python/instrumentation/test_framework_instrumentation.py b/utils/python/instrumentation/test_framework_instrumentation.py
deleted file mode 100644
index 88253fe..0000000
--- a/utils/python/instrumentation/test_framework_instrumentation.py
+++ /dev/null
@@ -1,202 +0,0 @@
-#
-# Copyright (C) 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.
-
-import datetime
-import logging
-import operator
-import os
-import time
-
-from vts.runners.host import logger
-from vts.utils.python.instrumentation import test_framework_instrumentation_categories as tfic
-from vts.utils.python.instrumentation import test_framework_instrumentation_event as tfie
-
-
-# global category listing
-categories = tfic.TestFrameworkInstrumentationCategories()
-# TODO(yuexima): use data class
-counts = {}
-
-DEFAULT_CATEGORY = 'Misc'
-DEFAULT_FILE_NAME_TEXT_RESULT = 'instrumentation_data.txt'
-
-
-def Begin(name, category=DEFAULT_CATEGORY, enable_logging=None, disable_subevent_logging=False):
- """Marks the beginning of an event.
-
- Params:
- name: string, name of the event.
- category: string, category of the event. Default category will be used if not specified.
- enable_logging: bool or None. Whether to put the event in logging.
- Should be set to False when timing small pieces of code that could take
- very short time to run.
- If not specified or is None, global configuration will be used.
- disable_subevent_logging: bool, whether to disable logging for events created after this
- event begins and before this event ends. This will overwrite
- subevent's logging setting if set to True.
-
- Returns:
- Event object representing the event
- """
- event = tfie.TestFrameworkInstrumentationEvent(name, category)
- event.Begin(enable_logging=enable_logging, disable_subevent_logging=disable_subevent_logging)
- return event
-
-
-def End(name, category=DEFAULT_CATEGORY):
- """Marks the end of an event.
-
- This function tries to find an event in internal event stack by calling FindEvent
- method with the given category and name.
-
- Will log error and return None if no match is found.
-
- If multiple event with the same category and name are found, the last one will be used.
-
- Use this function with caution if there are multiple events began with the same name and
- category. It is highly recommended to call End() method from the Event object directly.
-
- Params:
- name: string, name of the event.
- category: string, category of the event. Default category will be used if not specified.
-
- Returns:
- Event object representing the event. None if cannot find an active matching event
- """
- event = FindEvent(name, category)
- if not event:
- logging.error('Event with category %s and name %s either does not '
- 'exists or has already ended. Skipping...', name, category)
- return None
-
- event.End()
- return event
-
-
-def FindEvent(name, category=DEFAULT_CATEGORY):
- """Finds an existing event that has started given the names.
-
- Use this function with caution if there are multiple events began with the same name and
- category. It is highly recommended to call End() method from the Event object directly.
-
- Params:
- name: string, name of the event.
- category: string, category of the event. Default category will be used if not specified.
-
- Returns:
- TestFrameworkInstrumentationEvent object if found; None otherwise.
- """
- for event in reversed(tfie.event_stack):
- if event.Match(name, category):
- return event
-
- return None
-
-
-def Count(name, category=DEFAULT_CATEGORY):
- """Counts the occurrence of an event.
-
- Events will be mapped using name and category as key.
-
- Params:
- name: string, name of the event.
- category: string, category of the event. Default category will be used if not specified.
- """
- name, category = tfie.NormalizeNameCategory(name, category)
- # TODO(yuexima): give warning when there's illegal char, but only once for each combination.'
- if (name, category) not in counts:
- counts[(name, category)] = [time.time()]
- else:
- counts[name, category].append(time.time())
-
-
-def GenerateTextReport():
- """Compile instrumentation results into a simple text output format for visualization.
-
- Returns:
- a string containing result text.
- """
- class EventItem:
- """Temporary data storage class for instrumentation text result generation.
-
- Attributes:
- name: string, event name
- category: string, event category
- time_cpu: float, CPU time of the event (can be begin or end)
- time_wall: float, wall time of the event (can be begin or end)
- type: string, begin or end
- """
- name = ''
- category = ''
- time_cpu = -1
- time_wall = -1
- type = ''
- duration = -1
-
- results = []
-
- for event in tfie.event_data:
- ei = EventItem()
- ei.name = event.name
- ei.category = event.category
- ei.type = 'begin'
- ei.time_cpu = event.timestamp_begin_cpu
- ei.time_wall = event.timestamp_begin_wall
- results.append(ei)
-
- for event in tfie.event_data:
- ei = EventItem()
- ei.name = event.name
- ei.category = event.category
- ei.type = 'end'
- ei.time_cpu = event.timestamp_end_cpu
- ei.time_wall = event.timestamp_end_wall
- ei.duration = event.timestamp_end_wall - event.timestamp_begin_wall
- results.append(ei)
-
- results.sort(key=operator.attrgetter('time_cpu'))
-
- result_text = []
-
- level = 0
- for e in results:
- if e.type == 'begin':
- s = ('Begin [%s @ %s] ' % (e.name, e.category) +
- datetime.datetime.fromtimestamp(e.time_wall).strftime('%Y-%m-%d %H:%M:%S_%f'))
- result_text.append(' '*level + s)
- level += 1
- else:
- s = ('End [%s @ %s] ' % (e.name, e.category) +
- datetime.datetime.fromtimestamp(e.time_wall).strftime('%Y-%m-%d %H:%M:%S_%f'))
- level -= 1
- result_text.append(' '*level + s)
- result_text.append('\n')
- result_text.append(' '*level + "%.4f" % e.duration)
- result_text.append('\n')
-
- return ''.join(result_text)
-
-
-def CompileResults(directory=None, filename=DEFAULT_FILE_NAME_TEXT_RESULT):
- """Writes instrumentation results into a simple text output format for visualization.
-
- Args:
- directory: string, parent path of result
- filename: string, result file name
- """
- if not directory:
- directory = logging.log_path
- with open(os.path.join(directory, filename), 'w') as f:
- f.write(GenerateTextReport())
diff --git a/utils/python/instrumentation/test_framework_instrumentation_categories.py b/utils/python/instrumentation/test_framework_instrumentation_categories.py
deleted file mode 100644
index 7522b08..0000000
--- a/utils/python/instrumentation/test_framework_instrumentation_categories.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#
-# Copyright (C) 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.
-
-import logging
-
-
-class TestFrameworkInstrumentationCategories(object):
- """Enum values for common category strings."""
- FRAMEWORK_SETUP = 'Framework setUp'
- FRAMEWORK_TEARDOWN = 'Framework tearDown'
- TEST_MODULE_SETUP = 'Test module setUp'
- TEST_MODULE_TEARDOWN = 'Test module tearDown'
- TEST_CLASS_SETUP = 'Test class setUp'
- TEST_CLASS_TEARDOWN = 'Test class tearDown'
- TEST_CASE_SETUP = 'Test case setUp'
- TEST_CASE_TEARDOWN = 'Test case tearDown'
- DEVICE_SETUP = 'Device setUp'
- DEVICE_CLEANUP = 'Device cleanUp'
- FAILED_TEST_CASE_PROCESSING = 'Failed test case processing'
- TEST_CASE_EXECUTION = 'Test case execution'
- RESULT_PROCESSING = 'Result processing'
- WAITING_FOR_DEVICE_RESPOND = 'Waiting for device respond'
-
- def Add(self, key, value):
- """Add a category key and value to the class attribute.
-
- Key being empty or starting with non-letter is not allowed.
-
- Returns:
- bool, whether adding the values is success
- """
- if not key or not key[0].isalpha():
- logging.error('Category name empty or starting with non-letter '
- 'is not allowed. Ignoring key=[%s], value=[%s]',
- key, value)
- return False
-
- if hasattr(self, key):
- logging.warn('Categories key %s already exists with value %s. '
- 'Overwriting with %s.', key, getattr(self,key), value)
-
- setattr(self, key, value)
- return True
\ No newline at end of file
diff --git a/utils/python/instrumentation/test_framework_instrumentation_event.py b/utils/python/instrumentation/test_framework_instrumentation_event.py
deleted file mode 100644
index aed5b5e..0000000
--- a/utils/python/instrumentation/test_framework_instrumentation_event.py
+++ /dev/null
@@ -1,263 +0,0 @@
-#
-# Copyright (C) 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.
-
-import logging
-import time
-import re
-
-
-# Log prefix to be parsed by performance analysis tools
-LOGGING_PREFIX = '[Instrumentation]'
-# Log line template in the format of <prefix> <type> @<category> #<name>
-# Do not use tab(\t) because sometime they can be printed to log as the string '\t'
-LOGGING_TEMPLATE = LOGGING_PREFIX + ' {category}: {name} {status}'
-# Characters not allowed in provided event category or name
-# In event init method, these characters are joint by '|' as regex. Modifications to
-# the replacing logic be required if escape character is needed.
-ILLEGAL_CHARS = ':\t\r\n'
-
-# A list of events that have began but not ended.
-event_stack = []
-# A list of events that have finished
-# TODO(yuexima): use a new class to store data
-event_data = []
-
-
-def NormalizeNameCategory(name, category):
- """Replaces illegal characters in name and category.
-
- Illegal characters defined in ILLEGAL_CHARS will be replaced with '_'.
-
- Args:
- name: string
- category: string
-
- Returns:
- a tuple (string, string), name and category
- """
- if set(ILLEGAL_CHARS) & set(category + name):
- category = re.sub('|'.join(ILLEGAL_CHARS), '_', category)
- name = re.sub('|'.join(ILLEGAL_CHARS), '_', name)
-
- return name, category
-
-
-class TestFrameworkInstrumentationEvent(object):
- """An object that represents an event.
-
- Attributes:
- category: string, a category mark represents a high level event
- category such as preparer setup and test execution.
- error: string, None if no error. Otherwise contains error messages such
- as duplicated Begin or End.
- name: string, a string to mark specific name of an event for human
- reading. Final performance analysis will mostly focus on category
- granularity instead of name granularity.
- status: int, 0 for not started, 1 for started, 2 for ended, 3 for removed.
- timestamp_begin_cpu: float, cpu time of event begin
- timestamp_begin_wall: float, wall time of event begin
- timestamp_end_cpu: float, cpu time of event end
- Note: on some operating system (such as windows), the difference
- between start and end cpu time may be measured using
- wall time.
- timestamp_end_wall: float, wall time of event end
- _enable_logging: bool or None. Whether to put the event in logging.
- Should be set to False when timing small pieces of code that could take
- very short time to run.
- This value should only be set once for log consistency.
- If is None, global configuration will be used.
- _disable_subevent_logging: bool, whether to disable logging for events created after this
- event begins and before this event ends. This will overwrite
- subevent's logging setting if set to True.
- """
- category = None
- name = None
- status = 0
- error = None
- _enable_logging = False
- _disable_subevent_logging = False
- # TODO(yuexima): add on/off toggle param for logging.
-
- timestamp_begin_cpu = -1
- timestamp_begin_wall = -1
- timestamp_end_cpu = -1
- timestamp_end_wall = -1
-
- def __init__(self, name, category):
- self.name, self.category = NormalizeNameCategory(name, category)
-
- if (name, category) != (self.name, self.category):
- self.LogW('TestFrameworkInstrumentation: illegal character detected in '
- 'category or name string. Provided name: %s, category: %s. '
- 'Replacing them as "_"', name, category)
-
- def Match(self, name, category):
- """Checks whether the given category and name matches this event."""
- return category == self.category and name == self.name
-
- def Begin(self, enable_logging=None, disable_subevent_logging=False):
- """Performs logging action for the beginning of this event.
-
- Args:
- enable_logging: bool or None. Whether to put the event in logging.
- Should be set to False when timing small pieces of code that could take
- very short time to run.
- If not specified or is None, global configuration will be used.
- This value can only be set in Begin method to make logging consistent.
- disable_subevent_logging: bool, whether to disable logging for events created after this
- event begins and before this event ends. This will overwrite
- subevent's logging setting if set to True.
- """
- timestamp_begin_cpu = time.clock()
- timestamp_begin_wall = time.time()
- global event_stack
- if event_stack and event_stack[-1]._disable_subevent_logging:
- self._enable_logging = False
- self._disable_subevent_logging = True
- else:
- if enable_logging is not None:
- self._enable_logging = enable_logging
- self._disable_subevent_logging = disable_subevent_logging
-
- if self.status == 1:
- self.LogE('TestFrameworkInstrumentation: event %s has already began. '
- 'Skipping Begin.', self)
- self.error = 'Tried to Begin but already began'
- return
- elif self.status == 2:
- self.LogE('TestFrameworkInstrumentation: event %s has already ended. '
- 'Skipping Begin.', self)
- self.error = 'Tried to Begin but already ended'
- return
- elif self.status == 3:
- self.LogE('TestFrameworkInstrumentation: event %s has already been removed. '
- 'Skipping Begin.', self)
- self.error = 'Tried to Begin but already been removed'
- return
-
- self.LogD(LOGGING_TEMPLATE.format(category=self.category,
- name=self.name,
- status='BEGIN'))
-
- self.status = 1
- self.timestamp_begin_cpu = timestamp_begin_cpu
- self.timestamp_begin_wall = timestamp_begin_wall
- event_stack.append(self)
-
- def End(self):
- """Performs logging action for the end of this event."""
- timestamp_end_cpu = time.clock()
- timestamp_end_wall = time.time()
- if self.status == 0:
- self.LogE('TestFrameworkInstrumentation: event %s has not yet began. '
- 'Skipping End.', self)
- self.error = 'Tried to End but have not began'
- return
- elif self.status == 2:
- self.LogE('TestFrameworkInstrumentation: event %s has already ended. '
- 'Skipping End.', self)
- self.error = 'Tried to End but already ended'
- return
- elif self.status == 3:
- self.LogE('TestFrameworkInstrumentation: event %s has already been removed. '
- 'Skipping End.', self)
- self.error = 'Tried to End but already been removed'
- return
-
- self.LogD(LOGGING_TEMPLATE.format(category=self.category,
- name=self.name,
- status='END'))
-
- self.status = 2
- self.timestamp_end_cpu = timestamp_end_cpu
- self.timestamp_end_wall = timestamp_end_wall
- global event_data
- event_data.append(self)
- global event_stack
- event_stack.remove(self)
-
- def CheckEnded(self, remove_reason=''):
- """Checks whether this event has ended and remove it if not.
-
- This method is designed to be used in a try-catch exception block, where it is
- not obvious whether the End() method has ever been called. In such case, if
- End() has not been called, it usually means exception has happened and the event
- should either be removed or automatically ended. Here we choose remove because
- this method could be called in the finally block in a try-catch block, and there
- could be a lot of noise before reaching the finally block.
-
- This method does not support being called directly in test_framework_instrumentation
- module with category and name lookup, because there can be events with same names.
-
- Calling this method multiple times on the same Event object is ok.
-
- Args:
- remove_reason: string, reason to remove to be recorded when the event was
- not properly ended. Default is empty string.
- """
- if self.status < 2:
- self.Remove(remove_reason)
-
- def Remove(self, remove_reason=''):
- """Removes this event from reports and record the reason.
-
- Calling this method multiple times on the same Event object is ok.
-
- Args:
- remove_reason: string, reason to remove to be recorded when the event was
- not properly ended. Default is empty string.
- """
- if self.status == 3:
- return
-
- self.LogD(LOGGING_TEMPLATE.format(category=self.category,
- name=self.name,
- status='REMOVE') +
- ' | Reason: %s' % remove_reason)
-
- self.error = remove_reason
- self.status = 3
- global event_stack
- event_stack.remove(self)
-
- def LogD(self, *args):
- """Wrapper function for logging.debug"""
- self._Log(logging.debug, *args)
-
- def LogI(self, *args):
- """Wrapper function for logging.info"""
- self._Log(logging.info, *args)
-
- def LogW(self, *args):
- """Wrapper function for logging.warn"""
- self._Log(logging.warn, *args)
-
- def LogE(self, *args):
- """Wrapper function for logging.error"""
- self._Log(logging.error, *args)
-
- def _Log(self, log_func, *args):
- if self._enable_logging != False:
- log_func(*args)
-
- def __str__(self):
- return 'Event object: @%s #%s' % (self.category, self.name) + \
- '\n Begin timestamp(CPU): %s' % self.timestamp_begin_cpu + \
- '\n End timestamp(CPU): %s' % self.timestamp_end_cpu + \
- '\n Begin timestamp(wall): %s' % self.timestamp_begin_wall + \
- '\n End timestamp(wall): %s' % self.timestamp_end_wall + \
- '\n Status: %s' % self.status + \
- '\n Duration(CPU): %s' % (self.timestamp_end_cpu - self.timestamp_begin_cpu) + \
- '\n Duration(wall): %s' % (self.timestamp_end_wall - self.timestamp_begin_wall)
diff --git a/utils/python/instrumentation/test_framework_instrumentation_test.py b/utils/python/instrumentation/test_framework_instrumentation_test.py
deleted file mode 100644
index 5e370ec..0000000
--- a/utils/python/instrumentation/test_framework_instrumentation_test.py
+++ /dev/null
@@ -1,232 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 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.
-#
-
-import unittest
-
-from vts.utils.python.instrumentation import test_framework_instrumentation as tfi
-from vts.utils.python.instrumentation import test_framework_instrumentation_event as tfie
-from vts.utils.python.instrumentation import test_framework_instrumentation_test_submodule as tfits
-
-
-class TestFrameworkInstrumentationTest(unittest.TestCase):
- """Unit tests for test_framework_instrumentation module"""
-
- def setUp(self):
- """Setup tasks"""
- self.category = 'category_default'
- self.name = 'name_default'
- tfie.event_data = []
- tfie.event_stack = []
- tfi.counts = {}
-
- def testEventName(self):
- """Tests whether illegal characters are being recognized and replaced."""
- for name in tfie.ILLEGAL_CHARS:
- # TODO(yuexima): disable error logging for this test case
- event = tfie.TestFrameworkInstrumentationEvent(name, '')
- self.assertNotEqual(event.name, name, 'name %s should not be accepted.' % name)
-
- def testEventMatch(self):
- """Tests whether Event object can match with a category and name."""
- category = '1'
- name = '2'
- event = tfie.TestFrameworkInstrumentationEvent(name, category)
- self.assertTrue(event.Match(name, category))
- self.assertFalse(event.Match('3', category))
-
- def testEndAlreadyEnded(self):
- """Tests End command on already ended event."""
- event = tfi.Begin(self.name, self.category, enable_logging=False)
- event.End()
- self.assertEqual(event.status, 2)
- self.assertIsNone(event.error)
- event.End()
- self.assertEqual(event.status, 2)
- self.assertTrue(event.error)
-
- def testEndMatch(self):
- """Tests End command with name matching."""
- event = tfi.Begin(self.name, self.category)
- self.assertEqual(event.status, 1)
- tfi.End(self.name, self.category)
- self.assertEqual(event.status, 2)
- self.assertIsNone(event.error)
-
- def testEndFromOtherModule(self):
- """Tests the use of End command from another module."""
- event = tfi.Begin(self.name, self.category)
- self.assertEqual(event.status, 1)
- tfits.TestFrameworkInstrumentationTestSubmodule().End(self.name, self.category)
- self.assertEqual(event.status, 2)
- self.assertIsNone(event.error)
-
- def testCategories(self):
- """Tests access to TestFrameworkInstrumentationCategories object"""
- self.assertTrue(tfi.categories.Add(self.name, self.category))
- self.assertFalse(tfi.categories.Add('', self.name))
- self.assertFalse(tfi.categories.Add(None, self.name))
- self.assertFalse(tfi.categories.Add('1a', self.name))
-
- def testCheckEnded(self):
- """Tests the CheckEnded method of TestFrameworkInstrumentationEvent"""
- event = tfi.Begin(self.name, self.category)
-
- # Verify initial condition
- self.assertTrue(bool(tfie.event_stack))
- self.assertEqual(event.status, 1)
-
- event.CheckEnded()
- # Check event status is Remove
- self.assertEqual(event.status, 3)
-
- # Check event is removed from stack
- self.assertFalse(bool(tfie.event_stack))
-
- # Check whether duplicate calls doesn't give error
- event.CheckEnded()
- self.assertEqual(event.status, 3)
-
- def testRemove(self):
- """Tests the Remove method of TestFrameworkInstrumentationEvent"""
- event = tfi.Begin(self.name, self.category)
-
- # Verify initial condition
- self.assertTrue(bool(tfie.event_stack))
- self.assertEqual(event.status, 1)
-
- event.Remove()
- # Check event status is Remove
- self.assertEqual(event.status, 3)
-
- # Check event is removed from stack
- self.assertFalse(bool(tfie.event_stack))
-
- # Check whether duplicate calls doesn't give error
- event.Remove()
- self.assertEqual(event.status, 3)
-
- def testEndAlreadyRemoved(self):
- """Tests End command on already ended event."""
- event = tfi.Begin(self.name, self.category, enable_logging=False)
- reason = 'no reason'
- event.Remove(reason)
- self.assertEqual(event.status, 3)
- self.assertEqual(event.error, reason)
- event.End()
- self.assertEqual(event.status, 3)
- self.assertNotEqual(event.error, reason)
-
- def testEnableLogging(self):
- """Tests the enable_logging option."""
- # Test not specified case
- event = tfi.Begin(self.name, self.category)
- self.assertFalse(event._enable_logging)
- event.End()
-
- # Test set to True case
- event = tfi.Begin(self.name, self.category, enable_logging=True)
- self.assertTrue(event._enable_logging)
- event.End()
-
- # Test set to False case
- event = tfi.Begin(self.name, self.category, enable_logging=None)
- self.assertFalse(event._enable_logging)
- event.End()
-
- def testDisableSubEventLoggingOverwriting(self):
- """Tests the disable_subevent_logging option's overwriting feature.
-
- Tests whether the top event's disable_subevent_logging overwrite
- subevent's disable_subevent_logging option only when it is set to True
- """
- # Test top event disable_subevent_logging option not specified case
- event = tfi.Begin(self.name, self.category)
- self.assertFalse(event._disable_subevent_logging)
- event_sub = tfi.Begin(self.name, self.category, disable_subevent_logging=True)
- self.assertTrue(event_sub._disable_subevent_logging)
- event_sub.End()
- event.End()
-
- # Test top event disable_subevent_logging option set to False
- event = tfi.Begin(self.name, self.category, disable_subevent_logging=False)
- self.assertFalse(event._disable_subevent_logging)
- event_sub = tfi.Begin(self.name, self.category, disable_subevent_logging=True)
- self.assertTrue(event_sub._disable_subevent_logging)
- event_sub.End()
- event.End()
-
- # Test top event disable_subevent_logging option set to True
- event = tfi.Begin(self.name, self.category, disable_subevent_logging=True)
- self.assertTrue(event._disable_subevent_logging)
- event_sub1 = tfi.Begin(self.name, self.category, disable_subevent_logging=False)
- self.assertTrue(event_sub1._disable_subevent_logging)
- event_sub1.End()
- event_sub2 = tfi.Begin(self.name, self.category)
- self.assertTrue(event_sub2._disable_subevent_logging)
- event_sub2.End()
- event.End()
-
- def testDisableSubEventLoggingNesting(self):
- """Tests the disable_subevent_logging option.
-
- Tests whether the top event's disable_subevent_logging can overwrite
- subevents of deeper levels when set to True.
- """
- # Test top event disable_subevent_logging option set to True
- event = tfi.Begin(self.name, self.category, disable_subevent_logging=True)
- self.assertTrue(event._disable_subevent_logging)
- event_sub = tfi.Begin(self.name, self.category, disable_subevent_logging=False)
- self.assertTrue(event_sub._disable_subevent_logging)
- event_sub_sub1 = tfi.Begin(self.name, self.category)
- self.assertTrue(event_sub_sub1._disable_subevent_logging)
- event_sub_sub1.End()
- event_sub_sub2 = tfi.Begin(self.name, self.category, disable_subevent_logging=False)
- self.assertTrue(event_sub_sub2._disable_subevent_logging)
- event_sub_sub2.End()
- event_sub.End()
- event.End()
-
- def testCount(self):
- """Tests the count API."""
- tfi.Count(self.name, self.category)
- tfi.Count(self.name, self.category)
- self.assertEqual(len(tfi.counts), 1)
- self.assertEqual(len(tfi.counts[self.name, self.category]), 2)
- tfi.Count(self.name)
- self.assertEqual(len(tfi.counts), 2)
-
- def testGenerateTextReport(self):
- """Tests the GenerateTextReport method."""
- event = tfi.Begin('name1', 'cat1', disable_subevent_logging=True)
- event_sub = tfi.Begin('name2', 'cat2', disable_subevent_logging=False)
- event_sub.End()
- event.End()
- res = tfi.GenerateTextReport()
-
- # Checks result is not empty
- self.assertGreater(len(res), 0)
-
- # Since the format of the result is subject to change, here we only
- # checks whether the names and categories are mentioned in the result.
- self.assertIn('name1', res)
- self.assertIn('name2', res)
- self.assertIn('cat1', res)
- self.assertIn('cat2', res)
-
-
-if __name__ == "__main__":
- unittest.main()
\ No newline at end of file
diff --git a/utils/python/instrumentation/test_framework_instrumentation_test_submodule.py b/utils/python/instrumentation/test_framework_instrumentation_test_submodule.py
deleted file mode 100644
index aa7f022..0000000
--- a/utils/python/instrumentation/test_framework_instrumentation_test_submodule.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Copyright (C) 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.
-#
-
-from vts.utils.python.instrumentation import test_framework_instrumentation as tfi
-
-class TestFrameworkInstrumentationTestSubmodule(object):
- """Unit test submodule for test_framework_instrumentation module"""
-
- def End(self, name, category):
- """Use End command on an event started from other module given category and name ."""
- tfi.End(name, category)
\ No newline at end of file
diff --git a/utils/python/io/__init__.py b/utils/python/io/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/io/__init__.py
+++ /dev/null
diff --git a/utils/python/io/capture_printout.py b/utils/python/io/capture_printout.py
deleted file mode 100644
index d1df4d0..0000000
--- a/utils/python/io/capture_printout.py
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# 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.
-#
-
-
-from cStringIO import StringIO
-import sys
-
-
-class CaptureStdout(list):
- '''Capture system stdout as a list of string.
-
- Usage example:
- with CaptureStdout() as output:
- print 'something'
-
- print 'Got output list: %s' % output
- '''
-
- def __enter__(self):
- self.sys_stdout = sys.stdout
- sys.stdout = StringIO()
- return self
-
- def __exit__(self, *args):
- self.extend(sys.stdout.getvalue().splitlines())
- sys.stdout = self.sys_stdout
\ No newline at end of file
diff --git a/utils/python/io/file_util.py b/utils/python/io/file_util.py
deleted file mode 100644
index 480335f..0000000
--- a/utils/python/io/file_util.py
+++ /dev/null
@@ -1,126 +0,0 @@
-#
-# 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.
-#
-
-import logging
-import os
-import shutil
-import tempfile
-
-
-def FindFile(directory, filename):
- '''Find a file under directory given the filename.
-
- Args:
- directory: string, directory path
- filename: string, file name to find
-
- Returns:
- String, path to the file found. None if not found.
- '''
- for (dirpath, dirnames, filenames) in os.walk(
- directory, followlinks=False):
- for fn in filenames:
- if fn == filename:
- return os.path.join(dirpath, filename)
-
- return None
-
-
-def Rmdirs(path, ignore_errors=False):
- '''Remove the given directory and its contents recursively.
-
- Args:
- path: string, directory to delete
- ignore_errors: bool, whether to ignore errors. Defaults to False
-
- Returns:
- bool, True if directory is deleted.
- False if errors occur or directory does not exist.
- '''
- return_value = False
- if os.path.exists(path):
- try:
- shutil.rmtree(path, ignore_errors=ignore_errors)
- return_value = True
- except OSError as e:
- logging.exception(e)
- return return_value
-
-
-def Mkdir(path, skip_if_exists=True):
- """Make a leaf directory.
-
- This method only makes the leaf directory. This means if the parent directory
- doesn't exist, the method will catch an OSError and return False.
-
- Args:
- path: string, directory to make
- skip_if_exists: bool, True for ignoring exisitng dir. False for throwing
- error from os.mkdir. Defaults to True
-
- Returns:
- bool, True if directory is created or directory already exists
- (with skip_if_exists being True).
- False if errors occur or directory already exists (with skip_if_exists being False).
- """
- if skip_if_exists and os.path.exists(path):
- return True
-
- try:
- os.mkdir(path)
- return True
- except OSError as e:
- logging.exception(e)
- return False
-
-
-def Makedirs(path, skip_if_exists=True):
- '''Make directories lead to the given path.
-
- This method makes all parent directories if they don't exist.
-
- Args:
- path: string, directory to make
- skip_if_exists: bool, True for ignoring exisitng dir. False for throwing
- error from os.makedirs. Defaults to True
-
- Returns:
- bool, True if directory is created or directory already exists
- (with skip_if_exists being True).
- False if errors occur or directory already exists (with skip_if_exists being False).
- '''
- if skip_if_exists and os.path.exists(path):
- return True
-
- try:
- os.makedirs(path)
- return True
- except OSError as e:
- logging.exception(e)
- return False
-
-
-def MakeTempDir(base_dir):
- """Make a temp directory based on the given path and return its path.
-
- Args:
- base_dir: string, base directory to make temp directory.
-
- Returns:
- string, relative path to created temp directory
- """
- Makedirs(base_dir)
- return tempfile.mkdtemp(dir=base_dir)
\ No newline at end of file
diff --git a/utils/python/io/file_util_test.py b/utils/python/io/file_util_test.py
deleted file mode 100644
index bb59a3c..0000000
--- a/utils/python/io/file_util_test.py
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/usr/bin/env python
-#
-# 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.
-#
-
-import os
-import random
-import string
-import unittest
-
-from vts.utils.python.io import file_util
-
-
-class FileUtilTest(unittest.TestCase):
- def setUp(self):
- """Resets generated directory list"""
- self._dirs = []
-
- def tearDown(self):
- """Removes existing directories"""
- for path in self._dirs:
- file_util.Rmdirs(path)
-
- def testMakeAndRemoveDirs(self):
- """Tests making and removing directories """
- dir_name = ''.join(
- random.choice(string.ascii_lowercase + string.digits)
- for _ in range(12))
- self._dirs.append(dir_name)
-
- # make non-existing directory
- result = file_util.Makedirs(dir_name)
- self.assertEqual(True, result)
-
- # make existing directory
- result = file_util.Makedirs(dir_name)
- self.assertEqual(False, result)
-
- # delete existing directory
- result = file_util.Rmdirs(dir_name)
- self.assertEqual(True, result)
-
- # delete non-existing directory
- result = file_util.Rmdirs(dir_name)
- self.assertEqual(False, result)
-
- def testMakeTempDir(self):
- """Tests making temp directory """
- base_dir = ''.join(
- random.choice(string.ascii_lowercase + string.digits)
- for _ in range(12))
- self._dirs.append(base_dir)
-
- # make temp directory
- result = file_util.MakeTempDir(base_dir)
- self.assertTrue(os.path.join(base_dir, "tmp"))
-
- def testMakeException(self):
- """Tests making directory and raise exception """
- dir_name = ''.join(
- random.choice(string.ascii_lowercase + string.digits)
- for _ in range(12))
- self._dirs.append(dir_name)
-
- file_util.Makedirs(dir_name)
- self.assertRaises(Exception,
- file_util.Makedirs(dir_name, skip_if_exists=False))
-
- def testRemoveException(self):
- """Tests removing directory and raise exception """
- dir_name = ''.join(
- random.choice(string.ascii_lowercase + string.digits)
- for _ in range(12))
- self._dirs.append(dir_name)
-
- link_name = ''.join(
- random.choice(string.ascii_lowercase + string.digits)
- for _ in range(12))
-
- file_util.Makedirs(dir_name)
- os.symlink(dir_name, link_name)
- try:
- self.assertRaises(Exception,
- file_util.Rmdirs(link_name, ignore_errors=False))
- finally:
- os.remove(link_name)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/utils/python/mirror/__init__.py b/utils/python/mirror/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/mirror/__init__.py
+++ /dev/null
diff --git a/utils/python/mirror/hal_mirror.py b/utils/python/mirror/hal_mirror.py
deleted file mode 100644
index 8fdb56a..0000000
--- a/utils/python/mirror/hal_mirror.py
+++ /dev/null
@@ -1,213 +0,0 @@
-#
-# 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.
-#
-
-import copy
-import logging
-import random
-import sys
-
-from google.protobuf import text_format
-
-from vts.proto import AndroidSystemControlMessage_pb2 as ASysCtrlMsg
-from vts.proto import ComponentSpecificationMessage_pb2 as CompSpecMsg
-from vts.utils.python.fuzzer import FuzzerUtils
-from vts.utils.python.mirror import native_entity_mirror
-from vts.utils.python.mirror import py2pb
-
-_DEFAULT_TARGET_BASE_PATHS = ["/system/lib64/hw"]
-_DEFAULT_HWBINDER_SERVICE = "default"
-
-INTERFACE = "interface"
-API = "api"
-
-
-class MirrorObjectError(Exception):
- """Raised when there is a general error in manipulating a mirror object."""
- pass
-
-
-class HalMirror(native_entity_mirror.NativeEntityMirror):
- """The class that acts as the mirror to an Android device's HAL layer.
-
- This class exists on the host and can be used to communicate to a
- particular HIDL HAL on the target side.
-
- Attributes:
- _callback_server: the instance of a callback server.
- """
-
- def __init__(self,
- client,
- callback_server,
- hal_driver_id=None,
- if_spec_message=None,
- caller_uid=None):
- super(HalMirror, self).__init__(client, hal_driver_id, if_spec_message,
- caller_uid)
- self._callback_server = callback_server
-
- def InitHalDriver(self, target_type, target_version_major,
- target_version_minor, target_package,
- target_component_name, hw_binder_service_name,
- handler_name, bits, is_test_hal):
- """Initiates the driver for a HIDL HAL on the target device and loads
- the interface specification message.
-
- Args:
- target_type: string, the target type name (e.g., light, camera).
- target_version_major:
- int, the target component major version (e.g., 1.0 -> 1).
- target_version_minor:
- int, the target component minor version (e.g., 1.0 -> 0).
- target_package: . separated string (e.g., a.b.c) to denote the
- package name of target component.
- target_component_name: string, the target componet name (e.g., INfc).
- hw_binder_service_name: string, name of the HAL service instance
- (e.g. default)
- handler_name: string, the name of the handler. target_type is used
- by default.
- bits: integer, processor architecture indicator: 32 or 64.
- is_test_hal: bool, whether the HAL service is a test HAL
- (e.g. msgq).
-
- Raises:
- errors.ComponentLoadingError is raised when error occurs trying to
- create a MirrorObject.
- """
- driver_id = self.LaunchMirrorDriver(
- ASysCtrlMsg.VTS_DRIVER_TYPE_HAL_HIDL,
- "hal_hidl",
- target_type,
- target_version_major,
- target_version_minor,
- target_package=target_package,
- target_component_name=target_component_name,
- handler_name=handler_name,
- hw_binder_service_name=hw_binder_service_name,
- bits=bits,
- is_test_hal=is_test_hal)
- self._driver_id = driver_id
-
- #TODO: ListApis assumes only one HAL is loaded at a time, need to
- # figure out a way to get the api_spec when we want to test
- # multiple HALs together.
- found_api_spec = self._client.ListApis()
- if not found_api_spec:
- raise errors.ComponentLoadingError(
- "No API found for %s" % target_type)
- if_spec_msg = CompSpecMsg.ComponentSpecificationMessage()
- text_format.Merge(found_api_spec, if_spec_msg)
-
- self._if_spec_msg = if_spec_msg
-
- def GetCallbackFunctionID(self, function_pointer):
- """Gets registsred callback function id for the given function_pointer.
-
- Args:
- function_pointer: the callback function pointer.
-
- Returns:
- Id for the call back function registered with callback server.
- """
- if self._callback_server:
- id = self._callback_server.GetCallbackId(function_pointer)
- if id is None:
- id = self._callback_server.RegisterCallback(function_pointer)
- return str(id)
- else:
- raise MirrorObjectError("callback server is not started.")
-
- def GetHidlCallbackInterface(self, interface_name, **kwargs):
- """Gets the ProtoBuf message for a callback interface based on args.
-
- Args:
- interface_name: string, the callback interface name.
- **kwargs: a dict for the arg name and value pairs
-
- Returns:
- VariableSpecificationMessage that contains the callback interface
- description.
- """
- var_msg = CompSpecMsg.VariableSpecificationMessage()
- var_msg.name = interface_name
- var_msg.type = CompSpecMsg.TYPE_FUNCTION_POINTER
- var_msg.is_callback = True
-
- msg = self._if_spec_msg
- specification = self._client.ReadSpecification(
- interface_name, msg.component_class, msg.component_type,
- msg.component_type_version_major, msg.component_type_version_minor,
- msg.package)
- logging.debug("specification: %s", specification)
- interface = getattr(specification, INTERFACE, None)
- apis = getattr(interface, API, [])
- for api in apis:
- function_pointer = None
- if api.name in kwargs:
- function_pointer = kwargs[api.name]
- else:
-
- def stub(*args):
- """Stub implementation for any callback function."""
- logging.debug(
- "Entering stub implementation"
- " for callback function: %s", api.name)
- for arg_index in range(len(args)):
- logging.debug("arg%s: %s", arg_index, args[arg_index])
-
- function_pointer = stub
- func_pt_msg = var_msg.function_pointer.add()
- func_pt_msg.function_name = api.name
- func_pt_msg.id = self.GetCallbackFunctionID(function_pointer)
-
- return var_msg
-
- def GetHidlTypeInterface(self, interface_name):
- """Gets a HalMirror for HIDL HAL types specification.
-
- Args:
- interface_name: string, the name of a target interface to read.
- """
- return self.GetHalMirrorForInterface(interface_name)
-
- def GetHalMirrorForInterface(self, interface_name, driver_id=None):
- """Gets a HalMirror for a HIDL HAL interface.
-
- Args:
- interface_name: string, the name of a target interface to read.
- driver_id: int, driver is of the corresponding HIDL HAL interface.
-
- Returns:
- a host-side mirror of a HIDL HAL interface.
- """
- if not self._if_spec_msg:
- raise MirrorObjectError("specification is not loaded")
- msg = self._if_spec_msg
- found_api_spec = self._client.ReadSpecification(
- interface_name,
- msg.component_class,
- msg.component_type,
- msg.component_type_version_major,
- msg.component_type_version_minor,
- msg.package,
- recursive=True)
-
- logging.debug("found_api_spec %s", found_api_spec)
- if not driver_id:
- driver_id = self._driver_id
- # Instantiate a MirrorObject and return it.
- return HalMirror(self._client, self._callback_server, driver_id,
- found_api_spec)
diff --git a/utils/python/mirror/lib_mirror.py b/utils/python/mirror/lib_mirror.py
deleted file mode 100644
index 02fd649..0000000
--- a/utils/python/mirror/lib_mirror.py
+++ /dev/null
@@ -1,103 +0,0 @@
-#
-# 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.
-#
-
-import logging
-
-from google.protobuf import text_format
-
-from vts.runners.host import errors
-from vts.proto import AndroidSystemControlMessage_pb2 as ASysCtrlMsg
-from vts.proto import ComponentSpecificationMessage_pb2 as CompSpecMsg
-from vts.utils.python.mirror import native_entity_mirror
-
-
-class LibMirror(native_entity_mirror.NativeEntityMirror):
- """The class that acts as the mirror to an Android device's Lib layer.
-
- This class holds and manages the life cycle of multiple mirror objects that
- map to different lib components.
-
- One can use this class to create and destroy a lib mirror object.
- """
-
- def InitLibDriver(self, target_type, target_version_major,
- target_version_minor, target_package, target_filename,
- target_basepaths, handler_name, bits):
- """Initiates the driver for a lib on the target device and loads
- the interface specification message.
-
- Args:
- target_type: string, the target type name (e.g., light, camera).
- target_version_major:
- int, the target component major version (e.g. 1.0 -> 1).
- target_version_minor:
- int, the target component minor version (e.g. 1.0 -> 0).
- target_package: . separated string (e.g., a.b.c) to denote the
- package name of target component.
- target_filename: string, the target file name (e.g., libm.so).
- target_basepaths: list of strings, the paths to look for target
- files in.
- handler_name: string, the name of the handler. target_type is used
- by default.
- bits: integer, processor architecture indicator: 32 or 64.
- """
- # Get all the libs available on the target.
- lib_list = self._client.ListHals(target_basepaths)
- if not lib_list:
- raise errors.ComponentLoadingError(
- "Could not find any lib under path %s" % target_basepaths)
- logging.debug(lib_list)
-
- # Find the corresponding filename for Lib target type.
- if target_filename is not None:
- for name in lib_list:
- if name.endswith(target_filename):
- target_filename = name
- break
- else:
- for name in lib_list:
- if target_type in name:
- # TODO: check more exactly (e.g., multiple hits).
- target_filename = name
-
- if not target_filename:
- raise errors.ComponentLoadingError(
- "No file found for target type %s." % target_type)
-
- driver_id = self.LaunchMirrorDriver(
- ASysCtrlMsg.VTS_DRIVER_TYPE_HAL_CONVENTIONAL,
- "lib_shared",
- target_type,
- target_version_major,
- target_version_minor,
- target_package=target_package,
- target_filename=target_filename,
- handler_name=handler_name,
- bits=bits)
-
- self._driver_id = driver_id
-
- #TODO: ListApis assumes only one lib is loaded at a time, need to
- # figure out a way to get the api_spec when we want to test
- # multiple libs together.
- found_api_spec = self._client.ListApis()
- if not found_api_spec:
- raise errors.ComponentLoadingError(
- "No API found for %s" % target_type)
- if_spec_msg = CompSpecMsg.ComponentSpecificationMessage()
- text_format.Merge(found_api_spec, if_spec_msg)
-
- self._if_spec_msg = if_spec_msg
diff --git a/utils/python/mirror/mirror_object.py b/utils/python/mirror/mirror_object.py
deleted file mode 100644
index a3cc988..0000000
--- a/utils/python/mirror/mirror_object.py
+++ /dev/null
@@ -1,167 +0,0 @@
-#
-# 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.
-#
-
-import logging
-
-from vts.runners.host import errors
-
-_DEFAULT_HWBINDER_SERVICE = "default"
-
-COMPONENT_CLASS_DICT = {
- "hal_conventional": 1,
- "hal_conventional_submodule": 2,
- "hal_legacy": 3,
- "hal_hidl": 4,
- "hal_hidl_wrapped_conventional": 5,
- "lib_shared": 11
-}
-
-COMPONENT_TYPE_DICT = {
- "audio": 1,
- "camera": 2,
- "gps": 3,
- "gnss": 3,
- "light": 4,
- "wifi": 5,
- "mobile": 6,
- "bluetooth": 7,
- "nfc": 8,
- "vibrator": 12,
- "thermal": 13,
- "tv_input": 14,
- "tv_cec": 15,
- "sensors": 16,
- "vehicle": 17,
- "vr": 18,
- "graphics_allocator": 19,
- "graphics_mapper": 20,
- "radio": 21,
- "contexthub": 22,
- "graphics_composer": 23,
- "media_omx": 24,
- "tests_msgq": 25,
- "tests_memory": 26,
- "dumpstate": 27,
- "media_c2": 28,
- "bionic_libm": 1001,
- "bionic_libc": 1002,
- "vndk_libcutils": 1101
-}
-
-
-class MirrorObject(object):
- """The class that mirrors objects on the native side.
-
- Attributes:
- _client: VtsTcpClient, the client instance that can be used to send
- commands to the target-side's agent.
- _caller_uid: string, the caller's UID if not None.
- """
-
- def __init__(self, client, caller_uid=None):
- self._client = client
- self._caller_uid = caller_uid
-
- def CleanUp(self):
- if self._client:
- self._client.Disconnect()
-
- def SetCallerUid(self, uid):
- """Sets target-side caller's UID.
-
- Args:
- uid: string, the caller's UID.
- """
- self._caller_uid = uid
-
- def LaunchMirrorDriver(self,
- driver_type,
- target_class,
- target_type,
- target_version_major,
- target_version_minor,
- target_package="",
- target_filename=None,
- target_component_name=None,
- handler_name=None,
- service_name=None,
- hw_binder_service_name=_DEFAULT_HWBINDER_SERVICE,
- bits=64,
- is_test_hal=False):
- """Initiates the driver for a lib on the target device and creates a top
- level MirroObject for it.
-
- Args:
- driver_type: type of
- target_class: string, the target class name (e.g., lib).
- target_type: string, the target type name (e.g., light, camera).
- target_version_major:
- int, the target component major version (e.g. 1.0 -> 1).
- target_version_minor:
- int, the target component minor version (e.g. 1.0 -> 0).
- target_basepaths: list of strings, the paths to look for target
- files in. Default is _DEFAULT_TARGET_BASE_PATHS.
- target_package: . separated string (e.g., a.b.c) to denote the
- package name of target component.
- target_filename: string, the target file name (e.g., libm.so).
- handler_name: string, the name of the handler. target_type is used
- by default.
- bits: integer, processor architecture indicator: 32 or 64.
- Default is 64 bits.
- is_test_hal: bool, whether the HAL service is a test HAL
- (e.g. msgq).
-
- Raises:
- errors.ComponentLoadingError is raised when error occurs trying to
- create a MirrorObject.
- """
- if bits not in [32, 64]:
- raise error.ComponentLoadingError(
- "Invalid value for bits: %s" % bits)
- if not handler_name:
- handler_name = target_type
- if not service_name:
- service_name = "vts_driver_%s" % handler_name
-
- # Launch the corresponding driver of the requested HAL on the target.
- logging.debug("Init the driver service for %s", target_type)
- target_class_id = COMPONENT_CLASS_DICT[target_class.lower()]
- target_type_id = COMPONENT_TYPE_DICT[target_type.lower()]
-
- driver_id = self._client.LaunchDriverService(
- driver_type=driver_type,
- service_name=service_name,
- bits=bits,
- file_path=target_filename,
- target_class=target_class_id,
- target_type=target_type_id,
- target_version_major=target_version_major,
- target_version_minor=target_version_minor,
- target_package=target_package,
- target_component_name=target_component_name,
- hw_binder_service_name=hw_binder_service_name,
- is_test_hal=is_test_hal)
-
- if driver_id == -1:
- raise errors.ComponentLoadingError(
- "Failed to launch driver service %s from file path %s" %
- (target_type, target_filename))
-
- return driver_id
-
- def Ping(self):
- """Returns true iff pinging the agent is successful, False otherwise."""
- return self._client.Ping()
diff --git a/utils/python/mirror/mirror_tracker.py b/utils/python/mirror/mirror_tracker.py
deleted file mode 100644
index a53a310..0000000
--- a/utils/python/mirror/mirror_tracker.py
+++ /dev/null
@@ -1,587 +0,0 @@
-#
-# 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.
-#
-
-import logging
-
-from vts.proto import AndroidSystemControlMessage_pb2 as ASysCtrlMsg
-from vts.runners.host import const
-from vts.runners.host import errors
-from vts.runners.host.tcp_client import vts_tcp_client
-from vts.runners.host.tcp_server import callback_server
-from vts.utils.python.mirror import hal_mirror
-from vts.utils.python.mirror import lib_mirror
-from vts.utils.python.mirror import shell_mirror
-from vts.utils.python.mirror import resource_mirror
-
-_DEFAULT_TARGET_BASE_PATHS = ["/system/lib64/hw"]
-_DEFAULT_HWBINDER_SERVICE = "default"
-_DEFAULT_SHELL_NAME = "_default"
-_MAX_ADB_SHELL_LENGTH = 950
-
-
-class MirrorTracker(object):
- """The class tracks all mirror objects on the host side.
-
- Attributes:
- _host_command_port: int, the host-side port for command-response
- sessions.
- _host_callback_port: int, the host-side port for callback sessions.
- _adb: An AdbProxy object used for interacting with the device via adb.
- _registered_mirrors: dict, key is mirror handler name, value is the
- mirror object.
- _callback_server: VtsTcpServer, the server that receives and handles
- callback messages from target side.
- shell_default_nohup: bool, whether to use nohup by default in shell commands.
- """
-
- def __init__(self,
- host_command_port,
- host_callback_port=None,
- start_callback_server=False,
- adb=None):
- self._host_command_port = host_command_port
- self._host_callback_port = host_callback_port
- self._adb = adb
- self._registered_mirrors = {}
- self._callback_server = None
- self.shell_default_nohup = False
- if start_callback_server:
- self._StartCallbackServer()
-
- def __del__(self):
- self.CleanUp()
-
- def CleanUp(self):
- """Shutdown services and release resources held by the registered mirrors.
- """
- for mirror in self._registered_mirrors.values():
- mirror.CleanUp()
- self._registered_mirrors = {}
- if self._callback_server:
- self._callback_server.Stop()
- self._callback_server = None
-
- def RemoveMirror(self, mirror_name):
- self._registered_mirrors[mirror_name].CleanUp()
- self._registered_mirrors.pop(mirror_name)
-
- def _StartCallbackServer(self):
- """Starts the callback server.
-
- Raises:
- errors.ComponentLoadingError is raised if the callback server fails
- to start.
- """
- self._callback_server = callback_server.CallbackServer()
- _, port = self._callback_server.Start(self._host_callback_port)
- if port != self._host_callback_port:
- raise errors.ComponentLoadingError(
- "Failed to start a callback TcpServer at port %s" %
- self._host_callback_port)
-
- def Heal(self):
- """Performs a self healing.
-
- Includes self diagnosis that looks for any framework errors.
-
- Returns:
- bool, True if everything is ok; False otherwise.
- """
- res = all(map(lambda shell: shell.Heal(), self._registered_mirrors.values()))
-
- if not res:
- logging.error('Self diagnosis found problems in mirror_tracker.')
-
- return res
-
- def InitFmq(self,
- existing_queue=None,
- new_queue_name=None,
- data_type="uint16_t",
- sync=True,
- queue_size=0,
- blocking=False,
- reset_pointers=True,
- client=None):
- """Initializes a fast message queue object.
-
- This method will initialize a fast message queue object on the target side,
- create a mirror object for the FMQ, and register it in the tracker.
-
- Args:
- existing_queue: string or MirrorObject.
- This argument identifies an existing queue mirror object.
- If specified, it will tell the target driver to create a
- new message queue object based on an existing message queue.
- If it is None, that means creating a brand new message queue.
- new_queue_name: string, name of the new queue, used as key in the tracker.
- If not specified, this function dynamically generates a name.
- data_type: string, type of data in the queue.
- sync: bool, whether the queue is synchronized (only has one reader).
- queue_size: int, size of the queue.
- blocking: bool, whether blocking is enabled.
- reset_pointers: bool, whether to reset read/write pointers when
- creating a new message queue object based on an existing message queue.
- client: VtsTcpClient, if an existing session should be used.
- If not specified, creates a new one.
-
- Returns:
- ResourcFmqMirror object,
- it allows users to directly call methods on the mirror object.
- """
- # Check if queue name already exists in tracker.
- if new_queue_name is not None and new_queue_name in self._registered_mirrors:
- logging.error("Queue name already exists in tracker.")
- return None
-
- # Need to initialize a client if caller doesn't provide one.
- if client is None:
- client = vts_tcp_client.VtsTcpClient()
- client.Connect(
- command_port=self._host_command_port,
- callback_port=self._host_callback_port)
-
- # Create a new queue by default.
- existing_queue_id = -1
- # Check if caller wants to create a queue object based on
- # an existing queue object.
- if existing_queue is not None:
- # Check if caller provides a string.
- if type(existing_queue) == str:
- if existing_queue in self._registered_mirrors:
- data_type = self._registered_mirrors[
- existing_queue].dataType
- sync = self._registered_mirrors[
- existing_queue].sync
- existing_queue_id = self._registered_mirrors[
- existing_queue].queueId
- else:
- logging.error("Nonexisting queue name in mirror_tracker.")
- return None
- # Check if caller provides a resource mirror object.
- elif isinstance(existing_queue, resource_mirror.ResourceFmqMirror):
- data_type = existing_queue.dataType
- sync = existing_queue.sync
- existing_queue_id = existing_queue.queueId
- else:
- logging.error(
- "Unsupported way of finding an existing queue object.")
- return None
-
- # Create a resource mirror object.
- mirror = resource_mirror.ResourceFmqMirror(data_type, sync, client)
- mirror._create(existing_queue_id, queue_size, blocking, reset_pointers)
- if mirror.queueId == -1:
- # Failed to create queue object, error logged in resource_mirror.
- return None
-
- # Needs to dynamically generate queue name if caller doesn't provide one
- if new_queue_name is None:
- new_queue_name = "queue_id_" + str(mirror._queue_id)
- self._registered_mirrors[new_queue_name] = mirror
- return mirror
-
- def InitHidlMemory(self, mem_size=0, client=None, mem_name=None):
- """Initialize a hidl_memory object.
-
- This method will initialize a hidl_memory object on the target side,
- create a mirror object, and register it in the tracker.
-
- Args:
- mem_size: int, size of the memory region.
- client: VtsTcpClient, if an existing session should be used.
- If not specified, creates a new one.
- mem_name: string, name of the memory region.
- If not specified, dynamically assign the memory region a name.
-
- Returns:
- ResourceHidlMemoryMirror object,
- it allows users to directly call methods on the mirror object.
- """
- # Check if mem_name already exists in tracker.
- if mem_name is not None and mem_name in self._registered_mirrors:
- logging.error("Memory name already exists in tracker.")
- return None
-
- # Need to initialize a client if caller doesn't provide one.
- if client is None:
- client = vts_tcp_client.VtsTcpClient()
- client.Connect(
- command_port=self._host_command_port,
- callback_port=self._host_callback_port)
-
- # Create a resource_mirror object.
- mirror = resource_mirror.ResourceHidlMemoryMirror(client)
- mirror._allocate(mem_size)
- if mirror.memId == -1:
- # Failed to create memory object, error logged in resource_mirror.
- return None
-
- # Need to dynamically assign a memory name
- # if caller doesn't provide one.
- if mem_name is None:
- mem_name = "mem_id_" + str(mirror._mem_id)
- self._registered_mirrors[mem_name] = mirror
- return mirror
-
- def InitHidlHandleForSingleFile(self,
- filepath,
- mode,
- ints=[],
- client=None,
- handle_name=None):
- """Initialize a hidl_handle object.
-
- This method will initialize a hidl_handle object on the target side,
- create a mirror object, and register it in the tracker.
- TODO: Currently only support creating a handle for a single file.
- In the future, need to support arbitrary file descriptor types
- (e.g. socket, pipe), and more than one file.
-
- Args:
- filepath: string, path to the file.
- mode: string, specifying the mode to open the file.
- ints: int list, useful integers to be stored in handle object.
- client: VtsTcpClient, if an existing session should be used.
- If not specified, create a new one.
- handle_name: string, name of the handle object.
- If not specified, dynamically assign the handle object a name.
-
- Returns:
- ResourceHidlHandleMirror object,
- it allows users to directly call methods on the mirror object.
- """
- # Check if handle_name already exists in tracker.
- if handle_name is not None and handle_name in self._registered_mirrors:
- logging.error("Handle name already exists in tracker.")
- return None
-
- # Need to initialize a client if caller doesn't provide one.
- if not client:
- client = vts_tcp_client.VtsTcpClient()
- client.Connect(
- command_port=self._host_command_port,
- callback_port=self._host_callback_port)
-
- # Create a resource_mirror object.
- mirror = resource_mirror.ResourceHidlHandleMirror(client)
- mirror._createHandleForSingleFile(filepath, mode, ints)
- if mirror.handleId == -1:
- # Failed to create handle object, error logged in resource_mirror.
- return None
-
- # Need to dynamically assign a handle name
- # if caller doesn't provide one.
- if handle_name is None:
- handle_name = "handle_id_" + str(mirror._handle_id)
- self._registered_mirrors[handle_name] = mirror
- return mirror
-
- def InitHidlHal(self,
- target_type,
- target_version=None,
- target_package=None,
- target_component_name=None,
- target_basepaths=_DEFAULT_TARGET_BASE_PATHS,
- handler_name=None,
- hw_binder_service_name=_DEFAULT_HWBINDER_SERVICE,
- bits=64,
- target_version_major=None,
- target_version_minor=None,
- is_test_hal=False):
- """Initiates a handler for a particular HIDL HAL.
-
- This will initiate a driver service for a HAL on the target side, create
- a mirror object for a HAL, and register it in the tracker.
-
- Args:
- target_type: string, the target type name (e.g., light, camera).
- target_version (deprecated, now use major and minor versions):
- float, the target component version (e.g., 1.0).
- target_package: string, the package name of a target HIDL HAL.
- target_basepaths: list of strings, the paths to look for target
- files in. Default is _DEFAULT_TARGET_BASE_PATHS.
- handler_name: string, the name of the handler. target_type is used
- by default.
- hw_binder_service_name: string, the name of a HW binder service.
- bits: integer, processor architecture indicator: 32 or 64.
- target_version_major:
- int, the target component major version (e.g., 1.0 -> 1).
- target_version_minor:
- int, the target component minor version (e.g., 1.0 -> 0).
- If host doesn't provide major and minor versions separately,
- parse it from the float version of target_version.
- is_test_hal: bool, whether the HAL service is a test HAL
- (e.g. msgq).
-
- Raises:
- USERError if user doesn't provide a version of the HAL service.
- """
- target_version_major, target_version_minor = self.GetTargetVersion(
- target_version, target_version_major, target_version_minor)
- if not handler_name:
- handler_name = target_type
- client = vts_tcp_client.VtsTcpClient()
- client.Connect(
- command_port=self._host_command_port,
- callback_port=self._host_callback_port)
- mirror = hal_mirror.HalMirror(client, self._callback_server)
- mirror.InitHalDriver(target_type, target_version_major,
- target_version_minor, target_package,
- target_component_name, hw_binder_service_name,
- handler_name, bits, is_test_hal)
- self._registered_mirrors[target_type] = mirror
-
- def InitSharedLib(self,
- target_type,
- target_version=None,
- target_basepaths=_DEFAULT_TARGET_BASE_PATHS,
- target_package="",
- target_filename=None,
- handler_name=None,
- bits=64,
- target_version_major=None,
- target_version_minor=None):
- """Initiates a handler for a particular lib.
-
- This will initiate a driver service for a lib on the target side, create
- a mirror object for a lib, and register it in the tracker.
-
- Args:
- target_type: string, the target type name (e.g., light, camera).
- target_version (deprecated, now use major and minor versions):
- float, the target component version (e.g., 1.0).
- target_basepaths: list of strings, the paths to look for target
- files in. Default is _DEFAULT_TARGET_BASE_PATHS.
- target_package: . separated string (e.g., a.b.c) to denote the
- package name of target component.
- target_filename: string, the target file name (e.g., libm.so).
- handler_name: string, the name of the handler. target_type is used
- by default.
- bits: integer, processor architecture indicator: 32 or 64.
- target_version_major:
- int, the target component major version (e.g., 1.0 -> 1).
- target_version_minor:
- int, the target component minor version (e.g., 1.0 -> 0).
- If host doesn't provide major and minor versions separately,
- parse it from the float version of target_version.
-
- Raises:
- USERError if user doesn't provide a version of the HAL service.
- """
- target_version_major, target_version_minor = self.GetTargetVersion(
- target_version, target_version_major, target_version_minor)
- if not handler_name:
- handler_name = target_type
- client = vts_tcp_client.VtsTcpClient()
- client.Connect(command_port=self._host_command_port)
- mirror = lib_mirror.LibMirror(client)
- mirror.InitLibDriver(target_type, target_version_major,
- target_version_minor, target_package,
- target_filename, target_basepaths, handler_name,
- bits)
- self._registered_mirrors[handler_name] = mirror
-
- def InvokeTerminal(self, instance_name, bits=32):
- """Initiates a handler for a particular shell terminal.
-
- This will initiate a driver service for a shell on the target side,
- create a mirror object for the shell, and register it in the tracker.
-
- Args:
- instance_name: string, the shell terminal instance name.
- bits: integer, processor architecture indicator: 32 or 64.
- """
- if not instance_name:
- raise error.ComponentLoadingError("instance_name is None")
- if bits not in [32, 64]:
- raise error.ComponentLoadingError(
- "Invalid value for bits: %s" % bits)
-
- if instance_name in self._registered_mirrors:
- logging.warning("shell driver %s already exists", instance_name)
- return
-
- client = vts_tcp_client.VtsTcpClient()
- client.Connect(command_port=self._host_command_port)
-
- logging.debug("Init the driver service for shell, %s", instance_name)
- launched = client.LaunchDriverService(
- driver_type=ASysCtrlMsg.VTS_DRIVER_TYPE_SHELL,
- service_name="shell_" + instance_name,
- bits=bits)
-
- if not launched:
- raise errors.ComponentLoadingError(
- "Failed to launch shell driver service %s" % instance_name)
-
- mirror = shell_mirror.ShellMirror(client, self._adb)
- self._registered_mirrors[instance_name] = mirror
-
- def DisableShell(self):
- """Disables all registered shell mirrors."""
- for mirror in self._registered_mirrors.values():
- if not isinstance(mirror, shell_mirror.ShellMirror):
- logging.error("mirror object is not a shell mirror")
- continue
- mirror.enabled = False
-
- def Execute(self, commands, no_except=False, nohup=None):
- """Execute shell command(s).
-
- This method automatically decide whether to use adb shell or vts shell
- driver on the device based on performance benchmark results.
-
- The difference in the decision logic will only have impact on the performance, but
- will be transparent to the user of this method.
-
- The current logic is:
- 1. If shell_default_nohup is disabled and command
- list size is smaller or equal than 3, use adb shell. Otherwise, use
- shell driver (with nohup).
-
- 2. If adb shell is used, no_except will always be true.
-
- This is subject to further optimization.
-
- Args:
- commands: string or list or tuple, commands to execute on device.
- no_except: bool, whether to throw exceptions. If set to True,
- when exception happens, return code will be -1 and
- str(err) will be in stderr. Result will maintain the
- same length as with input commands.
- nohup: bool or None, True for using nohup for shell commands; False for
- not using nohup; None for using default setting.
-
- Returns:
- dictionary of list, command results that contains stdout,
- stderr, and exit_code.
- """
- if not isinstance(commands, (list, tuple)):
- commands = [commands]
-
- if nohup is None:
- nohup = self.shell_default_nohup
-
- # TODO(yuexima): further optimize the threshold and nohup adb command
- non_nohup_adb_threshold = 3
- if (not nohup and len(commands) <= non_nohup_adb_threshold
- and not filter(lambda cmd: len(cmd) > _MAX_ADB_SHELL_LENGTH, commands)):
- return self._ExecuteShellCmdViaAdbShell(commands)
- else:
- return self._ExecuteShellCmdViaVtsDriver(commands, no_except)
-
- def _ExecuteShellCmdViaVtsDriver(self, commands, no_except):
- """Execute shell command(s) using default shell terminal.
-
- Args:
- commands: string or list or tuple, commands to execute on device
- no_except: bool, whether to throw exceptions. If set to True,
- when exception happens, return code will be -1 and
- str(err) will be in stderr. Result will maintain the
- same length as with input command.
-
- Returns:
- dictionary of list, command results that contains stdout,
- stderr, and exit_code.
- """
- if _DEFAULT_SHELL_NAME not in self._registered_mirrors:
- self.InvokeTerminal(_DEFAULT_SHELL_NAME)
-
- return getattr(self, _DEFAULT_SHELL_NAME).Execute(commands, no_except)
-
- def _ExecuteShellCmdViaAdbShell(self, commands):
- """Execute shell command(s) using adb shell command.
-
- Args:
- commands: string or list or tuple, command to execute on device
-
- Returns:
- dictionary of list, command results that contains stdout,
- stderr, and exit_code.
- """
- all = {const.STDOUT: [],
- const.STDERR: [],
- const.EXIT_CODE: []}
-
- for cmd in commands:
- res = self._adb.shell(cmd, no_except=True)
- all[const.STDOUT].append(res[const.STDOUT])
- all[const.STDERR].append(res[const.STDERR])
- all[const.EXIT_CODE].append(res[const.EXIT_CODE])
-
- return all
-
- def SetConnTimeout(self, timeout):
- """Set remove shell connection timeout for default shell terminal.
-
- Args:
- timeout: int, TCP connection timeout in seconds.
- """
- if _DEFAULT_SHELL_NAME not in self._registered_mirrors:
- self.InvokeTerminal(_DEFAULT_SHELL_NAME)
- getattr(self, _DEFAULT_SHELL_NAME).SetConnTimeout(timeout)
-
- def GetTargetVersion(self, target_version, target_version_major,
- target_version_minor):
- """Get the actual target version provided by the host.
-
- If the host provides major and minor versions separately, directly return them.
- Otherwise, manually parse it from the float version.
- If all of them are None, raise a user error.
-
- Args:
- target_version: float, the target component HAL version (e.g. 1.0).
- target_version_major:
- int, the target component HAL major version (e.g. 1.0 -> 1).
- target_version_minor:
- int, the target component HAL minor version (e.g. 1.0 -> 0).
-
- Returns:
- two integers, actual major and minor HAL versions.
-
- Raises: user error, if no version is provided.
- """
- # Check if host provides major and minor versions separately
- if (target_version_minor != None and target_version_minor != None):
- return target_version_major, target_version_minor
-
- # If not, manually parse it from float version
- if (target_version != None):
- target_version_str = str(target_version)
- [target_version_major,
- target_version_minor] = target_version_str.split(".")
- return int(target_version_major), int(target_version_minor)
-
- raise errors.USERError("User has to provide a target version.")
-
- def GetTcpClient(self, mirror_name):
- """Gets the TCP client used in this tracker.
- Useful for reusing session to access shared data.
-
- Args:
- mirror_name: used to identify mirror object.
- """
- if mirror_name in self._registered_mirrors:
- return self._registered_mirrors[mirror_name]._client
- return None
-
- def __getattr__(self, name):
- if name in self._registered_mirrors:
- return self._registered_mirrors[name]
- else:
- logging.error("No mirror found with name: %s", name)
- return None
diff --git a/utils/python/mirror/native_entity_mirror.py b/utils/python/mirror/native_entity_mirror.py
deleted file mode 100644
index ded7c3f..0000000
--- a/utils/python/mirror/native_entity_mirror.py
+++ /dev/null
@@ -1,406 +0,0 @@
-#
-# 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.
-#
-
-import copy
-import logging
-import random
-import sys
-
-from google.protobuf import text_format
-
-from vts.proto import AndroidSystemControlMessage_pb2 as ASysCtrlMsg
-from vts.proto import ComponentSpecificationMessage_pb2 as CompSpecMsg
-from vts.utils.python.fuzzer import FuzzerUtils
-from vts.utils.python.mirror import mirror_object
-from vts.utils.python.mirror import py2pb
-from vts.utils.python.mirror import resource_mirror
-
-_DEFAULT_TARGET_BASE_PATHS = ["/system/lib64/hw"]
-_DEFAULT_HWBINDER_SERVICE = "default"
-
-INTERFACE = "interface"
-API = "api"
-
-
-class MirrorObjectError(Exception):
- """Raised when there is a general error in manipulating a mirror object."""
- pass
-
-
-class VtsEnum(object):
- """Enum's host-side mirror instance."""
-
- def __init__(self, attribute):
- logging.debug(attribute)
- for enumerator, scalar_value in zip(attribute.enum_value.enumerator,
- attribute.enum_value.scalar_value):
- setattr(self, enumerator,
- getattr(scalar_value, attribute.enum_value.scalar_type))
-
-
-class NativeEntityMirror(mirror_object.MirrorObject):
- """The class that acts as the mirror to an Android device's HAL layer.
-
- This is the base class used to communicate to a particular HAL or Lib in
- the VTS agent on the target side.
-
- Attributes:
- _client: the TCP client instance.
- _caller_uid: string, the caller's UID if not None.
- _if_spec_msg: the interface specification message of a host object to
- mirror.
- _last_raw_code_coverage_data: NativeCodeCoverageRawDataMessage,
- last seen raw code coverage data.
- """
-
- def __init__(self,
- client,
- driver_id=None,
- if_spec_message=None,
- caller_uid=None):
- super(NativeEntityMirror, self).__init__(client, caller_uid)
- self._driver_id = driver_id
- self._if_spec_msg = if_spec_message
- self._last_raw_code_coverage_data = None
-
- def GetApi(self, api_name):
- """Gets the ProtoBuf message for given api.
-
- Args:
- api_name: string, the name of the target function API.
-
- Returns:
- FunctionSpecificationMessage if found, None otherwise
- """
- logging.debug("GetAPI %s for %s", api_name, self._if_spec_msg)
- # handle reserved methods first.
- if api_name == "notifySyspropsChanged":
- func_msg = CompSpecMsg.FunctionSpecificationMessage()
- func_msg.name = api_name
- return func_msg
- if isinstance(self._if_spec_msg,
- CompSpecMsg.ComponentSpecificationMessage):
- if len(self._if_spec_msg.interface.api) > 0:
- for api in self._if_spec_msg.interface.api:
- if api.name == api_name:
- return copy.copy(api)
- else:
- logging.error("unknown spec type %s", type(self._if_spec_msg))
- sys.exit(1)
- return None
-
- def GetAttribute(self, attribute_name):
- """Gets the ProtoBuf message for given attribute.
-
- Args:
- attribute_name: string, the name of a target attribute
- (optionally excluding the namespace).
-
- Returns:
- VariableSpecificationMessage if found, None otherwise
- """
- if self._if_spec_msg.attribute:
- for attribute in self._if_spec_msg.attribute:
- if (not attribute.is_const and
- (attribute.name == attribute_name
- or attribute.name.endswith("::" + attribute_name))):
- return attribute
- if (self._if_spec_msg.interface
- and self._if_spec_msg.interface.attribute):
- for attribute in self._if_spec_msg.interface.attribute:
- if (not attribute.is_const and
- (attribute.name == attribute_name
- or attribute.name.endswith("::" + attribute_name))):
- return attribute
- return None
-
- def GetConstType(self, type_name):
- """Returns the ProtoBuf message for given const type.
-
- Args:
- type_name: string, the name of the target const data variable.
-
- Returns:
- VariableSpecificationMessage if found, None otherwise
- """
- try:
- if self._if_spec_msg.attribute:
- for attribute in self._if_spec_msg.attribute:
- if attribute.is_const and attribute.name == type_name:
- return attribute
- elif (attribute.type == CompSpecMsg.TYPE_ENUM
- and attribute.name.endswith(type_name)):
- return attribute
- if self._if_spec_msg.interface and self._if_spec_msg.interface.attribute:
- for attribute in self._if_spec_msg.interface.attribute:
- if attribute.is_const and attribute.name == type_name:
- return attribute
- elif (attribute.type == CompSpecMsg.TYPE_ENUM
- and attribute.name.endswith(type_name)):
- return attribute
- return None
- except AttributeError as e:
- # TODO: check in advance whether self._if_spec_msg Interface
- # SpecificationMessage.
- return None
-
- def Py2Pb(self, attribute_name, py_values):
- """Returns the ProtoBuf of a give Python values.
-
- Args:
- attribute_name: string, the name of a target attribute.
- py_values: Python values.
-
- Returns:
- Converted VariableSpecificationMessage if found, None otherwise
- """
- attribute_spec = self.GetAttribute(attribute_name)
- if attribute_spec:
- converted_attr = py2pb.Convert(attribute_spec, py_values)
- if converted_attr is None:
- raise MirrorObjectError(
- "Failed to convert attribute %s", attribute_spec)
- return converted_attr
- logging.error("Can not find attribute: %s", attribute_name)
- return None
-
- # TODO: Guard against calls to this function after self.CleanUp is called.
- def __getattr__(self, api_name, *args, **kwargs):
- """Calls a target component's API.
-
- Args:
- api_name: string, the name of an API function to call.
- *args: a list of arguments
- **kwargs: a dict for the arg name and value pairs
- """
-
- def RemoteCall(*args, **kwargs):
- """Dynamically calls a remote API and returns the result value."""
- func_msg = self.GetApi(api_name)
- if not func_msg:
- raise MirrorObjectError("api %s unknown", func_msg)
-
- logging.debug("remote call %s%s", api_name, args)
- if args:
- for arg_msg, value_msg in zip(func_msg.arg, args):
- logging.debug("arg msg %s", arg_msg)
- logging.debug("value %s", value_msg)
- if value_msg is not None:
- converted_msg = py2pb.Convert(arg_msg, value_msg)
- if converted_msg is None:
- raise MirrorObjectError("Failed to convert arg %s", value_msg)
- logging.debug("converted_message: %s", converted_msg)
- arg_msg.CopyFrom(converted_msg)
- else:
- # TODO: use kwargs
- for arg in func_msg.arg:
- # TODO: handle other
- if (arg.type == CompSpecMsg.TYPE_SCALAR
- and arg.scalar_type == "pointer"):
- arg.scalar_value.pointer = 0
- logging.debug(func_msg)
-
- call_msg = CompSpecMsg.FunctionCallMessage()
- if self._if_spec_msg.component_class:
- call_msg.component_class = self._if_spec_msg.component_class
- call_msg.hal_driver_id = self._driver_id
- call_msg.api.CopyFrom(func_msg)
- logging.debug("final msg %s", call_msg)
- results = self._client.CallApi(
- text_format.MessageToString(call_msg), self._caller_uid)
- if (isinstance(results, tuple) and len(results) == 2
- and isinstance(results[1], dict)
- and "coverage" in results[1]):
- self._last_raw_code_coverage_data = results[1]["coverage"]
- results = results[0]
-
- if isinstance(results, list): # Non-HIDL HAL does not return list.
- # Translate TYPE_HIDL_INTERFACE to halMirror.
- for i, _ in enumerate(results):
- result = results[i]
- if (not result or not isinstance(
- result, CompSpecMsg.VariableSpecificationMessage)):
- # no need to process the return values.
- continue
-
- if result.type == CompSpecMsg.TYPE_HIDL_INTERFACE:
- if result.hidl_interface_id <= -1:
- results[i] = None
- driver_id = result.hidl_interface_id
- nested_interface_name = \
- result.predefined_type.split("::")[-1]
- logging.debug("Nested interface name: %s",
- nested_interface_name)
- nested_interface = self.GetHalMirrorForInterface(
- nested_interface_name, driver_id)
- results[i] = nested_interface
- elif (result.type == CompSpecMsg.TYPE_FMQ_SYNC
- or result.type == CompSpecMsg.TYPE_FMQ_UNSYNC):
- if (result.fmq_value[0].fmq_id == -1):
- logging.error("Invalid new queue_id.")
- results[i] = None
- else:
- # Retrieve type of data in this FMQ.
- data_type = None
- # For scalar, read scalar_type field.
- if result.fmq_value[0].type == \
- CompSpecMsg.TYPE_SCALAR:
- data_type = result.fmq_value[0].scalar_type
- # For enum, struct, and union, read predefined_type
- # field.
- elif (result.fmq_value[0].type ==
- CompSpecMsg.TYPE_ENUM or
- result.fmq_value[0].type ==
- CompSpecMsg.TYPE_STRUCT or
- result.fmq_value[0].type ==
- CompSpecMsg.TYPE_UNION):
- data_type = result.fmq_value[0].predefined_type
-
- # Encounter an unknown type in FMQ.
- if data_type == None:
- logging.error(
- "Unknown type %d in the new FMQ.",
- result.fmq_value[0].type)
- results[i] = None
- continue
- sync = result.type == CompSpecMsg.TYPE_FMQ_SYNC
- fmq_mirror = resource_mirror.ResourceFmqMirror(
- data_type, sync, self._client,
- result.fmq_value[0].fmq_id)
- results[i] = fmq_mirror
- elif result.type == CompSpecMsg.TYPE_HIDL_MEMORY:
- if result.hidl_memory_value.mem_id == -1:
- logging.error("Invalid new mem_id.")
- results[i] = None
- else:
- mem_mirror = resource_mirror.ResourceHidlMemoryMirror(
- self._client, result.hidl_memory_value.mem_id)
- results[i] = mem_mirror
- elif result.type == CompSpecMsg.TYPE_HANDLE:
- if result.handle_value.handle_id == -1:
- logging.error("Invalid new handle_id.")
- results[i] = None
- else:
- handle_mirror = resource_mirror.ResourceHidlHandleMirror(
- self._client, result.handle_value.handle_id)
- results[i] = handle_mirror
- if len(results) == 1:
- # single return result, return the value directly.
- return results[0]
- return results
-
- def MessageGenerator(*args, **kwargs):
- """Dynamically generates a custom message instance."""
- if args:
- return self.Py2Pb(api_name, args)
- else:
- #TODO: handle kwargs
- return None
-
- #TODO: deprecate this or move it to a separate class.
- def MessageFuzzer(arg_msg):
- """Fuzz a custom message instance."""
- if not self.GetAttribute(api_name):
- raise MirrorObjectError("fuzz arg %s unknown" % arg_msg)
-
- if arg_msg.type == CompSpecMsg.TYPE_STRUCT:
- index = random.randint(0, len(arg_msg.struct_value))
- count = 0
- for struct_value in arg_msg.struct_value:
- if count == index:
- if struct_value.scalar_type == "uint32_t":
- struct_value.scalar_value.uint32_t ^= FuzzerUtils.mask_uint32_t(
- )
- elif struct_value.scalar_type == "int32_t":
- mask = FuzzerUtils.mask_int32_t()
- if mask == (1 << 31):
- struct_value.scalar_value.int32_t *= -1
- struct_value.scalar_value.int32_t += 1
- else:
- struct_value.scalar_value.int32_t ^= mask
- else:
- raise MirrorObjectError(
- "support %s" % struct_value.scalar_type)
- break
- count += 1
- logging.debug("fuzzed %s", arg_msg)
- else:
- raise MirrorObjectError(
- "unsupported fuzz message type %s." % arg_msg.type)
- return arg_msg
-
- def ConstGenerator():
- """Dynamically generates a const variable's value."""
- arg_msg = self.GetConstType(api_name)
- if not arg_msg:
- raise MirrorObjectError("const %s unknown" % arg_msg)
- logging.debug("check %s", api_name)
- if arg_msg.type == CompSpecMsg.TYPE_SCALAR:
- ret_v = getattr(arg_msg.scalar_value, arg_msg.scalar_type,
- None)
- if ret_v is None:
- raise MirrorObjectError("No value found for type %s in %s."
- % (arg_msg.scalar_type, api_name))
- return ret_v
- elif arg_msg.type == CompSpecMsg.TYPE_STRING:
- return arg_msg.string_value.message
- elif arg_msg.type == CompSpecMsg.TYPE_ENUM:
- return VtsEnum(arg_msg)
- raise MirrorObjectError("const %s not found" % api_name)
-
- # handle APIs.
- func_msg = self.GetApi(api_name)
- if func_msg:
- logging.debug("api %s", func_msg)
- return RemoteCall
-
- # handle attributes.
- arg_msg = self.GetConstType(api_name)
- if arg_msg:
- logging.debug("const %s *\n%s", api_name, arg_msg)
- return ConstGenerator()
-
- fuzz = False
- if api_name.endswith("_fuzz"):
- fuzz = True
- api_name = api_name[:-5]
- arg_msg = self.GetAttribute(api_name)
- if arg_msg:
- logging.debug("arg %s", arg_msg)
- if not fuzz:
- return MessageGenerator
- else:
- return MessageFuzzer
-
- raise MirrorObjectError("unknown api name %s" % api_name)
-
- def GetRawCodeCoverage(self):
- """Returns any measured raw code coverage data."""
- return self._last_raw_code_coverage_data
-
- def __str__(self):
- """Prints all the attributes and methods."""
- result = ""
- if self._if_spec_msg:
- if self._if_spec_msg.attribute:
- for attribute in self._if_spec_msg.attribute:
- result += "attribute %s\n" % attribute.name
- if self._if_spec_msg.interface:
- for attribute in self._if_spec_msg.interface.attribute:
- result += "interface attribute %s\n" % attribute.name
- for api in self._if_spec_msg.interface.api:
- result += "api %s\n" % api.name
- return result
diff --git a/utils/python/mirror/pb2py.py b/utils/python/mirror/pb2py.py
deleted file mode 100644
index b39f867..0000000
--- a/utils/python/mirror/pb2py.py
+++ /dev/null
@@ -1,182 +0,0 @@
-#
-# 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.
-#
-
-import logging
-import sys
-
-from vts.proto import ComponentSpecificationMessage_pb2 as CompSpecMsg
-
-
-def PbEnum2PyValue(var):
- """Converts VariableSecificationMessage (Enum) to Python value.
-
- Args:
- var: VariableSpecificationMessage to convert.
-
- Returns:
- a converted value.
- """
- return getattr(var.scalar_value, var.scalar_type)
-
-
-def PbMask2PyValue(var):
- """Converts VariableSecificationMessage (Mask) to Python value.
-
- Args:
- var: VariableSpecificationMessage to convert.
-
- Returns:
- a converted value.
- """
- return getattr(var.scalar_value, var.scalar_type)
-
-
-def PbScalar2PyValue(var):
- """Converts VariableSecificationMessage (Scalar) to Python value.
-
- Args:
- message: VariableSpecificationMessage to convert.
-
- Returns:
- Converted scalar value.
- """
- return getattr(var.scalar_value, var.scalar_type)
-
-
-def PbString2PyString(var):
- """Converts VTS VariableSecificationMessage (String) to Python string.
-
- Args:
- var: VariableSpecificationMessage to convert.
-
- Returns:
- Converted string.
- """
- return var.string_value.message
-
-
-def PbVector2PyList(var):
- """Converts VariableSecificationMessage (Vector) to a Python list.
-
- Args:
- var: VariableSpecificationMessage to convert.
-
- Returns:
- A converted list if valid, None otherwise.
- """
- result = []
- for curr_value in var.vector_value:
- if curr_value.type == CompSpecMsg.TYPE_SCALAR:
- result.append(PbScalar2PyValue(curr_value))
- elif curr_value.type == CompSpecMsg.TYPE_STRUCT:
- result.append(PbStruct2PyDict(curr_value))
- else:
- logging.error("unsupported type %s", curr_value.type)
- return None
- return result
-
-
-def PbArray2PyList(var):
- """Converts VariableSecificationMessage (Array) to a Python list.
-
- Args:
- var: VariableSpecificationMessage to convert.
-
- Returns:
- A converted list if valid, None otherwise
- """
- result = []
- for curr_value in var.vector_value:
- if curr_value.type == CompSpecMsg.TYPE_SCALAR:
- result.append(PbScalar2PyValue(curr_value))
- elif curr_value.type == CompSpecMsg.TYPE_STRUCT:
- result.append(PbStruct2PyDict(curr_value))
- else:
- logging.error("unsupported type %s", curr_value.type)
- return None
- return result
-
-
-def PbStruct2PyDict(var):
- """Converts VariableSecificationMessage (struct) to Python dict.
-
- Args:
- var: VariableSpecificationMessage to convert.
-
- Returns:
- a dict, containing the converted data if valid. None otherwise.
- """
- result = {}
- for attr in var.struct_value:
- if attr.type == CompSpecMsg.TYPE_ENUM:
- result[attr.name] = PbEnum2PyValue(attr)
- elif attr.type == CompSpecMsg.TYPE_SCALAR:
- result[attr.name] = PbScalar2PyValue(attr)
- elif attr.type == CompSpecMsg.TYPE_STRING:
- result[attr.name] = PbString2PyString(attr)
- elif attr.type == CompSpecMsg.TYPE_VECTOR:
- result[attr.name] = PbVector2PyList(attr)
- elif attr.type == CompSpecMsg.TYPE_STRUCT:
- result[attr.name] = PbStruct2PyDict(attr)
- elif attr.type == CompSpecMsg.TYPE_Array:
- result[attr.name] = PbArray2PyList(attr)
- else:
- logging.error("PyDict2PbStruct: unsupported type %s",
- attr.type)
- return None
- return result
-
-
-def PbPredefined2PyValue(var):
- """Converts VariableSecificationMessage (PREDEFINED_TYPE) to Python value.
-
- Args:
- var: VariableSpecificationMessage to convert.
-
- Returns:
- a converted value.
- """
- return var.predefined_type
-
-
-def Convert(var):
- """Converts VariableSecificationMessage to Python native data structure.
-
- Args:
- var: VariableSpecificationMessage of a target variable to convert.
-
- Returns:
- A list containing the converted Python values if valid. None otherwise.
- """
- if var.type == CompSpecMsg.TYPE_PREDEFINED:
- return PbPredefined2PyValue(var)
- elif var.type == CompSpecMsg.TYPE_SCALAR:
- return PbScalar2PyValue(var)
- elif var.type == CompSpecMsg.TYPE_VECTOR:
- return PbVector2PyList(var)
- elif var.type == CompSpecMsg.TYPE_STRUCT:
- return PbStruct2PyDict(var)
- elif var.type == CompSpecMsg.TYPE_ENUM:
- return PbEnum2PyValue(var)
- elif var.type == CompSpecMsg.TYPE_STRING:
- return PbString2PyString(var)
- elif var.type == CompSpecMsg.TYPE_MASK:
- return PbMask2PyValue(var)
- else:
- logging.error("Got unsupported callback arg type %s" % var.type)
- return None
-
- return message
diff --git a/utils/python/mirror/py2pb.py b/utils/python/mirror/py2pb.py
deleted file mode 100644
index edf9afa..0000000
--- a/utils/python/mirror/py2pb.py
+++ /dev/null
@@ -1,315 +0,0 @@
-#
-# 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.
-#
-
-import logging
-import sys
-
-from vts.proto import ComponentSpecificationMessage_pb2 as CompSpecMsg
-
-
-def PyValue2PbEnum(message, pb_spec, py_value):
- """Converts Python value to VTS VariableSecificationMessage (Enum).
-
- Args:
- message: VariableSpecificationMessage is the current and result
- value message.
- pb_spec: VariableSpecificationMessage which captures the
- specification of a target attribute.
- py_value: Python value provided by a test case.
-
- Returns:
- Converted VariableSpecificationMessage if found, None otherwise
- """
- if pb_spec.name:
- message.name = pb_spec.name
- message.type = CompSpecMsg.TYPE_ENUM
- # Look for the enum definition and retrieve the scalar type.
- scalar_type = pb_spec.enum_value.scalar_type
- if scalar_type != "":
- # If the scalar type definition is found, set it and return.
- setattr(message.scalar_value, scalar_type, py_value)
- return
- # Use default scalar_type int32_t for enum definition if the definition
- # is not found.
- setattr(message.scalar_value, "int32_t", py_value)
-
-
-def PyValue2PbScalar(message, pb_spec, py_value):
- """Converts Python value to VTS VariableSecificationMessage (Scalar).
-
- Args:
- message: VariableSpecificationMessage is the current and result
- value message.
- pb_spec: VariableSpecificationMessage which captures the
- specification of a target attribute.
- py_value: Python value provided by a test case.
-
- Returns:
- Converted VariableSpecificationMessage if found, None otherwise
- """
- if pb_spec.name:
- message.name = pb_spec.name
- message.type = CompSpecMsg.TYPE_SCALAR
- message.scalar_type = pb_spec.scalar_type
- setattr(message.scalar_value, pb_spec.scalar_type, py_value)
-
-
-def PyString2PbString(message, pb_spec, py_value):
- """Converts Python string to VTS VariableSecificationMessage (String).
-
- Args:
- message: VariableSpecificationMessage is the current and result
- value message.
- pb_spec: VariableSpecificationMessage which captures the
- specification of a target attribute.
- py_value: Python value provided by a test case.
-
- Returns:
- Converted VariableSpecificationMessage if found, None otherwise
- """
- if pb_spec.name:
- message.name = pb_spec.name
- message.type = CompSpecMsg.TYPE_STRING
- message.string_value.message = py_value
- message.string_value.length = len(py_value)
-
-
-def PyList2PbVector(message, pb_spec, py_value):
- """Converts Python list value to VTS VariableSecificationMessage (Vector).
-
- Args:
- message: VariableSpecificationMessage is the current and result
- value message.
- pb_spec: VariableSpecificationMessage which captures the
- specification of a target attribute.
- py_value: Python value provided by a test case.
-
- Returns:
- Converted VariableSpecificationMessage if found, None otherwise
- """
- if pb_spec.name:
- message.name = pb_spec.name
- message.type = CompSpecMsg.TYPE_VECTOR
- if len(py_value) == 0:
- return message
-
- vector_spec = pb_spec.vector_value[0]
- for curr_value in py_value:
- new_vector_message = message.vector_value.add()
- new_vector_message.CopyFrom(Convert(vector_spec, curr_value))
- message.vector_size = len(py_value)
- return message
-
-
-def FindSubStructType(pb_spec, sub_struct_name):
- """Finds a specific sub_struct type.
-
- Args:
- pb_spec: VariableSpecificationMessage which captures the
- specification of a target attribute.
- sub_struct_name: string, the name of a sub struct to look up.
-
- Returns:
- VariableSpecificationMessage if found or None otherwise.
- """
- for sub_struct in pb_spec.sub_struct:
- if sub_struct.name == sub_struct_name:
- return sub_struct
- return None
-
-
-def FindSubUnionType(pb_spec, sub_union_name):
- """Finds a specific sub_union type.
-
- Args:
- pb_spec: VariableSpecificationMessage which captures the
- specification of a target attribute.
- sub_union_name: string, the name of a sub union to look up.
-
- Returns:
- VariableSpecificationMessage if found or None otherwise.
- """
- for sub_union in pb_spec.sub_union:
- if sub_union.name == sub_union_name:
- return sub_union
- return None
-
-
-def PyDict2PbStruct(message, pb_spec, py_value):
- """Converts Python dict to VTS VariableSecificationMessage (struct).
-
- Args:
- pb_spec: VariableSpecificationMessage which captures the
- specification of a target attribute.
- py_value: A dictionary that represents a struct.
-
- Returns:
- Converted VariableSpecificationMessage if found, None otherwise
- """
- if pb_spec.name:
- message.name = pb_spec.name
- message.type = CompSpecMsg.TYPE_STRUCT
- provided_attrs = set(py_value.keys())
- for attr in pb_spec.struct_value:
- if attr.name in py_value:
- provided_attrs.remove(attr.name)
- curr_value = py_value[attr.name]
- attr_msg = message.struct_value.add()
- if attr.type == CompSpecMsg.TYPE_ENUM:
- PyValue2PbEnum(attr_msg, attr, curr_value)
- elif attr.type == CompSpecMsg.TYPE_SCALAR:
- PyValue2PbScalar(attr_msg, attr, curr_value)
- elif attr.type == CompSpecMsg.TYPE_STRING:
- PyString2PbString(attr_msg, attr, curr_value)
- elif attr.type == CompSpecMsg.TYPE_VECTOR:
- PyList2PbVector(attr_msg, attr, curr_value)
- elif attr.type == CompSpecMsg.TYPE_STRUCT:
- sub_attr = FindSubStructType(pb_spec, attr.predefined_type)
- if sub_attr:
- PyDict2PbStruct(attr_msg, sub_attr, curr_value)
- else:
- logging.error("PyDict2PbStruct: substruct not found.")
- return None
- elif attr.type == CompSpecMsg.TYPE_UNION:
- sub_attr = FindSubStructType(pb_spec, attr.predefined_type)
- if sub_attr:
- PyDict2PbUnion(attr_msg, sub_attr, curr_value)
- else:
- logging.error("PyDict2PbStruct: subunion not found.")
- return None
- else:
- logging.error("PyDict2PbStruct: unsupported type %s",
- attr.type)
- return None
- else:
- # TODO: instead crash the test, consider to generate default value
- # in case not provided in the py_value.
- logging.error("PyDict2PbStruct: attr %s not provided", attr.name)
- return None
- if len(provided_attrs) > 0:
- logging.error("PyDict2PbStruct: provided dictionary included elements" +
- " not part of the type being converted to: %s",
- provided_attrs)
- return None
- return message
-
-
-def PyDict2PbUnion(message, pb_spec, py_value):
- """Converts Python dict to VTS VariableSecificationMessage (union).
-
- Args:
- pb_spec: VariableSpecificationMessage which captures the
- specification of a target attribute.
- py_value: A dictionary that represents a struct.
-
- Returns:
- Converted VariableSpecificationMessage if found, None otherwise
- """
- if len(py_value) > 1:
- logging.error("PyDict2PbUnion: Union only allows specifying " +
- "at most one field. Current Python dictionary " +
- "has size %d", len(py_value))
- return None
-
- if pb_spec.name:
- message.name = pb_spec.name
- message.type = CompSpecMsg.TYPE_UNION
- provided_attrs = set(py_value.keys())
- for attr in pb_spec.union_value:
- # Since it is a union type, we stop after finding one field name
- # that matches, and shouldn't throw an error when name is not found.
- if attr.name in py_value:
- provided_attrs.remove(attr.name)
- curr_value = py_value[attr.name]
- attr_msg = message.union_value.add()
- if attr.type == CompSpecMsg.TYPE_ENUM:
- PyValue2PbEnum(attr_msg, attr, curr_value)
- elif attr.type == CompSpecMsg.TYPE_SCALAR:
- PyValue2PbScalar(attr_msg, attr, curr_value)
- elif attr.type == CompSpecMsg.TYPE_STRING:
- PyString2PbString(attr_msg, attr, curr_value)
- elif attr.type == CompSpecMsg.TYPE_VECTOR:
- PyList2PbVector(attr_msg, attr, curr_value)
- elif attr.type == CompSpecMsg.TYPE_STRUCT:
- # TODO: is a nested struct in union stored in sub_union field.
- sub_attr = FindSubUnionType(pb_spec, attr.predefined_type)
- if sub_attr:
- PyDict2PbStruct(attr_msg, sub_attr, curr_value)
- else:
- logging.error("PyDict2PbStruct: substruct not found.")
- return None
- elif attr.type == CompSpecMsg.TYPE_UNION:
- sub_attr = FindSubUnionType(pb_spec, attr.predefined_type)
- if sub_attr:
- PyDict2PbUnion(attr_msg, sub_attr, curr_value)
- else:
- logging.error("PyDict2PbUnion: subunion not found.")
- return None
- else:
- logging.error("PyDict2PbStruct: unsupported type %s",
- attr.type)
- return None
- else:
- # Add a field, where name field is initialized as an empty string.
- # In generated driver implementation, driver knows this field is
- # not used, and skip reading it.
- message.union_value.add()
-
- if len(provided_attrs) > 0:
- logging.error("PyDict2PbUnion: specified field is not in the union " +
- "definition for union type %s", provided_attrs)
- return None
- return message
-
-
-def Convert(pb_spec, py_value):
- """Converts Python native data structure to VTS VariableSecificationMessage.
-
- Args:
- pb_spec: VariableSpecificationMessage which captures the
- specification of a target attribute.
- py_value: Python value provided by a test case.
-
- Returns:
- Converted VariableSpecificationMessage if found, None otherwise
- """
- if not pb_spec:
- logging.error("py2pb.Convert: ProtoBuf spec is None", pb_spec)
- return None
-
- message = CompSpecMsg.VariableSpecificationMessage()
- message.name = pb_spec.name
-
- if isinstance(py_value, CompSpecMsg.VariableSpecificationMessage):
- message.CopyFrom(py_value)
- elif pb_spec.type == CompSpecMsg.TYPE_STRUCT:
- PyDict2PbStruct(message, pb_spec, py_value)
- elif pb_spec.type == CompSpecMsg.TYPE_UNION:
- PyDict2PbUnion(message, pb_spec, py_value)
- elif pb_spec.type == CompSpecMsg.TYPE_ENUM:
- PyValue2PbEnum(message, pb_spec, py_value)
- elif pb_spec.type == CompSpecMsg.TYPE_SCALAR:
- PyValue2PbScalar(message, pb_spec, py_value)
- elif pb_spec.type == CompSpecMsg.TYPE_STRING:
- PyString2PbString(message, pb_spec, py_value)
- elif pb_spec.type == CompSpecMsg.TYPE_VECTOR:
- PyList2PbVector(message, pb_spec, py_value)
- else:
- logging.error("py2pb.Convert: unsupported type %s",
- pb_spec.type)
- return None
-
- return message
diff --git a/utils/python/mirror/resource_mirror.py b/utils/python/mirror/resource_mirror.py
deleted file mode 100644
index d801ff6..0000000
--- a/utils/python/mirror/resource_mirror.py
+++ /dev/null
@@ -1,786 +0,0 @@
-#
-# Copyright (C) 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.
-#
-import logging
-
-from vts.proto import AndroidSystemControlMessage_pb2 as ASysCtrlMsg
-from vts.proto import VtsResourceControllerMessage_pb2 as ResControlMsg
-from vts.proto import ComponentSpecificationMessage_pb2 as CompSpecMsg
-from vts.utils.python.mirror import mirror_object
-
-
-class ResourceFmqMirror(mirror_object.MirrorObject):
- """This is a class that mirrors FMQ resource allocated on the target side.
-
- Attributes:
- SUPPORTED_SCALAR_TYPES: set, contains all scalar types supported by FMQ.
- If the type of FMQ is one of those, this class
- prepares the write data from caller provided
- Python data.
- _client: VtsTcpClient, the TCP client instance.
- _queue_id: int, used to identify the queue object on the target side.
- _data_type: type of data in the queue.
- _sync: bool, whether the queue is synchronized.
- """
-
- SUPPORTED_SCALAR_TYPES = {
- "uint8_t", "int8_t", "uint16_t", "int16_t", "uint32_t", "int32_t",
- "uint64_t", "int64_t", "bool_t", "double_t"
- }
-
- def __init__(self, data_type, sync, client, queue_id=-1):
- """Initialize a FMQ mirror.
-
- Args:
- data_type: string, type of data in the queue
- (e.g. "uint32_t", "int16_t").
- sync: bool, whether queue is synchronized (only has one reader).
- client: VtsTcpClient, specifies the session that this mirror use.
- queue_id: int, identifies the queue on the target side.
- Optional if caller initializes a new FMQ mirror.
- """
- super(ResourceFmqMirror, self).__init__(client)
- self._data_type = data_type
- self._sync = sync
- self._queue_id = queue_id
-
- def _create(self, queue_id, queue_size, blocking, reset_pointers):
- """Initiate a fast message queue object on the target side.
-
- This method registers a FMQ object on the target side, and stores
- the queue_id in the class attribute.
- Users should not directly call this method because it will overwrite
- the original queue_id stored in the mirror object, leaving that
- queue object out of reference.
- Users should always call InitFmq() in mirror_tracker.py to obtain a
- new queue object.
-
- Args:
- queue_id: int, identifies the message queue object on the target side.
- queue_size: int, size of the queue.
- blocking: bool, whether blocking is enabled in the queue.
- reset_pointers: bool, whether to reset read/write pointers when
- creating a message queue object based on an existing message queue.
- """
- # Prepare arguments.
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.FMQ_CREATE, queue_id)
- request_msg.queue_size = queue_size
- request_msg.blocking = blocking
- request_msg.reset_pointers = reset_pointers
-
- # Send and receive data.
- fmq_response = self._client.SendFmqRequest(request_msg)
- if fmq_response is not None and fmq_response.queue_id != -1:
- self._queue_id = fmq_response.queue_id
- else:
- self._queue_id = -1
- logging.error("Failed to create a new queue object.")
-
- def read(self, data, data_size):
- """Initiate a non-blocking read request to FMQ driver.
-
- Args:
- data: list, data to be filled by this function. The list will
- be emptied before the function starts to put read data into
- it, which is consistent with the function behavior on the
- target side.
- data_size: int, length of data to read.
-
- Returns:
- bool, true if the operation succeeds,
- false otherwise.
- """
- # Prepare arguments.
- del data[:]
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.FMQ_READ, self._queue_id)
- request_msg.read_data_size = data_size
-
- # Send and receive data.
- fmq_response = self._client.SendFmqRequest(request_msg)
- if fmq_response is not None and fmq_response.success:
- self._extractReadData(fmq_response, data)
- return True
- return False
-
- # TODO: support long-form blocking read in the future when there is use case.
- def readBlocking(self, data, data_size, time_out_nanos=0):
- """Initiate a blocking read request (short-form) to FMQ driver.
-
- Args:
- data: list, data to be filled by this function. The list will
- be emptied before the function starts to put read data into
- it, which is consistent with the function behavior on the
- target side.
- data_size: int, length of data to read.
- time_out_nanos: int, wait time (in nanoseconds) when blocking.
- The default value is 0 (no blocking).
-
- Returns:
- bool, true if the operation succeeds,
- false otherwise.
- """
- # Prepare arguments.
- del data[:]
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.FMQ_READ_BLOCKING, self._queue_id)
- request_msg.read_data_size = data_size
- request_msg.time_out_nanos = time_out_nanos
-
- # Send and receive data.
- fmq_response = self._client.SendFmqRequest(request_msg)
- if fmq_response is not None and fmq_response.success:
- self._extractReadData(fmq_response, data)
- return True
- return False
-
- def write(self, data, data_size):
- """Initiate a non-blocking write request to FMQ driver.
-
- Args:
- data: list, data to be written.
- data_size: int, length of data to write.
- The function will only write data up until data_size,
- i.e. extraneous data will be discarded.
-
- Returns:
- bool, true if the operation succeeds,
- false otherwise.
- """
- # Prepare arguments.
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.FMQ_WRITE, self._queue_id)
- prepare_result = self._prepareWriteData(request_msg, data[:data_size])
- if not prepare_result:
- # Prepare write data failure, error logged in _prepareWriteData().
- return False
-
- # Send and receive data.
- fmq_response = self._client.SendFmqRequest(request_msg)
- if fmq_response is not None:
- return fmq_response.success
- return False
-
- # TODO: support long-form blocking write in the future when there is use case.
- def writeBlocking(self, data, data_size, time_out_nanos=0):
- """Initiate a blocking write request (short-form) to FMQ driver.
-
- Args:
- data: list, data to be written.
- data_size: int, length of data to write.
- The function will only write data up until data_size,
- i.e. extraneous data will be discarded.
- time_out_nanos: int, wait time (in nanoseconds) when blocking.
- The default value is 0 (no blocking).
-
- Returns:
- bool, true if the operation succeeds,
- false otherwise.
- """
- # Prepare arguments.
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.FMQ_WRITE_BLOCKING, self._queue_id)
- prepare_result = self._prepareWriteData(request_msg, data[:data_size])
- if not prepare_result:
- # Prepare write data failure, error logged in _prepareWriteData().
- return False
- request_msg.time_out_nanos = time_out_nanos
-
- # Send and receive data.
- fmq_response = self._client.SendFmqRequest(request_msg)
- if fmq_response is not None:
- return fmq_response.success
- return False
-
- def availableToWrite(self):
- """Get space available to write in the queue.
-
- Returns:
- int, number of slots available.
- """
- # Prepare arguments.
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.FMQ_AVAILABLE_WRITE, self._queue_id)
-
- # Send and receive data.
- return self._processUtilMethod(request_msg)
-
- def availableToRead(self):
- """Get number of items available to read.
-
- Returns:
- int, number of items.
- """
- # Prepare arguments.
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.FMQ_AVAILABLE_READ, self._queue_id)
-
- # Send and receive data.
- return self._processUtilMethod(request_msg)
-
- def getQuantumSize(self):
- """Get size of item in the queue.
-
- Returns:
- int, size of item.
- """
- # Prepare arguments.
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.FMQ_GET_QUANTUM_SIZE, self._queue_id)
-
- # send and receive data
- return self._processUtilMethod(request_msg)
-
- def getQuantumCount(self):
- """Get number of items that fit in the queue.
-
- Returns:
- int, number of items.
- """
- # Prepare arguments.
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.FMQ_GET_QUANTUM_COUNT, self._queue_id)
-
- # Send and receive data.
- return self._processUtilMethod(request_msg)
-
- def isValid(self):
- """Check if the queue is valid.
-
- Returns:
- bool, true if the queue is valid.
- """
- # Prepare arguments.
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.FMQ_IS_VALID, self._queue_id)
-
- # Send and receive data.
- fmq_response = self._client.SendFmqRequest(request_msg)
- if fmq_response is not None:
- return fmq_response.success
- return False
-
- @property
- def queueId(self):
- """Gets the id assigned from the target side.
-
- Returns:
- int, id of the queue.
- """
- return self._queue_id
-
- @property
- def dataType(self):
- """Get the type of data of this FMQ mirror.
-
- Returns:
- string, type of data in the queue
- """
- return self._data_type
-
- @property
- def sync(self):
- """Get the synchronization option of this FMQ mirror.
-
- Returns:
- bool, true if the queue is synchronized (only has one reader).
- """
- return self._sync
-
- def _createTemplateRequestMessage(self, operation, queue_id):
- """Creates a template FmqRequestMessage with common arguments among
- all FMQ operations.
-
- Args:
- operation: FmqOp, fmq operations.
- (see test/vts/proto/VtsResourceControllerMessage.proto).
- queue_id: int, identifies the message queue object on target side.
-
- Returns:
- FmqRequestMessage, fmq request message.
- (See test/vts/proto/VtsResourceControllerMessage.proto).
- """
- request_msg = ResControlMsg.FmqRequestMessage()
- request_msg.operation = operation
- request_msg.data_type = self._data_type
- request_msg.sync = self._sync
- request_msg.queue_id = queue_id
- return request_msg
-
- def _prepareWriteData(self, request_msg, data):
- """Converts python list to repeated protobuf field.
-
- If the type of data in the queue is a supported scalar, caller can
- directly supply the python native value. Otherwise, caller needs to
- supply a list of VariableSpecificationMessage.
-
- Args:
- request_msg: FmqRequestMessage, arguments for a FMQ operation
- request.
- data: VariableSpecificationMessage list or a list of scalar values.
- If the type of FMQ is scalar type, caller can directly
- specify the Python scalar data. Otherwise, caller has to
- provide each item as VariableSpecificationMessage.
-
- Returns:
- bool, true if preparation succeeds, false otherwise.
- This function can fail if caller doesn't provide a list of
- VariableSpecificationMessage when type of data in the queue
- is not a supported scalar type.
- """
- for curr_value in data:
- new_message = request_msg.write_data.add()
- if isinstance(curr_value,
- CompSpecMsg.VariableSpecificationMessage):
- new_message.CopyFrom(curr_value)
- elif self._data_type in self.SUPPORTED_SCALAR_TYPES:
- new_message.type = CompSpecMsg.TYPE_SCALAR
- new_message.scalar_type = self._data_type
- setattr(new_message.scalar_value, self._data_type, curr_value)
- else:
- logging.error("Need to provide VariableSpecificationMessage " +
- "if type of data in the queue is not a " +
- "supported scalar type.")
- return False
- return True
-
- def _extractReadData(self, response_msg, data):
- """Extracts read data from the response message returned by client.
-
- Args:
- response_msg: FmqResponseMessage, contains response from FMQ driver.
- data: list, to be filled by this function. data buffer is provided
- by caller, so this function will append every element to the
- buffer.
- """
- for item in response_msg.read_data:
- data.append(self._client.GetPythonDataOfVariableSpecMsg(item))
-
- def _processUtilMethod(self, request_msg):
- """Sends request message and process response message for util methods
- that return an unsigned integer,
- e.g. availableToWrite, availableToRead.
-
- Args:
- request_msg: FmqRequestMessage, arguments for a FMQ operation request.
-
- Returns: int, information about the queue,
- None if the operation is unsuccessful.
- """
- fmq_response = self._client.SendFmqRequest(request_msg)
- if fmq_response is not None and fmq_response.success:
- return fmq_response.sizet_return_val
- return None
-
-
-class ResourceHidlMemoryMirror(mirror_object.MirrorObject):
- """This class mirrors hidl_memory resource allocated on the target side.
-
- Attributes:
- _client: the TCP client instance.
- _mem_id: int, used to identify the memory region on the target side.
- """
-
- def __init__(self, client, mem_id=-1):
- super(ResourceHidlMemoryMirror, self).__init__(client)
- self._mem_id = mem_id
-
- def _allocate(self, mem_size):
- """Initiate a hidl_memory region on the target side.
-
- This method stores the mem_id in the class attribute.
- Users should not directly call this method to get a new memory region,
- because it will overwrite the original memory object with mem_id,
- making that memory object out of reference.
- Users should always call InitHidlMemory() in mirror_tracker.py to get
- a new memory region.
-
- Args:
- mem_size: int, size of the requested memory region.
- """
- # Prepare arguments.
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.MEM_PROTO_ALLOCATE)
- request_msg.mem_size = mem_size
-
- # Send and receive data.
- response_msg = self._client.SendHidlMemoryRequest(request_msg)
- if response_msg is not None and response_msg.new_mem_id != -1:
- self._mem_id = response_msg.new_mem_id
- else:
- logging.error("Failed to allocate memory region.")
-
- def read(self):
- """Notify that caller will read the entire memory region.
-
- Before every actual read operation, caller must call this method
- or readRange() first.
-
- Returns:
- bool, true if the operation succeeds, false otherwise.
- """
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.MEM_PROTO_START_READ)
-
- response_msg = self._client.SendHidlMemoryRequest(request_msg)
- if response_msg is not None:
- if not response_msg.success:
- logging.error("Failed to find memory region with id %d",
- self._mem_id)
- return response_msg.success
- return False
-
- def readRange(self, start, length):
- """Notify that caller will read only part of memory region.
-
- Notify that caller will read starting at start and
- ending at start + length.
- Before every actual read operation, caller must call this method
- or read() first.
-
- Args:
- start: int, offset from the start of memory region to be modified.
- length: int, number of bytes to be modified.
-
- Returns:
- bool, true if the operation succeeds, false otherwise.
- """
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.MEM_PROTO_START_READ_RANGE)
- request_msg.start = start
- request_msg.length = length
-
- response_msg = self._client.SendHidlMemoryRequest(request_msg)
- if response_msg is not None:
- if not response_msg.success:
- logging.error("Failed to find memory region with id %d",
- self._mem_id)
- return response_msg.success
- return False
-
- def update(self):
- """Notify that caller will possibly write to all memory region.
-
- Before every actual write operation, caller must call this method
- or updateRange() first.
-
- Returns:
- bool, true if the operation succeeds, false otherwise.
- """
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.MEM_PROTO_START_UPDATE)
-
- response_msg = self._client.SendHidlMemoryRequest(request_msg)
- if response_msg is not None:
- if not response_msg.success:
- logging.error("Failed to find memory region with id %d",
- self._mem_id)
- return response_msg.success
- return False
-
- def updateRange(self, start, length):
- """Notify that caller will only write to part of memory region.
-
- Notify that caller will only write starting at start and
- ending at start + length.
- Before every actual write operation, caller must call this method
- or update() first.
-
- Args:
- start: int, offset from the start of memory region to be modified.
- length: int, number of bytes to be modified.
-
- Returns:
- bool, true if the operation succeeds, false otherwise.
- """
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.MEM_PROTO_START_UPDATE_RANGE)
- request_msg.start = start
- request_msg.length = length
-
- response_msg = self._client.SendHidlMemoryRequest(request_msg)
- if response_msg is not None:
- if not response_msg.success:
- logging.error("Failed to find memory region with id %d",
- self._mem_id)
- return response_msg.success
- return False
-
- def readBytes(self, length, start=0):
- """This method performs actual read operation.
-
- This method helps caller perform actual read operation on the
- memory region, because host side won't be able to cast c++ pointers.
-
- Args:
- length: int, number of bytes to read.
- start: int, offset from the start of memory region to read.
-
- Returns:
- string, data read from memory.
- Caller can perform conversion on the result to obtain the
- corresponding data structure in python.
- None, indicate if the read fails.
- """
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.MEM_PROTO_READ_BYTES)
- request_msg.start = start
- request_msg.length = length
-
- response_msg = self._client.SendHidlMemoryRequest(request_msg)
- if response_msg is not None:
- if response_msg.success:
- return response_msg.read_data
- logging.error("Failed to find memory region with id %d",
- self._mem_id)
- return None
-
- def updateBytes(self, data, length, start=0):
- """This method performs actual write operation.
-
- This method helps caller perform actual write operation on the
- memory region, because host side won't be able to cast c++ pointers.
-
- Args:
- data: string, bytes to be written into memory.
- Caller can use bytearray() function to convert python
- data structures into python, and call str() on the resulting
- bytearray object.
- length: int, number of bytes to write.
- start: int, offset from the start of memory region to be modified.
-
- Returns:
- bool, true if the operation succeeds, false otherwise.
- """
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.MEM_PROTO_UPDATE_BYTES)
- request_msg.write_data = data
- request_msg.start = start
- request_msg.length = length
-
- response_msg = self._client.SendHidlMemoryRequest(request_msg)
- if response_msg is not None:
- if not response_msg.success:
- logging.error("Failed to find memory region with id %d",
- self._mem_id)
- return response_msg.success
- return False
-
- def commit(self):
- """Caller signals done with operating on the memory region.
-
- Caller needs to call this method after reading/writing.
-
- Returns:
- bool, true if the operation succeeds, false otherwise.
- """
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.MEM_PROTO_COMMIT)
-
- response_msg = self._client.SendHidlMemoryRequest(request_msg)
- if response_msg is not None:
- if not response_msg.success:
- logging.error("Failed to find memory region with id %d",
- self._mem_id)
- return response_msg.success
- return False
-
- def getSize(self):
- """Gets the size of the memory region.
-
- Returns:
- int, size of memory region, -1 to signal operation failure.
- """
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.MEM_PROTO_GET_SIZE)
-
- response_msg = self._client.SendHidlMemoryRequest(request_msg)
- if response_msg is not None:
- if response_msg.success:
- return response_msg.mem_size
- logging.error("Failed to find memory region with id %d",
- self._mem_id)
- return -1
-
- @property
- def memId(self):
- """Gets the id assigned from the target side.
-
- Returns:
- int, id of the memory object.
- """
- return self._mem_id
-
- def _createTemplateRequestMessage(self, operation):
- """Creates a template HidlMemoryRequestMessage.
-
- This method creates a message that contains common arguments among
- all hidl_memory operations.
-
- Args:
- operation: HidlMemoryOp, hidl_memory operations.
- (see test/vts/proto/VtsResourceControllerMessage.proto).
-
- Returns:
- HidlMemoryRequestMessage, hidl_memory request message.
- (See test/vts/proto/VtsResourceControllerMessage.proto).
- """
- request_msg = ResControlMsg.HidlMemoryRequestMessage()
- request_msg.operation = operation
- request_msg.mem_id = self._mem_id
- return request_msg
-
-
-class ResourceHidlHandleMirror(mirror_object.MirrorObject):
- """This class mirrors hidl_handle resource allocated on the target side.
-
- TODO: support more than file types in the future, e.g. socket, pipe.
-
- Attributes:
- _client: the TCP client instance.
- _handle_id: int, used to identify the handle object on the target side.
- """
-
- def __init__(self, client, handle_id=-1):
- super(ResourceHidlHandleMirror, self).__init__(client)
- self._handle_id = handle_id
-
- def CleanUp(self):
- """Close open file descriptors on target-side drivers.
-
- Developers can call this method to close open file descriptors
- in all handle objects.
- Note: This method needs to be called before self._client
- is disconnected. self._client is most likely initialized in
- one of the hal_mirror.
- """
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.HANDLE_PROTO_DELETE)
- self._client.SendHidlHandleRequest(request_msg)
-
- def _createHandleForSingleFile(self, filepath, mode, int_data):
- """Initiate a hidl_handle object containing a single file descriptor.
-
- This method stores the handle_id in the class attribute.
- Users should not directly call this method to create a new
- handle object, because it will overwrite the original handle object,
- making that handle object out of reference.
- Users should always call InitHidlHandle() in mirror_tracker.py to get
- a new handle object.
-
- Args:
- filepath: string, path to the file to be opened.
- mode: string, specifying the mode to open the file.
- int_data: int list, useful integers to store in the handle object.
- """
- # Prepare arguments.
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.HANDLE_PROTO_CREATE_FILE)
- request_msg.handle_info.num_fds = 1
- request_msg.handle_info.num_ints = len(int_data)
-
- # TODO: support more than one file descriptors at once.
- # Add the file information into proto message.
- fd_message = request_msg.handle_info.fd_val.add()
- fd_message.type = CompSpecMsg.FILE_TYPE
- fd_message.file_mode_str = mode
- fd_message.file_name = filepath
-
- # Add the integers into proto message.
- request_msg.handle_info.int_val.extend(int_data)
-
- # Send and receive data.
- response_msg = self._client.SendHidlHandleRequest(request_msg)
- if response_msg is not None and response_msg.new_handle_id != -1:
- self._handle_id = response_msg.new_handle_id
- else:
- logging.error("Failed to create handle object.")
-
- def readFile(self, read_data_size, index=0):
- """Reads from a given file in the handle object.
-
- Args:
- read_data_size: int, number of bytes to read.
- index: int, index of file among all files in the handle object.
- Optional if host only wants to read from one file.
-
- Returns:
- string, data read from the file.
- """
- # Prepare arguments.
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.HANDLE_PROTO_READ_FILE)
- request_msg.read_data_size = read_data_size
-
- # Send and receive data.
- response_msg = self._client.SendHidlHandleRequest(request_msg)
- if response_msg is not None and response_msg.success:
- return response_msg.read_data
- # TODO: more detailed error message.
- logging.error("Failed to read from the file.")
- return None
-
- def writeFile(self, write_data, index=0):
- """Writes to a given file to the handle object.
-
- Args:
- write_data: string, data to be written into file.
- index: int, index of file among all files in the handle object.
- Optional if host only wants to write into one file.
-
- Returns:
- int, number of bytes written.
- """
- # Prepare arguments.
- request_msg = self._createTemplateRequestMessage(
- ResControlMsg.HANDLE_PROTO_WRITE_FILE)
- request_msg.write_data = write_data
-
- # Send and receive data.
- response_msg = self._client.SendHidlHandleRequest(request_msg)
- if response_msg is not None and response_msg.success:
- return response_msg.write_data_size
- # TODO: more detailed error message.
- logging.error("Failed to write into the file.")
- return None
-
- @property
- def handleId(self):
- """Gets the id assigned from the target side.
-
- Returns:
- int, id of the handle object.
- """
- return self._handle_id
-
- def _createTemplateRequestMessage(self, operation):
- """Creates a template HidlHandleRequestMessage.
-
- This method creates a HidlHandleRequestMessage with common arguments
- among all hidl_handle operations.
-
- Args:
- operation: HidlHandleOp, hidl_handle operations.
- (see test/vts/proto/VtsResourceControllerMessage.proto).
-
- Returns:
- HidlHandleRequestMessage, hidl_handle request message.
- (See test/vts/proto/VtsResourceControllerMessage.proto).
- """
- request_msg = ResControlMsg.HidlHandleRequestMessage()
- request_msg.operation = operation
- request_msg.handle_id = self._handle_id
- return request_msg
diff --git a/utils/python/mirror/shell_mirror.py b/utils/python/mirror/shell_mirror.py
deleted file mode 100644
index a8d2855..0000000
--- a/utils/python/mirror/shell_mirror.py
+++ /dev/null
@@ -1,111 +0,0 @@
-#
-# 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.
-#
-import logging
-import os
-import re
-import shutil
-import tempfile
-
-from vts.runners.host import const
-from vts.utils.python.mirror import mirror_object
-
-
-class ShellMirror(mirror_object.MirrorObject):
- """The class that acts as the mirror to an Android device's shell terminal.
-
- Attributes:
- _client: the TCP client instance.
- _adb: An AdbProxy object used for interacting with the device via adb.
- enabled: bool, whether remote shell feature is enabled for the device.
- """
-
- TMP_FILE_PATTERN = "/data/local/tmp/nohup.*"
-
- def __init__(self, client, adb):
- super(ShellMirror, self).__init__(client)
- self._adb = adb
- self.enabled = True
-
- def Heal(self):
- """Performs a self healing.
-
- Includes self diagnosis that looks for any framework errors.
-
- Returns:
- bool, True if everything is ok; False otherwise.
- """
- res = True
-
- if self._client:
- res &= self._client.Heal()
-
- if not res:
- logging.error('Self diagnosis found problems in shell mirror.')
-
- return res
-
- def Execute(self, command, no_except=False):
- '''Execute remote shell commands on device.
-
- Args:
- command: string or a list of string, shell commands to execute on
- device.
- no_except: bool, if set to True, no exception will be thrown and
- error code will be -1 with error message on stderr.
-
- Returns:
- A dictionary containing shell command execution results
- '''
- if not self.enabled:
- # TODO(yuexima): use adb shell instead when RPC is disabled
- return {
- const.STDOUT: [""] * len(command),
- const.STDERR:
- ["VTS remote shell has been disabled."] * len(command),
- const.EXIT_CODE: [-2] * len(command)
- }
- result = self._client.ExecuteShellCommand(command, no_except)
-
- tmp_dir = tempfile.mkdtemp()
- pattern = re.compile(self.TMP_FILE_PATTERN)
-
- for result_val, result_type in zip(
- [result[const.STDOUT], result[const.STDERR]],
- ["stdout", "stderr"]):
- for index, val in enumerate(result_val):
- # If val is a tmp file name, pull the file and set the contents
- # to result.
- if pattern.match(val):
- tmp_file = os.path.join(tmp_dir, result_type + str(index))
- logging.debug("pulling file: %s to %s", val, tmp_file)
- self._adb.pull(val, tmp_file)
- result_val[index] = open(tmp_file, "r").read()
- self._adb.shell("rm -f %s" % val)
- else:
- result_val[index] = val
-
- shutil.rmtree(tmp_dir)
- logging.debug("resp for VTS_AGENT_COMMAND_EXECUTE_SHELL_COMMAND: %s",
- result)
- return result
-
- def SetConnTimeout(self, timeout):
- """Set remote shell connection timeout.
-
- Args:
- timeout: int, TCP connection timeout in seconds.
- """
- self._client.timeout = timeout
diff --git a/utils/python/os/__init__.py b/utils/python/os/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/os/__init__.py
+++ /dev/null
diff --git a/utils/python/os/env_utils.py b/utils/python/os/env_utils.py
deleted file mode 100644
index bac8d60..0000000
--- a/utils/python/os/env_utils.py
+++ /dev/null
@@ -1,46 +0,0 @@
-#
-# Copyright 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.
-
-import os
-
-
-def SaveAndClearEnvVars(var_name_list):
- """Saves and clears the values of existing environment variables.
-
- Args:
- var_name_list: a list of strings where each string is the environment
- variable name.
-
- Returns:
- a dict where the key is an environment variable and the value is the
- saved environment variable value.
- """
- env_vars = {}
- for var_name in var_name_list:
- if var_name in os.environ:
- env_vars[var_name] = os.environ[var_name]
- os.environ[var_name] = ""
- return env_vars
-
-
-def RestoreEnvVars(env_vars):
- """Restores the values of existing environment variables.
-
- Args:
- env_vars: a dict where the key is an environment variable and
- the value is the environment variable value to set.
- """
- for var_name in env_vars:
- os.environ[var_name] = env_vars[var_name]
diff --git a/utils/python/os/path_utils.py b/utils/python/os/path_utils.py
deleted file mode 100644
index a157db4..0000000
--- a/utils/python/os/path_utils.py
+++ /dev/null
@@ -1,66 +0,0 @@
-#
-# Copyright 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.
-
-import posixpath
-
-
-def JoinTargetPath(path, *paths):
- """Concatenates paths and inserts target path separators between them.
-
- Args:
- path: string, the first path to be concatenated.
- *paths: tuple of strings, the other paths to be concatenated.
-
- Returns:
- string, the concatenated path.
- """
- return posixpath.join(path, *paths)
-
-
-def TargetBaseName(path):
- """Returns the base name of the path on target device.
-
- Args:
- path: string, the path on target device.
-
- Returns:
- string, the base name.
- """
- return posixpath.basename(path)
-
-
-def TargetDirName(path):
- """Returns the directory name of the path on target device.
-
- Args:
- path: string, the path on target device.
-
- Returns:
- string, the directory name.
- """
- return posixpath.dirname(path)
-
-
-def TargetNormPath(path):
- """Removes redundant separators and resolves relative path.
-
- Args:
- path: string, the path on target device.
-
- Returns:
- string, the normalized path.
- """
- return posixpath.normpath(path)
-
diff --git a/utils/python/performance/__init__.py b/utils/python/performance/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/performance/__init__.py
+++ /dev/null
diff --git a/utils/python/performance/benchmark_parser.py b/utils/python/performance/benchmark_parser.py
deleted file mode 100644
index a6fcdeb..0000000
--- a/utils/python/performance/benchmark_parser.py
+++ /dev/null
@@ -1,94 +0,0 @@
-#
-# 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.
-#
-
-import json
-
-
-class GoogleBenchmarkJsonParser(object):
- """This class parses the JSON output of Google benchmark.
-
- Example
- {
- "context": {
- "date": "2017-05-16 11:57:21",
- "num_cpus": 4,
- "mhz_per_cpu": 19,
- "cpu_scaling_enabled": true,
- "library_build_type": "release"
- },
- "benchmarks": [
- {
- "name": "BM_sendVec_binder/4",
- "iterations": 27744,
- "real_time": 51485,
- "cpu_time": 23655,
- "time_unit": "ns"
- },
- ...
- ]
- }
-
- Attributes:
- _benchmarks: The "benchmarks" property of the JSON object.
- """
-
- _BENCHMARKS = "benchmarks"
- _NAME = "name"
- _ITERATIONS = "iterations"
- _REAL_TIME = "real_time"
- _CPU_TIME = "cpu_time"
-
- def __init__(self, json_string):
- """Converts the JSON string to internal data structure.
-
- Args:
- json_string: The output of Google benchmark in JSON format.
- """
- json_obj = json.loads(json_string)
- self._benchmarks = json_obj[self._BENCHMARKS]
-
- def GetArguments(self):
- """Returns the "name" properties with function names stripped.
-
- Returns:
- A list of strings.
- """
- args = []
- for bm in self._benchmarks:
- name = bm[self._NAME].split("/", 1)
- args.append(name[1].encode("utf-8") if len(name) >= 2 else "")
- return args
-
- def GetRealTime(self):
- """Returns the "real_time" properties.
-
- Returns:
- A list of integers.
- """
- return [int(float(x[self._REAL_TIME])) for x in self._benchmarks]
-
- def ToTable(self):
- """Returns the benchmarks in a table.
-
- Returns:
- A 2-dimensional list. The first row contains the column names. The
- following rows are the benchmarks.
- """
- table = [[self._NAME, self._REAL_TIME, self._CPU_TIME,
- self._ITERATIONS]]
- for record in self._benchmarks:
- table.append([record[x] for x in table[0]])
- return table
diff --git a/utils/python/precondition/__init__.py b/utils/python/precondition/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/precondition/__init__.py
+++ /dev/null
diff --git a/utils/python/precondition/precondition_utils.py b/utils/python/precondition/precondition_utils.py
deleted file mode 100644
index 1afd64a..0000000
--- a/utils/python/precondition/precondition_utils.py
+++ /dev/null
@@ -1,218 +0,0 @@
-#
-# 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.
-#
-
-import json
-import logging
-
-from vts.runners.host import const
-from vts.runners.host import errors
-from vts.runners.host import keys
-from vts.utils.python.file import target_file_utils
-from vts.utils.python.hal import hal_service_name_utils
-
-
-def CanRunHidlHalTest(test_instance,
- dut,
- shell=None,
- run_as_compliance_test=False):
- """Checks HAL precondition of a test instance.
-
- Args:
- test_instance: the test instance which inherits BaseTestClass.
- dut: the AndroidDevice under test.
- shell: the ShellMirrorObject to execute command on the device.
- If not specified, the function creates one from dut.
- run_as_compliance_test: boolean, whether it is a compliance test.
-
- Returns:
- True if the precondition is satisfied; False otherwise.
- """
- if shell is None:
- dut.shell.InvokeTerminal("check_hal_preconditions")
- shell = dut.shell.check_hal_preconditions
-
- opt_params = [
- keys.ConfigKeys.IKEY_ABI_BITNESS,
- keys.ConfigKeys.IKEY_PRECONDITION_HWBINDER_SERVICE,
- keys.ConfigKeys.IKEY_PRECONDITION_FILE_PATH_PREFIX,
- keys.ConfigKeys.IKEY_PRECONDITION_LSHAL,
- ]
- test_instance.getUserParams(opt_param_names=opt_params)
-
- bitness = str(getattr(test_instance, keys.ConfigKeys.IKEY_ABI_BITNESS, ""))
-
- hwbinder_service_name = str(
- getattr(test_instance,
- keys.ConfigKeys.IKEY_PRECONDITION_HWBINDER_SERVICE, ""))
- if hwbinder_service_name:
- if not hwbinder_service_name.startswith("android.hardware."):
- logging.error("The given hwbinder service name %s is invalid.",
- hwbinder_service_name)
- else:
- cmd_results = shell.Execute("ps -A")
- hwbinder_service_name += "@"
- if (any(cmd_results[const.EXIT_CODE]) or
- hwbinder_service_name not in cmd_results[const.STDOUT][0]):
- logging.warn("The required hwbinder service %s not found.",
- hwbinder_service_name)
- return False
-
- file_path_prefix = getattr(test_instance, "file_path_prefix", "")
- if file_path_prefix and bitness:
- logging.debug("FILE_PATH_PREFIX: %s", file_path_prefix)
- logging.debug("Test bitness: %s", bitness)
- tag = "_" + bitness + "bit"
- if tag in file_path_prefix:
- for path_prefix in file_path_prefix[tag]:
- if not target_file_utils.Exists(path_prefix, shell):
- msg = (
- "The required file (prefix: {}) for {}-bit testcase "
- "not found.").format(path_prefix, bitness)
- logging.warn(msg)
- return False
-
- hal = str(
- getattr(test_instance, keys.ConfigKeys.IKEY_PRECONDITION_LSHAL, ""))
- if hal:
- testable, _ = hal_service_name_utils.GetHalServiceName(
- shell, hal, bitness, run_as_compliance_test)
- return testable
-
- logging.debug("Precondition check pass.")
- return True
-
-def CheckFeaturePrecondition(test_instance, dut, shell=None):
- """Checks feature precondition of a test instance.
-
- Args:
- test_instance: the test instance which inherits BaseTestClass.
- dut: the AndroidDevice under test.
- shell: the ShellMirrorObject to execute command on the device.
- If not specified, the function creates one from dut.
-
- Returns:
- True if the devise has the required feature; False otherwise.
- """
- opt_params = [
- keys.ConfigKeys.IKEY_PRECONDITION_FEATURE,
- ]
- test_instance.getUserParams(opt_param_names=opt_params)
-
- feature = str(
- getattr(test_instance, keys.ConfigKeys.IKEY_PRECONDITION_FEATURE, ""))
- if feature:
- # If system is not running, needs to start the framework first.
- if not dut.isFrameworkRunning():
- if not dut.start():
- logging.warn("Failed to start Android framework.")
- return False
-
- if shell is None:
- dut.shell.InvokeTerminal("check_feature_precondition")
- shell = dut.shell.check_feature_precondition
-
- cmd_results = shell.Execute("LD_LIBRARY_PATH= pm list features")
- if (any(cmd_results[const.EXIT_CODE])
- or feature not in cmd_results[const.STDOUT][0]):
- logging.warn("The required feature %s not found.", feature)
- return False
- logging.debug("Feature precondition check pass.")
- return True
-
-def MeetFirstApiLevelPrecondition(test_instance, dut=None):
- """Checks first API level precondition of a test instance.
-
- If the device's ro.product.first_api_level is 0, this function checks
- ro.build.version.sdk.
-
- Args:
- test_instance: the test instance which inherits BaseTestClass.
- dut: the AndroidDevice under test.
-
- Returns:
- True if the device's first API level is greater than or equal to the
- value of the precondition; False otherwise.
- """
- opt_params = [keys.ConfigKeys.IKEY_PRECONDITION_FIRST_API_LEVEL]
- test_instance.getUserParams(opt_param_names=opt_params)
- if not hasattr(test_instance,
- keys.ConfigKeys.IKEY_PRECONDITION_FIRST_API_LEVEL):
- return True
-
- precond_level_attr = getattr(
- test_instance, keys.ConfigKeys.IKEY_PRECONDITION_FIRST_API_LEVEL, 0)
- try:
- precond_level = int(precond_level_attr)
- except ValueError:
- logging.error("Cannot parse first API level precondition: %s",
- precond_level_attr)
- return True
-
- if not dut:
- logging.debug("Read first API level from the first device.")
- dut = test_instance.android_devices[0]
- device_level = dut.getLaunchApiLevel(strict=False)
- if not device_level:
- logging.error("Cannot read first API level from device. "
- "Assume it meets the precondition.")
- return True
-
- logging.debug("Device's first API level=%d; precondition=%d", device_level,
- precond_level)
- return device_level >= precond_level
-
-
-def CheckSysPropPrecondition(test_instance, dut, shell=None):
- """Checks sysprop precondition of a test instance.
-
- Args:
- test_instance: the test instance which inherits BaseTestClass.
- dut: the AndroidDevice under test.
- shell: the ShellMirrorObject to execute command on the device.
- If not specified, the function creates one from dut.
-
- Returns:
- False if precondition is not met (i.e., to skip tests),
- True otherwise (e.g., when no sysprop precondition is set;
- the precondition is satisfied;
- there is an error in retrieving the target sysprop; or
- the specified sysprop is undefined)
- """
- if not hasattr(test_instance, keys.ConfigKeys.IKEY_PRECONDITION_SYSPROP):
- return True
-
- precond_sysprop = str(
- getattr(test_instance, keys.ConfigKeys.IKEY_PRECONDITION_SYSPROP, ''))
- if "=" not in precond_sysprop:
- logging.error("precondition-sysprop value is invalid.")
- return True
-
- if shell is None:
- dut.shell.InvokeTerminal("check_sysprop_precondition")
- shell = dut.shell.check_sysprop_precondition
-
- sysprop_key, sysprop_value = precond_sysprop.split('=')
- cmd_results = shell.Execute('getprop %s' % sysprop_key)
- if any(cmd_results[const.EXIT_CODE]):
- logging.error('Failed to read sysprop:\n%s', sysprop_key)
- return True
- else:
- value = cmd_results[const.STDOUT][0].strip()
- if len(value) == 0:
- return True
- elif value != sysprop_value:
- return False
- return True
diff --git a/utils/python/profiling/__init__.py b/utils/python/profiling/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/profiling/__init__.py
+++ /dev/null
diff --git a/utils/python/profiling/profiling_utils.py b/utils/python/profiling/profiling_utils.py
deleted file mode 100644
index 004d195..0000000
--- a/utils/python/profiling/profiling_utils.py
+++ /dev/null
@@ -1,458 +0,0 @@
-#
-# 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.
-
-import logging
-import os
-
-from google.protobuf import text_format
-from vts.proto import ComponentSpecificationMessage_pb2 as CompSpecMsg
-from vts.proto import VtsProfilingMessage_pb2 as VtsProfilingMsg
-from vts.proto import VtsReportMessage_pb2 as ReportMsg
-from vts.runners.host import asserts
-from vts.runners.host import const
-from vts.runners.host import keys
-from vts.utils.python.common import cmd_utils
-from vts.utils.python.os import path_utils
-from vts.utils.python.web import feature_utils
-
-LOCAL_PROFILING_TRACE_PATH = "/tmp/vts-test-trace"
-TARGET_PROFILING_TRACE_PATH = "/data/local/tmp/"
-HAL_INSTRUMENTATION_LIB_PATH_32 = "/data/local/tmp/32/"
-HAL_INSTRUMENTATION_LIB_PATH_64 = "/data/local/tmp/64/"
-DEFAULT_HAL_ROOT = "android.hardware."
-
-_PROFILING_DATA = "profiling_data"
-_HOST_PROFILING_DATA = "host_profiling_data"
-
-
-class VTSProfilingData(object):
- """Class to store the VTS profiling data.
-
- Attributes:
- values: A dict that stores the profiling data. e.g. latencies of each api.
- options: A set of strings where each string specifies an associated
- option (which is the form of 'key=value').
- """
-
- def __init__(self):
- self.values = {}
- self.options = set()
-
-
-EVENT_TYPE_DICT = {
- 0: "SERVER_API_ENTRY",
- 1: "SERVER_API_EXIT",
- 2: "CLIENT_API_ENTRY",
- 3: "CLIENT_API_EXIT",
- 4: "SYNC_CALLBACK_ENTRY",
- 5: "SYNC_CALLBACK_EXIT",
- 6: "ASYNC_CALLBACK_ENTRY",
- 7: "ASYNC_CALLBACK_EXIT",
- 8: "PASSTHROUGH_ENTRY",
- 9: "PASSTHROUGH_EXIT",
-}
-
-
-class VTSApiCoverageData(object):
- """Class to store the API coverage data.
-
- Attributes:
- package_name: sting, HAL package name (e.g. android.hardware.foo).
- version_major: string, HAL major version (e.g. 1).
- version_minor: string, HAL minor version (e.g. 0).
- interface_name: string, HAL interface name (e.g. IFoo).
- total_apis: A set of strings, each string represents an API name defined
- in the given HAL.
- covered_apis: A set of strings, each string represents an API name
- covered by the test.
- """
-
- def __init__(self, package_name, version, interface_name):
- self.package_name = package_name
- self.version_major, self.version_minor = version.split(".")
- self.interface_name = interface_name
- self.total_apis = set()
- self.covered_apis = set()
-
-
-class ProfilingFeature(feature_utils.Feature):
- """Feature object for profiling functionality.
-
- Attributes:
- enabled: boolean, True if profiling is enabled, False otherwise
- web: (optional) WebFeature, object storing web feature util for test run.
- data_file_path: Path to the data directory within vts package.
- api_coverage_data: A dictionary from full HAL interface name
- (e.g. android.hardware.foo@1.0::IFoo) to VtsApiCoverageData.
- """
-
- _TOGGLE_PARAM = keys.ConfigKeys.IKEY_ENABLE_PROFILING
- _REQUIRED_PARAMS = [keys.ConfigKeys.IKEY_DATA_FILE_PATH]
- _OPTIONAL_PARAMS = [
- keys.ConfigKeys.IKEY_PROFILING_TRACING_PATH,
- keys.ConfigKeys.IKEY_TRACE_FILE_TOOL_NAME,
- keys.ConfigKeys.IKEY_SAVE_TRACE_FILE_REMOTE,
- keys.ConfigKeys.IKEY_ABI_BITNESS,
- keys.ConfigKeys.IKEY_PROFILING_ARG_VALUE,
- ]
-
- def __init__(self, user_params, web=None):
- """Initializes the profiling feature.
-
- Args:
- user_params: A dictionary from parameter name (String) to parameter value.
- web: (optional) WebFeature, object storing web feature util for test run
- """
- self.ParseParameters(self._TOGGLE_PARAM, self._REQUIRED_PARAMS,
- self._OPTIONAL_PARAMS, user_params)
- self.web = web
- if self.enabled:
- logging.info("Profiling is enabled.")
- else:
- logging.debug("Profiling is disabled.")
-
- self.data_file_path = getattr(self,
- keys.ConfigKeys.IKEY_DATA_FILE_PATH, None)
- self.api_coverage_data = {}
-
- def _IsEventFromBinderizedHal(self, event_type):
- """Returns True if the event type is from a binderized HAL."""
- if event_type in [8, 9]:
- return False
- return True
-
- def GetTraceFiles(self,
- dut,
- host_profiling_trace_path=None,
- trace_file_tool=None):
- """Pulls the trace file and save it under the profiling trace path.
-
- Args:
- dut: the testing device.
- host_profiling_trace_path: directory that stores trace files on host.
- trace_file_tool: tools that used to store the trace file.
-
- Returns:
- Name list of trace files that stored on host.
- """
- if not os.path.exists(LOCAL_PROFILING_TRACE_PATH):
- os.makedirs(LOCAL_PROFILING_TRACE_PATH)
-
- if not host_profiling_trace_path:
- host_profiling_trace_path = LOCAL_PROFILING_TRACE_PATH
-
- target_trace_file = path_utils.JoinTargetPath(
- TARGET_PROFILING_TRACE_PATH, "*.vts.trace")
- results = dut.shell.Execute("ls " + target_trace_file)
- asserts.assertTrue(results, "failed to find trace file")
- stdout_lines = results[const.STDOUT][0].split("\n")
- logging.debug("stdout: %s", stdout_lines)
- trace_files = []
- for line in stdout_lines:
- if line:
- temp_file_name = os.path.join(LOCAL_PROFILING_TRACE_PATH,
- os.path.basename(line.strip()))
- dut.adb.pull("%s %s" % (line, temp_file_name))
- trace_file_name = os.path.join(host_profiling_trace_path,
- os.path.basename(line.strip()))
- logging.info("Saving profiling traces: %s" % trace_file_name)
- if temp_file_name != trace_file_name:
- file_cmd = ""
- if trace_file_tool:
- file_cmd += trace_file_tool
- file_cmd += " cp " + temp_file_name + " " + trace_file_name
- results = cmd_utils.ExecuteShellCommand(file_cmd)
- if results[const.EXIT_CODE][0] != 0:
- logging.error(results[const.STDERR][0])
- logging.error("Fail to execute command: %s" % file_cmd)
- trace_files.append(temp_file_name)
- return trace_files
-
- def EnableVTSProfiling(self, shell, hal_instrumentation_lib_path=None):
- """ Enable profiling by setting the system property.
-
- Args:
- shell: shell to control the testing device.
- hal_instrumentation_lib_path: string, the path of directory that stores
- profiling libraries.
- """
- hal_instrumentation_lib_path_32 = HAL_INSTRUMENTATION_LIB_PATH_32
- hal_instrumentation_lib_path_64 = HAL_INSTRUMENTATION_LIB_PATH_64
- if hal_instrumentation_lib_path is not None:
- bitness = getattr(self, keys.ConfigKeys.IKEY_ABI_BITNESS, None)
- if bitness == '64':
- hal_instrumentation_lib_path_64 = hal_instrumentation_lib_path
- elif bitness == '32':
- hal_instrumentation_lib_path_32 = hal_instrumentation_lib_path
- else:
- logging.error('Unknown abi bitness "%s". Using 64bit hal '
- 'instrumentation lib path.', bitness)
-
- # cleanup any existing traces.
- shell.Execute(
- "rm " + os.path.join(TARGET_PROFILING_TRACE_PATH, "*.vts.trace"))
- logging.debug("enabling VTS profiling.")
-
- # give permission to write the trace file.
- shell.Execute("chmod 777 " + TARGET_PROFILING_TRACE_PATH)
-
- shell.Execute("setprop hal.instrumentation.lib.path.32 " +
- hal_instrumentation_lib_path_32)
- shell.Execute("setprop hal.instrumentation.lib.path.64 " +
- hal_instrumentation_lib_path_64)
-
- if getattr(self, keys.ConfigKeys.IKEY_PROFILING_ARG_VALUE, False):
- shell.Execute("setprop hal.instrumentation.profile.args true")
- else:
- shell.Execute("setprop hal.instrumentation.profile.args false")
- shell.Execute("setprop hal.instrumentation.enable true")
-
- def DisableVTSProfiling(self, shell):
- """ Disable profiling by resetting the system property.
-
- Args:
- shell: shell to control the testing device.
- """
- shell.Execute("setprop hal.instrumentation.lib.path \"\"")
- shell.Execute("setprop hal.instrumentation.profile.args \"\"")
- shell.Execute("setprop hal.instrumentation.enable false")
-
- def _ParseTraceData(self, trace_file, measure_api_coverage):
- """Parses the data stored in trace_file, calculates the avg/max/min
- latency for each API.
-
- Args:
- trace_file: file that stores the trace data.
- measure_api_coverage: whether to measure the api coverage data.
-
- Returns:
- VTSProfilingData which contain the list of API names and the avg/max/min
- latency for each API.
- """
- profiling_data = VTSProfilingData()
- api_timestamps = {}
- api_latencies = {}
-
- trace_processor_binary = os.path.join(self.data_file_path, "host",
- "bin", "trace_processor")
- trace_processor_lib = os.path.join(self.data_file_path, "host",
- "lib64")
- trace_processor_cmd = [
- "chmod a+x %s" % trace_processor_binary,
- "LD_LIBRARY_PATH=%s %s -m profiling_trace %s" %
- (trace_processor_lib, trace_processor_binary, trace_file)
- ]
-
- results = cmd_utils.ExecuteShellCommand(trace_processor_cmd)
- if any(results[cmd_utils.EXIT_CODE]):
- logging.error("Fail to execute command: %s" % trace_processor_cmd)
- logging.error("stdout: %s" % results[const.STDOUT])
- logging.error("stderr: %s" % results[const.STDERR])
- return profiling_data
-
- stdout_lines = results[const.STDOUT][1].split("\n")
- first_line = True
- for line in stdout_lines:
- if not line:
- continue
- if first_line:
- _, mode = line.split(":")
- profiling_data.options.add("hidl_hal_mode=%s" % mode)
- first_line = False
- else:
- full_api, latency = line.rsplit(":", 1)
- full_interface, api_name = full_api.rsplit("::", 1)
- if profiling_data.values.get(api_name):
- profiling_data.values[api_name].append(long(latency))
- else:
- profiling_data.values[api_name] = [long(latency)]
-
- if measure_api_coverage:
- package, interface_name = full_interface.split("::")
- package_name, version = package.split("@")
-
- if full_interface in self.api_coverage_data:
- self.api_coverage_data[
- full_interface].covered_apis.add(api_name)
- else:
- total_apis = self._GetTotalApis(
- package_name, version, interface_name)
- if total_apis:
- vts_api_coverage = VTSApiCoverageData(
- package_name, version, interface_name)
- vts_api_coverage.total_apis = total_apis
- if api_name in total_apis:
- vts_api_coverage.covered_apis.add(api_name)
- else:
- logging.warning("API %s is not supported by %s",
- api_name, full_interface)
- self.api_coverage_data[
- full_interface] = vts_api_coverage
-
- return profiling_data
-
- def _GetTotalApis(self, package_name, version, interface_name):
- """Parse the specified vts spec and get all APIs defined in the spec.
-
- Args:
- package_name: string, HAL package name.
- version: string, HAL version.
- interface_name: string, HAL interface name.
-
- Returns:
- A set of strings, each string represents an API defined in the spec.
- """
- total_apis = set()
- spec_proto = CompSpecMsg.ComponentSpecificationMessage()
- # TODO: support general package that does not start with android.hardware.
- if not package_name.startswith(DEFAULT_HAL_ROOT):
- logging.warning("Unsupported hal package: %s", package_name)
- return total_apis
-
- hal_package_path = package_name[len(DEFAULT_HAL_ROOT):].replace(
- ".", "/")
- vts_spec_path = os.path.join(
- self.data_file_path, "spec/hardware/interfaces", hal_package_path,
- version, "vts", interface_name[1:] + ".vts")
- logging.debug("vts_spec_path: %s", vts_spec_path)
- with open(vts_spec_path, 'r') as spec_file:
- spec_string = spec_file.read()
- text_format.Merge(spec_string, spec_proto)
- for api in spec_proto.interface.api:
- if not api.is_inherited:
- total_apis.add(api.name)
- return total_apis
-
- def StartHostProfiling(self, name):
- """Starts a profiling operation.
-
- Args:
- name: string, the name of a profiling point
-
- Returns:
- True if successful, False otherwise
- """
- if not self.enabled:
- return False
-
- if not hasattr(self, _HOST_PROFILING_DATA):
- setattr(self, _HOST_PROFILING_DATA, {})
-
- host_profiling_data = getattr(self, _HOST_PROFILING_DATA)
-
- if name in host_profiling_data:
- logging.error("profiling point %s is already active.", name)
- return False
- host_profiling_data[name] = feature_utils.GetTimestamp()
- return True
-
- def StopHostProfiling(self, name):
- """Stops a profiling operation.
-
- Args:
- name: string, the name of a profiling point
- """
- if not self.enabled:
- return
-
- if not hasattr(self, _HOST_PROFILING_DATA):
- setattr(self, _HOST_PROFILING_DATA, {})
-
- host_profiling_data = getattr(self, _HOST_PROFILING_DATA)
-
- if name not in host_profiling_data:
- logging.error("profiling point %s is not active.", name)
- return False
-
- start_timestamp = host_profiling_data[name]
- end_timestamp = feature_utils.GetTimestamp()
- if self.web and self.web.enabled:
- self.web.AddProfilingDataTimestamp(name, start_timestamp,
- end_timestamp)
- return True
-
- def ProcessTraceDataForTestCase(self, dut, measure_api_coverage=True):
- """Pulls the generated trace file to the host, parses the trace file to
- get the profiling data (e.g. latency of each API call) and stores these
- data in _profiling_data.
-
- Requires the feature to be enabled; no-op otherwise.
-
- Args:
- dut: the registered device.
- """
- if not self.enabled:
- return
-
- if not hasattr(self, _PROFILING_DATA):
- setattr(self, _PROFILING_DATA, [])
-
- profiling_data = getattr(self, _PROFILING_DATA)
-
- trace_files = []
- save_trace_remote = getattr(
- self, keys.ConfigKeys.IKEY_SAVE_TRACE_FILE_REMOTE, False)
- if save_trace_remote:
- trace_files = self.GetTraceFiles(
- dut,
- getattr(self, keys.ConfigKeys.IKEY_PROFILING_TRACING_PATH,
- None),
- getattr(self, keys.ConfigKeys.IKEY_TRACE_FILE_TOOL_NAME, None))
- else:
- trace_files = self.GetTraceFiles(dut)
-
- for file in trace_files:
- logging.info("parsing trace file: %s.", file)
- data = self._ParseTraceData(file, measure_api_coverage)
- if data:
- profiling_data.append(data)
-
- def ProcessAndUploadTraceData(self, upload_api_coverage=True):
- """Process and upload profiling trace data.
-
- Requires the feature to be enabled; no-op otherwise.
-
- Merges the profiling data generated by each test case, calculates the
- aggregated max/min/avg latency for each API and uploads these latency
- metrics to webdb.
-
- Args:
- upload_api_coverage: whether to upload the API coverage data.
- """
- if not self.enabled:
- return
-
- merged_profiling_data = VTSProfilingData()
- for data in getattr(self, _PROFILING_DATA, []):
- for item in data.options:
- merged_profiling_data.options.add(item)
- for api, latences in data.values.items():
- if merged_profiling_data.values.get(api):
- merged_profiling_data.values[api].extend(latences)
- else:
- merged_profiling_data.values[api] = latences
- for api, latencies in merged_profiling_data.values.items():
- if not self.web or not self.web.enabled:
- continue
-
- self.web.AddProfilingDataUnlabeledVector(
- api,
- latencies,
- merged_profiling_data.options,
- x_axis_label="API processing latency (nano secs)",
- y_axis_label="Frequency")
-
- if upload_api_coverage:
- self.web.AddApiCoverageReport(self.api_coverage_data.values())
diff --git a/utils/python/reporting/__init__.py b/utils/python/reporting/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/reporting/__init__.py
+++ /dev/null
diff --git a/utils/python/reporting/log_uploading_utils.py b/utils/python/reporting/log_uploading_utils.py
deleted file mode 100644
index 0974873..0000000
--- a/utils/python/reporting/log_uploading_utils.py
+++ /dev/null
@@ -1,130 +0,0 @@
-#
-# 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.
-
-import logging
-import os
-
-from vts.proto import VtsReportMessage_pb2 as ReportMsg
-from vts.runners.host import keys
-from vts.utils.python.reporting import report_file_utils
-from vts.utils.python.systrace import systrace_controller
-from vts.utils.python.web import feature_utils
-
-
-class LogUploadingFeature(feature_utils.Feature):
- """Feature object for log uploading functionality.
-
- Attributes:
- enabled: boolean, True if log uploading is enabled, False otherwise.
- web: (optional) WebFeature, object storing web feature util for test run.
- _report_file_util: report file util object for uploading logs to distant.
- _report_file_util_gcs: report file util object for uploading logs to gcs.
- """
-
- _TOGGLE_PARAM = keys.ConfigKeys.IKEY_ENABLE_LOG_UPLOADING
- _REQUIRED_PARAMS = [
- keys.ConfigKeys.IKEY_ANDROID_DEVICE,
- ]
- _OPTIONAL_PARAMS = [
- keys.ConfigKeys.KEY_TESTBED_NAME,
- keys.ConfigKeys.IKEY_LOG_UPLOADING_USE_DATE_DIRECTORY,
- keys.ConfigKeys.IKEY_LOG_UPLOADING_PATH,
- keys.ConfigKeys.IKEY_LOG_UPLOADING_URL_PREFIX,
- keys.ConfigKeys.IKEY_LOG_UPLOADING_GCS_BUCKET_NAME,
- keys.ConfigKeys.IKEY_SERVICE_JSON_PATH
- ]
-
- def __init__(self, user_params, web=None):
- """Initializes the log uploading feature.
-
- Args:
- user_params: A dictionary from parameter name (String) to parameter value.
- web: (optional) WebFeature, object storing web feature util for test run
- """
- self.ParseParameters(
- toggle_param_name=self._TOGGLE_PARAM,
- required_param_names=self._REQUIRED_PARAMS,
- optional_param_names=self._OPTIONAL_PARAMS,
- user_params=user_params)
- self.web = web
-
- if self.enabled:
- logging.info("Log uploading is enabled")
- else:
- logging.debug("Log uploading is disabled")
- return
-
- if all(hasattr(self, attr) for attr in [
- keys.ConfigKeys.IKEY_LOG_UPLOADING_GCS_BUCKET_NAME,
- keys.ConfigKeys.IKEY_SERVICE_JSON_PATH]):
- gcs_bucket_name = getattr(
- self, keys.ConfigKeys.IKEY_LOG_UPLOADING_GCS_BUCKET_NAME)
- gcs_url_prefix = "https://storage.cloud.google.com/" + gcs_bucket_name + "/"
- self._report_file_util_gcs = report_file_utils.ReportFileUtil(
- flatten_source_dir=True,
- use_destination_date_dir=getattr(
- self,
- keys.ConfigKeys.IKEY_LOG_UPLOADING_USE_DATE_DIRECTORY,
- True),
- destination_dir=gcs_bucket_name,
- url_prefix=gcs_url_prefix,
- gcs_key_path=getattr(self,
- keys.ConfigKeys.IKEY_SERVICE_JSON_PATH))
-
- if hasattr(self, keys.ConfigKeys.IKEY_LOG_UPLOADING_PATH):
- self._report_file_util = report_file_utils.ReportFileUtil(
- flatten_source_dir=True,
- use_destination_date_dir=getattr(
- self,
- keys.ConfigKeys.IKEY_LOG_UPLOADING_USE_DATE_DIRECTORY,
- True),
- destination_dir=getattr(
- self, keys.ConfigKeys.IKEY_LOG_UPLOADING_PATH),
- url_prefix=getattr(
- self, keys.ConfigKeys.IKEY_LOG_UPLOADING_URL_PREFIX, None))
-
- def UploadLogs(self, prefix=None, dryrun=False):
- """Save test logs and add log urls to report message.
-
- Args:
- prefix: string, file name prefix. Will be auto-generated if not provided.
- dryrun: bool, whether to perform a dry run that attaches
- destination URLs to result message only. if True,
- log files will not be actually uploaded.
- """
- if not self.enabled:
- return
-
- if not prefix:
- prefix = '%s_%s_' % (
- getattr(self, keys.ConfigKeys.KEY_TESTBED_NAME, ''),
- self.web.report_msg.start_timestamp)
-
- def path_filter(path):
- '''filter to exclude proto files in log uploading'''
- return not path.endswith('_proto.msg')
-
- for object_name in ['_report_file_util_gcs', '_report_file_util']:
- if hasattr(self, object_name):
- report_file_util = getattr(self, object_name)
- urls = report_file_util.SaveReportsFromDirectory(
- source_dir=logging.log_path,
- file_name_prefix=prefix,
- file_path_filters=path_filter,
- dryrun=dryrun)
- if urls is None:
- logging.error('Error happened when saving logs.')
- elif self.web and self.web.enabled:
- self.web.AddLogUrls(urls)
\ No newline at end of file
diff --git a/utils/python/reporting/report_file_utils.py b/utils/python/reporting/report_file_utils.py
deleted file mode 100644
index 7bc676f..0000000
--- a/utils/python/reporting/report_file_utils.py
+++ /dev/null
@@ -1,272 +0,0 @@
-#
-# 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.
-
-import datetime
-import logging
-import os
-import shutil
-import tempfile
-
-from vts.utils.python.common import cmd_utils
-from vts.utils.python.gcs import gcs_api_utils
-
-
-def NotNoneStr(item):
- '''Convert a variable to string only if it is not None'''
- return str(item) if item is not None else None
-
-
-class ReportFileUtil(object):
- '''Utility class for report file saving.
-
- Contains methods to save report files or read incremental parts of
- report files to a destination folder and get URLs.
- Used by profiling util, systrace util, and host log reporting.
-
- Attributes:
- _flatten_source_dir: bool, whether to flatten source directory
- structure in destination directory. Current
- implementation assumes no duplicated fine names
- _use_destination_date_dir: bool, whether to create date directory
- in destination directory
- _source_dir: string, source directory that contains report files
- _destination_dir: string, the GCS destination bucket name.
- _url_prefix: string, a prefix added to relative destination file paths.
- If set to None, will use parent directory path.
- _use_gcs: bool, whether or not this ReportFileUtil is using GCS.
- _gcs_api_utils: GcsApiUtils object used by the ReportFileUtil object.
- _gcs_available: bool, whether or not the GCS agent is available.
- '''
-
- def __init__(self,
- flatten_source_dir=False,
- use_destination_date_dir=False,
- source_dir=None,
- destination_dir=None,
- url_prefix=None,
- gcs_key_path=None):
- """Initializes the ReportFileUtils object.
-
- Args:
- flatten_source_dir: bool, whether or not flatten the directory structure.
- use_destination_date_dir: bool, whether or not use date as part of name,
- source_dir: string, path to the source directory.
- destination_dir: string, path to the destination directory.
- url_prefix: string, prefix of the url used to upload the link to dashboard.
- gcs_key_path: string, path to the GCS key file.
- """
- source_dir = NotNoneStr(source_dir)
- destination_dir = NotNoneStr(destination_dir)
- url_prefix = NotNoneStr(url_prefix)
-
- self._flatten_source_dir = flatten_source_dir
- self._use_destination_date_dir = use_destination_date_dir
- self._source_dir = source_dir
- self._destination_dir = destination_dir
- self._url_prefix = url_prefix
- self._use_gcs = False
-
- if gcs_key_path is not None:
- self._use_gcs = True
- self._gcs_api_utils = gcs_api_utils.GcsApiUtils(
- gcs_key_path, destination_dir)
- self._gcs_available = self._gcs_api_utils.Enabled
-
- def _ConvertReportPath(self,
- src_path,
- root_dir=None,
- new_file_name=None,
- file_name_prefix=None):
- '''Convert report source file path to destination path and url.
-
- Args:
- src_path: string, source report file path.
- new_file_name: string, new file name to use on destination.
- file_name_prefix: string, prefix added to destination file name.
- if new_file_name is set, prefix will be added
- to new_file_name as well.
-
- Returns:
- tuple(string, string), containing destination path and url
- '''
- root_dir = NotNoneStr(root_dir)
- new_file_name = NotNoneStr(new_file_name)
- file_name_prefix = NotNoneStr(file_name_prefix)
-
- dir_path = os.path.dirname(src_path)
-
- relative_path = os.path.basename(src_path)
- if new_file_name:
- relative_path = new_file_name
- if file_name_prefix:
- relative_path = file_name_prefix + relative_path
- if not self._flatten_source_dir and root_dir:
- relative_path = os.path.join(
- os.path.relpath(dir_path, root_dir), relative_path)
- if self._use_destination_date_dir:
- now = datetime.datetime.now()
- date = now.strftime('%Y-%m-%d')
- relative_path = os.path.join(date, relative_path)
-
- if self._use_gcs:
- dest_path = relative_path
- else:
- dest_path = os.path.join(self._destination_dir, relative_path)
-
- url = dest_path
- if self._url_prefix is not None:
- url = self._url_prefix + relative_path
- return dest_path, url
-
- def _PushReportFile(self, src_path, dest_path):
- '''Push a report file to destination.
-
- Args:
- src_path: string, source path of report file
- dest_path: string, destination path of report file
- '''
- logging.info('Uploading log %s to %s.', src_path, dest_path)
-
- src_path = NotNoneStr(src_path)
- dest_path = NotNoneStr(dest_path)
-
- parent_dir = os.path.dirname(dest_path)
- if not os.path.exists(parent_dir):
- try:
- os.makedirs(parent_dir)
- except OSError as e:
- logging.exception(e)
- shutil.copy(src_path, dest_path)
-
- def _PushReportFileGcs(self, src_path, dest_path):
- """Upload args src file to the bucket in Google Cloud Storage.
-
- Args:
- src_path: string, source path of report file
- dest_path: string, destination path of report file
- """
- if not self._gcs_available:
- logging.error('Logs not being uploaded.')
- return
-
- logging.info('Uploading log %s to %s.', src_path, dest_path)
-
- src_path = NotNoneStr(src_path)
- dest_path = NotNoneStr(dest_path)
-
- # Copy snapshot to temp as GCS will not handle dynamic files.
- temp_dir = tempfile.mkdtemp()
- shutil.copy(src_path, temp_dir)
- src_path = os.path.join(temp_dir, os.path.basename(src_path))
- logging.debug('Snapshot of logs: %s', src_path)
-
- try:
- self._gcs_api_utils.UploadFile(src_path, dest_path)
- except IOError as e:
- logging.exception(e)
- finally:
- logging.debug('removing temporary directory')
- try:
- shutil.rmtree(temp_dir)
- except OSError as e:
- logging.exception(e)
-
- def SaveReport(self, src_path, new_file_name=None, file_name_prefix=None):
- '''Save report file to destination.
-
- Args:
- src_path: string, source report file path.
- new_file_name: string, new file name to use on destination.
- file_name_prefix: string, prefix added to destination file name.
- if new_file_name is set, prefix will be added
- to new_file_name as well.
-
- Returns:
- string, destination URL of saved report file.
- If url_prefix is set to None, will return destination path of
- report files. If error happens during read or write operation,
- this method will return None.
- '''
- src_path = NotNoneStr(src_path)
- new_file_name = NotNoneStr(new_file_name)
- file_name_prefix = NotNoneStr(file_name_prefix)
-
- try:
- dest_path, url = self._ConvertReportPath(
- src_path,
- new_file_name=new_file_name,
- file_name_prefix=file_name_prefix)
- if self._use_gcs:
- self._PushReportFileGcs(src_path, dest_path)
- else:
- self._PushReportFile(src_path, dest_path)
-
- return url
- except IOError as e:
- logging.exception(e)
-
- def SaveReportsFromDirectory(self,
- source_dir=None,
- file_name_prefix=None,
- file_path_filters=None,
- dryrun=False):
- '''Save report files from source directory to destination.
-
- Args:
- source_dir: string, source directory where report files are stored.
- if None, class attribute source_dir will be used.
- Default is None.
- file_name_prefix: string, prefix added to destination file name
- file_path_filter: function, a functions that return True (pass) or
- False (reject) given original file path.
- dryrun: bool, whether to perform a dry run to get urls only.
-
- Returns:
- A list of string, containing destination URLs of saved report files.
- If url_prefix is set to None, will return destination path of
- report files. If error happens during read or write operation,
- this method will return None.
- '''
- source_dir = NotNoneStr(source_dir)
- file_name_prefix = NotNoneStr(file_name_prefix)
- if not source_dir:
- source_dir = self._source_dir
-
- try:
- urls = []
-
- for (dirpath, dirnames, filenames) in os.walk(
- source_dir, followlinks=False):
- for filename in filenames:
- src_path = os.path.join(dirpath, filename)
- dest_path, url = self._ConvertReportPath(
- src_path,
- root_dir=source_dir,
- file_name_prefix=file_name_prefix)
-
- if file_path_filters and not file_path_filters(src_path):
- continue
-
- #TODO(yuexima): handle duplicated destination file names
- if not dryrun:
- if self._use_gcs:
- self._PushReportFileGcs(src_path, dest_path)
- else:
- self._PushReportFile(src_path, dest_path)
- urls.append(url)
-
- return urls
- except IOError as e:
- logging.exception(e)
diff --git a/utils/python/reporting/report_file_utils_test.py b/utils/python/reporting/report_file_utils_test.py
deleted file mode 100644
index 529afea..0000000
--- a/utils/python/reporting/report_file_utils_test.py
+++ /dev/null
@@ -1,195 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 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.
-
-import datetime
-import mock
-import os
-import unittest
-
-from vts.utils.python.reporting import report_file_utils
-
-
-def simple_os_walk(source_dir, followlinks):
- """mock function created for os.walk"""
- root = "/root"
- dirs = ("dir1", "dir2")
- files = ("dir1/file1_1.txt", "dir1/file1_2.txt", "dir1/file1_3.txt",
- "dir2/file2_1")
- return [(root, dirs, files)]
-
-
-def simple_PushReportFileGcs(src_path, dest_path):
- """mock function created for _PushReportFileGcs"""
- return
-
-
-def simple_tempfile_mkdtemp():
- """mock function for tempfile.mkdtemp"""
- return 'temp_dir'
-
-
-class ReportFileUtilsTest(unittest.TestCase):
- """Unit tests for report_file_utils module"""
-
- def setUp(self):
- """setup tasks"""
- self.category = "category_default"
- self.name = "name_default"
-
- def testInitializationDefault(self):
- """Tests the default setting initialization of a UploadGcs object."""
- _report_file_util = report_file_utils.ReportFileUtil()
- self.assertEqual(_report_file_util._flatten_source_dir, False)
- self.assertEqual(_report_file_util._use_destination_date_dir, False)
- self.assertEqual(_report_file_util._source_dir, None)
- self.assertEqual(_report_file_util._destination_dir, None)
- self.assertEqual(_report_file_util._url_prefix, None)
-
- def testInitializationCustom(self):
- """Tests the custom setting initialization of a UploadGcs object."""
- _report_file_util = report_file_utils.ReportFileUtil(
- flatten_source_dir=True,
- use_destination_date_dir=True,
- destination_dir="vts-log",
- url_prefix="https://storage.cloud.google.com/vts-log/")
-
- self.assertEqual(_report_file_util._flatten_source_dir, True)
- self.assertEqual(_report_file_util._use_destination_date_dir, True)
- self.assertEqual(_report_file_util._source_dir, None)
- self.assertEqual(_report_file_util._destination_dir, "vts-log")
- self.assertEqual(_report_file_util._url_prefix,
- "https://storage.cloud.google.com/vts-log/")
-
- def testConvertReportPath(self):
- """Tests _ConvertReportPath."""
- _report_file_util = report_file_utils.ReportFileUtil(
- flatten_source_dir=False,
- use_destination_date_dir=False,
- destination_dir="vts-log",
- url_prefix="https://storage.cloud.google.com/vts-log/")
- _report_file_util._use_gcs = True
-
- src_path = "dir1/dir1_1/dir_1_1_1/file1"
- root_dir = "dir1/dir1_1"
- file_name_prefix = ""
- dest_path, url = _report_file_util._ConvertReportPath(
- src_path=src_path,
- root_dir=root_dir,
- file_name_prefix=file_name_prefix)
-
- self.assertEqual(
- dest_path,
- os.path.join(
- os.path.relpath(os.path.dirname(src_path), root_dir),
- os.path.basename(src_path)))
- self.assertEqual(
- url,
- os.path.join(
- _report_file_util._url_prefix,
- os.path.join(
- os.path.relpath(os.path.dirname(src_path), root_dir),
- os.path.basename(src_path))))
-
- def testConvertReportPathFlatten(self):
- """Tests _ConvertReportPath with flattened source dir."""
- _report_file_util = report_file_utils.ReportFileUtil(
- flatten_source_dir=True,
- use_destination_date_dir=False,
- destination_dir="vts-log",
- url_prefix="https://storage.cloud.google.com/vts-log/")
- _report_file_util._use_gcs = True
-
- src_path = "dir1/dir1_1/dir_1_1_1/file1"
- root_dir = "dir1/dir1_1"
- file_name_prefix = ""
- dest_path, url = _report_file_util._ConvertReportPath(
- src_path=src_path,
- root_dir=root_dir,
- file_name_prefix=file_name_prefix)
-
- self.assertEqual(dest_path, os.path.basename(src_path))
- self.assertEqual(
- url,
- os.path.join(_report_file_util._url_prefix,
- os.path.basename(src_path)))
-
- def testConvertReportPathFlattenDateDir(self):
- """Tests _ConvertReportPath with flattened source dir and date dir."""
- _report_file_util = report_file_utils.ReportFileUtil(
- flatten_source_dir=True,
- use_destination_date_dir=True,
- destination_dir="vts-log",
- url_prefix="https://storage.cloud.google.com/vts-log/")
- _report_file_util._use_gcs = True
-
- src_path = "dir1/dir1_1/dir_1_1_1/file1"
- root_dir = "dir1/dir1_1"
- file_name_prefix = ""
- dest_path, url = _report_file_util._ConvertReportPath(
- src_path=src_path,
- root_dir=root_dir,
- file_name_prefix=file_name_prefix)
-
- self.assertEqual(
- dest_path,
- os.path.join(datetime.datetime.now().strftime('%Y-%m-%d'),
- os.path.basename(src_path)))
- self.assertEqual(
- url,
- os.path.join(
- _report_file_util._url_prefix,
- os.path.join(datetime.datetime.now().strftime('%Y-%m-%d'),
- os.path.basename(src_path))))
-
- @mock.patch('tempfile.mkdtemp', side_effect=simple_tempfile_mkdtemp)
- def testPushReportFileGcs(self, simple_tempfile_mkdtemp):
- """Tests the _PushReportFileGcs function with mocking"""
- _report_file_util = report_file_utils.ReportFileUtil()
- _report_file_util._gcs_api_utils = mock.MagicMock()
- _report_file_util._gcs_available = True
- report_file_utils.shutil = mock.MagicMock()
- _report_file_util._PushReportFileGcs("src_path", "dest_path")
- _report_file_util._gcs_api_utils.UploadFile.assert_called_with(
- "temp_dir/src_path", "dest_path")
- report_file_utils.shutil.copy.assert_called_with(
- 'src_path', 'temp_dir')
- report_file_utils.shutil.rmtree.assert_called_with('temp_dir')
-
- @mock.patch(
- 'vts.utils.python.reporting.report_file_utils.ReportFileUtil._PushReportFileGcs',
- side_effect=simple_PushReportFileGcs)
- @mock.patch('os.walk', side_effect=simple_os_walk)
- def testSaveReportsFromDirectory(self, simple_os_walk,
- simple_PushReportFileGcs):
- """Tests the SaveReportsFromDirectory function with mocking"""
- _report_file_util = report_file_utils.ReportFileUtil(
- flatten_source_dir=False,
- use_destination_date_dir=False,
- destination_dir="vts-log")
- _report_file_util._use_gcs = True
-
- source_dir = "/root"
- file_name_prefix = "prefix_"
- urls = _report_file_util.SaveReportsFromDirectory(
- source_dir=source_dir,
- file_name_prefix=file_name_prefix,
- file_path_filters=None)
- simple_os_walk.assert_called_with(source_dir, followlinks=False)
- self.assertEqual(simple_PushReportFileGcs.call_count, 4)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/utils/python/systrace/__init__.py b/utils/python/systrace/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/systrace/__init__.py
+++ /dev/null
diff --git a/utils/python/systrace/systrace_controller.py b/utils/python/systrace/systrace_controller.py
deleted file mode 100644
index 3ff2d2b..0000000
--- a/utils/python/systrace/systrace_controller.py
+++ /dev/null
@@ -1,271 +0,0 @@
-#
-# 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.
-
-import os
-import tempfile
-import shutil
-import subprocess
-import logging
-
-PATH_SYSTRACE_SCRIPT = os.path.join('tools/external/chromium-trace',
- 'systrace.py')
-EXPECTED_START_STDOUT = 'Starting tracing'
-
-
-class SystraceController(object):
- '''A util to start/stop systrace through shell command.
-
- Attributes:
- _android_vts_path: string, path to android-vts
- _path_output: string, systrace temporally output path
- _path_systrace_script: string, path to systrace controller python script
- _device_serial: string, device serial string
- _subprocess: subprocess.Popen, a subprocess objects of systrace shell command
- is_valid: boolean, whether the current environment setting for
- systrace is valid
- process_name: string, process name to trace. The value can be empty.
- '''
-
- def __init__(self, android_vts_path, device_serial, process_name=''):
- self._android_vts_path = android_vts_path
- self._path_output = None
- self._subprocess = None
- self._device_serial = device_serial
- if not device_serial:
- logging.warning(
- 'Device serial is not provided for systrace. '
- 'Tool will not start if multiple devices are connected.')
- self.process_name = process_name
- self._path_systrace_script = os.path.join(android_vts_path,
- PATH_SYSTRACE_SCRIPT)
- self.is_valid = os.path.exists(self._path_systrace_script)
- if not self.is_valid:
- logging.error('invalid systrace script path: %s',
- self._path_systrace_script)
-
- @property
- def is_valid(self):
- ''''returns whether the current environment setting is valid'''
- return self._is_valid
-
- @is_valid.setter
- def is_valid(self, is_valid):
- ''''Set valid status'''
- self._is_valid = is_valid
-
- @property
- def process_name(self):
- ''''returns process name'''
- return self._process_name
-
- @process_name.setter
- def process_name(self, process_name):
- ''''Set process name'''
- self._process_name = process_name
-
- @property
- def has_output(self):
- ''''returns whether output file exists and not empty.
-
- Returns:
- False if output path is not specified, or output file doesn't exist, or output
- file size is zero; True otherwise.
- '''
- if not self._path_output:
- logging.warning('systrace output path is empty.')
- return False
-
- try:
- if os.path.getsize(self._path_output) == 0:
- logging.warning('systrace output file is empty.')
- return False
- except OSError:
- logging.error('systrace output file does not exist: %s',
- self._path_output)
- return False
- return True
-
- def Start(self):
- '''Start systrace process.
-
- Use shell command to start a python systrace script
-
- Returns:
- True if successfully started systrace; False otherwise.
- '''
- self._subprocess = None
- self._path_output = None
-
- if not self.is_valid:
- logging.error(
- 'Cannot start systrace: configuration is not correct for %s.',
- self.process_name)
- return False
-
- # TODO: check target device for compatibility (e.g. has systrace hooks)
- process_name_arg = ''
- if self.process_name:
- process_name_arg = '-a %s' % self.process_name
-
- device_serial_arg = ''
- if self._device_serial:
- device_serial_arg = '--serial=%s' % self._device_serial
-
- tmp_dir = tempfile.mkdtemp()
- tmp_filename = self.process_name if self.process_name else 'systrace'
- self._path_output = str(os.path.join(tmp_dir, tmp_filename + '.html'))
-
- cmd = ('python -u {script} hal sched '
- '{process_name_arg} {serial} -o {output}').format(
- script=self._path_systrace_script,
- process_name_arg=process_name_arg,
- serial=device_serial_arg,
- output=self._path_output)
- process = subprocess.Popen(
- str(cmd),
- shell=True,
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
-
- line = ''
- success = False
- while process.poll() is None:
- line += process.stdout.read(1)
-
- if not line:
- break
- elif EXPECTED_START_STDOUT in line:
- success = True
- break
-
- if not success:
- logging.error('Failed to start systrace on process %s',
- self.process_name)
- stdout, stderr = process.communicate()
- logging.error('stdout: %s', line + stdout)
- logging.error('stderr: %s', stderr)
- logging.error('ret_code: %s', process.returncode)
- return False
-
- self._subprocess = process
- logging.info('Systrace started for %s', self.process_name)
- return True
-
- def Stop(self):
- '''Stop systrace process.
-
- Returns:
- True if successfully stopped systrace or systrace already stopped;
- False otherwise.
- '''
- if not self.is_valid:
- logging.warn(
- 'Cannot stop systrace: systrace was not started for %s.',
- self.process_name)
- return False
-
- if not self._subprocess:
- logging.debug('Systrace already stopped.')
- return True
-
- # Press enter to stop systrace script
- self._subprocess.stdin.write('\n')
- self._subprocess.stdin.flush()
- # Wait for output to be written down
- # TODO: use subprocess.TimeoutExpired after upgrading to python >3.3
- out, err = self._subprocess.communicate()
- logging.info('Systrace stopped for %s', self.process_name)
- logging.debug('Systrace stdout: %s', out)
- if err.strip():
- logging.error('Systrace stderr: %s', err)
-
- self._subprocess = None
-
- return True
-
- def ReadLastOutput(self):
- '''Read systrace output html.
-
- Returns:
- string, data of systrace html output. None if failed to read.
- '''
- if not self.is_valid or not self._subprocess:
- logging.warn(
- 'Cannot read output: systrace was not started for %s.',
- self.process_name)
- return None
-
- if not self.has_output:
- logging.error(
- 'systrace did not started/ended correctly. Output is empty.')
- return False
-
- try:
- with open(self._path_output, 'r') as f:
- data = f.read()
- logging.debug('Systrace output length for %s: %s',
- process_name, len(data))
- return data
- except Exception as e:
- logging.error('Cannot read output: file open failed, %s', e)
- return None
-
- def SaveLastOutput(self, report_path=None):
- if not report_path:
- logging.error('report path supplied is None')
- return False
- report_path = str(report_path)
-
- if not self.has_output:
- logging.error(
- 'systrace did not started/ended correctly. Output is empty.')
- return False
-
- parent_dir = os.path.dirname(report_path)
- if not os.path.exists(parent_dir):
- try:
- os.makedirs(parent_dir)
- except Exception as e:
- logging.error('error happened while creating directory: %s', e)
- return False
-
- try:
- shutil.copy(self._path_output, report_path)
- except Exception as e: # TODO(yuexima): more specific error catch
- logging.error('failed to copy output to report path: %s', e)
- return False
-
- return True
-
- def ClearLastOutput(self):
- '''Clear systrace output html.
-
- Since output are created in temp directories, this step is optional.
-
- Returns:
- True if successfully deleted temp output file; False otherwise.
- '''
-
- if self._path_output:
- try:
- shutil.rmtree(os.path.basename(self._path_output))
- except Exception as e:
- logging.error('failed to remove systrace output file. %s', e)
- return False
- finally:
- self._path_output = None
-
- return True
diff --git a/utils/python/systrace/systrace_utils.py b/utils/python/systrace/systrace_utils.py
deleted file mode 100644
index a4a2be5..0000000
--- a/utils/python/systrace/systrace_utils.py
+++ /dev/null
@@ -1,141 +0,0 @@
-#
-# 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.
-
-import logging
-import os
-
-from vts.proto import VtsReportMessage_pb2 as ReportMsg
-from vts.runners.host import keys
-from vts.utils.python.systrace import systrace_controller
-from vts.utils.python.web import feature_utils
-
-_SYSTRACE_CONTROLLER = "systrace_controller"
-
-
-class SystraceFeature(feature_utils.Feature):
- """Feature object for systrace functionality.
-
- Attributes:
- enabled: boolean, True if systrace is enabled, False otherwise
- web: (optional) WebFeature, object storing web feature util for test run
- """
-
- _TOGGLE_PARAM = keys.ConfigKeys.IKEY_ENABLE_SYSTRACE
- _REQUIRED_PARAMS = [
- keys.ConfigKeys.KEY_TESTBED_NAME, keys.ConfigKeys.IKEY_ANDROID_DEVICE,
- keys.ConfigKeys.IKEY_DATA_FILE_PATH,
- keys.ConfigKeys.IKEY_SYSTRACE_REPORT_PATH,
- keys.ConfigKeys.IKEY_SYSTRACE_REPORT_URL_PREFIX
- ]
- _OPTIONAL_PARAMS = [keys.ConfigKeys.IKEY_SYSTRACE_PROCESS_NAME]
-
- def __init__(self, user_params, web=None):
- """Initializes the systrace feature.
-
- Args:
- user_params: A dictionary from parameter name (String) to parameter value.
- web: (optional) WebFeature, object storing web feature util for test run
- """
- self.ParseParameters(self._TOGGLE_PARAM, self._REQUIRED_PARAMS,
- self._OPTIONAL_PARAMS, user_params)
- self.web = web
- if self.enabled:
- logging.info("Systrace is enabled.")
- else:
- logging.debug("Systrace is disabled.")
-
- def StartSystrace(self):
- """Initialize systrace controller if enabled.
-
- Requires the feature to be enabled; no-op otherwise.
- """
- if not self.enabled:
- return
-
- process_name = getattr(self,
- keys.ConfigKeys.IKEY_SYSTRACE_PROCESS_NAME, '')
- process_name = str(process_name)
- data_file_path = getattr(self, keys.ConfigKeys.IKEY_DATA_FILE_PATH)
-
- # TODO: handle device_serial for multi-device
- android_devices = getattr(self, keys.ConfigKeys.IKEY_ANDROID_DEVICE)
- if not isinstance(android_devices, list):
- logging.warn("android device information not available")
- return
- device_spec = android_devices[0]
- serial = device_spec.get(keys.ConfigKeys.IKEY_SERIAL)
- if not serial:
- logging.error("Serial for device at index 0 is not available.")
- self.enabled = False
- serial = str(serial)
-
- android_vts_path = os.path.normpath(os.path.join(data_file_path, '..'))
- self.controller = systrace_controller.SystraceController(
- android_vts_path, device_serial=serial, process_name=process_name)
- self.controller.Start()
-
- def ProcessAndUploadSystrace(self, test_name):
- """Stops and outputs the systrace data to configured path.
-
- Requires the feature to be enabled; no-op otherwise.
-
- Args:
- test_name: String, the name of the test
- """
- if not self.enabled:
- return
-
- controller = getattr(self, "controller", None)
- if not controller:
- logging.warn("ProcessSystrace: missing systrace controller")
- return
-
- controller.Stop()
-
- if not controller.has_output:
- logging.warn("ProcessSystrace: systrace controller has no output")
- return
-
- try:
- test_module_name = getattr(self, keys.ConfigKeys.KEY_TESTBED_NAME)
- process = controller.process_name
- time = feature_utils.GetTimestamp()
- report_path = getattr(self,
- keys.ConfigKeys.IKEY_SYSTRACE_REPORT_PATH)
- report_destination_file_name = 'systrace_{test}_{process}_{time}.html'.format(
- test=test_name, process=process, time=time)
- report_destination_file_path = os.path.join(
- report_path, report_destination_file_name)
- if controller.SaveLastOutput(report_destination_file_path):
- logging.debug('Systrace output saved to %s',
- report_destination_file_path)
- else:
- logging.error('Failed to save systrace output.')
-
- report_url_prefix = getattr(
- self, keys.ConfigKeys.IKEY_SYSTRACE_REPORT_URL_PREFIX)
- report_url_prefix = str(report_url_prefix)
- report_destination_file_url = '%s%s' % (
- report_url_prefix, report_destination_file_name)
-
- if self.web and self.web.enabled:
- self.web.AddSystraceUrl(report_destination_file_url)
- logging.info('systrace result path %s .',
- report_destination_file_url)
- except Exception as e: # TODO(yuexima): more specific exceptions catch
- logging.exception('Failed to add systrace to report message %s', e)
- finally:
- if not controller.ClearLastOutput():
- logging.error('failed to clear last systrace output.')
diff --git a/utils/python/web/__init__.py b/utils/python/web/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/utils/python/web/__init__.py
+++ /dev/null
diff --git a/utils/python/web/dashboard_rest_client.py b/utils/python/web/dashboard_rest_client.py
deleted file mode 100644
index 617a4af..0000000
--- a/utils/python/web/dashboard_rest_client.py
+++ /dev/null
@@ -1,115 +0,0 @@
-
-# Copyright 2016 Google Inc.
-#
-# 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.
-
-import base64
-import logging
-import os
-import subprocess
-import tempfile
-
-from oauth2client import service_account
-
-_OPENID_SCOPE = 'openid'
-
-class DashboardRestClient(object):
- """Instance of the Dashboard REST client.
-
- Attributes:
- post_cmd: String, The command-line string to post data to the dashboard,
- e.g. 'wget <url> --post-file '
- service_json_path: String, The path to the service account keyfile
- created from Google App Engine settings.
- auth_token: ServiceAccountCredentials object or None if not
- initialized.
- """
-
- def __init__(self, post_cmd, service_json_path):
- self.post_cmd = post_cmd
- self.service_json_path = service_json_path
- self.auth_token = None
-
- def Initialize(self):
- """Initializes the client with an auth token and access token.
-
- Returns:
- True if the client is initialized successfully, False otherwise.
- """
- try:
- self.auth_token = service_account.ServiceAccountCredentials.from_json_keyfile_name(
- self.service_json_path, [_OPENID_SCOPE])
- self.auth_token.get_access_token()
- except IOError as e:
- logging.error("Error reading service json keyfile: %s", e)
- return False
- except (ValueError, KeyError) as e:
- logging.error("Invalid service json keyfile: %s", e)
- return False
- return True
-
-
- def _GetToken(self):
- """Gets an OAuth2 token using from a service account json keyfile.
-
- Uses the service account keyfile located at 'service_json_path', provided
- to the constructor, to request an OAuth2 token.
-
- Returns:
- String, an OAuth2 token using the service account credentials.
- None if authentication fails.
- """
- return str(self.auth_token.get_access_token().access_token)
-
- def AddAuthToken(self, post_message):
- """Add OAuth2 token to the dashboard message.
-
- Args:
- post_message: DashboardPostMessage, The data to post.
-
- Returns:
- True if successful, False otherwise
- """
- token = self._GetToken()
- if not token:
- return False
-
- post_message.access_token = token
-
- def PostData(self, post_message):
- """Post data to the dashboard database.
-
- Puts data into the dashboard database using its proto REST endpoint.
-
- Args:
- post_message: DashboardPostMessage, The data to post.
-
- Returns:
- True if successful, False otherwise
- """
- post_bytes = base64.b64encode(post_message.SerializeToString())
-
- with tempfile.NamedTemporaryFile(delete=False) as file:
- file.write(post_bytes)
- p = subprocess.Popen(
- self.post_cmd.format(path=file.name),
- shell=True,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- output, err = p.communicate()
- os.remove(file.name)
-
- if p.returncode or err:
- logging.error("Row insertion failed: %s", err)
- return False
- return True
diff --git a/utils/python/web/feature_utils.py b/utils/python/web/feature_utils.py
deleted file mode 100644
index 65a857b..0000000
--- a/utils/python/web/feature_utils.py
+++ /dev/null
@@ -1,69 +0,0 @@
-#
-# 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.
-#
-import logging
-import time
-
-
-def GetTimestamp():
- """Returns the current UTC time (unit: microseconds)."""
- return int(time.time() * 1000000)
-
-
-class Feature(object):
- """Configuration object for a feature.
-
- Stores configuration parameters and metadata.
-
- Attributes:
- enabled: boolean, True if the feature is enabled, False otherwise
- """
-
- enabled = False
-
- def ParseParameters(self,
- toggle_param_name=None,
- required_param_names=[],
- optional_param_names=[],
- user_params={}):
- """Creates a feature configuration object.
-
- Args:
- toggle_param_name: String, The name of the parameter used to toggle the feature
- required_param_names: list, The list of parameter names that are required
- optional_param_names: list, The list of parameter names that are optional
- """
- self.enabled = False
- if toggle_param_name:
- if toggle_param_name not in user_params:
- logging.debug("Missing toggle parameter in configuration: %s",
- toggle_param_name)
- return
- if not user_params[toggle_param_name]:
- logging.debug("Feature disabled in configuration: %s=False",
- toggle_param_name)
- return
-
- for name in required_param_names:
- if name not in user_params:
- return
- else:
- setattr(self, name, user_params[name])
-
- self.enabled = True
-
- for name in optional_param_names:
- if name in user_params:
- setattr(self, name, user_params[name])
diff --git a/utils/python/web/web_utils.py b/utils/python/web/web_utils.py
deleted file mode 100644
index 86ef450..0000000
--- a/utils/python/web/web_utils.py
+++ /dev/null
@@ -1,470 +0,0 @@
-#
-# 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.
-#
-
-import base64
-import getpass
-import logging
-import os
-import socket
-import time
-
-from vts.proto import VtsReportMessage_pb2 as ReportMsg
-from vts.runners.host import keys
-from vts.utils.python.web import dashboard_rest_client
-from vts.utils.python.web import feature_utils
-
-_PROFILING_POINTS = "profiling_points"
-
-
-class WebFeature(feature_utils.Feature):
- """Feature object for web functionality.
-
- Attributes:
- enabled: boolean, True if web feature is enabled, False otherwise
- report_msg: TestReportMessage, Proto summarizing the test run
- current_test_report_msg: TestCaseReportMessage, Proto summarizing the current test case
- rest_client: DashboardRestClient, client to which data will be posted
- """
-
- _TOGGLE_PARAM = keys.ConfigKeys.IKEY_ENABLE_WEB
- _REQUIRED_PARAMS = [
- keys.ConfigKeys.IKEY_DASHBOARD_POST_COMMAND,
- keys.ConfigKeys.IKEY_SERVICE_JSON_PATH,
- keys.ConfigKeys.KEY_TESTBED_NAME, keys.ConfigKeys.IKEY_BUILD,
- keys.ConfigKeys.IKEY_ANDROID_DEVICE, keys.ConfigKeys.IKEY_ABI_NAME,
- keys.ConfigKeys.IKEY_ABI_BITNESS
- ]
- _OPTIONAL_PARAMS = [
- keys.ConfigKeys.RUN_AS_VTS_SELFTEST,
- keys.ConfigKeys.IKEY_ENABLE_PROFILING,
- ]
-
- def __init__(self, user_params):
- """Initializes the web feature.
-
- Parses the arguments and initializes the web functionality.
-
- Args:
- user_params: A dictionary from parameter name (String) to parameter value.
- """
- self.ParseParameters(
- toggle_param_name=self._TOGGLE_PARAM,
- required_param_names=self._REQUIRED_PARAMS,
- optional_param_names=self._OPTIONAL_PARAMS,
- user_params=user_params)
- if not self.enabled:
- return
-
- # Initialize the dashboard client
- post_cmd = getattr(self, keys.ConfigKeys.IKEY_DASHBOARD_POST_COMMAND)
- service_json_path = str(
- getattr(self, keys.ConfigKeys.IKEY_SERVICE_JSON_PATH))
- try:
- self.rest_client = dashboard_rest_client.DashboardRestClient(
- post_cmd, service_json_path)
- if not self.rest_client.Initialize():
- self.enabled = False
- except Exception as e:
- logging.exception("Failed to create REST client.")
- self.enabled = False
-
- self.report_msg = ReportMsg.TestReportMessage()
- self.report_msg.test = str(
- getattr(self, keys.ConfigKeys.KEY_TESTBED_NAME))
-
- if getattr(self, keys.ConfigKeys.IKEY_ENABLE_PROFILING, False):
- self.report_msg.test += "Profiling"
-
- self.report_msg.test_type = ReportMsg.VTS_HOST_DRIVEN_STRUCTURAL
- self.report_msg.start_timestamp = feature_utils.GetTimestamp()
- self.report_msg.host_info.hostname = socket.gethostname()
-
- android_devices = getattr(self, keys.ConfigKeys.IKEY_ANDROID_DEVICE,
- None)
- if not android_devices or not isinstance(android_devices, list):
- logging.warn("android device information not available")
- return
-
- for device_spec in android_devices:
- dev_info = self.report_msg.device_info.add()
- for elem in [
- keys.ConfigKeys.IKEY_PRODUCT_TYPE,
- keys.ConfigKeys.IKEY_PRODUCT_VARIANT,
- keys.ConfigKeys.IKEY_BUILD_FLAVOR,
- keys.ConfigKeys.IKEY_BUILD_ID, keys.ConfigKeys.IKEY_BRANCH,
- keys.ConfigKeys.IKEY_BUILD_ALIAS,
- keys.ConfigKeys.IKEY_API_LEVEL, keys.ConfigKeys.IKEY_SERIAL
- ]:
- if elem in device_spec:
- setattr(dev_info, elem, str(device_spec[elem]))
- # TODO: get abi information differently for multi-device support.
- setattr(dev_info, keys.ConfigKeys.IKEY_ABI_NAME,
- str(getattr(self, keys.ConfigKeys.IKEY_ABI_NAME)))
- setattr(dev_info, keys.ConfigKeys.IKEY_ABI_BITNESS,
- str(getattr(self, keys.ConfigKeys.IKEY_ABI_BITNESS)))
-
- def SetTestResult(self, result=None):
- """Set the current test case result to the provided result.
-
- If None is provided as a result, the current test report will be cleared, which results
- in a silent skip.
-
- Requires the feature to be enabled; no-op otherwise.
-
- Args:
- result: ReportMsg.TestCaseResult, the result of the current test or None.
- """
- if not self.enabled:
- return
-
- if not result:
- self.report_msg.test_case.remove(self.current_test_report_msg)
- self.current_test_report_msg = None
- else:
- self.current_test_report_msg.test_result = result
-
- def AddTestReport(self, test_name):
- """Creates a report for the specified test.
-
- Requires the feature to be enabled; no-op otherwise.
-
- Args:
- test_name: String, the name of the test
- """
- if not self.enabled:
- return
- self.current_test_report_msg = self.report_msg.test_case.add()
- self.current_test_report_msg.name = test_name
- self.current_test_report_msg.start_timestamp = feature_utils.GetTimestamp(
- )
-
- def AddApiCoverageReport(self, api_coverage_data_vec, isGlobal=True):
- """Adds an API coverage report to the VtsReportMessage.
-
- Translate each element in the give coverage data vector into a
- ApiCoverageReportMessage within the report message.
-
- Args:
- api_coverage_data_vec: list of VTSApiCoverageData which contains
- the metadata (e.g. package_name, version)
- and the total/covered api names.
- isGlobal: boolean, True if the coverage data is for the entire test,
- False if only for the current test case.
- """
-
- if not self.enabled:
- return
-
- if isGlobal:
- report = self.report_msg
- else:
- report = self.current_test_report_msg
-
- for api_coverage_data in api_coverage_data_vec:
- api_coverage = report.api_coverage.add()
- api_coverage.hal_interface.hal_package_name = api_coverage_data.package_name
- api_coverage.hal_interface.hal_version_major = int(
- api_coverage_data.version_major)
- api_coverage.hal_interface.hal_version_minor = int(
- api_coverage_data.version_minor)
- api_coverage.hal_interface.hal_interface_name = api_coverage_data.interface_name
- api_coverage.hal_api.extend(api_coverage_data.total_apis)
- api_coverage.covered_hal_api.extend(api_coverage_data.covered_apis)
-
- def AddCoverageReport(self,
- coverage_vec,
- src_file_path,
- git_project_name,
- git_project_path,
- revision,
- covered_count,
- line_count,
- isGlobal=True):
- """Adds a coverage report to the VtsReportMessage.
-
- Processes the source information, git project information, and processed
- coverage information and stores it into a CoverageReportMessage within the
- report message.
-
- Args:
- coverage_vec: list, list of coverage counts (int) for each line
- src_file_path: the path to the original source file
- git_project_name: the name of the git project containing the source
- git_project_path: the path from the root to the git project
- revision: the commit hash identifying the source code that was used to
- build a device image
- covered_count: int, number of lines covered
- line_count: int, total number of lines
- isGlobal: boolean, True if the coverage data is for the entire test, False if only for
- the current test case.
- """
- if not self.enabled:
- return
-
- if isGlobal:
- report = self.report_msg
- else:
- report = self.current_test_report_msg
-
- coverage = report.coverage.add()
- coverage.total_line_count = line_count
- coverage.covered_line_count = covered_count
- coverage.line_coverage_vector.extend(coverage_vec)
-
- src_file_path = os.path.relpath(src_file_path, git_project_path)
- coverage.file_path = src_file_path
- coverage.revision = revision
- coverage.project_name = git_project_name
-
- def AddProfilingDataTimestamp(
- self,
- name,
- start_timestamp,
- end_timestamp,
- x_axis_label="Latency (nano secs)",
- y_axis_label="Frequency",
- regression_mode=ReportMsg.VTS_REGRESSION_MODE_INCREASING):
- """Adds the timestamp profiling data to the web DB.
-
- Requires the feature to be enabled; no-op otherwise.
-
- Args:
- name: string, profiling point name.
- start_timestamp: long, nanoseconds start time.
- end_timestamp: long, nanoseconds end time.
- x-axis_label: string, the x-axis label title for a graph plot.
- y-axis_label: string, the y-axis label title for a graph plot.
- regression_mode: specifies the direction of change which indicates
- performance regression.
- """
- if not self.enabled:
- return
-
- if not hasattr(self, _PROFILING_POINTS):
- setattr(self, _PROFILING_POINTS, set())
-
- if name in getattr(self, _PROFILING_POINTS):
- logging.error("profiling point %s is already active.", name)
- return
-
- getattr(self, _PROFILING_POINTS).add(name)
- profiling_msg = self.report_msg.profiling.add()
- profiling_msg.name = name
- profiling_msg.type = ReportMsg.VTS_PROFILING_TYPE_TIMESTAMP
- profiling_msg.regression_mode = regression_mode
- profiling_msg.start_timestamp = start_timestamp
- profiling_msg.end_timestamp = end_timestamp
- profiling_msg.x_axis_label = x_axis_label
- profiling_msg.y_axis_label = y_axis_label
-
- def AddProfilingDataVector(
- self,
- name,
- labels,
- values,
- data_type,
- options=[],
- x_axis_label="x-axis",
- y_axis_label="y-axis",
- regression_mode=ReportMsg.VTS_REGRESSION_MODE_INCREASING):
- """Adds the vector profiling data in order to upload to the web DB.
-
- Requires the feature to be enabled; no-op otherwise.
-
- Args:
- name: string, profiling point name.
- labels: a list or set of labels.
- values: a list or set of values where each value is an integer.
- data_type: profiling data type.
- options: a set of options.
- x-axis_label: string, the x-axis label title for a graph plot.
- y-axis_label: string, the y-axis label title for a graph plot.
- regression_mode: specifies the direction of change which indicates
- performance regression.
- """
- if not self.enabled:
- return
-
- if not hasattr(self, _PROFILING_POINTS):
- setattr(self, _PROFILING_POINTS, set())
-
- if name in getattr(self, _PROFILING_POINTS):
- logging.error("profiling point %s is already active.", name)
- return
-
- getattr(self, _PROFILING_POINTS).add(name)
- profiling_msg = self.report_msg.profiling.add()
- profiling_msg.name = name
- profiling_msg.type = data_type
- profiling_msg.regression_mode = regression_mode
- if labels:
- profiling_msg.label.extend(labels)
- profiling_msg.value.extend(values)
- profiling_msg.x_axis_label = x_axis_label
- profiling_msg.y_axis_label = y_axis_label
- profiling_msg.options.extend(options)
-
- def AddProfilingDataLabeledVector(
- self,
- name,
- labels,
- values,
- options=[],
- x_axis_label="x-axis",
- y_axis_label="y-axis",
- regression_mode=ReportMsg.VTS_REGRESSION_MODE_INCREASING):
- """Adds the labeled vector profiling data in order to upload to the web DB.
-
- Requires the feature to be enabled; no-op otherwise.
-
- Args:
- name: string, profiling point name.
- labels: a list or set of labels.
- values: a list or set of values where each value is an integer.
- options: a set of options.
- x-axis_label: string, the x-axis label title for a graph plot.
- y-axis_label: string, the y-axis label title for a graph plot.
- regression_mode: specifies the direction of change which indicates
- performance regression.
- """
- self.AddProfilingDataVector(
- name, labels, values, ReportMsg.VTS_PROFILING_TYPE_LABELED_VECTOR,
- options, x_axis_label, y_axis_label, regression_mode)
-
- def AddProfilingDataUnlabeledVector(
- self,
- name,
- values,
- options=[],
- x_axis_label="x-axis",
- y_axis_label="y-axis",
- regression_mode=ReportMsg.VTS_REGRESSION_MODE_INCREASING):
- """Adds the unlabeled vector profiling data in order to upload to the web DB.
-
- Requires the feature to be enabled; no-op otherwise.
-
- Args:
- name: string, profiling point name.
- values: a list or set of values where each value is an integer.
- options: a set of options.
- x-axis_label: string, the x-axis label title for a graph plot.
- y-axis_label: string, the y-axis label title for a graph plot.
- regression_mode: specifies the direction of change which indicates
- performance regression.
- """
- self.AddProfilingDataVector(
- name, None, values, ReportMsg.VTS_PROFILING_TYPE_UNLABELED_VECTOR,
- options, x_axis_label, y_axis_label, regression_mode)
-
- def AddSystraceUrl(self, url):
- """Creates a systrace report message with a systrace URL.
-
- Adds a systrace report to the current test case report and supplies the
- url to the systrace report.
-
- Requires the feature to be enabled; no-op otherwise.
-
- Args:
- url: String, the url of the systrace report.
- """
- if not self.enabled:
- return
- systrace_msg = self.current_test_report_msg.systrace.add()
- systrace_msg.url.append(url)
-
- def AddLogUrls(self, urls):
- """Creates a log message with log file URLs.
-
- Adds a log message to the current test module report and supplies the
- url to the log files.
-
- Requires the feature to be enabled; no-op otherwise.
-
- Args:
- urls: list of string, the URLs of the logs.
- """
- if not self.enabled or urls is None:
- return
-
- for url in urls:
- for log_msg in self.report_msg.log:
- if log_msg.url == url:
- continue
-
- log_msg = self.report_msg.log.add()
- log_msg.url = url
- log_msg.name = os.path.basename(url)
-
- def GetTestModuleKeys(self):
- """Returns the test module name and start timestamp.
-
- Those two values can be used to find the corresponding entry
- in a used nosql database without having to lock all the data
- (which is infesiable) thus are essential for strong consistency.
- """
- return self.report_msg.test, self.report_msg.start_timestamp
-
- def GenerateReportMessage(self, requested, executed):
- """Uploads the result to the web service.
-
- Requires the feature to be enabled; no-op otherwise.
-
- Args:
- requested: list, A list of test case records requested to run
- executed: list, A list of test case records that were executed
-
- Returns:
- binary string, serialized report message.
- None if web is not enabled.
- """
- if not self.enabled:
- return None
-
- for test in requested[len(executed):]:
- msg = self.report_msg.test_case.add()
- msg.name = test.test_name
- msg.start_timestamp = feature_utils.GetTimestamp()
- msg.end_timestamp = msg.start_timestamp
- msg.test_result = ReportMsg.TEST_CASE_RESULT_FAIL
-
- self.report_msg.end_timestamp = feature_utils.GetTimestamp()
-
- build = getattr(self, keys.ConfigKeys.IKEY_BUILD)
- if keys.ConfigKeys.IKEY_BUILD_ID in build:
- build_id = str(build[keys.ConfigKeys.IKEY_BUILD_ID])
- self.report_msg.build_info.id = build_id
-
- logging.debug("_tearDownClass hook: start (username: %s)",
- getpass.getuser())
-
- if len(self.report_msg.test_case) == 0:
- logging.warn("_tearDownClass hook: skip uploading (no test case)")
- return ''
-
- post_msg = ReportMsg.DashboardPostMessage()
- post_msg.test_report.extend([self.report_msg])
-
- self.rest_client.AddAuthToken(post_msg)
-
- message_b = base64.b64encode(post_msg.SerializeToString())
-
- logging.debug('Result proto message generated. size: %s',
- len(message_b))
-
- logging.debug("_tearDownClass hook: status upload time stamp %s",
- str(self.report_msg.start_timestamp))
-
- return message_b
\ No newline at end of file
diff --git a/utils/python/Android.bp b/vndk_utils/Android.bp
similarity index 89%
rename from utils/python/Android.bp
rename to vndk_utils/Android.bp
index bf480b9..d539a99 100644
--- a/utils/python/Android.bp
+++ b/vndk_utils/Android.bp
@@ -33,12 +33,4 @@
"vndk/__init__.py",
"vndk/vndk_utils.py",
],
- version: {
- py2: {
- enabled: true,
- },
- py3: {
- enabled: true,
- },
- },
}
diff --git a/utils/__init__.py b/vndk_utils/__init__.py
similarity index 100%
rename from utils/__init__.py
rename to vndk_utils/__init__.py
diff --git a/utils/python/android/__init__.py b/vndk_utils/android/__init__.py
similarity index 100%
rename from utils/python/android/__init__.py
rename to vndk_utils/android/__init__.py
diff --git a/utils/python/android/api.py b/vndk_utils/android/api.py
similarity index 100%
rename from utils/python/android/api.py
rename to vndk_utils/android/api.py
diff --git a/utils/python/library/README.md b/vndk_utils/library/README.md
similarity index 100%
rename from utils/python/library/README.md
rename to vndk_utils/library/README.md
diff --git a/utils/python/library/__init__.py b/vndk_utils/library/__init__.py
similarity index 100%
rename from utils/python/library/__init__.py
rename to vndk_utils/library/__init__.py
diff --git a/utils/python/library/ar_parser.py b/vndk_utils/library/ar_parser.py
similarity index 100%
rename from utils/python/library/ar_parser.py
rename to vndk_utils/library/ar_parser.py
diff --git a/utils/python/library/elf/__init__.py b/vndk_utils/library/elf/__init__.py
similarity index 100%
rename from utils/python/library/elf/__init__.py
rename to vndk_utils/library/elf/__init__.py
diff --git a/utils/python/library/elf/consts.py b/vndk_utils/library/elf/consts.py
similarity index 97%
rename from utils/python/library/elf/consts.py
rename to vndk_utils/library/elf/consts.py
index 95998c0..cac8881 100644
--- a/utils/python/library/elf/consts.py
+++ b/vndk_utils/library/elf/consts.py
@@ -51,9 +51,9 @@
# e_machine
EM_386 = 3
EM_X86_64 = 62
-EM_MIPS = 8
EM_ARM = 40
EM_AARCH64 = 183
+EM_RISCV = 243
# Relocation types
R_ARM_ABS32 = 0x02
@@ -64,6 +64,8 @@
R_386_RELATIVE = 8
R_X86_64_64 = 1
R_X86_64_RELATIVE = 8
+R_RISCV_64 = 2
+R_RISCV_RELATIVE = 3
# Section types
SHT_NULL = 0
@@ -156,10 +158,6 @@
PT_ARM_ARCHEXT = 0x70000000
PT_ARM_EXIDX = 0x70000001
PT_ARM_UNWIND = 0x70000001
-PT_MIPS_REGINFO = 0x70000000
-PT_MIPS_RTPROC = 0x70000001
-PT_MIPS_OPTIONS = 0x70000002
-PT_MIPS_ABIFLAGS = 0x70000003
# Dynamic array tags
# Name Value d_un Executable Shared Object
diff --git a/utils/python/library/elf/structs.py b/vndk_utils/library/elf/structs.py
similarity index 100%
rename from utils/python/library/elf/structs.py
rename to vndk_utils/library/elf/structs.py
diff --git a/utils/python/library/elf/testing/build-libtest.sh b/vndk_utils/library/elf/testing/build-libtest.sh
similarity index 100%
rename from utils/python/library/elf/testing/build-libtest.sh
rename to vndk_utils/library/elf/testing/build-libtest.sh
diff --git a/utils/python/library/elf/testing/libtest.so b/vndk_utils/library/elf/testing/libtest.so
similarity index 100%
rename from utils/python/library/elf/testing/libtest.so
rename to vndk_utils/library/elf/testing/libtest.so
Binary files differ
diff --git a/utils/python/library/elf/testing/test-android-rela.s b/vndk_utils/library/elf/testing/test-android-rela.s
similarity index 100%
rename from utils/python/library/elf/testing/test-android-rela.s
rename to vndk_utils/library/elf/testing/test-android-rela.s
diff --git a/utils/python/library/elf/testing/test-relr.s b/vndk_utils/library/elf/testing/test-relr.s
similarity index 100%
rename from utils/python/library/elf/testing/test-relr.s
rename to vndk_utils/library/elf/testing/test-relr.s
diff --git a/utils/python/library/elf/testing/test-section-1.s b/vndk_utils/library/elf/testing/test-section-1.s
similarity index 100%
rename from utils/python/library/elf/testing/test-section-1.s
rename to vndk_utils/library/elf/testing/test-section-1.s
diff --git a/utils/python/library/elf/testing/test-section-2.s b/vndk_utils/library/elf/testing/test-section-2.s
similarity index 100%
rename from utils/python/library/elf/testing/test-section-2.s
rename to vndk_utils/library/elf/testing/test-section-2.s
diff --git a/utils/python/library/elf/testing/test-sym-relocation.cpp b/vndk_utils/library/elf/testing/test-sym-relocation.cpp
similarity index 100%
rename from utils/python/library/elf/testing/test-sym-relocation.cpp
rename to vndk_utils/library/elf/testing/test-sym-relocation.cpp
diff --git a/utils/python/library/elf/utils.py b/vndk_utils/library/elf/utils.py
similarity index 100%
rename from utils/python/library/elf/utils.py
rename to vndk_utils/library/elf/utils.py
diff --git a/utils/python/library/elf/utils_test.py b/vndk_utils/library/elf/utils_test.py
similarity index 100%
rename from utils/python/library/elf/utils_test.py
rename to vndk_utils/library/elf/utils_test.py
diff --git a/utils/python/library/elf_parser.py b/vndk_utils/library/elf_parser.py
similarity index 99%
rename from utils/python/library/elf_parser.py
rename to vndk_utils/library/elf_parser.py
index 3447f36..36db1be 100644
--- a/utils/python/library/elf_parser.py
+++ b/vndk_utils/library/elf_parser.py
@@ -609,8 +609,6 @@
"""
for abi_prefix, machine in (("arm64", consts.EM_AARCH64),
("arm", consts.EM_ARM),
- ("mips64", consts.EM_MIPS),
- ("mips", consts.EM_MIPS),
("x86_64", consts.EM_X86_64),
("x86", consts.EM_386)):
if abi.startswith(abi_prefix):
diff --git a/utils/python/library/elf_parser_test.py b/vndk_utils/library/elf_parser_test.py
similarity index 100%
rename from utils/python/library/elf_parser_test.py
rename to vndk_utils/library/elf_parser_test.py
diff --git a/utils/python/library/vtable/__init__.py b/vndk_utils/library/vtable/__init__.py
similarity index 100%
rename from utils/python/library/vtable/__init__.py
rename to vndk_utils/library/vtable/__init__.py
diff --git a/utils/python/library/vtable/testing/build-libtest.sh b/vndk_utils/library/vtable/testing/build-libtest.sh
similarity index 100%
rename from utils/python/library/vtable/testing/build-libtest.sh
rename to vndk_utils/library/vtable/testing/build-libtest.sh
diff --git a/utils/python/library/vtable/testing/libtest.so b/vndk_utils/library/vtable/testing/libtest.so
similarity index 100%
rename from utils/python/library/vtable/testing/libtest.so
rename to vndk_utils/library/vtable/testing/libtest.so
Binary files differ
diff --git a/utils/python/library/vtable/testing/test-vtable.cpp b/vndk_utils/library/vtable/testing/test-vtable.cpp
similarity index 100%
rename from utils/python/library/vtable/testing/test-vtable.cpp
rename to vndk_utils/library/vtable/testing/test-vtable.cpp
diff --git a/utils/python/library/vtable/vtable_dumper.py b/vndk_utils/library/vtable/vtable_dumper.py
similarity index 99%
rename from utils/python/library/vtable/vtable_dumper.py
rename to vndk_utils/library/vtable/vtable_dumper.py
index db629d2..d97066e 100644
--- a/utils/python/library/vtable/vtable_dumper.py
+++ b/vndk_utils/library/vtable/vtable_dumper.py
@@ -126,6 +126,7 @@
consts.EM_AARCH64: (consts.R_AARCH64_ABS64, consts.R_AARCH64_RELATIVE),
consts.EM_386: (consts.R_386_32, consts.R_386_RELATIVE),
consts.EM_X86_64: (consts.R_X86_64_64, consts.R_X86_64_RELATIVE),
+ consts.EM_RISCV: (consts.R_RISCV_64, consts.R_RISCV_RELATIVE),
}
if machine in rel_type:
rel_abs_type, rel_relative_type = rel_type[machine]
diff --git a/utils/python/library/vtable/vtable_dumper_test.py b/vndk_utils/library/vtable/vtable_dumper_test.py
similarity index 100%
rename from utils/python/library/vtable/vtable_dumper_test.py
rename to vndk_utils/library/vtable/vtable_dumper_test.py
diff --git a/utils/python/vndk/__init__.py b/vndk_utils/vndk/__init__.py
similarity index 100%
rename from utils/python/vndk/__init__.py
rename to vndk_utils/vndk/__init__.py
diff --git a/utils/python/vndk/vndk_utils.py b/vndk_utils/vndk/vndk_utils.py
similarity index 86%
rename from utils/python/vndk/vndk_utils.py
rename to vndk_utils/vndk/vndk_utils.py
index 570fff6..b50ebbb 100644
--- a/utils/python/vndk/vndk_utils.py
+++ b/vndk_utils/vndk/vndk_utils.py
@@ -44,6 +44,24 @@
return True
+def IsVndkInstalledInVendor(dut):
+ """Returns whether the device's VNDK should be installed in vendor.
+
+ VNDK libraries are moved from system to vendor partition in V version.
+ VNDK 35 should be installed in vendor partiton.
+
+ Args:
+ dut: The AndroidDevice under test.
+
+ Returns:
+ A boolean, whether VNDK should be installed in vendor partition.
+ """
+ try:
+ return int(dut.GetVndkVersion()) > 34
+ except ValueError:
+ return False
+
+
def FormatVndkPath(pattern, bitness, version=""):
"""Formats a VNDK path.
diff --git a/runners/target/vts_hal_hidl_target/Android.bp b/vts_hal_hidl_target/Android.bp
similarity index 100%
rename from runners/target/vts_hal_hidl_target/Android.bp
rename to vts_hal_hidl_target/Android.bp
diff --git a/runners/target/vts_hal_hidl_target/VtsCoreUtil.cpp b/vts_hal_hidl_target/VtsCoreUtil.cpp
similarity index 100%
rename from runners/target/vts_hal_hidl_target/VtsCoreUtil.cpp
rename to vts_hal_hidl_target/VtsCoreUtil.cpp
diff --git a/runners/target/vts_hal_hidl_target/VtsCoreUtil.h b/vts_hal_hidl_target/VtsCoreUtil.h
similarity index 100%
rename from runners/target/vts_hal_hidl_target/VtsCoreUtil.h
rename to vts_hal_hidl_target/VtsCoreUtil.h
diff --git a/runners/target/vts_hal_hidl_target/VtsHalHidlTargetCallbackBase.cpp b/vts_hal_hidl_target/VtsHalHidlTargetCallbackBase.cpp
similarity index 100%
rename from runners/target/vts_hal_hidl_target/VtsHalHidlTargetCallbackBase.cpp
rename to vts_hal_hidl_target/VtsHalHidlTargetCallbackBase.cpp
diff --git a/runners/target/vts_hal_hidl_target/VtsHalHidlTargetCallbackBase.h b/vts_hal_hidl_target/VtsHalHidlTargetCallbackBase.h
similarity index 100%
rename from runners/target/vts_hal_hidl_target/VtsHalHidlTargetCallbackBase.h
rename to vts_hal_hidl_target/VtsHalHidlTargetCallbackBase.h
diff --git a/runners/target/vts_hal_hidl_target/VtsHalHidlTargetTestBase.cpp b/vts_hal_hidl_target/VtsHalHidlTargetTestBase.cpp
similarity index 100%
rename from runners/target/vts_hal_hidl_target/VtsHalHidlTargetTestBase.cpp
rename to vts_hal_hidl_target/VtsHalHidlTargetTestBase.cpp
diff --git a/runners/target/vts_hal_hidl_target/VtsHalHidlTargetTestBase.h b/vts_hal_hidl_target/VtsHalHidlTargetTestBase.h
similarity index 100%
rename from runners/target/vts_hal_hidl_target/VtsHalHidlTargetTestBase.h
rename to vts_hal_hidl_target/VtsHalHidlTargetTestBase.h
diff --git a/runners/target/vts_hal_hidl_target/VtsHalHidlTargetTestEnvBase.cpp b/vts_hal_hidl_target/VtsHalHidlTargetTestEnvBase.cpp
similarity index 100%
rename from runners/target/vts_hal_hidl_target/VtsHalHidlTargetTestEnvBase.cpp
rename to vts_hal_hidl_target/VtsHalHidlTargetTestEnvBase.cpp
diff --git a/runners/target/vts_hal_hidl_target/VtsHalHidlTargetTestEnvBase.h b/vts_hal_hidl_target/VtsHalHidlTargetTestEnvBase.h
similarity index 100%
rename from runners/target/vts_hal_hidl_target/VtsHalHidlTargetTestEnvBase.h
rename to vts_hal_hidl_target/VtsHalHidlTargetTestEnvBase.h