mirror of
https://github.com/reactos/ahk_tests.git
synced 2024-11-23 11:39:42 +00:00
[AHK_OllyDbg_1.10]
Match new design, add few more checks. Both tests tested and works fine in win2k3 sp2. svn path=/trunk/ahk_tests/; revision=1620
This commit is contained in:
parent
ff68fa28ac
commit
87611c2dd3
@ -26,47 +26,47 @@ SplitPath, szDocument, NameExt
|
||||
Process, Close, %NameExt% ; Terminate external app, because we don't want it running
|
||||
Sleep, 1000
|
||||
RunApplication(szDocument)
|
||||
if bContinue
|
||||
if not bContinue
|
||||
TestsFailed("We failed somewhere in prepare.ahk.")
|
||||
else
|
||||
{
|
||||
IfWinActive, OllyDbg - %NameExt%
|
||||
IfWinNotActive, OllyDbg - %NameExt%
|
||||
TestsFailed("Window 'OllyDbg - " NameExt "' is not active.")
|
||||
else
|
||||
{
|
||||
Sleep, 1000
|
||||
WinMenuSelectItem, OllyDbg - %NameExt%, , Debug, Run
|
||||
if not ErrorLevel
|
||||
if ErrorLevel
|
||||
TestsFailed("Unable to hit 'Debug -> Run' in 'OllyDbg - " NameExt "' window.")
|
||||
else
|
||||
{
|
||||
WinWaitActive, Calculator,,10
|
||||
if not ErrorLevel
|
||||
if ErrorLevel
|
||||
TestsFailed("'Calculator' window failed to appear.")
|
||||
else
|
||||
{
|
||||
Sleep, 2000
|
||||
WinClose, Calculator
|
||||
WinWaitClose, Calculator,, 5
|
||||
if not ErrorLevel
|
||||
if ErrorLevel
|
||||
TestsFailed("'Calculator' window failed to close.")
|
||||
else
|
||||
{
|
||||
WinWaitActive, OllyDbg - %NameExt%,, 7
|
||||
if not ErrorLevel
|
||||
if ErrorLevel
|
||||
TestsFailed("Window 'OllyDbg - " NameExt "' did not became active after closing 'Calculator' window.")
|
||||
else
|
||||
{
|
||||
Sleep, 1000
|
||||
WinClose, OllyDbg - %NameExt%
|
||||
WinWaitClose, OllyDbg - %NameExt%,,7
|
||||
if not ErrorLevel
|
||||
TestsOK("'" NameExt "' was opened via command line, ran it via 'Debug -> Run', closed its window and closed OllyDbg successfully.")
|
||||
else
|
||||
if ErrorLevel
|
||||
TestsFailed("'OllyDbg - " NameExt "' window failed to close.")
|
||||
else
|
||||
TestsOK("'" NameExt "' was opened via command line, ran it via 'Debug -> Run', closed its window and closed OllyDbg successfully.")
|
||||
}
|
||||
else
|
||||
TestsFailed("Window 'OllyDbg - " NameExt "' did not became active after closing 'Calculator' window.")
|
||||
}
|
||||
else
|
||||
TestsFailed("'Calculator' window failed to close.")
|
||||
}
|
||||
else
|
||||
TestsFailed("'Calculator' window failed to appear.")
|
||||
}
|
||||
else
|
||||
TestsFailed("Unable to hit 'Debug -> Run' in 'OllyDbg - " NameExt "' window.")
|
||||
}
|
||||
else
|
||||
TestsFailed("Window 'OllyDbg - " NameExt "' is not active.")
|
||||
}
|
||||
}
|
||||
else
|
||||
TestsFailed("We failed somewhere in prepare.ahk.")
|
||||
|
@ -18,45 +18,35 @@
|
||||
*/
|
||||
|
||||
ModuleExe = %A_WorkingDir%\Apps\OllyDbg 1.10 Setup.exe
|
||||
bContinue := false
|
||||
TestName = 1.install
|
||||
|
||||
TestsFailed := 0
|
||||
TestsOK := 0
|
||||
TestsTotal := 0
|
||||
|
||||
; Test if Setup file exists, if so, delete installed files, and run Setup
|
||||
IfExist, %ModuleExe%
|
||||
{
|
||||
Process, Close, OLLYDBG.exe
|
||||
; Get rid of other versions
|
||||
IfExist, %A_ProgramFiles%\OllyDbg
|
||||
{
|
||||
FileRemoveDir, %A_ProgramFiles%\OllyDbg, 1
|
||||
if not ErrorLevel
|
||||
{
|
||||
bContinue := true
|
||||
}
|
||||
else
|
||||
{
|
||||
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Can NOT delete existing '%A_ProgramFiles%\OllyDbg'.`n
|
||||
bContinue := false
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bContinue := true
|
||||
}
|
||||
|
||||
if bContinue
|
||||
{
|
||||
Run %ModuleExe%
|
||||
}
|
||||
}
|
||||
TestsTotal++
|
||||
IfNotExist, %ModuleExe%
|
||||
TestsFailed("Can NOT find '" ModuleExe "'")
|
||||
else
|
||||
{
|
||||
OutputDebug, %TestName%:%A_LineNumber%: Test failed: '%ModuleExe%' not found.`n
|
||||
bContinue := false
|
||||
Process, Close, OLLYDBG.exe
|
||||
Process, WaitClose, OLLYDBG.exe, 4
|
||||
if ErrorLevel
|
||||
TestsFailed("Process 'OLLYDBG.exe' failed to close.")
|
||||
else
|
||||
{
|
||||
InstallLocation = %A_ProgramFiles%\OllyDbg
|
||||
IfNotExist, %InstallLocation%
|
||||
bContinue := true ; No previous versions detected.
|
||||
else
|
||||
{
|
||||
FileRemoveDir, %InstallLocation%, 1
|
||||
if ErrorLevel
|
||||
TestsFailed("Previous version detected and failed to delete '" InstallLocation "'. 'OLLYDBG.exe' process not detected.")
|
||||
else
|
||||
{
|
||||
TestsOK("Either there was no previous versions or we succeeded removing it using hardcoded path.")
|
||||
Run %ModuleExe%
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -65,42 +55,49 @@ TestsTotal++
|
||||
if bContinue
|
||||
{
|
||||
WinWaitActive, 7-Zip self-extracting archive, Extract, 15
|
||||
if not ErrorLevel
|
||||
if ErrorLevel
|
||||
TestsFailed("'7-Zip self-extracting archive' window with 'Extract' button failed to appear.")
|
||||
else
|
||||
{
|
||||
Sleep, 250
|
||||
ControlSetText, Edit1, %A_ProgramFiles%\OllyDbg, 7-Zip self-extracting archive, Extract ; Path
|
||||
if not ErrorLevel
|
||||
{
|
||||
ControlClick, Button2, 7-Zip self-extracting archive, Extract ; Hit 'Extract' button
|
||||
if not ErrorLevel
|
||||
TestsOK("'7-Zip self-extracting archive' window appeared and 'Extract' was clicked.")
|
||||
else
|
||||
TestsFailed("Unable to click 'Extract' in '7-Zip self-extracting archive' window.")
|
||||
}
|
||||
else
|
||||
if ErrorLevel
|
||||
TestsFailed("Unable to change 'Edit1' control text to '" A_ProgramFiles "\OllyDbg'.")
|
||||
else
|
||||
{
|
||||
Sleep, 700
|
||||
ControlClick, Button2, 7-Zip self-extracting archive, Extract ; Hit 'Extract' button
|
||||
if ErrorLevel
|
||||
TestsFailed("Unable to click 'Extract' in '7-Zip self-extracting archive' window.")
|
||||
else
|
||||
{
|
||||
WinWaitClose, 7-Zip self-extracting archive, Extract, 4
|
||||
if ErrorLevel
|
||||
TestsFailed("'7-Zip self-extracting archive' window failed to close despite 'Extract' button being clicked.")
|
||||
else
|
||||
TestsOK("'7-Zip self-extracting archive' window appeared, 'Extract' button clicked, window closed.")
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
TestsFailed("'7-Zip self-extracting archive' window with 'Extract' button failed to appear.")
|
||||
}
|
||||
|
||||
|
||||
TestsTotal++
|
||||
if bContinue
|
||||
{
|
||||
SetTitleMatchMode, 1
|
||||
SetTitleMatchMode, 2 ; A window's title can contain WinTitle anywhere inside it to be a match.
|
||||
WinWaitActive, Extracting, Cancel, 10 ; Wait 10 secs for window to appear
|
||||
if not ErrorLevel ; Window is found and it is active
|
||||
if ErrorLevel
|
||||
TestsFailed("'Extracting' window failed to appear.")
|
||||
else
|
||||
{
|
||||
OutputDebug, OK: %TestName%:%A_LineNumber%: 'Extracting' window appeared, waiting for it to close.`n
|
||||
WinWaitClose, Extracting, Cancel, 15
|
||||
if not ErrorLevel
|
||||
TestsOK("'Extracting' window appeared and went away.")
|
||||
if ErrorLevel
|
||||
TestsFailed("'Extracting' window failed to close.")
|
||||
else
|
||||
TestsFailed("'Extracting' window failed to dissapear.")
|
||||
TestsOK("'Extracting' window went away.")
|
||||
}
|
||||
else
|
||||
TestsFailed("'Extracting' window failed to appear.")
|
||||
}
|
||||
|
||||
|
||||
@ -109,9 +106,8 @@ TestsTotal++
|
||||
if bContinue
|
||||
{
|
||||
Sleep, 2000
|
||||
ProgramExe = %A_ProgramFiles%\OllyDbg\OLLYDBG.EXE
|
||||
IfExist, %ProgramExe%
|
||||
TestsOK("The application has been installed, because '" ProgramExe "' was found.")
|
||||
IfExist, %InstallLocation%\OLLYDBG.exe
|
||||
TestsOK("The application has been installed, because '" InstallLocation "\OLLYDBG.exe' was found.")
|
||||
else
|
||||
TestsFailed("Something went wrong, can't find '" ProgramExe "'.")
|
||||
TestsFailed("Something went wrong, can't find '" InstallLocation "\OLLYDBG.exe'.")
|
||||
}
|
||||
|
@ -17,17 +17,39 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
bContinue := false
|
||||
TestsTotal := 0
|
||||
TestsSkipped := 0
|
||||
TestsFailed := 0
|
||||
TestsOK := 0
|
||||
TestsExecuted := 0
|
||||
TestName = prepare
|
||||
|
||||
ModuleExe = %A_ProgramFiles%\OllyDbg\OLLYDBG.EXE
|
||||
Process, Close, OLLYDBG.EXE
|
||||
Sleep, 1000
|
||||
|
||||
|
||||
; Terminate application
|
||||
TestsTotal++
|
||||
SplitPath, ModuleExe, ProcessExe
|
||||
Process, Close, %ProcessExe%
|
||||
Process, WaitClose, %ProcessExe%, 4
|
||||
if ErrorLevel
|
||||
TestsFailed("Process '" ProcessExe "' failed to close.")
|
||||
else
|
||||
TestsOK("")
|
||||
|
||||
|
||||
; Delete previously saved settings
|
||||
TestsTotal++
|
||||
if bContinue
|
||||
{
|
||||
SplitPath, ModuleExe,, OllyDbgDir
|
||||
IfExist, %OllyDbgDir%\ollydbg.ini
|
||||
{
|
||||
FileDelete, %OllyDbgDir%\ollydbg.ini
|
||||
if ErrorLevel
|
||||
TestsFailed("Unable to delete '" OllyDbgDir "\ollydbg.ini'.")
|
||||
else
|
||||
TestsOK("")
|
||||
}
|
||||
FileDelete, %OllyDbgDir%\*.udd
|
||||
FileDelete, %OllyDbgDir%\*.bak
|
||||
Sleep, 500
|
||||
}
|
||||
|
||||
|
||||
; Test if can start application
|
||||
RunApplication(PathToFile)
|
||||
@ -35,74 +57,65 @@ RunApplication(PathToFile)
|
||||
global ModuleExe
|
||||
global TestName
|
||||
global bContinue
|
||||
global TestsTotal
|
||||
global OllyDbgDir
|
||||
global ProcessExe
|
||||
|
||||
IfExist, %ModuleExe%
|
||||
TestsTotal++
|
||||
IfNotExist, %ModuleExe%
|
||||
TestsFailed("Can NOT find '" ModuleExe "'.")
|
||||
else
|
||||
{
|
||||
; Delete previously saved settings
|
||||
SplitPath, ModuleExe,, OllyDbgDir
|
||||
FileDelete, %OllyDbgDir%\ollydbg.ini
|
||||
FileDelete, %OllyDbgDir%\*.udd
|
||||
FileDelete, %OllyDbgDir%\*.bak
|
||||
Sleep, 1000
|
||||
|
||||
IfNotExist, %OllyDbgDir%\ollydbg.ini
|
||||
FileAppend, [Settings]`nCheck DLL versions=0`n, %OllyDbgDir%\ollydbg.ini
|
||||
if ErrorLevel
|
||||
TestsFailed("Unable to create '" OllyDbgDir "\ollydbg.ini'.")
|
||||
else
|
||||
{
|
||||
FileAppend, [Settings]`nCheck DLL versions=0`n, %OllyDbgDir%\ollydbg.ini
|
||||
if not ErrorLevel
|
||||
Sleep, 1000
|
||||
if PathToFile =
|
||||
{
|
||||
if PathToFile =
|
||||
Run, %ModuleExe%,, Max
|
||||
WinWaitActive, OllyDbg,, 10
|
||||
if ErrorLevel
|
||||
{
|
||||
Run, %ModuleExe%,, Max
|
||||
Sleep, 1000
|
||||
WinWaitActive, OllyDbg,, 10
|
||||
if not ErrorLevel
|
||||
{
|
||||
bContinue := true
|
||||
Sleep, 1000
|
||||
}
|
||||
Process, Exist, %ProcessExe%
|
||||
NewPID = %ErrorLevel% ; Save the value immediately since ErrorLevel is often changed.
|
||||
if NewPID = 0
|
||||
TestsFailed("Window 'OllyDbg' failed to appear. No '" ProcessExe "' process detected.")
|
||||
else
|
||||
{
|
||||
WinGetTitle, title, A
|
||||
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Window 'OllyDbg' failed to appear. Active window caption: '%title%'`n
|
||||
}
|
||||
TestsFailed("Window 'OllyDbg' failed to appear. '" ProcessExe "' process detected.")
|
||||
}
|
||||
else
|
||||
{
|
||||
IfExist, %PathToFile%
|
||||
{
|
||||
Run, %ModuleExe% "%PathToFile%",, Max
|
||||
Sleep, 1000
|
||||
SplitPath, PathToFile, NameExt
|
||||
WinWaitActive, OllyDbg - %NameExt%,,10
|
||||
if not ErrorLevel
|
||||
{
|
||||
bContinue := true
|
||||
Sleep, 1000
|
||||
}
|
||||
else
|
||||
{
|
||||
WinGetTitle, title, A
|
||||
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Window 'OllyDbg - %NameExt%' failed to appear. Active window caption: '%title%'`n
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Can NOT find '%PathToFile%'.`n
|
||||
}
|
||||
TestsOK("")
|
||||
Sleep, 1000
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Unable to create '%OllyDbgDir%\ollydbg.ini'.`n
|
||||
IfNotExist, %PathToFile%
|
||||
TestsFailed("Can NOT find '" PathToFile "'.")
|
||||
else
|
||||
{
|
||||
Run, %ModuleExe% "%PathToFile%",, Max
|
||||
SplitPath, PathToFile, NameExt
|
||||
WinWaitActive, OllyDbg - %NameExt%,,10
|
||||
if ErrorLevel
|
||||
{
|
||||
Process, Exist, %ProcessExe%
|
||||
NewPID = %ErrorLevel% ; Save the value immediately since ErrorLevel is often changed.
|
||||
if NewPID = 0
|
||||
TestsFailed("Window 'OllyDbg - " NameExt "' failed to appear. No '" ProcessExe "' process detected.")
|
||||
else
|
||||
TestsFailed("Window 'OllyDbg - " NameExt "' failed to appear. '" ProcessExe "' process detected.")
|
||||
}
|
||||
else
|
||||
{
|
||||
TestsOK("")
|
||||
Sleep, 1000
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Unable to delete '%OllyDbgDir%\ollydbg.ini'.`n
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Can NOT find '%ModuleExe%'.`n
|
||||
}
|
||||
}
|
@ -18,10 +18,8 @@
|
||||
*/
|
||||
|
||||
#Include ..\..\helper_functions.ahk
|
||||
InitalizeCounters()
|
||||
|
||||
|
||||
if 1 = --list
|
||||
{
|
||||
params =
|
||||
(
|
||||
|
||||
@ -29,35 +27,23 @@ params =
|
||||
2.debug_run
|
||||
|
||||
)
|
||||
FileAppend, %params%, *
|
||||
}
|
||||
else if 1 = 1.install
|
||||
{
|
||||
#include install_test.ahk
|
||||
}
|
||||
else
|
||||
{
|
||||
#include prepare.ahk
|
||||
|
||||
if 1 = 2.debug_run
|
||||
if CheckParam()
|
||||
{
|
||||
; Those brackets are required!
|
||||
if 1 = 1.install
|
||||
{
|
||||
#include debug_run.ahk
|
||||
#include install_test.ahk
|
||||
}
|
||||
else
|
||||
OutputDebug, Bad parameters: '%1%'!`r`n
|
||||
}
|
||||
|
||||
if 1 != --list
|
||||
{
|
||||
if not bContinue
|
||||
else
|
||||
{
|
||||
SplitPath, ModuleExe, fName ; Extract filename from given path
|
||||
WindowCleanUp(fName)
|
||||
}
|
||||
#include prepare.ahk
|
||||
|
||||
TestsSkipped := TestsTotal - TestsOK - TestsFailed
|
||||
TestsExecuted := TestsOK + TestsFailed
|
||||
if (TestsSkipped < 0 or TestsExecuted < 0)
|
||||
OutputDebug, %TestName%: Check TestsTotal, TestsOK and TestsFailed, because results returns less than 0.`n
|
||||
OutputDebug, %TestName%: %TestsExecuted% tests executed (0 marked as todo, %TestsFailed% failures), %TestsSkipped% skipped.`n
|
||||
if 1 = 2.debug_run
|
||||
{
|
||||
#include debug_run.ahk
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ShowTestResults()
|
||||
|
Loading…
Reference in New Issue
Block a user