OSDN Git Service

Start integration with gd rust & cert tests
authorZach Johnson <zachoverflow@google.com>
Wed, 4 Nov 2020 23:24:55 +0000 (15:24 -0800)
committerZach Johnson <zachoverflow@google.com>
Fri, 6 Nov 2020 21:10:24 +0000 (13:10 -0800)
two additional flags for gd/cert/run

--rust (rust on device)
--rhost (rust on host)

Bug: 171749953
Tag: #gd-refactor
Test: gd/cert/run --host
Change-Id: I11cbffdeca27cdfee12afbf2c8c0a5afa8ba2f17

gd/Android.mk
gd/cert/run
gd/cert/rust_android_devices_config.json [new file with mode: 0644]
gd/cert/rust_host_config.json [new file with mode: 0644]
gd/rust/facade/src/main.rs
gd/setup.py

index 95e644c..a2b42a2 100644 (file)
@@ -10,6 +10,7 @@ LOCAL_cert_test_sources := \
 
 LOCAL_host_executables := \
        $(HOST_OUT_EXECUTABLES)/bluetooth_stack_with_facade \
+       $(HOST_OUT_EXECUTABLES)/bluetooth_with_facades \
        $(HOST_OUT_EXECUTABLES)/root-canal
 
 LOCAL_host_python_extension_libraries := \
@@ -23,7 +24,10 @@ LOCAL_host_libraries := \
        $(HOST_OUT_SHARED_LIBRARIES)/libcrypto-host.so \
        $(HOST_OUT_SHARED_LIBRARIES)/libevent-host.so \
        $(HOST_OUT_SHARED_LIBRARIES)/libgrpc++_unsecure.so \
+       $(HOST_OUT_SHARED_LIBRARIES)/libgrpc++.so \
+       $(HOST_OUT_SHARED_LIBRARIES)/libgrpc_wrap.so \
        $(HOST_OUT_SHARED_LIBRARIES)/liblog.so \
+       $(HOST_OUT_SHARED_LIBRARIES)/libssl-host.so \
        $(HOST_OUT_SHARED_LIBRARIES)/libz-host.so \
        $(HOST_OUT_SHARED_LIBRARIES)/libprotobuf-cpp-full.so \
        $(HOST_OUT_SHARED_LIBRARIES)/libunwindstack.so \
@@ -97,4 +101,4 @@ $(bluetooth_cert_tests_py_package_zip): $(SOONG_ZIP) $(LOCAL_acts_zip) \
                -f $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata \
                -f $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib64/libc++.so.1
 
-$(call dist-for-goals,bluetooth_stack_with_facade,$(bluetooth_cert_tests_py_package_zip):bluetooth_cert_tests.zip)
\ No newline at end of file
+$(call dist-for-goals,bluetooth_stack_with_facade,$(bluetooth_cert_tests_py_package_zip):bluetooth_cert_tests.zip)
index 13c1c64..03d6a56 100755 (executable)
@@ -73,6 +73,7 @@ CERT_TEST_VENV=${ANDROID_BUILD_TOP}/out/dist/bluetooth_venv
 OUT_TARGET="${ANDROID_BUILD_TOP}/out/target"
 TEST_CONFIG="${ANDROID_BUILD_TOP}/system/bt/gd/cert/android_devices_config.json"
 TEST_FILTER="-tf ${ANDROID_BUILD_TOP}/system/bt/gd/cert/all_cert_testcases"
+BUILD_TARGET="bluetooth_stack_with_facade"
 
 CLEAN_VENV=false
 GOTTA_GO_FAST=false
@@ -150,6 +151,16 @@ function parse_options {
         TEST_CONFIG="${key#*=}"
         shift # past argument
         ;;
+        --rust)
+        BUILD_TARGET="bluetooth_with_facades"
+        TEST_CONFIG=$ANDROID_BUILD_TOP/system/bt/gd/cert/rust_android_devices_config.json
+        shift # past argument
+        ;;
+        --rhost)
+        BUILD_TARGET="bluetooth_with_facades"
+        TEST_CONFIG=$ANDROID_BUILD_TOP/system/bt/gd/cert/rust_host_config.json
+        shift # past argument
+        ;;
         # This will log everything to both log file and stdout
         --verbose)
         VERBOSE_MODE=true
@@ -167,7 +178,7 @@ function parse_options {
     if [[ -n "$1" ]] ; then
       TEST_FILTER="-tc $1"
     fi
-    
+
     INSTALL_ARGS="--reuse-acts"
     if [ "$CLEAN_VENV" == true ] ; then
       echo -e "${YELLOW}Cleaning up existing virtualenv${NOCOLOR}"
@@ -182,9 +193,9 @@ function parse_options {
 }
 
 function soong_build {
-    $ANDROID_BUILD_TOP/build/soong/soong_ui.bash --build-mode --"modules-in-a-dir" --dir="${ANDROID_BUILD_TOP}/system/bt/gd" dist bluetooth_stack_with_facade
+    $ANDROID_BUILD_TOP/build/soong/soong_ui.bash --build-mode --"modules-in-a-dir" --dir="${ANDROID_BUILD_TOP}/system/bt/gd" dist $BUILD_TARGET
     if [[ $? -ne 0 ]] ; then
-        echo "Failed to build bluetooth_stack_with_facade"
+        echo "Failed to build ${BUILD_TARGET}"
         exit 1
     fi
 }
diff --git a/gd/cert/rust_android_devices_config.json b/gd/cert/rust_android_devices_config.json
new file mode 100644 (file)
index 0000000..6d76310
--- /dev/null
@@ -0,0 +1,55 @@
+{   "_description": "Bluetooth cert testing",
+    "testbed":
+    [
+        {
+            "_description": "Two Android devices cert testbed",
+            "name": "AndroidDeviceCert",
+            "GdDevice":
+            [
+                {
+                    "grpc_port": "8898",
+                    "grpc_root_server_port": "8896",
+                    "signal_port": "8894",
+                    "label": "cert",
+                    "serial_number": "CERT",
+                    "name": "Cert Device",
+                    "cmd":
+                    [
+                        "adb",
+                        "-s",
+                        "$(serial_number)",
+                        "shell",
+                        "/system/bin/bluetooth_with_facadas",
+                        "--grpc-port=$(grpc_port)",
+                        "--root-server-port=$(grpc_root_server_port)",
+                        "--btsnoop=/data/misc/bluetooth/logs/btsnoop_hci.log",
+                        "--btconfig=/data/misc/bluedroid/bt_config.conf",
+                        "--signal-port=$(signal_port)"
+                    ]
+                },
+                {
+                    "grpc_port": "8899",
+                    "grpc_root_server_port": "8897",
+                    "signal_port": "8895",
+                    "label": "dut",
+                    "serial_number": "DUT",
+                    "name": "DUT Device",
+                    "cmd":
+                    [
+                        "adb",
+                        "-s",
+                        "$(serial_number)",
+                        "shell",
+                        "/system/bin/bluetooth_with_facades",
+                        "--grpc-port=$(grpc_port)",
+                        "--root-server-port=$(grpc_root_server_port)",
+                        "--btsnoop=/data/misc/bluetooth/logs/btsnoop_hci.log",
+                        "--btconfig=/data/misc/bluedroid/bt_config.conf",
+                        "--signal-port=$(signal_port)"
+                    ]
+                }
+            ]
+        }
+    ],
+    "logpath": "/tmp/logs"
+}
diff --git a/gd/cert/rust_host_config.json b/gd/cert/rust_host_config.json
new file mode 100644 (file)
index 0000000..2972a53
--- /dev/null
@@ -0,0 +1,50 @@
+
+{   "_description": "Bluetooth cert testing",
+    "testbed":
+    [
+        {
+            "_description": "Host only cert testbed",
+            "name": "HostOnlyCert",
+            "rootcanal":
+            {
+                "test_port": "6401",
+                "hci_port": "6402",
+                "link_layer_port": "6403"
+            },
+            "GdDevice":
+            [
+                {
+                    "grpc_port": "8998",
+                    "grpc_root_server_port": "8996",
+                    "signal_port": "8994",
+                    "label": "cert",
+                    "name": "Cert Device",
+                    "cmd":
+                    [
+                        "$GD_ROOT/bluetooth_with_facades",
+                        "--grpc-port=$(grpc_port)",
+                        "--root-server-port=$(grpc_root_server_port)",
+                        "--rootcanal-port=$(rootcanal_port)",
+                        "--signal-port=$(signal_port)"
+                    ]
+                },
+                {
+                    "grpc_port": "8999",
+                    "grpc_root_server_port": "8997",
+                    "signal_port": "8995",
+                    "label": "dut",
+                    "name": "DUT Device",
+                    "cmd":
+                    [
+                        "$GD_ROOT/bluetooth_with_facades",
+                        "--grpc-port=$(grpc_port)",
+                        "--root-server-port=$(grpc_root_server_port)",
+                        "--rootcanal-port=$(rootcanal_port)",
+                        "--signal-port=$(signal_port)"
+                    ]
+                }
+            ]
+        }
+    ],
+    "logpath": "/tmp/logs"
+}
index 3af3d3f..a480c98 100644 (file)
@@ -52,6 +52,21 @@ async fn async_main(rt: Arc<Runtime>, mut sigint: mpsc::UnboundedReceiver<()>) {
                 .default_value("8895")
                 .takes_value(true),
         )
+        .arg(
+            Arg::with_name("rootcanal-port")
+                .long("rootcanal-port")
+                .takes_value(true),
+        )
+        .arg(
+            Arg::with_name("btsnoop")
+                .long("btsnoop")
+                .takes_value(true),
+        )
+        .arg(
+            Arg::with_name("btconfig")
+                .long("btconfig")
+                .takes_value(true),
+        )
         .get_matches();
 
     let root_server_port = value_t!(matches, "root-server-port", u16).unwrap();
@@ -69,6 +84,7 @@ async fn async_main(rt: Arc<Runtime>, mut sigint: mpsc::UnboundedReceiver<()>) {
         .bind("0.0.0.0", root_server_port)
         .build()
         .unwrap();
+    server.start();
 
     indicate_started(signal_port).await;
     sigint.next().await;
index e794804..55df659 100644 (file)
@@ -31,7 +31,8 @@ install_requires = [
 
 host_executables = [
     'root-canal',
-    'bluetooth_stack_with_facade',
+    'bluetooth_stack_with_facade',  # c++
+    'bluetooth_with_facades',  # rust
 ]