FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

tests/ports/psoc-edge: Add machine.unique_id test. · micropython/micropython@0a7411c · GitHub

Commit 0a7411c

Browse files
authored andcommitted
tests/ports/psoc-edge: Add machine.unique_id test.
Signed-off-by: AkshayChandra-IFX <akshaychandra.nagzarkar@infineon.com> Signed-off-by: NaveenChengappa-IFX <Naveen.Chandura@infineon.com>
1 parent 665673c commit 0a7411c

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

‎tests/ports/psoc-edge/unique_id.py‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import machine
2+
3+
# ---------------------------------------------------------------------------
4+
# machine.unique_id() contract test.
5+
# Verifies that unique_id is bytes, has expected 64-bit length (8 bytes),
6+
# is non-zero, and remains stable across repeated calls on the same boot.
7+
# ---------------------------------------------------------------------------
8+
9+
print("***** Test 1: machine.unique_id() contract *****")
10+
uid0 = machine.unique_id()
11+
12+
ok = True
13+
if not isinstance(uid0, bytes):
14+
ok = False
15+
16+
if len(uid0) != 8:
17+
ok = False
18+
19+
if not any(b != 0 for b in uid0):
20+
ok = False
21+
22+
for _ in range(5):
23+
if machine.unique_id() != uid0:
24+
ok = False
25+
break
26+
27+
print("PASS" if ok else "FAIL")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
***** Test 1: machine.unique_id() contract *****
2+
PASS

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL