generated from hulk/gd32f4xx_template_cmake_vscode
GUI v0.2.9: fix chronic-lag root cause (log trim crash on PySide6 6.11) + 5 hardening fixes
- log trim used instance-level enum access (removed in PySide6 6.11), crashed
This commit is contained in:
@@ -227,5 +227,57 @@ with open(window._csv_path, encoding='utf-8-sig') as f:
|
||||
check('CSV 表头+2 行', len(lines), 3)
|
||||
check('CSV 故障行', lines[2].split(',')[2], 'SHRT')
|
||||
|
||||
# 6) 日志环形裁剪回归: 写满 500 行后封顶, 继续追加不抛异常、不无限增长。
|
||||
# (手工 cursor 裁剪用 cursor.Start/BlockUnderCursor 实例级枚举访问,
|
||||
# PySide6 6.11 上必然抛 AttributeError → 每 tick 异常中止, v0.2.8 改原生裁剪)
|
||||
for i in range(600):
|
||||
window._log(f'日志压力行 {i}')
|
||||
check('日志 500 行封顶', window.txt_log.blockCount() <= 500, True)
|
||||
window._log('封顶后追加行')
|
||||
check('封顶后可继续追加', window.txt_log.blockCount() <= 500, True)
|
||||
check('封顶后最新行在末尾',
|
||||
window.txt_log.toPlainText().splitlines()[-1].endswith('封顶后追加行'), True)
|
||||
|
||||
# 7) v0.2.9 回归: 故障标记封顶 / 滚动条跟随 / CSV 写失败自停 / 冻结切片右边界
|
||||
t_end = time.time()
|
||||
for i in range(app_fluent.MAX_FAULTS + 50):
|
||||
window._record_fault(t_end + i * 0.01, ff.SENSOR_OPEN)
|
||||
check('故障标记封顶', len(window.faults), app_fluent.MAX_FAULTS)
|
||||
|
||||
sb = window.txt_log.verticalScrollBar()
|
||||
sb.setValue(0)
|
||||
window._log('上翻后新行')
|
||||
check('上翻时不抢滚动条', sb.value() <= 1, True)
|
||||
sb.setValue(sb.maximum())
|
||||
window._log('贴底跟随行')
|
||||
check('贴底时跟随滚动', abs(sb.value() - sb.maximum()) <= 4, True)
|
||||
|
||||
|
||||
class _BoomFile:
|
||||
"""模拟写坏盘: write/flush 必抛 OSError(磁盘满/记录盘被拔)"""
|
||||
def write(self, *_a):
|
||||
raise OSError(28, '模拟磁盘满')
|
||||
def flush(self):
|
||||
raise OSError(28, '模拟磁盘满')
|
||||
def close(self):
|
||||
pass
|
||||
|
||||
|
||||
window._csv = _BoomFile()
|
||||
window._csv_path = 'dummy.csv'
|
||||
window._add_sample(time.time(), 25.0)
|
||||
check('CSV 写失败自动停止记录', window._csv is None, True)
|
||||
check('CSV 失败后按钮复位', window.btn_csv.text(), '开始记录')
|
||||
|
||||
c = window.chart
|
||||
c._samples_t, c._samples_v = [1.0, 2.0, 3.0, 4.0], [1, 2, 3, 4]
|
||||
c._frozen_at = 2.5
|
||||
ts, _vs = c._visible(0, 2.5)
|
||||
check('冻结切片不含冻结尾后样本', ts, [1.0, 2.0])
|
||||
c._frozen_at = None
|
||||
ts, _vs = c._visible(0, 99)
|
||||
check('实时切片完整', ts, [1.0, 2.0, 3.0, 4.0])
|
||||
c._samples_t, c._samples_v = window.samples_t, window.samples_v
|
||||
|
||||
print('RESULT:', 'FAIL:' + ','.join(fails) if fails else 'ALL PASS')
|
||||
sys.exit(1 if fails else 0)
|
||||
|
||||
Reference in New Issue
Block a user