Bug 1055580 - Intermittent test_cache2-14b-concurent-readers-complete.js | 1 == 3 | 2 == 1 | 3 == 2. r=michal, a=test-only
authorHonza Bambas <honzab.moz@firemni.cz>
Wed, 19 Nov 2014 18:46:09 +0100
changeset 226134 5d29e9cd389e8e37312ad4e7be12f0d28751a04e
parent 226133 9fd2eb4765336a377798f9102ca9b421a8a3d1d5
child 226135 67a53bb6b0bd70219699129d40d1a4c9d7f016f5
push id4175
push userryanvm@gmail.com
push dateMon, 24 Nov 2014 17:08:09 +0000
treeherdermozilla-beta@e247a7f7c438 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmichal, test-only
bugs1055580
milestone34.0
Bug 1055580 - Intermittent test_cache2-14b-concurent-readers-complete.js | 1 == 3 | 2 == 1 | 3 == 2. r=michal, a=test-only
netwerk/test/unit/head_cache2.js
netwerk/test/unit/test_cache2-14b-concurent-readers-complete.js
--- a/netwerk/test/unit/head_cache2.js
+++ b/netwerk/test/unit/head_cache2.js
@@ -42,16 +42,18 @@ const RECREATE =        1 << 10;
 // Do not give me the entry
 const NOTWANTED =       1 << 11;
 // Tell the cache to wait for the entry to be completely written first
 const COMPLETE =        1 << 12;
 // Don't write meta/data and don't set valid in the callback, consumer will do it manually
 const DONTFILL =        1 << 13;
 // Used in combination with METAONLY, don't call setValid() on the entry after metadata has been set
 const DONTSETVALID =    1 << 14;
+// Notify before checking the data, useful for proper callback ordering checks
+const NOTIFYBEFOREREAD = 1 << 15;
 
 var log_c2 = true;
 function LOG_C2(o, m)
 {
   if (!log_c2) return;
   if (!m)
     dump("TEST-INFO | CACHE2: " + o + "\n");
   else
@@ -232,16 +234,18 @@ OpenCallback.prototype =
         })
       })
     }
     else { // NORMAL
       do_check_true(!!entry);
       do_check_eq(entry.getMetaDataElement("meto"), this.workingMetadata);
       if (this.behavior & THROWAVAIL)
         this.throwAndNotify(entry);
+      if (this.behavior & NOTIFYBEFOREREAD)
+        this.goon(entry, true);
 
       var wrapper = Cc["@mozilla.org/scriptableinputstream;1"].
                     createInstance(Ci.nsIScriptableInputStream);
       var self = this;
       pumpReadStream(entry.openInputStream(0), function(data) {
         do_check_eq(data, self.workingData);
         self.onDataCheckPassed = true;
         LOG_C2(self, "entry read done");
--- a/netwerk/test/unit/test_cache2-14b-concurent-readers-complete.js
+++ b/netwerk/test/unit/test_cache2-14b-concurent-readers-complete.js
@@ -9,31 +9,40 @@ function run_test()
     })
   );
 
   var mc = new MultipleCallbacks(3, finish_cache2_test);
 
   var order = 0;
 
   asyncOpenCacheEntry("http://x/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
-    new OpenCallback(NORMAL|COMPLETE, "x1m", "x1d", function(entry) {
-      ++order;
-      do_check_eq(order, newCacheBackEndUsed() ? 3 : 1);
-      mc.fired();
+    new OpenCallback(NORMAL|COMPLETE|NOTIFYBEFOREREAD, "x1m", "x1d", function(entry, beforeReading) {
+      if (beforeReading) {
+        ++order;
+        do_check_eq(order, newCacheBackEndUsed() ? 3 : 1);
+      } else {
+        mc.fired();
+      }
     })
   );
   asyncOpenCacheEntry("http://x/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
-    new OpenCallback(NORMAL, "x1m", "x1d", function(entry) {
-      ++order;
-      do_check_eq(order, newCacheBackEndUsed() ? 1 : 2);
-      mc.fired();
+    new OpenCallback(NORMAL|NOTIFYBEFOREREAD, "x1m", "x1d", function(entry, beforeReading) {
+      if (beforeReading) {
+        ++order;
+        do_check_eq(order, newCacheBackEndUsed() ? 1 : 2);
+      } else {
+        mc.fired();
+      }
     })
   );
   asyncOpenCacheEntry("http://x/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
-    new OpenCallback(NORMAL, "x1m", "x1d", function(entry) {
-      ++order;
-      do_check_eq(order, newCacheBackEndUsed() ? 2 : 3);
-      mc.fired();
+    new OpenCallback(NORMAL|NOTIFYBEFOREREAD, "x1m", "x1d", function(entry, beforeReading) {
+      if (beforeReading) {
+        ++order;
+        do_check_eq(order, newCacheBackEndUsed() ? 2 : 3);
+      } else {
+        mc.fired();
+      }
     })
   );
 
   do_test_pending();
 }