mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 20:21:04 +00:00
dac: update unit-test docs and examples for driver-NG
This commit is contained in:
34
examples/peripherals/dac/dac_basic/pytest_dac_basic.py
Normal file
34
examples/peripherals/dac/dac_basic/pytest_dac_basic.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
import pytest
|
||||
from pytest_embedded import Dut
|
||||
|
||||
|
||||
@pytest.mark.esp32
|
||||
@pytest.mark.esp32s2
|
||||
@pytest.mark.generic
|
||||
def test_dac_basic_example(dut: Dut) -> None:
|
||||
res = []
|
||||
for _ in range(10):
|
||||
res.append(dut.expect(r'DAC channel 0 vaule:( +)(\d+)(.*)DAC channel 1 vaule:( +)(\d+)', timeout=10))
|
||||
|
||||
avg1_ch1 = 0
|
||||
avg1_ch2 = 0
|
||||
avg2_ch1 = 0
|
||||
avg2_ch2 = 0
|
||||
|
||||
for val in res[0:5]:
|
||||
avg1_ch1 = avg1_ch1 + int(val.group(2))
|
||||
avg1_ch2 = avg1_ch2 + int(val.group(5))
|
||||
for val in res[5:10]:
|
||||
avg2_ch1 = avg1_ch1 + int(val.group(2))
|
||||
avg2_ch2 = avg1_ch2 + int(val.group(5))
|
||||
|
||||
avg1_ch1 = int(avg1_ch1 / 5)
|
||||
avg1_ch2 = int(avg1_ch2 / 5)
|
||||
avg2_ch1 = int(avg2_ch1 / 5)
|
||||
avg2_ch2 = int(avg2_ch2 / 5)
|
||||
|
||||
assert avg2_ch1 > avg1_ch1
|
||||
assert avg2_ch2 > avg1_ch2
|
Reference in New Issue
Block a user