flip_test: factor out the event loop/wait for event logic
flip_test: factor out the event loop/wait for event logic

Needed by an upcoming patch where we want to wait for an event without
starting a new round of test run.

No functional change.

Signed-off-by: Imre Deak <fbd5edba1988036c8923f0cca0cce6ac4811db29@intel.com>

dlespiau/checkmate-test-igt,ChrisCummins/intel-gpu-tools,tiagovignatti/intel-gpu-tools,ChrisCummins/intel-gpu-tools,erikarn/intel-gpu-tools,rib/intel-gpu-tools,mv0/intel-gpu-tools,ChrisCummins/intel-gpu-tools,dlespiau/checkmate-test-igt,chenxianqin/intel-gpu-tools,yipdw/intel-gpu-tools,yipdw/intel-gpu-tools,erikarn/intel-gpu-tools,tiagovignatti/intel-gpu-tools,rib/intel-gpu-tools,tiagovignatti/intel-gpu-tools,chenxianqin/intel-gpu-tools,dlespiau/intel-gpu-tools,chenxianqin/intel-gpu-tools,mv0/intel-gpu-tools,erikarn/intel-gpu-tools,mv0/intel-gpu-tools,dlespiau/intel-gpu-tools,ChrisCummins/intel-gpu-tools,rib/intel-gpu-tools,tiagovignatti/intel-gpu-tools,chenxianqin/intel-gpu-tools,yipdw/intel-gpu-tools,rib/intel-gpu-tools,dlespiau/intel-gpu-tools,erikarn/intel-gpu-tools,dlespiau/checkmate-test-igt,dlespiau/checkmate-test-igt,yipdw/intel-gpu-tools,mv0/intel-gpu-tools