mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
3595bf3564
The LogShake features allows one to shake its device to be able to dump a set of useful logging informations. This includes several log files, and also the Android properties. In the past, we relied on the /dev/__properties__ file to extract their content by parsing its value. This is duplicate work from the bionic libc and libcutils library. Worst, the format used to store the values in this file has been changed between JellyBean and Kitkat, so our parser was not able to dump the values: that explains bug 1079322. To fix this we make use of some of the underlying libc-defined functions used to iterate and get properties values: - __system_property_find_nth() to retrieve one arbitrary property by its number (starting from 0), and this returns a struct containing all the informations - __system_property_read() to read the values contained in the struct that was previously retrieved
75 lines
2.1 KiB
JavaScript
75 lines
2.1 KiB
JavaScript
/* jshint moz: true */
|
|
|
|
const {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 logMessages = LogParser.prettyPrintPropertiesArray(properties);
|
|
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();
|
|
});
|