Closed Bug 782338 Opened 12 years ago Closed 12 years ago

[B2G] Intermittent test_mobile_voice_state.js | Emulator callback still pending when finish() called

Categories

(Core :: DOM: Device Interfaces, defect)

All
Gonk (Firefox OS)
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla17

People

(Reporter: jgriffin, Assigned: vicamo)

References

Details

(Keywords: intermittent-failure)

Attachments

(1 file, 2 obsolete files)

On the B2G CI, test_mobile_voice_state.js sometimes fails with the error:

test_mobile_voice_state.js
TEST-UNEXPECTED-FAIL | Traceback (most recent call last):
File "/data/jenkins/workspace/webapi-marionette-test/testing/marionette/client/marionette/marionette_test.py", line 176, in runTest
results = self.marionette.execute_js_script(js, args, special_powers=True)
File "/data/jenkins/workspace/webapi-marionette-test/testing/marionette/client/marionette/marionette.py", line 369, in execute_js_script
specialPowers=special_powers)
File "/data/jenkins/workspace/webapi-marionette-test/testing/marionette/client/marionette/marionette.py", line 171, in _send_message
self._handle_error(response)
File "/data/jenkins/workspace/webapi-marionette-test/testing/marionette/client/marionette/marionette.py", line 228, in _handle_error
raise MarionetteException(message=message, status=status, stacktrace=stacktrace)
MarionetteException: Emulator callback still pending when finish() called

Seems like a possible timing issue.
Assignee: nobody → vyang
Status: NEW → ASSIGNED
Attached patch V1 (obsolete) — Splinter Review
Attachment #651984 - Flags: review?(marshall)
Blocks: 780558
Comment on attachment 651984 [details] [diff] [review]
V1

Review of attachment 651984 [details] [diff] [review]:
-----------------------------------------------------------------

r+ since this will probably work -- but it feels a bit like a hack. See comments below.

::: dom/network/tests/marionette/test_mobile_voice_state.js
@@ +110,5 @@
>  function cleanUp() {
>    SpecialPowers.clearUserPref(WHITELIST_PREF);
> +
> +  // For 'Emulator callback still pending when finish() called'
> +  setTimeout(finish, 1000);

It would be better if we provided runEmulatorCmd a callback, and wait for that callback before moving on to the next test function (or in this case, cleanUp()). I currently do this in my voicemail tests here:

https://mxr.mozilla.org/mozilla-central/source/dom/telephony/test/marionette/test_voicemail_statuschanged.js#12
Attachment #651984 - Flags: review?(marshall) → review+
Comment on attachment 651984 [details] [diff] [review]
V1

Review of attachment 651984 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/network/tests/marionette/test_mobile_voice_state.js
@@ +110,5 @@
>  function cleanUp() {
>    SpecialPowers.clearUserPref(WHITELIST_PREF);
> +
> +  // For 'Emulator callback still pending when finish() called'
> +  setTimeout(finish, 1000);

I agree with Marshall. I suggest something like this:

  let emulatorCmdPending = false;
  function setEmulatorVoiceState(state) {
    emulatorCmdPending = true;
    runEmulatorCmd("gsm voice " + state, function (result) {
      emulatorCmdPending = false;
      is(result[0], "OK");
    });
  }

and then do a tighter wait loop, e.g.:

  function cleanUp() {
    if (emulatorCmdPending) {
      setTimeout(cleanUp, 100);
      return;
    }
    SpecialPowers.clearUserPref(WHITELIST_PREF);
    finish();
  }
Attachment #651984 - Flags: review-
Attached patch V2 (obsolete) — Splinter Review
* rebase to include changes made in bug 780558
* address review comment #2 and #3. Thank you both ;)
Attachment #652652 - Flags: review?(philipp)
Attachment #652652 - Flags: review?(marshall)
Attachment #651984 - Attachment is obsolete: true
Comment on attachment 652652 [details] [diff] [review]
V2

Review of attachment 652652 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good
Attachment #652652 - Flags: review?(marshall) → review+
Attachment #652652 - Flags: review?(philipp) → review+
Attached patch V3Splinter Review
rebase only
Attachment #652652 - Attachment is obsolete: true
https://hg.mozilla.org/mozilla-central/rev/785cd1cb9446
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla17
Whiteboard: [orange]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: