Files
flipper/desktop/app/src/devices/__tests__/iOSLogs.node.tsx
Michel Weststrate d5fbe9a5b9 Support physical device logging
Summary:
Changelog: Logs plugin now supports physical iOS devices

As reported in https://github.com/facebook/flipper/issues/262 and linked papercut.

This diff adds support for iOS device logs through idb. Since idb doesn't respect `--json` flag at the moment, we perform the parsing in Flipper itself.

Reviewed By: passy

Differential Revision: D27346262

fbshipit-source-id: 3b314716f48bb9a7fe709370303396a51893359c
2021-03-29 07:00:47 -07:00

50 lines
2.8 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import IOSDevice from '../IOSDevice';
test('can parse log', () => {
const input = `Mar 25 17:06:38 iPhone symptomsd(SymptomEvaluator)[125] <Notice>: L2 Metrics on en0: rssi: -64 [0,0] -> -64, snr: 0 (cca [wake/total] self/other/intf): [0,0]/[0,0]/[0,0]/16 (txFrames/txReTx/txFail): 0/0/0 -> (was/is) 0/0`;
const parsed = IOSDevice.parseLogLine(input);
expect(parsed).toMatchObject({
message:
'L2 Metrics on en0: rssi: -64 [0,0] -> -64, snr: 0 (cca [wake/total] self/other/intf): [0,0]/[0,0]/[0,0]/16 (txFrames/txReTx/txFail): 0/0/0 -> (was/is) 0/0',
pid: 125,
tag: 'symptomsd(SymptomEvaluator)',
tid: 0,
type: 'verbose',
});
// don't check everything as parsing is time zone dependent
expect(parsed?.date.getMonth()).toBe(2);
expect(parsed?.date.getMinutes()).toBe(6);
expect(parsed?.date.getSeconds()).toBe(38);
});
test('all parseable', () => {
const inputs = [
`Mar 26 10:00:40 iPhone kernel(AppleBCMWLANCore)[0] <Notice>: LQM-WiFi: (2G) rxCrsGlitch=409 rxBphyCrsGlitch=226 rxStart=5672 rxBadPLCP=22 rxBphyBadPLCP=2 rxBadFCS=1740 rxFifo0Ovfl=0 rxFifo1Ovfl=0 rx_nobuf=0 rxAnyErr=48 rxResponseTimeout=612 rxNoDelim=18 rxFrmTooLong=0 rxFrmTooShort=10`,
`Mar 26 10:04:37 iPhone nsurlsessiond[108] <Notice>: NDSession <7E18A208-B0F3-400D-916E-AD844AF190F2> Task <5331FB72-769E-4B22-8EDF-3D4944B1970A>.<5> did receive data (629823296 of 1953496076 total bytes)`,
`Apr 2 03:00:26 iPhone locationd[4718] <Notice>: @ClxGps, Fix, 0, ll, N/A`,
];
inputs.forEach((input) => {
expect(IOSDevice.parseLogLine(input)).toBeDefined();
});
});
test('splits', () => {
const input = `Mar 26 10:26:57 iPhone containermanagerd[4981] <Notice>: stat [<private>]: exists: 1, isDirectory: 0, fsNode: <~~~>
Mar 26 10:26:57 iPhone containermanagerd[4981] <Notice>: [0] command=0, client=<<~~~>, u=<501/501/~~/2/1000>, uid=33, pid=5164, sandboxed=1, platform=2>, error=(none)
Mar 26 10:26:57 iPhone installd(libsystem_containermanager.dylib)[5164] <Notice>: container_create_or_lookup_for_platform: success
Mar 26 10:26:57 iPhone installd(libsystem_containermanager.dylib)[5164] <Notice>: container_copy_path: success
Mar 26 10:26:57 iPhone containermanagerd[4981] <Notice>: stat [<private>]: exists: 1, isDirectory: 0, fsNode: <~~~>
Mar 26 10:26:57 iPhone containermanagerd[4981] <Notice>: [0] command=7, client=<<~~~>, u=<501/501/~~/2/1000>, uid=33, pid=5164, sandboxed=1, platform=2>, error=(none)
Mar 26 10:26:57 iPhone installd(libsystem_containermanager.dylib)[5164] <Notice>: container_is_transient: success`;
expect(input.split('\0').length).toBe(7);
});