Skip to content

Commit 1df4f30

Browse files
committed
tests/ports: Added test case for ble_UUID.
Signed-off-by: Rathan25 <Rathan.Shidling-EE@infineon.com>
1 parent 72dc725 commit 1df4f30

3 files changed

Lines changed: 96 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import bluetooth
2+
3+
4+
# Test cases for 16-bit, 32-bit, and 128-bit UUIDs
5+
def test_uuids():
6+
print("=== UUID Testing ===\n")
7+
8+
# Valid UUIDs
9+
try:
10+
print("Testing valid 16-bit UUID:")
11+
val16 = 0x180D # Valid 16-bit UUID
12+
uuid16 = bluetooth.UUID(val16)
13+
print("Valid 16-bit UUID:", uuid16, "\n")
14+
except Exception as e:
15+
print("Error with valid 16-bit UUID:", e, "\n")
16+
17+
try:
18+
print("Testing valid 32-bit UUID:")
19+
val32 = b"\x12\x34\x56\x78" # Valid 32-bit UUID
20+
uuid32 = bluetooth.UUID(val32)
21+
print("Valid 32-bit UUID:", uuid32, "\n")
22+
except Exception as e:
23+
print("Error with valid 32-bit UUID:", e, "\n")
24+
25+
try:
26+
print("Testing valid 128-bit UUID:")
27+
val128 = b"\x12\x34\x56\x78\x9a\xbc\xde\xf0\x12\x34\x56\x78\x9a\xbc\xde\xf0" # Valid 128-bit UUID
28+
uuid128 = bluetooth.UUID(val128)
29+
print("Valid 128-bit UUID:", uuid128, "\n")
30+
except Exception as e:
31+
print("Error with valid 128-bit UUID:", e, "\n")
32+
33+
# Invalid UUIDs
34+
try:
35+
print("Testing invalid 16-bit UUID:")
36+
val16_invalid = 0x1FFFF # Invalid 16-bit UUID (too large)
37+
uuid16_invalid = bluetooth.UUID(val16_invalid)
38+
print("Invalid 16-bit UUID should not succeed:", uuid16_invalid, "\n")
39+
except Exception as e:
40+
print("Caught error with invalid 16-bit UUID:", e, "\n")
41+
42+
try:
43+
print("Testing invalid 32-bit UUID:")
44+
val32_invalid = b"\x12\x34\x56\x56\x78" # Invalid 32-bit UUID (not 4 bytes)
45+
uuid32_invalid = bluetooth.UUID(val32_invalid)
46+
print("Invalid 32-bit UUID should not succeed:", uuid32_invalid, "\n")
47+
except Exception as e:
48+
print("Caught error with invalid 32-bit UUID:", e, "\n")
49+
50+
try:
51+
print("Testing invalid 128-bit UUID:")
52+
val128_invalid = b"\x12\x34\x56\x78\x12\x34\x56\x78" # Invalid 128-bit UUID (not 16 bytes)
53+
uuid128_invalid = bluetooth.UUID(val128_invalid)
54+
print("Invalid 128-bit UUID should not succeed:", uuid128_invalid, "\n")
55+
except Exception as e:
56+
print("Caught error with invalid 128-bit UUID:", e, "\n")
57+
58+
print("=== UUID Testing Complete ===")
59+
60+
61+
# Run the test cases
62+
test_uuids()
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
=== UUID Testing ===
2+
3+
Testing valid 16-bit UUID:
4+
Created 16-bit UUID: 0x180d
5+
Valid 16-bit UUID:
6+
7+
Testing valid 32-bit UUID:
8+
Created 32-bit UUID from bytes: 0x78563412
9+
Valid 32-bit UUID:
10+
11+
Testing valid 128-bit UUID:
12+
Created 128-bit UUID from bytes: 12:34:56:78:9a:bc:de:f0:12:34:56:78:9a:bc:de:f0
13+
Valid 128-bit UUID: UUID(0x3412)
14+
15+
Testing invalid 16-bit UUID:
16+
Caught error with invalid 16-bit UUID: invalid UUID
17+
18+
Testing invalid 32-bit UUID:
19+
Caught error with invalid 32-bit UUID: invalid char in UUID
20+
21+
Testing invalid 128-bit UUID:
22+
Caught error with invalid 128-bit UUID: invalid char in UUID
23+
24+
=== UUID Testing Complete ===

tests/ports/psoc6/run_psoc6_tests.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ usage() {
3131
If followed by -x, runs advance tests too."
3232
echo " no-hw-ext run machine modules tests not requiring extended hardware"
3333
echo " adc run adc tests"
34+
echo " ble_UUID run ble_UUID tests"
3435
echo " pin run pin tests"
3536
echo " signal run signal tests"
3637
echo " pwm run pwm tests"
@@ -198,6 +199,9 @@ no_ext_hw_tests() {
198199
"-e ${tests_psoc6_dir}/board_only_hw/single/wdt.py \
199200
-e ${tests_psoc6_dir}/board_only_hw/single/wdt_reset_check.py"
200201
}
202+
ble_UUID_tests() {
203+
run_tests "ble_UUID" ${dev_test} "${tests_psoc6_dir}/board_only_hw/single/ble_UUID.py"
204+
}
201205

202206
adc_tests() {
203207
run_tests "adc" ${dev_test} "${tests_psoc6_dir}/board_ext_hw/single/adc.py"
@@ -308,6 +312,9 @@ run_ci_tests() {
308312

309313
dev_test=${devs_a[0]}
310314
pwm_tests
315+
316+
dev_test=${devs_a[0]}
317+
ble_UUID_tests
311318

312319
if [ "${board}" == "CY8CPROTO-062-4343W" ] || [ "${board}" == "CY8CPROTO-063-BLE" ]; then
313320
dev_test=${devs_a[0]}
@@ -414,6 +421,9 @@ case ${test_suite} in
414421
"signal")
415422
signal_tests
416423
;;
424+
"ble_UUID")
425+
ble_UUID_tests
426+
;;
417427
"adc")
418428
adc_tests
419429
;;

0 commit comments

Comments
 (0)