Browse Source

Add gzip and gzip test files

Lutz Roeder 7 years ago
parent
commit
fe29ccfdfa
3 changed files with 25 additions and 7 deletions
  1. 1 5
      src/gzip.js
  2. 23 1
      test/models.json
  3. 1 1
      test/test.js

+ 1 - 5
src/gzip.js

@@ -28,7 +28,7 @@ gzip.Entry = class {
         }
         var compressionMethod = reader.byte();
         if (compressionMethod != 8) {
-            throw new gzip.Error('Invalid compression method ' + compressionMethod.toString() + "'.");
+            throw new gzip.Error("Invalid compression method '" + compressionMethod.toString() + "'.");
         }
         var flags = reader.byte();
         reader.uint32(); // MTIME
@@ -103,10 +103,6 @@ gzip.Reader = class {
         this._position = value >= 0 ? value : this._end + value;
     }
 
-    peek() {
-        return this._position < this._end;
-    }
-
     skip(size) {
         if (this._position + size > this._end) {
             throw new gzip.Error('Data not available.');

+ 23 - 1
test/models.json

@@ -2330,6 +2330,20 @@
     "format": "ONNX v0",
     "link":   "https://github.com/Microsoft/onnxruntime/tree/master/onnxruntime/test/testdata"
   },
+  {
+    "type":   "onnx",
+    "target": "gzip_invalid_archive.tar.gz",
+    "source": "https://github.com/lutzroeder/netron/files/3027192/gzip_invalid_archive.tar.gz",
+    "error":  "Invalid GZIP archive in 'gzip_invalid_archive.tar.gz'.",
+    "link":   "https://github.com/lutzroeder/netron/issues/249"
+  },
+  {
+    "type":   "onnx",
+    "target": "gzip_invalid_compression.tar.gz",
+    "source": "https://github.com/lutzroeder/netron/files/3027193/gzip_invalid_compression.tar.gz",
+    "error":  "Invalid compression method '1' in 'gzip_invalid_compression.tar.gz'.",
+    "link":   "https://github.com/lutzroeder/netron/issues/249"
+  },
   {
     "type":   "onnx",
     "target": "input_0.pb",
@@ -2549,7 +2563,15 @@
   {
     "type":   "onnx",
     "target": "zfnet512_opset_9.onnx",
-    "source": "https://s3.amazonaws.com/download.onnx/models/opset_9/zfnet512.tar.gz[zfnet512/model.onnx]"
+    "source": "https://s3.amazonaws.com/download.onnx/models/opset_9/zfnet512.tar.gz[zfnet512/model.onnx]",
+    "link":   "https://github.com/onnx/models/blob/master/zfnet512/README.md"
+  },
+  {
+    "type":   "onnx",
+    "target": "zip_invalid_archive.zip",
+    "source": "https://github.com/lutzroeder/netron/files/3027198/zip_invalid_archive.zip",
+    "error":  "Invalid ZIP archive in 'zip_invalid_archive.zip'.",
+    "link":   "https://github.com/lutzroeder/netron/issues/250"
   },
   {
     "type":   "onnx",

+ 1 - 1
test/test.js

@@ -586,7 +586,7 @@ function next() {
         }
         loadModel(folder + '/' + completed[0], item, (err, model) => {
             if (err) {
-                if (!item.error && item.error != err.message) {
+                if (!item.error || item.error != err.message) {
                     console.error(err);
                     return;
                 }