|
| 1 | +// Copyright 2012 the V8 project authors. All rights reserved. |
| 2 | +// Redistribution and use in source and binary forms, with or without |
| 3 | +// modification, are permitted provided that the following conditions are |
| 4 | +// met: |
| 5 | +// |
| 6 | +// * Redistributions of source code must retain the above copyright |
| 7 | +// notice, this list of conditions and the following disclaimer. |
| 8 | +// * Redistributions in binary form must reproduce the above |
| 9 | +// copyright notice, this list of conditions and the following |
| 10 | +// disclaimer in the documentation and/or other materials provided |
| 11 | +// with the distribution. |
| 12 | +// * Neither the name of Google Inc. nor the names of its |
| 13 | +// contributors may be used to endorse or promote products derived |
| 14 | +// from this software without specific prior written permission. |
| 15 | +// |
| 16 | +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | + |
| 28 | +// Node polyfill |
| 29 | +var fs = require('fs'); |
| 30 | +var os = { |
| 31 | + system: function(name, args) { |
| 32 | + if (process.platform === 'linux' && name === 'nm') { |
| 33 | + // Filter out vdso and vsyscall entries. |
| 34 | + var arg = args[args.length - 1]; |
| 35 | + if (arg === '[vdso]' || |
| 36 | + arg == '[vsyscall]' || |
| 37 | + /^[0-9a-f]+-[0-9a-f]+$/.test(arg)) { |
| 38 | + return ''; |
| 39 | + } |
| 40 | + } |
| 41 | + return require('child_process').execFileSync( |
| 42 | + name, args, {encoding: 'utf8'}); |
| 43 | + } |
| 44 | +}; |
| 45 | +var print = console.log; |
| 46 | +function read(fileName) { |
| 47 | + return fs.readFileSync(fileName, 'utf8'); |
| 48 | +} |
| 49 | +arguments = process.argv.slice(2); |
| 50 | + |
| 51 | +// Polyfill "readline()". |
| 52 | +var fd = fs.openSync(arguments[arguments.length - 1], 'r'); |
| 53 | +var buf = new Buffer(4096); |
| 54 | +var dec = new (require('string_decoder').StringDecoder)('utf-8'); |
| 55 | +var line = ''; |
| 56 | +versionCheck(); |
| 57 | +function readline() { |
| 58 | + while (true) { |
| 59 | + var lineBreak = line.indexOf('\n'); |
| 60 | + if (lineBreak !== -1) { |
| 61 | + var res = line.slice(0, lineBreak); |
| 62 | + line = line.slice(lineBreak + 1); |
| 63 | + return res; |
| 64 | + } |
| 65 | + var bytes = fs.readSync(fd, buf, 0, buf.length); |
| 66 | + line += dec.write(buf.slice(0, bytes)); |
| 67 | + if (line.length === 0) { |
| 68 | + return false; |
| 69 | + } |
| 70 | + } |
| 71 | +} |
| 72 | + |
| 73 | +function versionCheck() { |
| 74 | + // v8-version looks like "v8-version,$major,$minor,$build,$patch,$candidate" |
| 75 | + // whereas process.versions.v8 is either "$major.$minor.$build" or |
| 76 | + // "$major.$minor.$build.$patch". |
| 77 | + var firstLine = readline(); |
| 78 | + line = firstLine + '\n' + line; |
| 79 | + firstLine = firstLine.split(','); |
| 80 | + var curVer = process.versions.v8.split('.'); |
| 81 | + if (firstLine.length !== 6 && firstLine[0] !== 'v8-version') { |
| 82 | + console.log('Unable to read v8-version from log file.'); |
| 83 | + return; |
| 84 | + } |
| 85 | + // Compare major, minor and build; ignore the patch and candidate fields. |
| 86 | + for (var i = 0; i < 3; i++) { |
| 87 | + if (curVer[i] !== firstLine[i + 1]) { |
| 88 | + console.log('Testing v8 version different from logging version'); |
| 89 | + return; |
| 90 | + } |
| 91 | + } |
| 92 | +} |
0 commit comments