Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.4 KiB

  1. Include('types.js');
  2. Include('utils.js');
  3. var g_fMsg = false;
  4. function pingtest_js::ScriptMain()
  5. {
  6. var nEvent;
  7. var nCount = 0;
  8. var strPing = ScriptParam.split(',')[0];
  9. var strWait = ScriptParam.split(',')[1];
  10. JSignalThreadSync('pingtestThreadReady');
  11. do
  12. {
  13. nEvent = JWaitForMultipleSyncs('pingtestThreadExit,' + strPing, 0, 0);
  14. if (nEvent == 2)
  15. {
  16. ++nCount;
  17. JAssert(WaitForSync(strPing, 1) == 1);
  18. ResetSync(strPing);
  19. JAssert(WaitForSync(strPing, 1) == 0);
  20. JSignalThreadSync(strWait);
  21. }
  22. }
  23. while(nEvent != 1);
  24. LogMsg("pingtest exiting. Received " + nCount + " pings");
  25. }
  26. function JSignalThreadSync(strSigs)
  27. {
  28. if (g_fMsg)
  29. LogMsg("SIGNALLING " + strSigs);
  30. SignalThreadSync(strSigs);
  31. }
  32. function JWaitForMultipleSyncs(strSigs, fWaitAll, nTimeOut)
  33. {
  34. if (g_fMsg)
  35. LogMsg("WAITING " + strSigs);
  36. var nEvent = WaitForMultipleSyncs(strSigs, fWaitAll, nTimeOut);
  37. if (g_fMsg)
  38. {
  39. if (nEvent == 0)
  40. LogMsg("TIMEOUT");
  41. else
  42. LogMsg("RECEIVED " + strSigs.split(',')[nEvent - 1]);
  43. }
  44. return nEvent;
  45. }
  46. function JWaitForSync(strSigs, nTimeOut)
  47. {
  48. if (g_fMsg)
  49. return JWaitForMultipleSyncs(strSigs, false, nTimeOut);
  50. return WaitForSync(strSigs, nTimeOut);
  51. }