public ArrayList<SPReport> launchSecurityTestJob() throws Exception { EmulatorManager emManager = new EmulatorManager( mSgdEnvironnement.getAdb(), null, EmulatorManager.GET_AVAILABLE_EMULATEUR_LIST, null); for (String emulator : emManager.getList_Available_Emulator()) { if (ConfigApp.DEBUG) { System.out.println("emulator" + emulator); } mSgdEnvironnement.setDevice(emulator); if (!ConfigApp.ISTEST) { mSgdEnvironnement.installSga(); mSgdEnvironnement.instrument_with_Emma_and_install(); } } mSgdEnvironnement.setDevice(null); numberOfThread = mSgdEnvironnement.getThread_number(); tm = new TaskManagerRunnable<INJTestJob>( get_S_test_Jobs(), numberOfThread, new TaskComparator<INJTestJob>(), mSgdEnvironnement.getAdb()); Long initTime = System.currentTimeMillis(); tm.execute(); int n = 1; boolean taskState = false; do { taskState = ((TaskManagerRunnable<INJTestJob>) tm).isAllResultReceived(); try { Thread.sleep(5000); n = n + 5; } catch (InterruptedException e) { e.printStackTrace(); } if (Utils.limit_time_isReached(initTime, MAX_TIME)) { System.out.println("Time " + MAX_TIME + " seconds is reached"); tm.stop(); break; } if ((verdict.size() == tasks.size())) { break; } } while (!taskState); System.out.println("Injection Test, finished after" + n + " seconds"); System.out.println("Waiting for the end of all jobs"); do { taskState = ((TaskManagerRunnable<INJTestJob>) tm).isTerminated(); try { Thread.sleep(1000); n = n + 1; System.out.print("."); } catch (InterruptedException e) { e.printStackTrace(); } } while (!taskState); return verdict; }
protected void checkJobStopCondition() { if (ConfigApp.DEBUG) { System.out.println("checkJobStopCondition"); System.out.println("tasks.size() :" + tasks.size()); System.out.println("verdict.size() :" + verdict.size()); } if (tasks.size() == verdict.size()) { tm.stop(); } }