|
|
@@ -4,6 +4,7 @@ import socket
|
|
|
|
|
|
import tiny_test_fw
|
|
|
import ttfw_idf
|
|
|
+from tiny_test_fw import Utility
|
|
|
from ttfw_idf import TestFormat
|
|
|
|
|
|
try:
|
|
|
@@ -17,14 +18,14 @@ def configure_eth_if(func): # type: (typing.Any) -> typing.Any
|
|
|
# try to determine which interface to use
|
|
|
netifs = os.listdir('/sys/class/net/')
|
|
|
target_if = ''
|
|
|
- print('detected interfaces: ' + str(netifs))
|
|
|
+ Utility.console_log('detected interfaces: ' + str(netifs))
|
|
|
for netif in netifs:
|
|
|
if netif.find('eth') == 0 or netif.find('enp') == 0 or netif.find('eno') == 0:
|
|
|
target_if = netif
|
|
|
break
|
|
|
if target_if == '':
|
|
|
raise Exception('no network interface found')
|
|
|
- print('Use ' + target_if + ' for testing')
|
|
|
+ Utility.console_log('Use ' + target_if + ' for testing')
|
|
|
so = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, 0x2222)
|
|
|
so.bind((target_if, 0))
|
|
|
|
|
|
@@ -81,6 +82,7 @@ def test_component_ut_esp_eth(env, appname): # type: (tiny_test_fw.Env, str) ->
|
|
|
expect_result = dut.expect(re.compile(r'([\s\S]*)DUT MAC: ([0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2})'),
|
|
|
timeout=10)
|
|
|
stdout = expect_result[0]
|
|
|
+ Utility.console_log('DUTs MAC address: {}'.format(expect_result[1]))
|
|
|
send_eth_packet(bytes.fromhex('ffffffffffff')) # broadcast frame
|
|
|
send_eth_packet(bytes.fromhex('010000000000')) # multicast frame
|
|
|
send_eth_packet(bytes.fromhex(expect_result[1].replace(':', ''))) # unicast frame
|