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

Commit f3c72986 authored by Etienne Ruffieux's avatar Etienne Ruffieux Committed by Thomas Girardier
Browse files

Add PTS-Bot GATT tests

Test: atest pts-bot:GATT/CL/GAS/BV-05-C
Test: atest pts-bot:GATT/CL/GAT/BV-01-C
Test: atest pts-bot:GATT/CL/GAT/BV-02-C
Tag: #feature
Bug: 245578454
Ignore-AOSP-First: cherry-pick from AOSP
Change-Id: Icc142685503833aba8db16fb8ae98b9028c1caa4
Merged-In: Icc142685503833aba8db16fb8ae98b9028c1caa4
parent f7c9c429
Loading
Loading
Loading
Loading
+55 −3
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@

import re
import sys
from threading import Thread

from mmi2grpc._helpers import assert_description
from mmi2grpc._proxy import ProfileProxy
@@ -440,8 +441,25 @@ class GATTProxy(ProfileProxy):

        assert self.connection is not None
        handle = stringHandleToInt(re.findall("'([a0-Z9]*)'O", description)[0])
        def read():
            nonlocal handle
            self.read_response = self.gatt.ReadCharacteristicFromHandle(\
                    connection=self.connection, handle=handle)
        worker = Thread(target=read)
        worker.start()
        worker.join(timeout=30)
        return "OK"

    @assert_description
    def MMI_IUT_READ_TIMEOUT(self, **kwargs):
        """
        Please wait for 30 seconds timeout to abort the procedure.

        Description:
        Verify that the Implementation Under Test (IUT) can handle timeout after
        send Read characteristic without receiving response in 30 seconds.
        """

        return "OK"

    @assert_description
@@ -714,8 +732,26 @@ class GATTProxy(ProfileProxy):
        matches = re.findall("'([a0-Z9]*)'O with <= '([a0-Z9]*)'", description)
        handle = stringHandleToInt(matches[0][0])
        data = bytes([1]) * int(matches[0][1])
        def write():
            nonlocal handle
            nonlocal data
            self.write_response = self.gatt.WriteAttFromHandle(connection=self.connection,\
                handle=handle, value=data)
        worker = Thread(target=write)
        worker.start()
        worker.join(timeout=30)
        return "OK"

    @assert_description
    def MMI_IUT_WRITE_TIMEOUT(self, **kwargs):
        """
        Please wait for 30 second timeout to abort the procedure.

        Description:
        Verify that the Implementation Under Test (IUT) can handle timeout after
        send Write characteristic without receiving response in 30 seconds.
        """

        return "OK"

    @assert_description
@@ -765,6 +801,22 @@ class GATTProxy(ProfileProxy):
                handle=handle, value=data)
        return "OK"

    def _mmi_150(self, description: str, **kwargs):
        """
        Please send an ATT_Write_Request to Client Support Features handle =
        'XXXX'O to enable Multiple Handle Value Notifications.

        Discover all
        characteristics if needed.
        """

        assert self.connection is not None
        handle = stringHandleToInt(re.findall("'([a0-Z9]*)'O", description)[0])
        data = bytes([4]) # Multiple Handle Value Notifications
        self.write_response = self.gatt.WriteAttFromHandle(connection=self.connection,\
                handle=handle, value=data)
        return "OK"

    def MMI_IUT_SEND_PREPARE_WRITE_GREATER_OFFSET(self, description: str, **kwargs):
        """
        Please send prepare write request with handle = 'XXXX'O and offset
+3 −3
Original line number Diff line number Diff line
@@ -233,6 +233,9 @@
    "GATT/SR/GAR/BV-04-C",
    "GATT/SR/GAR/BV-05-C",
    "GATT/SR/GAR/BV-09-C",
    "GATT/CL/GAS/BV-05-C",
    "GATT/CL/GAT/BV-01-C",
    "GATT/CL/GAT/BV-02-C",
    "GATT/SR/GAW/BI-02-C",
    "GATT/SR/GAW/BI-03-C",
    "GATT/SR/GAW/BI-05-C",
@@ -663,9 +666,6 @@
    "GATT/CL/GAR/BV-03-C",
    "GATT/CL/GAS/BV-01-C",
    "GATT/CL/GAS/BV-03-C",
    "GATT/CL/GAS/BV-05-C",
    "GATT/CL/GAT/BV-01-C",
    "GATT/CL/GAT/BV-02-C",
    "GATT/CL/GAT/BV-03-C",
    "GATT/CL/GAW/BI-05-C",
    "GATT/CL/GAW/BI-06-C",