diff options
author | Matt A. Tobin <email@mattatobin.com> | 2018-02-03 06:25:10 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2018-02-03 06:25:10 -0500 |
commit | 8b8c65072aedef94610748ce92c2ed3a19fd5517 (patch) | |
tree | 8614d386acf5db7a77b08d19a5854a7d75dab015 /b2g/components/test/unit/test_logparser.js | |
parent | 8c3a46bd13a0660a3ff1e0379dbf515873a852d2 (diff) | |
download | UXP-8b8c65072aedef94610748ce92c2ed3a19fd5517.tar UXP-8b8c65072aedef94610748ce92c2ed3a19fd5517.tar.gz UXP-8b8c65072aedef94610748ce92c2ed3a19fd5517.tar.lz UXP-8b8c65072aedef94610748ce92c2ed3a19fd5517.tar.xz UXP-8b8c65072aedef94610748ce92c2ed3a19fd5517.zip |
Purge b2g/
Diffstat (limited to 'b2g/components/test/unit/test_logparser.js')
-rw-r--r-- | b2g/components/test/unit/test_logparser.js | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/b2g/components/test/unit/test_logparser.js b/b2g/components/test/unit/test_logparser.js deleted file mode 100644 index 624dcc6e2..000000000 --- a/b2g/components/test/unit/test_logparser.js +++ /dev/null @@ -1,75 +0,0 @@ -/* jshint moz: true */ - -var {utils: Cu, classes: Cc, interfaces: Ci} = Components; - -function debug(msg) { - var timestamp = Date.now(); - dump("LogParser: " + timestamp + ": " + msg + "\n"); -} - -function run_test() { - Cu.import("resource:///modules/LogParser.jsm"); - debug("Starting"); - run_next_test(); -} - -function makeStream(file) { - var fileStream = Cc["@mozilla.org/network/file-input-stream;1"] - .createInstance(Ci.nsIFileInputStream); - fileStream.init(file, -1, -1, 0); - var bis = Cc["@mozilla.org/binaryinputstream;1"] - .createInstance(Ci.nsIBinaryInputStream); - bis.setInputStream(fileStream); - return bis; -} - -add_test(function test_parse_logfile() { - let loggerFile = do_get_file("data/test_logger_file"); - - let loggerStream = makeStream(loggerFile); - - // Initialize arrays to hold the file contents (lengths are hardcoded) - let loggerArray = new Uint8Array(loggerStream.readByteArray(4037)); - - loggerStream.close(); - - let logMessages = LogParser.parseLogArray(loggerArray); - - ok(logMessages.length === 58, "There should be 58 messages in the log"); - - let expectedLogEntry = { - processId: 271, threadId: 271, - seconds: 790796, nanoseconds: 620000001, time: 790796620.000001, - priority: 4, tag: "Vold", - message: "Vold 2.1 (the revenge) firing up\n" - }; - - deepEqual(expectedLogEntry, logMessages[0]); - run_next_test(); -}); - -add_test(function test_print_properties() { - let properties = { - "ro.secure": "1", - "sys.usb.state": "diag,serial_smd,serial_tty,rmnet_bam,mass_storage,adb" - }; - - let logMessagesRaw = LogParser.prettyPrintPropertiesArray(properties); - let logMessages = new TextDecoder("utf-8").decode(logMessagesRaw); - let logMessagesArray = logMessages.split("\n"); - - ok(logMessagesArray.length === 3, "There should be 3 lines in the log."); - notEqual(logMessagesArray[0], "", "First line should not be empty"); - notEqual(logMessagesArray[1], "", "Second line should not be empty"); - equal(logMessagesArray[2], "", "Last line should be empty"); - - let expectedLog = [ - "[ro.secure]: [1]", - "[sys.usb.state]: [diag,serial_smd,serial_tty,rmnet_bam,mass_storage,adb]", - "" - ].join("\n"); - - deepEqual(expectedLog, logMessages); - - run_next_test(); -}); |