|
| 1 | +#coding:utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | +ID: issue-7823 |
| 5 | +ISSUE: https://github.com/FirebirdSQL/firebird/issues/7823 |
| 6 | +TITLE: ISQL command SHOW DATABASE crashes in absence of firebird.msg |
| 7 | +NOTES: |
| 8 | + [24.01.2024] pzotov |
| 9 | + Test implemented only for Windows. |
| 10 | + Confirmed bug on 6.0.0.222: ISQL crashes after 'show database' and further statements are not executed. |
| 11 | + Checked on 6.0.0.223 - all fine. |
| 12 | +""" |
| 13 | +import shutil |
| 14 | +import subprocess |
| 15 | +from pathlib import Path |
| 16 | +import pytest |
| 17 | +from firebird.qa import * |
| 18 | + |
| 19 | +db = db_factory() |
| 20 | +act = python_act('db', substitutions = [('^((?!(SUCCESS_MSG)).)*$', ''), ('[ \t]+', ' ')]) |
| 21 | + |
| 22 | +expected_stdout = """ |
| 23 | + SUCCESS_MSG Ok |
| 24 | +""" |
| 25 | + |
| 26 | +tmp_isql = temp_file('isql.exe') |
| 27 | +tmp_clnt = temp_file('fbclient.dll') |
| 28 | +tmp_sql = temp_file('check.sql') |
| 29 | +tmp_log = temp_file('check.log') |
| 30 | + |
| 31 | +@pytest.mark.version('>=6.0') |
| 32 | +@pytest.mark.platform('Windows') |
| 33 | +def test_1(act: Action, tmp_isql: Path, tmp_clnt: Path, tmp_sql: Path, tmp_log: Path, capsys): |
| 34 | + print(Path(act.vars['bin-dir'],'isql.exe')) |
| 35 | + print(tmp_isql) |
| 36 | + shutil.copy2(Path(act.vars['bin-dir'],'isql.exe'), tmp_isql) |
| 37 | + shutil.copy2(Path(act.vars['bin-dir'],'fbclient.dll'), tmp_clnt) |
| 38 | + |
| 39 | + #cmd_isql = [str(tmp_isql), act.db.dsn, '-user', act.db.user, '-pas', act.db.password, '-i', str(tmp_sql)] |
| 40 | + cmd_isql = [str(tmp_isql), act.vars['host']+'/'+act.vars['port']+':'+str(act.db.db_path), '-user', act.db.user, '-pas', act.db.password, '-i', str(tmp_sql)] |
| 41 | + cmd_line = ' '.join(cmd_isql) |
| 42 | + sql_text = f""" |
| 43 | + -- {cmd_line} |
| 44 | + set list on; |
| 45 | + -- this cased crash of ISQL: |
| 46 | + show database; |
| 47 | + -- this was not executed before fix: |
| 48 | + select 'Ok' as success_msg from rdb$database; |
| 49 | + """ |
| 50 | + tmp_sql.write_text(sql_text) |
| 51 | + |
| 52 | + with open(tmp_log, 'w') as f: |
| 53 | + subprocess.run( cmd_isql, stdout = f, stderr = subprocess.STDOUT) |
| 54 | + |
| 55 | + with open(tmp_log, 'r') as f: |
| 56 | + for line in f: |
| 57 | + print(line) |
| 58 | + |
| 59 | + act.expected_stdout = expected_stdout |
| 60 | + act.stdout = capsys.readouterr().out |
| 61 | + assert act.clean_stdout == act.clean_expected_stdout |
0 commit comments