From 85b4add05fed8a292499cc176a35891b3235b29a Mon Sep 17 00:00:00 2001 From: pavel-zotov Date: Sat, 3 Feb 2024 10:04:49 +0300 Subject: [PATCH] Added/Updated tests\bugs\gh_7992_test.py: Checked on 5.0.1.1330, 6.0.0.247. --- tests/bugs/gh_7992_test.py | 52 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/bugs/gh_7992_test.py diff --git a/tests/bugs/gh_7992_test.py b/tests/bugs/gh_7992_test.py new file mode 100644 index 00000000..752ae33e --- /dev/null +++ b/tests/bugs/gh_7992_test.py @@ -0,0 +1,52 @@ +#coding:utf-8 + +""" +ID: issue-7992 +ISSUE: https://github.com/FirebirdSQL/firebird/issues/7992 +TITLE: Assertion (space > 0) failure during restore +DESCRIPTION: +NOTES: + [03.02.2024] pzotov + Confirmed problem on 5.0.1.1328, 6.0.0.244 (common builds): restore terminates prematurely, firebird crashes. + Checked on 5.0.1.1330, 6.0.0.247. +""" +import subprocess +from pathlib import Path +import zipfile +import locale +import re +import pytest +from firebird.qa import * +from firebird.driver import SrvRestoreFlag + +db = db_factory() +act = python_act('db') +fbk_file = temp_file('gh_7992.tmp.fbk') + +expected_stdout = """ + gbak:finishing, closing, and going home + gbak:adjusting the ONLINE and FORCED WRITES flags +""" + +@pytest.mark.version('>=5.0.1') +def test_1(act: Action, fbk_file: Path, capsys): + zipped_fbk_file = zipfile.Path(act.files_dir / 'gh_7992.zip', at = 'gh_7992.fbk') + fbk_file.write_bytes(zipped_fbk_file.read_bytes()) + + allowed_patterns = \ + ( + 'gbak:finishing, closing, and going home' + ,'gbak:adjusting the ONLINE and FORCED WRITES flags' + ) + allowed_patterns = [ re.compile(p, re.IGNORECASE) for p in allowed_patterns ] + + with act.connect_server(encoding=locale.getpreferredencoding()) as srv: + srv.database.restore(database=act.db.db_path, backup=fbk_file, flags=SrvRestoreFlag.REPLACE, verbose=True) + restore_log = srv.readlines() + for line in restore_log: + if act.match_any(line.strip(), allowed_patterns): + print(line) + + act.expected_stdout = expected_stdout + act.stdout = capsys.readouterr().out + assert act.clean_stdout == act.clean_expected_stdout