experimental afl driven ui testing
Change-Id: I1933951c52adc75ed36db2c083c232f29b6140d6
This commit is contained in:
@@ -494,6 +494,7 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier )
|
|||||||
// vcl/unx/generic/app/sm.cxx:
|
// vcl/unx/generic/app/sm.cxx:
|
||||||
oArg != "session=" &&
|
oArg != "session=" &&
|
||||||
#endif
|
#endif
|
||||||
|
oArg != "eventtesting" &&
|
||||||
//ignore additional legacy options that don't do anything anymore
|
//ignore additional legacy options that don't do anything anymore
|
||||||
oArg != "nocrashreport" &&
|
oArg != "nocrashreport" &&
|
||||||
m_unknown.isEmpty())
|
m_unknown.isEmpty())
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include "tools/debug.hxx"
|
#include "tools/debug.hxx"
|
||||||
#include "tools/solar.h"
|
#include "tools/solar.h"
|
||||||
#include "vcl/bitmapex.hxx"
|
#include "vcl/bitmapex.hxx"
|
||||||
|
#include "vcl/idle.hxx"
|
||||||
#include "vcl/dllapi.h"
|
#include "vcl/dllapi.h"
|
||||||
#include "vcl/keycod.hxx"
|
#include "vcl/keycod.hxx"
|
||||||
#include "vcl/svapp.hxx"
|
#include "vcl/svapp.hxx"
|
||||||
@@ -156,7 +157,12 @@ struct ImplSVAppData
|
|||||||
*/
|
*/
|
||||||
ImeStatusWindowMode meShowImeStatusWindow;
|
ImeStatusWindowMode meShowImeStatusWindow;
|
||||||
|
|
||||||
|
SvFileStream* mpEventTestInput;
|
||||||
|
Idle* mpEventTestingIdle;
|
||||||
|
int mnEventTestLimit;
|
||||||
|
|
||||||
DECL_STATIC_LINK_TYPED( ImplSVAppData, ImplQuitMsg, void*, void );
|
DECL_STATIC_LINK_TYPED( ImplSVAppData, ImplQuitMsg, void*, void );
|
||||||
|
DECL_LINK_TYPED(VclEventTestingHdl, Idle*, void);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ImplSVGDIData
|
struct ImplSVGDIData
|
||||||
|
@@ -327,11 +327,76 @@ const vcl::KeyCode* Application::GetReservedKeyCode( sal_uLong i )
|
|||||||
return &ImplReservedKeys::get()->first[i].mKeyCode;
|
return &ImplReservedKeys::get()->first[i].mKeyCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
bool InjectKeyEvent(SvStream& rStream)
|
||||||
|
{
|
||||||
|
VclPtr<vcl::Window> xWin(Application::GetActiveTopWindow());
|
||||||
|
if (!xWin)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
SalKeyEvent aKeyEvent;
|
||||||
|
rStream.ReadUInt64(aKeyEvent.mnTime);
|
||||||
|
rStream.ReadUInt16(aKeyEvent.mnCode);
|
||||||
|
rStream.ReadUInt16(aKeyEvent.mnCharCode);
|
||||||
|
rStream.ReadUInt16(aKeyEvent.mnRepeat);
|
||||||
|
if (!rStream.good())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ImplWindowFrameProc(xWin.get(), NULL, SALEVENT_KEYINPUT, &aKeyEvent);
|
||||||
|
ImplWindowFrameProc(xWin.get(), NULL, SALEVENT_KEYUP, &aKeyEvent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IMPL_LINK_NOARG_TYPED(ImplSVAppData, VclEventTestingHdl, Idle *, void)
|
||||||
|
{
|
||||||
|
SAL_INFO("vcl.eventtesting", "EventTestLimit is " << mnEventTestLimit);
|
||||||
|
if (mnEventTestLimit == 0)
|
||||||
|
{
|
||||||
|
delete mpEventTestInput;
|
||||||
|
delete mpEventTestingIdle;
|
||||||
|
SAL_INFO("vcl.eventtesting", "Event Limit reached, exiting" << mnEventTestLimit);
|
||||||
|
Application::Quit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Scheduler::ProcessTaskScheduling(true);
|
||||||
|
if (InjectKeyEvent(*mpEventTestInput))
|
||||||
|
--mnEventTestLimit;
|
||||||
|
if (!mpEventTestInput->good())
|
||||||
|
{
|
||||||
|
delete mpEventTestInput;
|
||||||
|
delete mpEventTestingIdle;
|
||||||
|
SAL_INFO("vcl.eventtesting", "Event Input exhausted, exiting" << mnEventTestLimit);
|
||||||
|
Application::Quit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Scheduler::ProcessTaskScheduling(true);
|
||||||
|
mpEventTestingIdle->Start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Application::Execute()
|
void Application::Execute()
|
||||||
{
|
{
|
||||||
ImplSVData* pSVData = ImplGetSVData();
|
ImplSVData* pSVData = ImplGetSVData();
|
||||||
pSVData->maAppData.mbInAppExecute = true;
|
pSVData->maAppData.mbInAppExecute = true;
|
||||||
|
|
||||||
|
sal_uInt16 n = GetCommandLineParamCount();
|
||||||
|
for (sal_uInt16 i = 0; i != n; ++i)
|
||||||
|
{
|
||||||
|
if (GetCommandLineParam(i) == "--eventtesting")
|
||||||
|
{
|
||||||
|
pSVData->maAppData.mnEventTestLimit = 10;
|
||||||
|
pSVData->maAppData.mpEventTestingIdle = new Idle("eventtesting");
|
||||||
|
pSVData->maAppData.mpEventTestingIdle->SetIdleHdl(LINK(&(pSVData->maAppData), ImplSVAppData, VclEventTestingHdl));
|
||||||
|
pSVData->maAppData.mpEventTestingIdle->SetPriority(SchedulerPriority::LOWEST);
|
||||||
|
pSVData->maAppData.mpEventTestInput = new SvFileStream("eventtesting", StreamMode::READ);
|
||||||
|
pSVData->maAppData.mpEventTestingIdle->Start();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while ( !pSVData->maAppData.mbAppQuit )
|
while ( !pSVData->maAppData.mbAppQuit )
|
||||||
Application::Yield();
|
Application::Yield();
|
||||||
|
|
||||||
|
13
vcl/workben/README.eventtesting
Normal file
13
vcl/workben/README.eventtesting
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
Notes on experimental afl driven ui fuzzing
|
||||||
|
|
||||||
|
only keyboard events for now
|
||||||
|
|
||||||
|
vcl/workben/eventtesting is just serialized "helloworld" keystrokes to get
|
||||||
|
things started
|
||||||
|
|
||||||
|
currently an arbitrary limit of 10 keystrokes before application quits in
|
||||||
|
order to initially explore that shallow space
|
||||||
|
|
||||||
|
Xnest :1
|
||||||
|
cp vcl/workben/eventtesting .
|
||||||
|
afl-fuzz -f eventtesting -t 10000 -i ~/fuzz/in.vcl -o ~/fuzz/out.vcl -d -T vcl -m 50000000 instdir/program/soffice.bin --nologo --writer --eventtesting --norestore --display :1
|
BIN
vcl/workben/eventtesting
Normal file
BIN
vcl/workben/eventtesting
Normal file
Binary file not shown.
Reference in New Issue
Block a user