Skip to content

test_plan.py

fixtur-ctrl-func-test.test_plan

FixturFab FixturCtrl Functional Test Plan

test_serial_number

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def test_serial_number(status_banner, user_dialog, serial_number, record_property):
    serial_number_pattern = r"^\d{4}$"  # Serial number should be a 4 digit number
    status_banner.override(True, status="Enter Serial Number...", color="#7E57C2")

    message = Dialog(
        title="ACTION REQUIRED:",
        message="Enter serial number",
        inputType="text",
    )
    response = user_dialog.send(message)

    qr_scan = response.inputText
    meas = qr_scan.split(";")[-1]

    error = f"Error with Serial Number Scanning. Wrong ID Format: {qr_scan}"
    error_msg = error + "\nPlease Try Again."
    log_vars(record_property)
    assert re.match(serial_number_pattern, meas), error_msg

    # Store serial number and release status banner
    serial_number.set(meas)
    status_banner.override(False)

test_fixture_close

Handles testing start when fixture is closed

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
def test_fixture_close(status_banner, user_dialog, fixture_config, fixtur_cntl):
    """Handles testing start when fixture is closed"""
    if fixture_config.slot_id == "DEV":
        try:
            status_banner.override(True, status="Fixture Closed...?", color="#7E57C2")

            message = Dialog(
                title="ACTION REQUIRED:",
                message="Is the fixture closed?",
                okButtonText="Yes",
                cancelButtonText="No",
            )

            response = user_dialog.send(message)

            status_banner.override(False)

            meas = response.okClicked
            assert meas

        except Exception as e:
            status_banner.override(False)
            raise e

    elif fixture_config.slot_id == "PROD":
        try:
            closed = fixtur_cntl.get_fixture_closed()
            if not closed:
                status_banner.override(
                    True, status=f"Close Fixture...", color="#E6B700"
                )

                # Wait for fixture to be closed
                while not closed:
                    closed = fixtur_cntl.get_fixture_closed()
                    time.sleep(1)

                status_banner.override(False)

        except Exception as e:
            status_banner.override(False)
            raise e

test_12v_continuity

Continuity Test.

Verify that the 12V supply input is not connected to GND.

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
def test_12v_continuity(test_fixture, test_config, record_property):
    """Continuity Test.

    Verify that the 12V supply input is not connected to GND.
    """

    # Setup
    test_fixture.pwr_select(False)
    test_fixture.en_12v(True)
    time.sleep(0.5)

    # Measure
    reading = test_fixture.get_continuity_reading()
    meas = round(reading["mean"], 3)

    # Teardown
    test_fixture.en_12v(False)

    error_msg = f"12V Continuity Test Failed: {meas}"
    log_vars(record_property)
    assert meas > float(test_config.min_limit), error_msg

test_5v_continuity

5V Continuity Test.

Verify that the 5V supply input is not connected to GND.

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
def test_5v_continuity(test_fixture, test_config, record_property):
    """5V Continuity Test.

    Verify that the 5V supply input is not connected to GND.
    """

    # Setup
    test_fixture.pwr_select(False)
    test_fixture.en_5v(True)
    time.sleep(0.5)

    # Measure
    reading = test_fixture.get_continuity_reading()
    meas = round(reading["mean"], 3)

    # Teardown
    test_fixture.en_5v(False)

    error_msg = f"5V Continuity Test Failed: {meas}"
    log_vars(record_property)
    assert meas > float(test_config.min_limit), error_msg

voltage_test_usb

VUSB Voltage Tests Setup/Teardown Fixture

Disconnect continuity test and enable VUSB supply.

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
@pytest.fixture(scope="class")
def voltage_test_usb(test_fixture, delays):
    """VUSB Voltage Tests Setup/Teardown Fixture

    Disconnect continuity test and enable VUSB supply.
    """

    # Hardware setup before tests in this sequence:
    print("SETUP TestVoltageVUSB")
    test_fixture.pwr_select(True)
    test_fixture.en_12v(False)
    test_fixture.en_5v(True)
    time.sleep(delays.PWR)

    yield

    # Hardware teardown after tests in this sequence:
    print("TEARDOWN TestVoltageVUSB")
    test_fixture.pwr_select(False)
    test_fixture.en_12v(False)
    test_fixture.en_5v(False)
    time.sleep(delays.PWR)

TestVoltageVUSB

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
class TestVoltageVUSB:
    def test_vusb_5v0_voltage(
        self, voltage_test_usb, test_fixture, test_config, record_property
    ):
        """DUT 5V Voltage Test.

        Verify that the DUT is receiving 5V from the VUSB supply.
        """

        # Measure
        reading = test_fixture.get_dut_5v0_reading()
        meas = round(reading["mean"], 3)

        error_msg = f"DUT 5V Voltage Test Failed: {meas}"
        log_vars(record_property)
        assert (
            float(test_config.min_limit) < meas < float(test_config.max_limit)
        ), error_msg

    def test_vusb_3v3_voltage(
        self, voltage_test_usb, test_fixture, test_config, record_property
    ):
        """DUT 3.3V Voltage Test.

        Verify that the DUT is receiving 3.3V from the VUSB supply.
        """

        # Measure
        reading = test_fixture.get_dut_3v3_reading()
        meas = round(reading["mean"], 3)

        error_msg = f"DUT 3.3V Voltage Test Failed: {meas}"
        log_vars(record_property)
        assert (
            float(test_config.min_limit) < meas < float(test_config.max_limit)
        ), error_msg

    def test_vusb_1v1_voltage(
        self, voltage_test_usb, test_fixture, test_config, record_property
    ):
        """DUT 1.1V Voltage Test.

        Verify that the DUT is receiving 1.1V from the VUSB supply.
        """

        # Measure
        reading = test_fixture.get_dut_1v1_reading()
        meas = round(reading["mean"], 3)

        error_msg = f"DUT 1.1V Voltage Test Failed: {meas}"
        log_vars(record_property)
        assert (
            float(test_config.min_limit) < meas < float(test_config.max_limit)
        ), error_msg

test_vusb_5v0_voltage

DUT 5V Voltage Test.

Verify that the DUT is receiving 5V from the VUSB supply.

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
def test_vusb_5v0_voltage(
    self, voltage_test_usb, test_fixture, test_config, record_property
):
    """DUT 5V Voltage Test.

    Verify that the DUT is receiving 5V from the VUSB supply.
    """

    # Measure
    reading = test_fixture.get_dut_5v0_reading()
    meas = round(reading["mean"], 3)

    error_msg = f"DUT 5V Voltage Test Failed: {meas}"
    log_vars(record_property)
    assert (
        float(test_config.min_limit) < meas < float(test_config.max_limit)
    ), error_msg

test_vusb_3v3_voltage

DUT 3.3V Voltage Test.

Verify that the DUT is receiving 3.3V from the VUSB supply.

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
def test_vusb_3v3_voltage(
    self, voltage_test_usb, test_fixture, test_config, record_property
):
    """DUT 3.3V Voltage Test.

    Verify that the DUT is receiving 3.3V from the VUSB supply.
    """

    # Measure
    reading = test_fixture.get_dut_3v3_reading()
    meas = round(reading["mean"], 3)

    error_msg = f"DUT 3.3V Voltage Test Failed: {meas}"
    log_vars(record_property)
    assert (
        float(test_config.min_limit) < meas < float(test_config.max_limit)
    ), error_msg

test_vusb_1v1_voltage

DUT 1.1V Voltage Test.

Verify that the DUT is receiving 1.1V from the VUSB supply.

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
def test_vusb_1v1_voltage(
    self, voltage_test_usb, test_fixture, test_config, record_property
):
    """DUT 1.1V Voltage Test.

    Verify that the DUT is receiving 1.1V from the VUSB supply.
    """

    # Measure
    reading = test_fixture.get_dut_1v1_reading()
    meas = round(reading["mean"], 3)

    error_msg = f"DUT 1.1V Voltage Test Failed: {meas}"
    log_vars(record_property)
    assert (
        float(test_config.min_limit) < meas < float(test_config.max_limit)
    ), error_msg

voltage_test_ext

12V External Voltage Tests Setup/Teardown Fixture

Disconnect continuity test and enable 12V supply.

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
@pytest.fixture(scope="class")
def voltage_test_ext(test_fixture, delays):
    """12V External Voltage Tests Setup/Teardown Fixture

    Disconnect continuity test and enable 12V supply.
    """
    # Hardware setup before tests in this sequence:
    print("SETUP TestVoltageVEXT")
    test_fixture.pwr_select(True)
    test_fixture.en_5v(False)
    test_fixture.en_12v(True)
    time.sleep(delays.PWR)

    yield

    # Hardware teardown after tests in this sequence:
    print("TEARDOWN TestVoltageVEXT")
    test_fixture.pwr_select(False)
    test_fixture.en_5v(False)
    test_fixture.en_12v(False)
    time.sleep(delays.PWR)

TestVoltageVEXT

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
class TestVoltageVEXT:
    def test_vext_5v0_voltage(
        self, voltage_test_ext, test_fixture, test_config, record_property
    ):
        """DUT 5V Voltage Test.

        Verify that the DUT is receiving 5V from the 12V supply.
        """
        # Measure
        reading = test_fixture.get_dut_5v0_reading()
        meas = round(reading["mean"], 3)

        error_msg = f"DUT 5V Voltage Test Failed: {meas}"
        log_vars(record_property)
        assert (
            float(test_config.min_limit) < meas < float(test_config.max_limit)
        ), error_msg

    def test_vext_3v3_voltage(
        self, voltage_test_ext, test_fixture, test_config, record_property
    ):
        """DUT 3.3V Voltage Test.

        Verify that the DUT is receiving 3.3V from the 12V supply.
        """

        # Measure
        reading = test_fixture.get_dut_3v3_reading()
        meas = round(reading["mean"], 3)

        error_msg = f"DUT 3.3V Voltage Test Failed: {meas}"
        log_vars(record_property)
        assert (
            float(test_config.min_limit) < meas < float(test_config.max_limit)
        ), error_msg

    def test_vext_1v1_voltage(
        self, voltage_test_ext, test_fixture, test_config, record_property
    ):
        """DUT 1.1V Voltage Test.

        Verify that the DUT is receiving 1.1V from the 12V supply.
        """

        # Measure
        reading = test_fixture.get_dut_1v1_reading()
        meas = round(reading["mean"], 3)

        error_msg = f"DUT 1.1V Voltage Test Failed: {meas}"
        log_vars(record_property)
        assert (
            float(test_config.min_limit) < meas < float(test_config.max_limit)
        ), error_msg

test_vext_5v0_voltage

DUT 5V Voltage Test.

Verify that the DUT is receiving 5V from the 12V supply.

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
def test_vext_5v0_voltage(
    self, voltage_test_ext, test_fixture, test_config, record_property
):
    """DUT 5V Voltage Test.

    Verify that the DUT is receiving 5V from the 12V supply.
    """
    # Measure
    reading = test_fixture.get_dut_5v0_reading()
    meas = round(reading["mean"], 3)

    error_msg = f"DUT 5V Voltage Test Failed: {meas}"
    log_vars(record_property)
    assert (
        float(test_config.min_limit) < meas < float(test_config.max_limit)
    ), error_msg

test_vext_3v3_voltage

DUT 3.3V Voltage Test.

Verify that the DUT is receiving 3.3V from the 12V supply.

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
def test_vext_3v3_voltage(
    self, voltage_test_ext, test_fixture, test_config, record_property
):
    """DUT 3.3V Voltage Test.

    Verify that the DUT is receiving 3.3V from the 12V supply.
    """

    # Measure
    reading = test_fixture.get_dut_3v3_reading()
    meas = round(reading["mean"], 3)

    error_msg = f"DUT 3.3V Voltage Test Failed: {meas}"
    log_vars(record_property)
    assert (
        float(test_config.min_limit) < meas < float(test_config.max_limit)
    ), error_msg

test_vext_1v1_voltage

DUT 1.1V Voltage Test.

Verify that the DUT is receiving 1.1V from the 12V supply.

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
def test_vext_1v1_voltage(
    self, voltage_test_ext, test_fixture, test_config, record_property
):
    """DUT 1.1V Voltage Test.

    Verify that the DUT is receiving 1.1V from the 12V supply.
    """

    # Measure
    reading = test_fixture.get_dut_1v1_reading()
    meas = round(reading["mean"], 3)

    error_msg = f"DUT 1.1V Voltage Test Failed: {meas}"
    log_vars(record_property)
    assert (
        float(test_config.min_limit) < meas < float(test_config.max_limit)
    ), error_msg

func_tests

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
@pytest.fixture(scope="class")
def func_tests(test_fixture, fixtur_cntl, delays):
    """ """

    # Hardware setup before tests in this sequence:
    print("SETUP TestFunctional")

    test_fixture.pwr_select(True)
    test_fixture.en_12v(False)
    test_fixture.en_5v(True)

    # Put into BOOTSEL mode
    test_fixture.bootsel()

    yield test_fixture

    # Hardware teardown after tests in this sequence:
    print("TEARDOWN TestFunctional")
    for channel in range(1, 7):
        test_fixture.en_usb_serial(state=False, usb=channel)
        test_fixture.en_usb_load(state=False, usb=channel)

    test_fixture.pwr_select(False)
    test_fixture.en_12v(False)
    test_fixture.en_5v(False)

serial_open

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
314
315
316
317
318
319
320
321
322
323
@pytest.fixture(scope="class")
def serial_open(dut_serial):
    """ """
    dut_serial.open()
    dut_serial.usb_port_enable_all(False)

    yield dut_serial

    dut_serial.usb_port_enable_all(False)
    dut_serial.close()

check_disk_exist

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
326
327
328
def check_disk_exist(disk):
    output = subprocess.check_output(["lsblk"]).decode("utf-8")
    return disk.replace("/dev/", "") in output

find_sdx_devices

Finds and returns a list of existing sdx devices.

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
331
332
333
334
335
336
337
338
339
def find_sdx_devices():
    """
    Finds and returns a list of existing sdx devices.
    """
    sdx_devices = []
    for device_path in glob.glob("/dev/sd*"):
        if os.path.exists(device_path):
            sdx_devices.append(device_path)
    return sdx_devices

TestFunctional

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
class TestFunctional:
    @pytest.mark.prog
    def test_prog(
        self,
        func_tests,
        fixtur_cntl,
        test_config,
        fixture_config,
        record_property,
        delays,
    ):
        """Program RP2040"""
        start = time.time()
        ffc_sn = str(fixture_config.user_vars["FIXT_FFC_SERIAL"])
        port = find_device_by_serial(
            ffc_sn, check_if=False
        )  # Get port of FFC not in Fixture Base (DUT)
        while not port:
            time.sleep(delays.CMD)
            sdx = find_sdx_devices()
            if sdx:
                func_tests.arduino_cli.port = sdx[0]
                break

            port = find_device_by_serial(
                ffc_sn, check_if=False
            )  # Get port of FFC not in Fixture Base (DUT)
            if port:
                func_tests.arduino_cli.port = port
                output = subprocess.check_output(["usbreset", "2e8a:000a"]).decode(
                    "utf-8"
                )
                print(output)

            if time.time() - start > delays.BOOT:
                raise TimeoutError("Timeout")

        sketch_dir = str(fixture_config.user_vars["SKETCH_DIR"])
        arduino_cli = func_tests.arduino_cli

        arduino_cli.compile(sketch_dir=sketch_dir)
        output = arduino_cli.upload(sketch_dir=sketch_dir)

        assert output, test_config.error_msg

        # Reboot DUT
        func_tests.en_5v(False)
        func_tests.en_5v(True)
        time.sleep(delays.PWR)

        try:
            start = time.time()
            while not port:
                port = find_device_by_serial(
                    ffc_sn, check_if=False
                )  # Get port of FFC not in Fixture Base (DUT)

                if port:
                    func_tests.arduino_cli.port = port
                    output = subprocess.check_output(["usbreset", "2e8a:000a"]).decode(
                        "utf-8"
                    )
                    print(output)

                if time.time() - start > delays.BOOT:
                    raise TimeoutError(
                        f"Could not find serial port: {func_tests.arduino_cli.port}"
                    )

            while not os.path.exists(port):
                time.sleep(delays.CMD)

                if time.time() - start > delays.BOOT:
                    raise TimeoutError(
                        f"Could not find serial port: {func_tests.arduino_cli.port}"
                    )

        except Exception:
            error_msg = (
                str(test_config.error_msg)
                + f"Unable to Find Serial Port {func_tests.arduino_cli.port}"
            )
            log_vars(record_property)
            assert False

    def test_version(self, serial_open, test_config, record_property):
        """ """

        min_limit = str(test_config.user_vars["FIRMWARE_VERSION"])
        meas = serial_open.firmware_version()

        log_vars(record_property)
        assert min_limit == meas, test_config.error_msg

    @pytest.mark.parametrize(
        "test_id, error_code, channel, adc, div",
        [
            ("3.3.01", "3301", 1, 10, 2),
            ("3.3.02", "3302", 2, 11, 2),
            ("3.3.03", "3303", 3, 12, 2),
            ("3.3.04", "3304", 4, 13, 2),
            ("3.3.05", "3305", 5, 14, 2),
            ("3.3.06", "3306", 6, 15, 2),
        ],
    )
    def test_usb_loads(
        self,
        test_id,
        error_code,
        channel,
        adc,
        div,
        func_tests,
        serial_open,
        test_config,
        delays,
        record_property,
    ):
        """ """
        print(test_config)

        test_id, error_code = test_id, error_code
        description = test_config.description + f"Verify Channel {channel}"
        log_vars(record_property)

        on_output = serial_open.usb_port_enable(state=True, port=channel)
        func_tests.en_usb_load(state=True, usb=channel)

        time.sleep(delays.USB_LOAD)
        meas = round(func_tests.get_mux_reading(adc)["mean"] * div, 3)

        off_output = serial_open.usb_port_enable(state=False, port=channel)

        func_tests.en_usb_load(state=False, usb=channel)

        log_vars(record_property)
        assert f"OK -- USB port {channel} is turned on." in on_output

        assert float(test_config.min_limit) < meas < float(test_config.max_limit)

        assert f"OK -- USB port {channel} is turned off." in off_output

    @pytest.mark.parametrize(
        "test_id, error_code, channel",
        [
            ("3.3.07", "3307", 1),
            ("3.3.08", "3308", 2),
            ("3.3.09", "3309", 3),
            ("3.3.10", "3310", 4),
            ("3.3.11", "3311", 5),
            ("3.3.12", "3312", 6),
        ],
    )
    def test_usb_serial(
        self,
        test_id,
        error_code,
        channel,
        func_tests,
        serial_open,
        test_config,
        delays,
        record_property,
    ):
        """ """
        print(test_config)

        test_id, error_code = test_id, error_code
        description = test_config.description + f"Verify Channel {channel}"
        log_vars(record_property)

        serial_str = "ID 1a86:7523 QinHeng Electronics CH340 serial converter"

        output = subprocess.check_output(["lsusb"]).decode("utf-8")
        serial_devices_off = output.count(serial_str)

        serial_open.usb_port_enable(state=True, port=channel)
        func_tests.en_usb_serial(state=True, usb=channel)
        time.sleep(delays.USB_SERIAL)

        output = subprocess.check_output(["lsusb"]).decode("utf-8")
        meas = output.count(serial_str) - serial_devices_off

        serial_open.usb_port_enable(state=False, port=channel)
        func_tests.en_usb_serial(state=False, usb=channel)
        time.sleep(delays.USB_SERIAL)

        log_vars(record_property)
        assert meas > 0

    def test_usb_enable_all(self, serial_open, record_property):
        """ """
        output = serial_open.usb_port_enable_all(state=True)

        log_vars(record_property)
        assert "OK - All USB ports have been turned on." in output

        output = serial_open.usb_port_enable_all(state=False)

        log_vars(record_property)
        assert "OK - All USB ports have been turned off." in output

    @pytest.mark.parametrize(
        "test_id, error_code, channel",
        [
            ("3.4.1", "341", 1),
            ("3.4.2", "342", 2),
            ("3.4.3", "343", 3),
        ],
    )
    def test_cycles(
        self,
        test_id,
        error_code,
        channel,
        func_tests,
        serial_open,
        test_config,
        test_fixture,
        record_property,
    ):
        """ """
        test_id, error_code = test_id, error_code
        description = test_config.description + f"Verify Channel {channel}"
        log_vars(record_property)

        cycles = serial_open.get_cycles(eeprom=channel)
        print(cycles)

        serial_open.zero_cycles(eeprom=channel)

        meas = serial_open.get_cycles(eeprom=channel)
        print(meas)

        log_vars(record_property)
        assert meas == 0

    def test_find_eeproms(self, func_tests, serial_open, record_property):
        """ """
        device_data = serial_open.get_i2c_eeprom_devices()
        print(device_data)

    def test_fixture_state(self, func_tests, serial_open, record_property):
        """ """
        meas = not serial_open.get_fixture_closed()
        log_vars(record_property)
        assert meas

    @pytest.mark.parametrize(
        "test_id, error_code, channel",
        [
            ("3.7.1", "371", 21),
            ("3.7.2", "372", 22),
            ("3.7.3", "373", 23),
            ("3.7.4", "374", 24),
            ("3.7.5", "375", 25),
        ],
    )
    def test_gpio(
        self,
        test_id,
        error_code,
        channel,
        func_tests,
        serial_open,
        test_config,
        record_property,
    ):
        test_id, error_code = test_id, error_code
        description = test_config.description + f"Verify Digital IO {channel}"
        log_vars(record_property)

        serial_open.set_gpio_mode(gpio=channel, mode="out")

        serial_open.set_gpio_state(gpio=channel, state=True)

        meas = serial_open.get_gpio_state(gpio=channel)
        assert meas

    @pytest.mark.parametrize(
        "test_id, error_code, channel",
        [
            ("3.8.1", "381", 0),
            ("3.8.2", "382", 1),
            ("3.8.3", "383", 2),
            ("3.8.4", "384", 3),
        ],
    )
    def test_adc(
        self,
        test_id,
        error_code,
        channel,
        func_tests,
        serial_open,
        test_config,
        record_property,
    ):
        test_id, error_code = test_id, error_code
        description = test_config.description + f"Verify Channel {channel}"
        log_vars(record_property)

        meas = serial_open.get_analog_state(aio=channel)
        assert meas

test_prog

Program RP2040

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
@pytest.mark.prog
def test_prog(
    self,
    func_tests,
    fixtur_cntl,
    test_config,
    fixture_config,
    record_property,
    delays,
):
    """Program RP2040"""
    start = time.time()
    ffc_sn = str(fixture_config.user_vars["FIXT_FFC_SERIAL"])
    port = find_device_by_serial(
        ffc_sn, check_if=False
    )  # Get port of FFC not in Fixture Base (DUT)
    while not port:
        time.sleep(delays.CMD)
        sdx = find_sdx_devices()
        if sdx:
            func_tests.arduino_cli.port = sdx[0]
            break

        port = find_device_by_serial(
            ffc_sn, check_if=False
        )  # Get port of FFC not in Fixture Base (DUT)
        if port:
            func_tests.arduino_cli.port = port
            output = subprocess.check_output(["usbreset", "2e8a:000a"]).decode(
                "utf-8"
            )
            print(output)

        if time.time() - start > delays.BOOT:
            raise TimeoutError("Timeout")

    sketch_dir = str(fixture_config.user_vars["SKETCH_DIR"])
    arduino_cli = func_tests.arduino_cli

    arduino_cli.compile(sketch_dir=sketch_dir)
    output = arduino_cli.upload(sketch_dir=sketch_dir)

    assert output, test_config.error_msg

    # Reboot DUT
    func_tests.en_5v(False)
    func_tests.en_5v(True)
    time.sleep(delays.PWR)

    try:
        start = time.time()
        while not port:
            port = find_device_by_serial(
                ffc_sn, check_if=False
            )  # Get port of FFC not in Fixture Base (DUT)

            if port:
                func_tests.arduino_cli.port = port
                output = subprocess.check_output(["usbreset", "2e8a:000a"]).decode(
                    "utf-8"
                )
                print(output)

            if time.time() - start > delays.BOOT:
                raise TimeoutError(
                    f"Could not find serial port: {func_tests.arduino_cli.port}"
                )

        while not os.path.exists(port):
            time.sleep(delays.CMD)

            if time.time() - start > delays.BOOT:
                raise TimeoutError(
                    f"Could not find serial port: {func_tests.arduino_cli.port}"
                )

    except Exception:
        error_msg = (
            str(test_config.error_msg)
            + f"Unable to Find Serial Port {func_tests.arduino_cli.port}"
        )
        log_vars(record_property)
        assert False

test_version

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
427
428
429
430
431
432
433
434
def test_version(self, serial_open, test_config, record_property):
    """ """

    min_limit = str(test_config.user_vars["FIRMWARE_VERSION"])
    meas = serial_open.firmware_version()

    log_vars(record_property)
    assert min_limit == meas, test_config.error_msg

test_usb_loads

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
@pytest.mark.parametrize(
    "test_id, error_code, channel, adc, div",
    [
        ("3.3.01", "3301", 1, 10, 2),
        ("3.3.02", "3302", 2, 11, 2),
        ("3.3.03", "3303", 3, 12, 2),
        ("3.3.04", "3304", 4, 13, 2),
        ("3.3.05", "3305", 5, 14, 2),
        ("3.3.06", "3306", 6, 15, 2),
    ],
)
def test_usb_loads(
    self,
    test_id,
    error_code,
    channel,
    adc,
    div,
    func_tests,
    serial_open,
    test_config,
    delays,
    record_property,
):
    """ """
    print(test_config)

    test_id, error_code = test_id, error_code
    description = test_config.description + f"Verify Channel {channel}"
    log_vars(record_property)

    on_output = serial_open.usb_port_enable(state=True, port=channel)
    func_tests.en_usb_load(state=True, usb=channel)

    time.sleep(delays.USB_LOAD)
    meas = round(func_tests.get_mux_reading(adc)["mean"] * div, 3)

    off_output = serial_open.usb_port_enable(state=False, port=channel)

    func_tests.en_usb_load(state=False, usb=channel)

    log_vars(record_property)
    assert f"OK -- USB port {channel} is turned on." in on_output

    assert float(test_config.min_limit) < meas < float(test_config.max_limit)

    assert f"OK -- USB port {channel} is turned off." in off_output

test_usb_serial

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
@pytest.mark.parametrize(
    "test_id, error_code, channel",
    [
        ("3.3.07", "3307", 1),
        ("3.3.08", "3308", 2),
        ("3.3.09", "3309", 3),
        ("3.3.10", "3310", 4),
        ("3.3.11", "3311", 5),
        ("3.3.12", "3312", 6),
    ],
)
def test_usb_serial(
    self,
    test_id,
    error_code,
    channel,
    func_tests,
    serial_open,
    test_config,
    delays,
    record_property,
):
    """ """
    print(test_config)

    test_id, error_code = test_id, error_code
    description = test_config.description + f"Verify Channel {channel}"
    log_vars(record_property)

    serial_str = "ID 1a86:7523 QinHeng Electronics CH340 serial converter"

    output = subprocess.check_output(["lsusb"]).decode("utf-8")
    serial_devices_off = output.count(serial_str)

    serial_open.usb_port_enable(state=True, port=channel)
    func_tests.en_usb_serial(state=True, usb=channel)
    time.sleep(delays.USB_SERIAL)

    output = subprocess.check_output(["lsusb"]).decode("utf-8")
    meas = output.count(serial_str) - serial_devices_off

    serial_open.usb_port_enable(state=False, port=channel)
    func_tests.en_usb_serial(state=False, usb=channel)
    time.sleep(delays.USB_SERIAL)

    log_vars(record_property)
    assert meas > 0

test_usb_enable_all

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
532
533
534
535
536
537
538
539
540
541
542
def test_usb_enable_all(self, serial_open, record_property):
    """ """
    output = serial_open.usb_port_enable_all(state=True)

    log_vars(record_property)
    assert "OK - All USB ports have been turned on." in output

    output = serial_open.usb_port_enable_all(state=False)

    log_vars(record_property)
    assert "OK - All USB ports have been turned off." in output

test_cycles

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
@pytest.mark.parametrize(
    "test_id, error_code, channel",
    [
        ("3.4.1", "341", 1),
        ("3.4.2", "342", 2),
        ("3.4.3", "343", 3),
    ],
)
def test_cycles(
    self,
    test_id,
    error_code,
    channel,
    func_tests,
    serial_open,
    test_config,
    test_fixture,
    record_property,
):
    """ """
    test_id, error_code = test_id, error_code
    description = test_config.description + f"Verify Channel {channel}"
    log_vars(record_property)

    cycles = serial_open.get_cycles(eeprom=channel)
    print(cycles)

    serial_open.zero_cycles(eeprom=channel)

    meas = serial_open.get_cycles(eeprom=channel)
    print(meas)

    log_vars(record_property)
    assert meas == 0

test_find_eeproms

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
579
580
581
582
def test_find_eeproms(self, func_tests, serial_open, record_property):
    """ """
    device_data = serial_open.get_i2c_eeprom_devices()
    print(device_data)

test_fixture_state

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
584
585
586
587
588
def test_fixture_state(self, func_tests, serial_open, record_property):
    """ """
    meas = not serial_open.get_fixture_closed()
    log_vars(record_property)
    assert meas

test_gpio

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
@pytest.mark.parametrize(
    "test_id, error_code, channel",
    [
        ("3.7.1", "371", 21),
        ("3.7.2", "372", 22),
        ("3.7.3", "373", 23),
        ("3.7.4", "374", 24),
        ("3.7.5", "375", 25),
    ],
)
def test_gpio(
    self,
    test_id,
    error_code,
    channel,
    func_tests,
    serial_open,
    test_config,
    record_property,
):
    test_id, error_code = test_id, error_code
    description = test_config.description + f"Verify Digital IO {channel}"
    log_vars(record_property)

    serial_open.set_gpio_mode(gpio=channel, mode="out")

    serial_open.set_gpio_state(gpio=channel, state=True)

    meas = serial_open.get_gpio_state(gpio=channel)
    assert meas

test_adc

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
@pytest.mark.parametrize(
    "test_id, error_code, channel",
    [
        ("3.8.1", "381", 0),
        ("3.8.2", "382", 1),
        ("3.8.3", "383", 2),
        ("3.8.4", "384", 3),
    ],
)
def test_adc(
    self,
    test_id,
    error_code,
    channel,
    func_tests,
    serial_open,
    test_config,
    record_property,
):
    test_id, error_code = test_id, error_code
    description = test_config.description + f"Verify Channel {channel}"
    log_vars(record_property)

    meas = serial_open.get_analog_state(aio=channel)
    assert meas

test_io

Source code in test_plans/fixtur-ctrl-func-test/test_plan.py
648
649
650
651
652
653
654
655
656
657
658
659
660
661
def test_io(test_fixture, delays, record_property):
    gpio = test_fixture.io_expander
    gpio.set_direction(gpio.OUTPUT, bits=[1, 2, 3])
    gpio.set_polarity(gpio.DEFAULT, bits=[1, 2, 3])

    gpio.set_level(True, bits=(1, 2, 3))
    for bit in [1, 2, 3]:
        log_vars(record_property)
        assert gpio.is_high(bit)

    gpio.set_level(False, bits=(1, 2, 3))
    for bit in [1, 2, 3]:
        log_vars(record_property)
        assert not gpio.is_high(bit)