2018-11-19 03:46:21 +00:00
|
|
|
#!/usr/bin/env python
|
2021-05-31 04:43:23 +00:00
|
|
|
# SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
2021-01-26 02:49:01 +00:00
|
|
|
from __future__ import division, print_function
|
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
import sys
|
2021-01-26 02:49:01 +00:00
|
|
|
import unittest
|
2018-12-06 09:49:02 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
import efuse_table_gen
|
|
|
|
except ImportError:
|
2021-01-26 02:49:01 +00:00
|
|
|
sys.path.append('..')
|
2018-12-06 09:49:02 +00:00
|
|
|
import efuse_table_gen
|
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
|
|
|
|
'''
|
|
|
|
To run the test on local PC:
|
|
|
|
cd ~/esp/esp-idf/components/efuse/test_efuse_host/
|
|
|
|
./efuse_tests.py
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
2018-12-18 14:42:10 +00:00
|
|
|
class Py23TestCase(unittest.TestCase):
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(Py23TestCase, self).__init__(*args, **kwargs)
|
|
|
|
try:
|
|
|
|
self.assertRaisesRegex
|
|
|
|
except AttributeError:
|
|
|
|
# assertRaisesRegexp is deprecated in Python3 but assertRaisesRegex doesn't exist in Python2
|
|
|
|
# This fix is used in order to avoid using the alias from the six library
|
|
|
|
self.assertRaisesRegex = self.assertRaisesRegexp
|
|
|
|
|
|
|
|
|
|
|
|
class CSVParserTests(Py23TestCase):
|
2018-11-19 03:46:21 +00:00
|
|
|
|
|
|
|
def test_general(self):
|
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK3, 0, 5, Use for test name 1
|
|
|
|
name2, EFUSE_BLK3, 5, 4, Use for test name 2
|
|
|
|
"""
|
2018-12-06 09:49:02 +00:00
|
|
|
t = efuse_table_gen.FuseTable.from_csv(csv)
|
2018-11-19 03:46:21 +00:00
|
|
|
t.verify()
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[0].field_name, 'name1')
|
|
|
|
self.assertEqual(t[0].efuse_block, 'EFUSE_BLK3')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[0].bit_start, 0)
|
|
|
|
self.assertEqual(t[0].bit_count, 5)
|
|
|
|
self.assertEqual(t[0].comment, 'Use for test name 1')
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[1].field_name, 'name2')
|
|
|
|
self.assertEqual(t[1].efuse_block, 'EFUSE_BLK3')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[1].bit_start, 5)
|
|
|
|
self.assertEqual(t[1].bit_count, 4)
|
|
|
|
self.assertEqual(t[1].comment, 'Use for test name 2')
|
2018-11-19 03:46:21 +00:00
|
|
|
|
|
|
|
def test_seq_bit_start1_fill(self):
|
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK3, , 5,
|
|
|
|
name2, EFUSE_BLK3, , 4,
|
|
|
|
"""
|
2018-12-06 09:49:02 +00:00
|
|
|
t = efuse_table_gen.FuseTable.from_csv(csv)
|
2018-11-19 03:46:21 +00:00
|
|
|
t.verify()
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[0].field_name, 'name1')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[0].bit_start, 0)
|
|
|
|
self.assertEqual(t[0].bit_count, 5)
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[1].field_name, 'name2')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[1].bit_start, 5)
|
|
|
|
self.assertEqual(t[1].bit_count, 4)
|
2018-11-19 03:46:21 +00:00
|
|
|
|
|
|
|
def test_seq_bit_start2_fill(self):
|
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK3, , 5,
|
|
|
|
name2, EFUSE_BLK2, , 4,
|
|
|
|
"""
|
2018-12-06 09:49:02 +00:00
|
|
|
t = efuse_table_gen.FuseTable.from_csv(csv)
|
2018-11-19 03:46:21 +00:00
|
|
|
t.verify()
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[0].field_name, 'name1')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[0].bit_start, 0)
|
|
|
|
self.assertEqual(t[0].bit_count, 5)
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[1].field_name, 'name2')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[1].bit_start, 0)
|
|
|
|
self.assertEqual(t[1].bit_count, 4)
|
2018-11-19 03:46:21 +00:00
|
|
|
|
|
|
|
def test_seq_bit_start3_fill(self):
|
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK3, , 5,
|
|
|
|
name2, EFUSE_BLK2, , 4,
|
|
|
|
|
|
|
|
name3, EFUSE_BLK2, 5, 4,
|
|
|
|
"""
|
2018-12-06 09:49:02 +00:00
|
|
|
t = efuse_table_gen.FuseTable.from_csv(csv)
|
2018-11-19 03:46:21 +00:00
|
|
|
t.verify()
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[0].field_name, 'name1')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[0].bit_start, 0)
|
|
|
|
self.assertEqual(t[0].bit_count, 5)
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[1].field_name, 'name2')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[1].bit_start, 0)
|
|
|
|
self.assertEqual(t[1].bit_count, 4)
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[2].field_name, 'name3')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[2].bit_start, 5)
|
|
|
|
self.assertEqual(t[2].bit_count, 4)
|
2018-11-19 03:46:21 +00:00
|
|
|
|
|
|
|
def test_seq_bit_start4_fill(self):
|
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK3, , 5,
|
|
|
|
name2, EFUSE_BLK2, , 4,
|
|
|
|
, EFUSE_BLK2, , 4,
|
|
|
|
name1, EFUSE_BLK3, , 5,
|
|
|
|
"""
|
2021-01-26 02:49:01 +00:00
|
|
|
with self.assertRaisesRegex(efuse_table_gen.InputError, 'Field names must be unique'):
|
2018-12-07 12:32:58 +00:00
|
|
|
efuse_table_gen.FuseTable.from_csv(csv)
|
2018-11-19 03:46:21 +00:00
|
|
|
|
|
|
|
def test_seq_bit_start5_fill(self):
|
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK3, , 5,
|
|
|
|
name2, EFUSE_BLK2, , 4,
|
|
|
|
, EFUSE_BLK2, , 4,
|
|
|
|
name3, EFUSE_BLK3, 5, 5,
|
|
|
|
"""
|
2018-12-06 09:49:02 +00:00
|
|
|
t = efuse_table_gen.FuseTable.from_csv(csv)
|
2018-11-19 03:46:21 +00:00
|
|
|
t.verify()
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[0].field_name, 'name1')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[0].bit_start, 0)
|
|
|
|
self.assertEqual(t[0].bit_count, 5)
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[1].field_name, 'name2')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[1].bit_start, 0)
|
|
|
|
self.assertEqual(t[1].bit_count, 4)
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[2].field_name, 'name2')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[2].bit_start, 4)
|
|
|
|
self.assertEqual(t[2].bit_count, 4)
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[3].field_name, 'name3')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[3].bit_start, 5)
|
|
|
|
self.assertEqual(t[3].bit_count, 5)
|
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
def test_overlapping_bit_start_fail(self):
|
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK3, 1, 5, Use for test name 1
|
|
|
|
name2, EFUSE_BLK3, 5, 4, Use for test name 2
|
|
|
|
"""
|
2018-12-06 09:49:02 +00:00
|
|
|
t = efuse_table_gen.FuseTable.from_csv(csv)
|
efuse: Adds support structure of efuses in efuse_table
Supported a new format of efuse description using '.' in the name.
It means that RD_DIS.KEYx belongs to the range of the RD_DIS name.
RD_DIS, EFUSE_BLK0, 32, 7, Read protection
RD_DIS.KEY0, EFUSE_BLK0, 32, 1, Read protection for EFUSE_BLK4.
RD_DIS.KEY1, EFUSE_BLK0, 33, 1, Read protection for EFUSE_BLK5.
2021-05-21 08:21:03 +00:00
|
|
|
with self.assertRaisesRegex(efuse_table_gen.InputError, 'intersected with'):
|
2018-11-19 03:46:21 +00:00
|
|
|
t.verify()
|
|
|
|
|
|
|
|
def test_empty_field_name_fail(self):
|
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
, EFUSE_BLK3, , 5,
|
|
|
|
name2, EFUSE_BLK2, , 4,
|
|
|
|
"""
|
2021-01-26 02:49:01 +00:00
|
|
|
with self.assertRaisesRegex(efuse_table_gen.InputError, 'missing field name'):
|
2018-12-07 12:32:58 +00:00
|
|
|
efuse_table_gen.FuseTable.from_csv(csv)
|
2018-12-06 09:49:02 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
def test_unique_field_name_fail(self):
|
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK3, 0, 5, Use for test name 1
|
|
|
|
name1, EFUSE_BLK3, 5, 4, Use for test name 2
|
|
|
|
"""
|
2021-01-26 02:49:01 +00:00
|
|
|
with self.assertRaisesRegex(efuse_table_gen.InputError, 'Field names must be unique'):
|
2018-12-07 12:32:58 +00:00
|
|
|
efuse_table_gen.FuseTable.from_csv(csv)
|
2018-12-06 09:49:02 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
def test_bit_count_empty_fail(self):
|
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK3, 0, , Use for test name 1
|
|
|
|
name2, EFUSE_BLK3, 5, 4, Use for test name 2
|
|
|
|
"""
|
2021-01-26 02:49:01 +00:00
|
|
|
with self.assertRaisesRegex(efuse_table_gen.InputError, 'empty'):
|
2018-12-07 12:32:58 +00:00
|
|
|
efuse_table_gen.FuseTable.from_csv(csv)
|
2018-11-19 03:46:21 +00:00
|
|
|
|
|
|
|
def test_bit_start_num_fail(self):
|
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK3, k, 5, Use for test name 1
|
|
|
|
name2, EFUSE_BLK3, 5, 4, Use for test name 2
|
|
|
|
"""
|
2021-01-26 02:49:01 +00:00
|
|
|
with self.assertRaisesRegex(efuse_table_gen.InputError, 'Invalid field value'):
|
2018-12-07 12:32:58 +00:00
|
|
|
efuse_table_gen.FuseTable.from_csv(csv)
|
2018-11-19 03:46:21 +00:00
|
|
|
|
2018-12-06 09:49:02 +00:00
|
|
|
def test_join_entry(self):
|
2018-11-19 03:46:21 +00:00
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK2, 0, 6, Use for test name 1
|
|
|
|
name2, EFUSE_BLK2, 6, 5, Use for test name 2
|
|
|
|
name3, EFUSE_BLK3, 20, 5, Use for test name 3
|
|
|
|
, EFUSE_BLK3, 30, 5, Use for test name 3
|
|
|
|
name4, EFUSE_BLK2, 30, 5, Use for test name 4
|
|
|
|
"""
|
2018-12-06 09:49:02 +00:00
|
|
|
t = efuse_table_gen.FuseTable.from_csv(csv)
|
2018-11-19 03:46:21 +00:00
|
|
|
t.verify()
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[0].field_name, 'name1')
|
|
|
|
self.assertEqual(t[0].efuse_block, 'EFUSE_BLK2')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[0].bit_start, 0)
|
|
|
|
self.assertEqual(t[0].bit_count, 6)
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[1].field_name, 'name2')
|
|
|
|
self.assertEqual(t[1].efuse_block, 'EFUSE_BLK2')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[1].bit_start, 6)
|
|
|
|
self.assertEqual(t[1].bit_count, 5)
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[2].field_name, 'name3')
|
|
|
|
self.assertEqual(t[2].efuse_block, 'EFUSE_BLK3')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[2].bit_start, 20)
|
|
|
|
self.assertEqual(t[2].bit_count, 5)
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[3].field_name, 'name3')
|
|
|
|
self.assertEqual(t[3].efuse_block, 'EFUSE_BLK3')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[3].bit_start, 30)
|
|
|
|
self.assertEqual(t[3].bit_count, 5)
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[4].field_name, 'name4')
|
|
|
|
self.assertEqual(t[4].efuse_block, 'EFUSE_BLK2')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[4].bit_start, 30)
|
|
|
|
self.assertEqual(t[4].bit_count, 5)
|
2018-11-19 03:46:21 +00:00
|
|
|
|
|
|
|
def test_block_fail(self):
|
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK5, 0, 5, Use for test name 1
|
|
|
|
name2, EFUSE_BLK3, 5, 4, Use for test name 2
|
|
|
|
"""
|
2019-06-18 11:34:05 +00:00
|
|
|
with self.assertRaisesRegex(efuse_table_gen.InputError, "'efuse_block' should be one of EFUSE_BLK0..EFUSE_BLK3"):
|
2018-12-07 12:32:58 +00:00
|
|
|
efuse_table_gen.FuseTable.from_csv(csv)
|
2018-11-19 03:46:21 +00:00
|
|
|
|
|
|
|
def test_field_size_is_ok(self):
|
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK0, 0, 224, Use for test name 1
|
|
|
|
name2, EFUSE_BLK1, 0, 256, Use for test name 2
|
|
|
|
"""
|
2018-12-18 14:42:10 +00:00
|
|
|
efuse_table_gen.max_blk_len = 256
|
2018-12-06 09:49:02 +00:00
|
|
|
t = efuse_table_gen.FuseTable.from_csv(csv)
|
2018-11-19 03:46:21 +00:00
|
|
|
t.verify()
|
|
|
|
|
2018-12-06 09:49:02 +00:00
|
|
|
def test_field_blk3_size_is_more(self):
|
2018-11-19 03:46:21 +00:00
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
2018-12-06 09:49:02 +00:00
|
|
|
name1, EFUSE_BLK3, 190, 1, Use for test name 1
|
|
|
|
name2, EFUSE_BLK3, 191, 5, Use for test name 2
|
2018-11-19 03:46:21 +00:00
|
|
|
"""
|
2018-12-18 14:42:10 +00:00
|
|
|
efuse_table_gen.max_blk_len = 192
|
2018-12-06 09:49:02 +00:00
|
|
|
t = efuse_table_gen.FuseTable.from_csv(csv)
|
2021-01-26 02:49:01 +00:00
|
|
|
with self.assertRaisesRegex(efuse_table_gen.InputError, 'The field is outside the boundaries'):
|
2018-11-19 03:46:21 +00:00
|
|
|
t.verify()
|
|
|
|
|
|
|
|
def test_field_blk1_size_is_more(self):
|
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK0, 0, 224, Use for test name 1
|
|
|
|
name2, EFUSE_BLK1, 1, 256, Use for test name 2
|
|
|
|
"""
|
2018-12-06 09:49:02 +00:00
|
|
|
t = efuse_table_gen.FuseTable.from_csv(csv)
|
2021-01-26 02:49:01 +00:00
|
|
|
with self.assertRaisesRegex(efuse_table_gen.InputError, 'The field is outside the boundaries'):
|
2018-11-19 03:46:21 +00:00
|
|
|
t.verify()
|
2018-12-06 09:49:02 +00:00
|
|
|
|
|
|
|
|
2018-12-18 14:42:10 +00:00
|
|
|
class VerificationTests(Py23TestCase):
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-12-06 09:49:02 +00:00
|
|
|
def test_general(self):
|
2018-11-19 03:46:21 +00:00
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK3, 0, 5, Use for test name 1
|
|
|
|
name2, EFUSE_BLK3, 5, 4, Use for test name 2
|
|
|
|
name1_1, EFUSE_BLK2, 0, 5, Use for test name 1_1
|
|
|
|
name2_1, EFUSE_BLK2, 5, 4, Use for test name 2_1
|
|
|
|
"""
|
2018-12-06 09:49:02 +00:00
|
|
|
t = efuse_table_gen.FuseTable.from_csv(csv)
|
2018-11-19 03:46:21 +00:00
|
|
|
t.verify()
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[0].field_name, 'name1')
|
|
|
|
self.assertEqual(t[0].efuse_block, 'EFUSE_BLK3')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[0].bit_start, 0)
|
|
|
|
self.assertEqual(t[0].bit_count, 5)
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[1].field_name, 'name2')
|
|
|
|
self.assertEqual(t[1].efuse_block, 'EFUSE_BLK3')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[1].bit_start, 5)
|
|
|
|
self.assertEqual(t[1].bit_count, 4)
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[2].field_name, 'name1_1')
|
|
|
|
self.assertEqual(t[2].efuse_block, 'EFUSE_BLK2')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[2].bit_start, 0)
|
|
|
|
self.assertEqual(t[2].bit_count, 5)
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-11-19 03:46:21 +00:00
|
|
|
self.assertEqual(t[3].field_name, 'name2_1')
|
|
|
|
self.assertEqual(t[3].efuse_block, 'EFUSE_BLK2')
|
2018-12-06 09:49:02 +00:00
|
|
|
self.assertEqual(t[3].bit_start, 5)
|
|
|
|
self.assertEqual(t[3].bit_count, 4)
|
|
|
|
|
|
|
|
def test_common_and_custom_table_use_the_same_bits(self):
|
|
|
|
csv_common = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK3, 0, 5, Use for test name 1
|
|
|
|
name2, EFUSE_BLK2, 5, 4, Use for test name 2
|
|
|
|
"""
|
|
|
|
common_table = efuse_table_gen.FuseTable.from_csv(csv_common)
|
2021-01-26 02:49:01 +00:00
|
|
|
common_table.verify('common_table')
|
2018-12-06 09:49:02 +00:00
|
|
|
two_tables = common_table
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-12-06 09:49:02 +00:00
|
|
|
csv_custom = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name3, EFUSE_BLK3, 20, 5, Use for test name 1
|
|
|
|
name4, EFUSE_BLK3, 4, 1, Use for test name 2
|
|
|
|
"""
|
|
|
|
custom_table = efuse_table_gen.FuseTable.from_csv(csv_custom)
|
2021-01-26 02:49:01 +00:00
|
|
|
custom_table.verify('custom_table')
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2018-12-06 09:49:02 +00:00
|
|
|
two_tables += custom_table
|
efuse: Adds support structure of efuses in efuse_table
Supported a new format of efuse description using '.' in the name.
It means that RD_DIS.KEYx belongs to the range of the RD_DIS name.
RD_DIS, EFUSE_BLK0, 32, 7, Read protection
RD_DIS.KEY0, EFUSE_BLK0, 32, 1, Read protection for EFUSE_BLK4.
RD_DIS.KEY1, EFUSE_BLK0, 33, 1, Read protection for EFUSE_BLK5.
2021-05-21 08:21:03 +00:00
|
|
|
with self.assertRaisesRegex(efuse_table_gen.InputError, 'intersected with'):
|
|
|
|
two_tables.verify()
|
|
|
|
|
|
|
|
def test_common_and_custom_table_use_nested_fields(self):
|
|
|
|
csv_common = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
namet1, EFUSE_BLK3, 0, 5, comment
|
|
|
|
namet2, EFUSE_BLK1, 8, 4, comment
|
|
|
|
"""
|
|
|
|
common_table = efuse_table_gen.FuseTable.from_csv(csv_common)
|
|
|
|
common_table.verify('common_table')
|
|
|
|
two_tables = common_table
|
|
|
|
|
|
|
|
csv_custom = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
namet1.D1, EFUSE_BLK3, 0, 2, comment
|
|
|
|
namet1.D1.D11, EFUSE_BLK3, 0, 1, comment
|
|
|
|
namet1.D1.D12, EFUSE_BLK3, 1, 1, comment
|
|
|
|
namet1.D2, EFUSE_BLK3, 2, 3, comment
|
|
|
|
namet2.F1, EFUSE_BLK1, 9, 1, comment
|
|
|
|
"""
|
|
|
|
custom_table = efuse_table_gen.FuseTable.from_csv(csv_custom)
|
|
|
|
custom_table.verify('custom_table')
|
|
|
|
|
|
|
|
two_tables += custom_table
|
|
|
|
two_tables.verify()
|
|
|
|
|
|
|
|
def test_common_and_custom_table_use_nested_fields2(self):
|
|
|
|
csv_common = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
namet3, EFUSE_BLK3, 0, 5, comment
|
|
|
|
namet2, EFUSE_BLK1, 8, 4, comment
|
|
|
|
"""
|
|
|
|
common_table = efuse_table_gen.FuseTable.from_csv(csv_common)
|
|
|
|
common_table.verify('common_table')
|
|
|
|
two_tables = common_table
|
|
|
|
|
|
|
|
csv_custom = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
namet1.D1, EFUSE_BLK3, 0, 2, comment
|
|
|
|
namet1.D1.D11, EFUSE_BLK3, 0, 1, comment
|
|
|
|
namet1.D1.D12, EFUSE_BLK3, 1, 1, comment
|
|
|
|
namet1.D2, EFUSE_BLK3, 2, 3, comment
|
|
|
|
namet2.F1, EFUSE_BLK1, 9, 1, comment
|
|
|
|
"""
|
|
|
|
custom_table = efuse_table_gen.FuseTable.from_csv(csv_custom)
|
|
|
|
custom_table.verify('custom_table')
|
|
|
|
|
|
|
|
two_tables += custom_table
|
|
|
|
with self.assertRaisesRegex(efuse_table_gen.InputError, 'namet1 is not found'):
|
2018-12-06 09:49:02 +00:00
|
|
|
two_tables.verify()
|
|
|
|
|
efuse: Adds support structure of efuses in efuse_table
Supported a new format of efuse description using '.' in the name.
It means that RD_DIS.KEYx belongs to the range of the RD_DIS name.
RD_DIS, EFUSE_BLK0, 32, 7, Read protection
RD_DIS.KEY0, EFUSE_BLK0, 32, 1, Read protection for EFUSE_BLK4.
RD_DIS.KEY1, EFUSE_BLK0, 33, 1, Read protection for EFUSE_BLK5.
2021-05-21 08:21:03 +00:00
|
|
|
def test_nested_fields1(self):
|
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK3, 0, 5, comment
|
|
|
|
name1.D1, EFUSE_BLK3, 0, 4, comment
|
|
|
|
name1.D1.D2, EFUSE_BLK3, 0, 3, comment
|
|
|
|
name1.D1.D2.D3, EFUSE_BLK3, 0, 2, comment
|
|
|
|
name1.D1.D2.D3.D4, EFUSE_BLK3, 0, 1, comment
|
|
|
|
"""
|
|
|
|
t = efuse_table_gen.FuseTable.from_csv(csv)
|
|
|
|
t.verify()
|
|
|
|
|
|
|
|
for i in range(0, 5):
|
|
|
|
self.assertEqual(t[i].bit_start, 0)
|
|
|
|
self.assertEqual(t[i].bit_count, 5 - i)
|
|
|
|
|
|
|
|
def test_nested_fields2(self):
|
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK3, 0, 5, comment
|
|
|
|
name1.D1, EFUSE_BLK3, 1, 4, comment
|
|
|
|
name1.D1.D2, EFUSE_BLK3, 2, 3, comment
|
|
|
|
name1.D1.D2.D3, EFUSE_BLK3, 3, 2, comment
|
|
|
|
name1.D1.D2.D3.D4, EFUSE_BLK3, 4, 1, comment
|
|
|
|
"""
|
|
|
|
t = efuse_table_gen.FuseTable.from_csv(csv)
|
|
|
|
t.verify()
|
|
|
|
|
|
|
|
for i in range(0, 5):
|
|
|
|
self.assertEqual(t[i].bit_start, i)
|
|
|
|
self.assertEqual(t[i].bit_count, 5 - i)
|
|
|
|
|
|
|
|
def test_nested_fields_fail1(self):
|
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK3, 0, 5, comment
|
|
|
|
name1.D1, EFUSE_BLK3, 1, 4, comment
|
|
|
|
name1.D1.D2, EFUSE_BLK3, 0, 1, comment
|
|
|
|
"""
|
|
|
|
t = efuse_table_gen.FuseTable.from_csv(csv)
|
|
|
|
with self.assertRaisesRegex(efuse_table_gen.InputError, 'out of range'):
|
|
|
|
t.verify()
|
|
|
|
|
|
|
|
def test_nested_fields_fail2(self):
|
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK3, 0, 5, comment
|
|
|
|
namet2, EFUSE_BLK2, 8, 4, comment
|
|
|
|
namet2.F1, EFUSE_BLK2, 5, 4, comment
|
|
|
|
"""
|
|
|
|
t = efuse_table_gen.FuseTable.from_csv(csv)
|
|
|
|
with self.assertRaisesRegex(efuse_table_gen.InputError, 'intersected with'):
|
|
|
|
t.verify()
|
|
|
|
|
|
|
|
def test_nested_fields_fail3(self):
|
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK3, 10, 5, comment
|
|
|
|
name11, EFUSE_BLK3, 5, 1, comment
|
|
|
|
namet2.F1, EFUSE_BLK2, 22, 1, comment
|
|
|
|
"""
|
|
|
|
t = efuse_table_gen.FuseTable.from_csv(csv)
|
|
|
|
with self.assertRaisesRegex(efuse_table_gen.InputError, 'namet2 is not found'):
|
|
|
|
t.verify()
|
|
|
|
|
|
|
|
def test_nested_fields_fail4(self):
|
|
|
|
csv = """
|
|
|
|
# field_name, efuse_block(EFUSE_BLK0..EFUSE_BLK3), bit_start(0..255), bit_count, comment
|
|
|
|
name1, EFUSE_BLK3, 10, 5, comment
|
|
|
|
name2, EFUSE_BLK3, 5, 1, comment
|
|
|
|
name2.F1, EFUSE_BLK2, 22, 1, comment
|
|
|
|
"""
|
|
|
|
t = efuse_table_gen.FuseTable.from_csv(csv)
|
|
|
|
with self.assertRaisesRegex(efuse_table_gen.InputError, 'name2 is not found'):
|
|
|
|
t.verify()
|
|
|
|
|
2018-12-07 12:32:58 +00:00
|
|
|
|
2021-01-26 02:49:01 +00:00
|
|
|
if __name__ == '__main__':
|
2018-11-19 03:46:21 +00:00
|
|
|
unittest.main()
|