OSDN Git Service

Cert: Unzip all cert files into the same virtual environment
authorJack He <siyuanh@google.com>
Thu, 5 Mar 2020 11:41:22 +0000 (03:41 -0800)
committerJack He <siyuanh@google.com>
Thu, 5 Mar 2020 12:07:19 +0000 (04:07 -0800)
* All Python import must root from system/bt/gd
* Include all .py files in system/bt/gd in bluetooth_cert_test.zip
* At runtime, unzip all cert files into the same bluetooth_cert_test_env
  folder so that generated files and developer written files are
  overlayed together
* This helps avoid duplicate module problem at runtime

Bug: 150321998
Test: source cert/run --host
Change-Id: I7a8b1fe9fbccae1b1b4e8bf31a759a1c1eb7475c

gd/Android.mk
gd/cert/python3.8-gd
gd/cert/run
gd/l2cap/classic/cert/l2cap_test.py

index a3b5c9d..108d0c1 100644 (file)
@@ -1,26 +1,10 @@
 LOCAL_PATH := $(call my-dir)
 
 bluetooth_cert_test_file_list := \
-    $(call all-named-files-under,*.py,cert) \
-    $(call all-named-files-under,*.sh,cert) \
-    $(call all-named-files-under,run,cert) \
+    $(call all-named-files-under,*.py,.) \
     $(call all-named-files-under,*.proto,cert facade hal hci/cert hci/facade l2cap/classic \
            l2cap/classic/cert neighbor/facade security) \
-    cert/all_cert_testcases \
-    cert/android_devices_config.json \
-    cert/host_config.json \
-    hal/cert/simple_hal_test.py \
-    hci/cert/acl_manager_test.py \
-    hci/cert/controller_test.py \
-    hci/cert/direct_hci_test.py \
-    hci/cert/le_acl_manager_test.py \
-    hci/cert/le_advertising_manager_test.py \
-    hci/cert/le_scanning_manager_test.py \
-    l2cap/classic/cert/l2cap_test.py \
-    l2cap/classic/cert/pts_l2cap_test.py \
-    neighbor/cert/neighbor_test.py \
-    security/cert/simple_security_test.py \
-    shim/cert/stack_test.py
+    cert/all_cert_testcases
 
 bluetooth_cert_test_file_list := $(addprefix $(LOCAL_PATH)/,$(bluetooth_cert_test_file_list))
 
index f77adfc..6aa24b2 100755 (executable)
@@ -1,4 +1,4 @@
 #! /bin/bash
-PYTHONPATH=$ANDROID_BUILD_TOP/out/host/linux-x86/lib64:$ANDROID_BUILD_TOP/system/bt/gd:$ANDROID_BUILD_TOP/out/dist/bluetooth_cert_test/system/bt/gd:$ANDROID_BUILD_TOP/out/dist/bluetooth_cert_generated_py/system/bt/gd:$PYTHONPATH \
-PATH=$ANDROID_HOST_OUT/nativetest64/root-canal:$ANDROID_HOST_OUT/nativetest64/bin:$PATH \
+BLUETOOTH_CERT_TEST_ENV=$ANDROID_BUILD_TOP/out/dist/bluetooth_cert_test_env
+PYTHONPATH=$BLUETOOTH_CERT_TEST_ENV/out/host/linux-x86/lib64:$BLUETOOTH_CERT_TEST_ENV/system/bt/gd:$PYTHONPATH \
  python3.8 "$@"
index 22f53d0..9634691 100755 (executable)
@@ -34,16 +34,19 @@ esac
 done
 set -- "${POSITIONAL[@]}" # restore positional parameters
 
+BLUETOOTH_CERT_TEST_ENV=$ANDROID_BUILD_TOP/out/dist/bluetooth_cert_test_env
+rm -rf BLUETOOTH_CERT_TEST_ENV
+mkdir -p $BLUETOOTH_CERT_TEST_ENV
+
 unzip -o -q $ANDROID_BUILD_TOP/out/dist/bluetooth_cert_generated_py.zip \
-   -d $ANDROID_BUILD_TOP/out/dist/bluetooth_cert_generated_py
+   -d $BLUETOOTH_CERT_TEST_ENV
 
 unzip -o -q $ANDROID_BUILD_TOP/out/dist/bluetooth_cert_test.zip \
-   -d $ANDROID_BUILD_TOP/out/dist/bluetooth_cert_test
+   -d $BLUETOOTH_CERT_TEST_ENV
 
 pushd .
 cd $ANDROID_BUILD_TOP
-PYTHONPATH=$ANDROID_BUILD_TOP/out/host/linux-x86/lib64:$ANDROID_BUILD_TOP/system/bt/gd:$ANDROID_BUILD_TOP/out/dist/bluetooth_cert_test/system/bt/gd:$ANDROID_BUILD_TOP/system/bt/gd:$ANDROID_BUILD_TOP/out/dist/bluetooth_cert_generated_py/system/bt/gd:$PYTHONPATH \
-PATH=$ANDROID_BUILD_TOP/out/dist/bluetooth_cert_test/out/host/linux-x86/nativetest64/root-canal:$ANDROID_BUILD_TOP/out/dist/bluetooth_cert_test/out/host/linux-x86/bin:$PATH \
+PYTHONPATH=$BLUETOOTH_CERT_TEST_ENV/out/host/linux-x86/lib64:$BLUETOOTH_CERT_TEST_ENV/system/bt/gd:$PYTHONPATH \
     python3.8 `which act.py`\
       -c $TEST_CONFIG \
       $TEST_FILTER \
index d29eddb..54735b6 100644 (file)
@@ -38,7 +38,7 @@ from bluetooth_packets_python3.l2cap_packets import CommandCode
 from bluetooth_packets_python3.l2cap_packets import SupervisoryFunction
 from bluetooth_packets_python3.l2cap_packets import Poll
 from bluetooth_packets_python3.l2cap_packets import InformationRequestInfoType
-from cert_l2cap import CertL2cap
+from l2cap.classic.cert.cert_l2cap import CertL2cap
 
 # Assemble a sample packet. TODO: Use RawBuilder
 SAMPLE_PACKET = l2cap_packets.CommandRejectNotUnderstoodBuilder(1)