6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-02-02 02:40:42 +01:00

Added/Updated tests\bugs\core_5691_test.py: adapted old test to work under new QA. Checked on 6.0.0.157, 5.0.0.1280, 4.0.5.3031

This commit is contained in:
pavel-zotov 2023-11-29 16:08:17 +03:00
parent e9ee32d4af
commit 1bd0dcaf44

View File

@ -5,217 +5,206 @@ ID: issue-5957
ISSUE: 5957 ISSUE: 5957
TITLE: File description on Firebird executables should be specific TITLE: File description on Firebird executables should be specific
DESCRIPTION: DESCRIPTION:
::: NB ::: ::: NB :::
We can not obtain 'File description' property using Python. We can not obtain 'File description' property using Python.
Also this property is not accessible for WMIC interface. Also this property is not accessible for WMIC interface.
For this reason it was decided to create on-the-fly Visual Basic script and process it by CSCRIPT.EXE utility For this reason it was decided to create on-the-fly Visual Basic script and process it by CSCRIPT.EXE utility
which exists since 2000/XP on every Windows host in %System%\\system32\\ folder. which exists since 2000/XP on every Windows host in %System%\\system32\\ folder.
VB script accepts full path and filename as single mandatory argument. VB script accepts full path and filename as single mandatory argument.
We run this script for each widely-used FB binaries (executables and DLLs). We run this script for each widely-used FB binaries (executables and DLLs).
Its output must contain only FILE name (w/o disk and path) and its 'File description' property value. Its output must contain only FILE name (w/o disk and path) and its 'File description' property value.
JIRA: CORE-5691 JIRA: CORE-5691
FBTEST: bugs.core_5691 FBTEST: bugs.core_5691
NOTES:
[29.11.2023] pzotov
Checked on 6.0.0.157, 5.0.0.1280, 4.0.5.3031
""" """
from pathlib import Path
import subprocess
import time
import pytest import pytest
from firebird.qa import * from firebird.qa import *
db = db_factory() db = db_factory()
act = python_act('db', substitutions=[('[ \\t]+', ' ')]) act = python_act('db', substitutions=[ ('[ \\t]+', ' '), ('\\(?\\d+([ ]|-)bit\\)?', '') ])
expected_stdout = """ tmp_vbs = temp_file('tmp_5691.vbs')
'fb_lock_print.exe' file description: firebird lock print tool (64-bit) tmp_log = temp_file('tmp_5691.log')
'fbclient.dll' file description: firebird client library (64-bit)
'fbguard.exe' file description: firebird guardian (64-bit)
'fbsvcmgr.exe' file description: firebird services management tool (64-bit)
'fbtracemgr.exe' file description: firebird trace management tool (64-bit)
'firebird.exe' file description: firebird server executable (64-bit)
'gbak.exe' file description: firebird gbak tool (64-bit)
'gfix.exe' file description: firebird gfix tool (64-bit)
'gstat.exe' file description: firebird gstat tool (64-bit)
'isql.exe' file description: firebird interactive query tool (64-bit)
'nbackup.exe' file description: firebird physical backup management tool (64-bit)
'chacha.dll' file description: firebird wire encryption plugin using chacha cypher (64-bit)
'engine13.dll' file description: firebird engine plugin (64-bit)
'fbtrace.dll' file description: firebird trace plugin (64-bit)
'legacy_auth.dll' file description: firebird legacy auth plugin (64-bit)
'legacy_usermanager.dll' file description: firebird legacy user manager plugin (64-bit)
'srp.dll' file description: firebird srp user manager plugin (64-bit)
'udr_engine.dll' file description: firebird user defined routines engine (64-bit)
"""
@pytest.mark.skip('FIXME: Not IMPLEMENTED')
@pytest.mark.version('>=4.0') @pytest.mark.version('>=4.0')
@pytest.mark.platform('Windows') @pytest.mark.platform('Windows')
def test_1(act: Action): def test_1(act: Action, tmp_vbs: Path, tmp_log: Path, capsys):
pytest.fail("Not IMPLEMENTED")
# test_script_1 # Get default value for 'Providers' parameter ("Remote,Engine13,Loopback"),
#--- # split it onto words and obtain name of 'engineNN':
# \\ engine_version = 'UNDEFINED'
# import os with act.db.connect() as con:
# import subprocess cur = con.cursor()
# from fdb import services # Remote, Engine13, Loopback
# cur.execute("select rdb$config_default from rdb$config where upper(rdb$config_name) = upper('Providers')")
# os.environ["ISC_USER"] = user_name for r in cur:
# os.environ["ISC_PASSWORD"] = user_password engine_version = [ p.lower().strip() for p in r[0].split(',') if p.lower().strip().startswith('engine'.lower()) ][0]
#
# #-------------------------------------------- assert 'engine'.lower() in engine_version
# def cleanup( f_names_list ):
# global os vbs_source = """
# for i in range(len( f_names_list )): Option Explicit
# if os.path.isfile( f_names_list[i]):
# os.remove( f_names_list[i] ) if wscript.arguments.count = 0 then
# #-------------------------------------------- wscript.echo "Missed fully qualified file name, i.e.: drive + path + file_name"
# wscript.quit
# fb_home = services.connect(host='localhost', user= user_name, password= user_password).get_home_directory() end if
# db_conn.close()
# dim fullname
# dim getDetails
# vbs_cmd = open( os.path.join(context['temp_directory'],'tmp_5691_get_file_descr.vbs'), 'w', buffering = 0)
# fullname = wscript.arguments(0)
# vbs_source = \\
# r''' rem https://www.tek-tips.com/viewthread.cfm?qid=1402419
# Option Explicit
# getDetails = GetFileDetails( fullName )
# if wscript.arguments.count = 0 then
# wscript.echo "Missed fully qualified file name, i.e.: drive + path + file_name"
# wscript.quit function GetFileDetails(fullName)
# end if
# on error resume next
# dim fullname
# dim getDetails dim fso
# dim objFile
# fullname = wscript.arguments(0)
# set fso = CreateObject("Scripting.FileSystemObject")
# rem https://www.tek-tips.com/viewthread.cfm?qid=1402419 set objFile = fso.GetFile(fullName)
#
# getDetails = GetFileDetails( fullName ) if not fso.FileExists(fullName) Then
# wscript.echo "File '" & fullName & "' does not exist."
# wscript.Quit
# function GetFileDetails(fullName) end if
#
# on error resume next dim fileName
# dim folderName
# dim fso
# dim objFile fileName = objFile.Name
# folderName = objFile.Path
# set fso = CreateObject("Scripting.FileSystemObject") folderName = Left(folderName, Len(folderName)-Len(fileName))
# set objFile = fso.GetFile(fullName)
# set objFile = Nothing
# if not fso.FileExists(fullName) Then set fso = Nothing
# wscript.echo "File '" & fullName & "' does not exist."
# wscript.Quit dim objShell
# end if dim objFolder
#
# dim fileName rem https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/bb776890(v=vs.85)
# dim folderName rem The Windows Shell provides a powerful set of automation objects <...>
# rem You can use these objects to access <...> the file system, launch programs, and change system settings.
# fileName = objFile.Name
# folderName = objFile.Path set objShell = CreateObject("Shell.Application")
# folderName = Left(folderName, Len(folderName)-Len(fileName)) set objFolder = objShell.NameSpace(folderName)
#
# set objFile = Nothing dim i
# set fso = Nothing dim fdescr_idx
# dim propertyName
# dim objShell
# dim objFolder i = 0
# fdescr_idx = 0
# rem https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/bb776890(v=vs.85) do
# rem The Windows Shell provides a powerful set of automation objects <...> propertyName = vbNullString
# rem You can use these objects to access <...> the file system, launch programs, and change system settings. rem https://docs.microsoft.com/en-us/windows/win32/shell/folder-getdetailsof
# rem retrieves details about an item in a folder. for example, its size, type, or the time of its last modification.
# set objShell = CreateObject("Shell.Application") propertyName = objFolder.GetDetailsOf(objFolder.Items, i)
# set objFolder = objShell.NameSpace(folderName) if LCase(propertyName) = LCase("file description") then
# fdescr_idx = i
# dim i exit do
# dim fdescr_idx end if
# dim propertyName
# if propertyName = vbNullString then
# i = 0 exit do
# fdescr_idx = 0 end if
# do i = i + 1
# propertyName = vbNullString loop
# rem https://docs.microsoft.com/en-us/windows/win32/shell/folder-getdetailsof propertyName = Nothing
# rem retrieves details about an item in a folder. for example, its size, type, or the time of its last modification. rem wscript.echo "fdescr_idx=",fdescr_idx
# propertyName = objFolder.GetDetailsOf(objFolder.Items, i)
# if LCase(propertyName) = LCase("file description") then dim objFolderItem
# fdescr_idx = i set objFolderItem = objFolder.ParseName(fileName)
# exit do
# end if if (not objFolderItem Is Nothing) then
# dim attribName
# if propertyName = vbNullString then dim objInfo
# exit do attribName = objFolder.GetDetailsOf(objFolder.Items, fdescr_idx)
# end if objInfo = objFolder.GetDetailsOf(objFolderItem, fdescr_idx)
# i = i + 1
# loop wscript.echo "'" & fileName & "' " & LCase(attribName) & ":", LCase(objInfo)
# propertyName = Nothing
# rem wscript.echo "fdescr_idx=",fdescr_idx attribName = Nothing
# objInfo = Nothing
# dim objFolderItem end if
# set objFolderItem = objFolder.ParseName(fileName)
# set objFolderItem = Nothing
# if (not objFolderItem Is Nothing) then set objFolder = Nothing
# dim attribName set objShell = Nothing
# dim objInfo end function
# attribName = objFolder.GetDetailsOf(objFolder.Items, fdescr_idx) """
# objInfo = objFolder.GetDetailsOf(objFolderItem, fdescr_idx)
# tmp_vbs.write_text(vbs_source)
# wscript.echo "'" & fileName & "' " & LCase(attribName) & ":", LCase(objInfo)
#
# attribName = Nothing f_list = ( 'fbclient.dll',
# objInfo = Nothing 'gbak.exe',
# end if 'gfix.exe',
# 'gstat.exe',
# set objFolderItem = Nothing 'fbguard.exe',
# set objFolder = Nothing 'isql.exe',
# set objShell = Nothing 'fb_lock_print.exe',
# end function 'firebird.exe',
# ''' 'nbackup.exe',
# 'fbtracemgr.exe',
# vbs_cmd.write(vbs_source) 'fbsvcmgr.exe',
# vbs_cmd.close() f'plugins/{engine_version}.dll',
# 'plugins/legacy_auth.dll',
# vbs_log = open( os.path.join(context['temp_directory'],'tmp_5691_get_file_descr.log'), 'w', buffering = 0) 'plugins/legacy_usermanager.dll',
# vbs_err = open( os.path.join(context['temp_directory'],'tmp_5691_get_file_descr.err'), 'w', buffering = 0) 'plugins/srp.dll',
# 'plugins/udr_engine.dll',
# f_list = ( 'fbclient.dll', 'plugins/chacha.dll',
# 'gbak.exe', 'plugins/fbtrace.dll',
# 'gfix.exe', )
# 'gstat.exe',
# 'fbguard.exe',
# 'isql.exe', #for x in sorted(f_list):
# 'fb_lock_print.exe', # print(act.vars['bin-dir'] / x)
# 'firebird.exe',
# 'nbackup.exe',
# 'fbtracemgr.exe', with open(tmp_log,'w') as vbs_log:
# 'fbsvcmgr.exe', for x in sorted(f_list):
# r'plugins\\engine13.dll', subprocess.call( [ 'cscript', '//nologo', str(tmp_vbs), act.vars['bin-dir'] / x ], stdout = vbs_log, stderr = subprocess.STDOUT )
# r'plugins\\legacy_auth.dll',
# r'plugins\\legacy_usermanager.dll',
# r'plugins\\srp.dll', with open( tmp_log,'r') as f:
# r'plugins\\udr_engine.dll', for line in f:
# r'plugins\\chacha.dll', print( line.lower() )
# r'plugins\\\\fbtrace.dll',
# ) expected_stdout = f"""
# for x in sorted(f_list): 'fb_lock_print.exe' file description: firebird lock print tool
# subprocess.call( [ 'cscript', '//nologo', vbs_cmd.name, ''.join( (fb_home, x) ) ], stdout = vbs_log, stderr = vbs_err ) 'fbclient.dll' file description: firebird client library
# 'fbguard.exe' file description: firebird guardian
# vbs_log.close() 'fbsvcmgr.exe' file description: firebird services management tool
# vbs_err.close() 'fbtracemgr.exe' file description: firebird trace management tool
# 'firebird.exe' file description: firebird server executable
# with open( vbs_err.name,'r') as f: 'gbak.exe' file description: firebird gbak tool
# for line in f: 'gfix.exe' file description: firebird gfix tool
# print("Unexpected STDERR, file "+vbs_err.name+": " + line) 'gstat.exe' file description: firebird gstat tool
# 'isql.exe' file description: firebird interactive query tool
# with open( vbs_log.name,'r') as f: 'nbackup.exe' file description: firebird physical backup management tool
# for line in f: 'chacha.dll' file description: firebird wire encryption plugin using chacha cypher
# print( line.lower() ) '{engine_version}.dll' file description: firebird engine plugin
# 'fbtrace.dll' file description: firebird trace plugin
# os.remove( vbs_log.name ) 'legacy_auth.dll' file description: firebird legacy auth plugin
# os.remove( vbs_err.name ) 'legacy_usermanager.dll' file description: firebird legacy user manager plugin
# os.remove( vbs_cmd.name ) 'srp.dll' file description: firebird srp user manager plugin
# 'udr_engine.dll' file description: firebird user defined routines engine
# """
#---
act.expected_stdout = expected_stdout
act.stdout = capsys.readouterr().out
assert act.clean_stdout == act.clean_expected_stdout