mirror of
https://github.com/reactos/ahk_tests.git
synced 2025-02-06 03:37:41 +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
|
Process, Close, %NameExt% ; Terminate external app, because we don't want it running
|
||||||
Sleep, 1000
|
Sleep, 1000
|
||||||
RunApplication(szDocument)
|
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
|
Sleep, 1000
|
||||||
WinMenuSelectItem, OllyDbg - %NameExt%, , Debug, Run
|
WinMenuSelectItem, OllyDbg - %NameExt%, , Debug, Run
|
||||||
if not ErrorLevel
|
if ErrorLevel
|
||||||
|
TestsFailed("Unable to hit 'Debug -> Run' in 'OllyDbg - " NameExt "' window.")
|
||||||
|
else
|
||||||
{
|
{
|
||||||
WinWaitActive, Calculator,,10
|
WinWaitActive, Calculator,,10
|
||||||
if not ErrorLevel
|
if ErrorLevel
|
||||||
|
TestsFailed("'Calculator' window failed to appear.")
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Sleep, 2000
|
Sleep, 2000
|
||||||
WinClose, Calculator
|
WinClose, Calculator
|
||||||
WinWaitClose, Calculator,, 5
|
WinWaitClose, Calculator,, 5
|
||||||
if not ErrorLevel
|
if ErrorLevel
|
||||||
|
TestsFailed("'Calculator' window failed to close.")
|
||||||
|
else
|
||||||
{
|
{
|
||||||
WinWaitActive, OllyDbg - %NameExt%,, 7
|
WinWaitActive, OllyDbg - %NameExt%,, 7
|
||||||
if not ErrorLevel
|
if ErrorLevel
|
||||||
|
TestsFailed("Window 'OllyDbg - " NameExt "' did not became active after closing 'Calculator' window.")
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Sleep, 1000
|
Sleep, 1000
|
||||||
WinClose, OllyDbg - %NameExt%
|
WinClose, OllyDbg - %NameExt%
|
||||||
WinWaitClose, OllyDbg - %NameExt%,,7
|
WinWaitClose, OllyDbg - %NameExt%,,7
|
||||||
if not ErrorLevel
|
if ErrorLevel
|
||||||
TestsOK("'" NameExt "' was opened via command line, ran it via 'Debug -> Run', closed its window and closed OllyDbg successfully.")
|
|
||||||
else
|
|
||||||
TestsFailed("'OllyDbg - " NameExt "' window failed to close.")
|
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
|
ModuleExe = %A_WorkingDir%\Apps\OllyDbg 1.10 Setup.exe
|
||||||
bContinue := false
|
|
||||||
TestName = 1.install
|
TestName = 1.install
|
||||||
|
|
||||||
TestsFailed := 0
|
|
||||||
TestsOK := 0
|
|
||||||
TestsTotal := 0
|
|
||||||
|
|
||||||
; Test if Setup file exists, if so, delete installed files, and run Setup
|
; Test if Setup file exists, if so, delete installed files, and run Setup
|
||||||
IfExist, %ModuleExe%
|
TestsTotal++
|
||||||
{
|
IfNotExist, %ModuleExe%
|
||||||
Process, Close, OLLYDBG.exe
|
TestsFailed("Can NOT find '" ModuleExe "'")
|
||||||
; 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%
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OutputDebug, %TestName%:%A_LineNumber%: Test failed: '%ModuleExe%' not found.`n
|
Process, Close, OLLYDBG.exe
|
||||||
bContinue := false
|
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
|
if bContinue
|
||||||
{
|
{
|
||||||
WinWaitActive, 7-Zip self-extracting archive, Extract, 15
|
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
|
Sleep, 250
|
||||||
ControlSetText, Edit1, %A_ProgramFiles%\OllyDbg, 7-Zip self-extracting archive, Extract ; Path
|
ControlSetText, Edit1, %A_ProgramFiles%\OllyDbg, 7-Zip self-extracting archive, Extract ; Path
|
||||||
if not ErrorLevel
|
if 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
|
|
||||||
TestsFailed("Unable to change 'Edit1' control text to '" A_ProgramFiles "\OllyDbg'.")
|
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++
|
TestsTotal++
|
||||||
if bContinue
|
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
|
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
|
OutputDebug, OK: %TestName%:%A_LineNumber%: 'Extracting' window appeared, waiting for it to close.`n
|
||||||
WinWaitClose, Extracting, Cancel, 15
|
WinWaitClose, Extracting, Cancel, 15
|
||||||
if not ErrorLevel
|
if ErrorLevel
|
||||||
TestsOK("'Extracting' window appeared and went away.")
|
TestsFailed("'Extracting' window failed to close.")
|
||||||
else
|
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
|
if bContinue
|
||||||
{
|
{
|
||||||
Sleep, 2000
|
Sleep, 2000
|
||||||
ProgramExe = %A_ProgramFiles%\OllyDbg\OLLYDBG.EXE
|
IfExist, %InstallLocation%\OLLYDBG.exe
|
||||||
IfExist, %ProgramExe%
|
TestsOK("The application has been installed, because '" InstallLocation "\OLLYDBG.exe' was found.")
|
||||||
TestsOK("The application has been installed, because '" ProgramExe "' was found.")
|
|
||||||
else
|
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
|
* 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
|
TestName = prepare
|
||||||
|
|
||||||
ModuleExe = %A_ProgramFiles%\OllyDbg\OLLYDBG.EXE
|
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
|
; Test if can start application
|
||||||
RunApplication(PathToFile)
|
RunApplication(PathToFile)
|
||||||
@ -35,74 +57,65 @@ RunApplication(PathToFile)
|
|||||||
global ModuleExe
|
global ModuleExe
|
||||||
global TestName
|
global TestName
|
||||||
global bContinue
|
global bContinue
|
||||||
|
global TestsTotal
|
||||||
|
global OllyDbgDir
|
||||||
|
global ProcessExe
|
||||||
|
|
||||||
IfExist, %ModuleExe%
|
TestsTotal++
|
||||||
|
IfNotExist, %ModuleExe%
|
||||||
|
TestsFailed("Can NOT find '" ModuleExe "'.")
|
||||||
|
else
|
||||||
{
|
{
|
||||||
; Delete previously saved settings
|
FileAppend, [Settings]`nCheck DLL versions=0`n, %OllyDbgDir%\ollydbg.ini
|
||||||
SplitPath, ModuleExe,, OllyDbgDir
|
if ErrorLevel
|
||||||
FileDelete, %OllyDbgDir%\ollydbg.ini
|
TestsFailed("Unable to create '" OllyDbgDir "\ollydbg.ini'.")
|
||||||
FileDelete, %OllyDbgDir%\*.udd
|
else
|
||||||
FileDelete, %OllyDbgDir%\*.bak
|
|
||||||
Sleep, 1000
|
|
||||||
|
|
||||||
IfNotExist, %OllyDbgDir%\ollydbg.ini
|
|
||||||
{
|
{
|
||||||
FileAppend, [Settings]`nCheck DLL versions=0`n, %OllyDbgDir%\ollydbg.ini
|
Sleep, 1000
|
||||||
if not ErrorLevel
|
if PathToFile =
|
||||||
{
|
{
|
||||||
if PathToFile =
|
Run, %ModuleExe%,, Max
|
||||||
|
WinWaitActive, OllyDbg,, 10
|
||||||
|
if ErrorLevel
|
||||||
{
|
{
|
||||||
Run, %ModuleExe%,, Max
|
Process, Exist, %ProcessExe%
|
||||||
Sleep, 1000
|
NewPID = %ErrorLevel% ; Save the value immediately since ErrorLevel is often changed.
|
||||||
WinWaitActive, OllyDbg,, 10
|
if NewPID = 0
|
||||||
if not ErrorLevel
|
TestsFailed("Window 'OllyDbg' failed to appear. No '" ProcessExe "' process detected.")
|
||||||
{
|
|
||||||
bContinue := true
|
|
||||||
Sleep, 1000
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
TestsFailed("Window 'OllyDbg' failed to appear. '" ProcessExe "' process detected.")
|
||||||
WinGetTitle, title, A
|
|
||||||
OutputDebug, %TestName%:%A_LineNumber%: Test failed: Window 'OllyDbg' failed to appear. Active window caption: '%title%'`n
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IfExist, %PathToFile%
|
TestsOK("")
|
||||||
{
|
Sleep, 1000
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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
|
#Include ..\..\helper_functions.ahk
|
||||||
|
InitalizeCounters()
|
||||||
|
|
||||||
|
|
||||||
if 1 = --list
|
|
||||||
{
|
|
||||||
params =
|
params =
|
||||||
(
|
(
|
||||||
|
|
||||||
@ -29,35 +27,23 @@ params =
|
|||||||
2.debug_run
|
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
|
else
|
||||||
OutputDebug, Bad parameters: '%1%'!`r`n
|
|
||||||
}
|
|
||||||
|
|
||||||
if 1 != --list
|
|
||||||
{
|
|
||||||
if not bContinue
|
|
||||||
{
|
{
|
||||||
SplitPath, ModuleExe, fName ; Extract filename from given path
|
#include prepare.ahk
|
||||||
WindowCleanUp(fName)
|
|
||||||
}
|
|
||||||
|
|
||||||
TestsSkipped := TestsTotal - TestsOK - TestsFailed
|
if 1 = 2.debug_run
|
||||||
TestsExecuted := TestsOK + TestsFailed
|
{
|
||||||
if (TestsSkipped < 0 or TestsExecuted < 0)
|
#include debug_run.ahk
|
||||||
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
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ShowTestResults()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user