frida-test 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/reporter/console.js +2 -2
- package/dist/reporter/summary.js +1 -1
- package/package.json +1 -1
- package/src/agent-runtime/registry.ts +19 -25
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frida-test Documentation
|
|
2
2
|
|
|
3
|
+
[](https://github.com/bernhste/frida-test/actions/workflows/test.yml)
|
|
4
|
+
|
|
3
5
|
This is a small test framework which runs on the target. It is used to unit test Frida code running on actual devices. It was originally developed to test the Frida agent code used in [frooky](https://github.com/cpholguera/frooky).
|
|
4
6
|
|
|
5
7
|
The following chapters explain how to write and run tests.
|
|
@@ -10,7 +12,7 @@ The following chapters explain how to write and run tests.
|
|
|
10
12
|
npm install --save-dev frida-test
|
|
11
13
|
```
|
|
12
14
|
|
|
13
|
-
After the installation, import the type `frida-test` into
|
|
15
|
+
After the installation, import the type `frida-test` into your project by adding the following configuration to the `tsconfig.json`:
|
|
14
16
|
|
|
15
17
|
```json
|
|
16
18
|
{
|
|
@@ -42,7 +44,7 @@ describe('Classloader', () => {
|
|
|
42
44
|
|
|
43
45
|
Tests can be nested to any depth and can be synchronous or asynchronous.
|
|
44
46
|
|
|
45
|
-
### Test
|
|
47
|
+
### Test Discovery
|
|
46
48
|
|
|
47
49
|
The framework collects every file matching `*.test.ts` in the directories passed on the command line, recursively.
|
|
48
50
|
|
|
@@ -84,7 +86,7 @@ myProject/
|
|
|
84
86
|
| `.not.<matcher>` | Inverts the assertion result |
|
|
85
87
|
|
|
86
88
|
> [!NOTE]
|
|
87
|
-
> `frida-test`
|
|
89
|
+
> `frida-test` tests itself. So for examples of all matchers and more, have a look at the `*.test.ts` files located in the [test folder](./tests/).
|
|
88
90
|
|
|
89
91
|
### Setup and Teardown
|
|
90
92
|
|
|
@@ -169,7 +171,7 @@ frida-test -U -N org.owasp.mastestapp.MASTestApp-iOS ./tests/ios ./tests/shared
|
|
|
169
171
|
frida-test -H 192.168.1.10:27042 --token secret -p 4926 ./tests/shared
|
|
170
172
|
```
|
|
171
173
|
|
|
172
|
-
##
|
|
174
|
+
## Compiling the Agent
|
|
173
175
|
|
|
174
176
|
`frida-test` automatically bundles the test suites and compiles them together with the testing framework into a Frida agent.
|
|
175
177
|
|
package/dist/reporter/console.js
CHANGED
|
@@ -24,10 +24,10 @@ function printTestResult(node, depth = 0) {
|
|
|
24
24
|
}
|
|
25
25
|
export function printTestSuiteResult(suite) {
|
|
26
26
|
if (suite.status == "failed") {
|
|
27
|
-
|
|
27
|
+
console.log(`❌ Test suite "${suite.name}" failed:`);
|
|
28
28
|
}
|
|
29
29
|
else if (suite.status == "passed") {
|
|
30
|
-
|
|
30
|
+
console.log(`✅ Test suite "${suite.name}" passed:`);
|
|
31
31
|
}
|
|
32
32
|
if (suite.testResult) {
|
|
33
33
|
printTestResult(suite.testResult, 1);
|
package/dist/reporter/summary.js
CHANGED
|
@@ -21,7 +21,7 @@ export function printSummary(runSummary) {
|
|
|
21
21
|
console.log(chalk.bold("Test Suites"));
|
|
22
22
|
for (const suite of testSuitesResults) {
|
|
23
23
|
const isPassed = suite.status === "passed";
|
|
24
|
-
console.log(` ${isPassed ?
|
|
24
|
+
console.log(` ${isPassed ? "✅" : "❌"} ${suite.name}`);
|
|
25
25
|
if (!isPassed && suite.testResult?.name) {
|
|
26
26
|
for (const line of suite.testResult.name.split("\n")) {
|
|
27
27
|
console.log(chalk.red(` ${line}`));
|
package/package.json
CHANGED
|
@@ -252,35 +252,29 @@ export async function runTests(nodes: TestSuiteNode[], emit: (message: AgentMess
|
|
|
252
252
|
|
|
253
253
|
const parentHooks: EachHooks = { beforeEach: rootHooks.beforeEach, afterEach: rootHooks.afterEach };
|
|
254
254
|
|
|
255
|
-
const settled = await Promise.allSettled(
|
|
256
|
-
nodes.map(async (node) => {
|
|
257
|
-
emit({ type: "test-suite-started", name: node.name });
|
|
258
|
-
const { result: testResult, counts } = await runTestSuiteNode(node, verbose, parentHooks);
|
|
259
|
-
const suiteResult: TestSuiteResult = { name: node.name, testResult, status: testResult.status };
|
|
260
|
-
emit({ type: "test-suite-finished", name: node.name, result: suiteResult });
|
|
261
|
-
return { suiteResult, counts };
|
|
262
|
-
}),
|
|
263
|
-
);
|
|
264
|
-
|
|
265
255
|
const testSuitesResults: TestSuiteResult[] = [];
|
|
266
256
|
let counts = ZERO_COUNTS;
|
|
267
257
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
counts =
|
|
272
|
-
|
|
258
|
+
for (const node of nodes) {
|
|
259
|
+
emit({ type: "test-suite-started", name: node.name });
|
|
260
|
+
try {
|
|
261
|
+
const { result: testResult, counts: nodeCounts } = await runTestSuiteNode(node, verbose, parentHooks);
|
|
262
|
+
const suiteResult: TestSuiteResult = { name: node.name, testResult, status: testResult.status };
|
|
263
|
+
emit({ type: "test-suite-finished", name: node.name, result: suiteResult });
|
|
264
|
+
testSuitesResults.push(suiteResult);
|
|
265
|
+
counts = addCounts(counts, nodeCounts);
|
|
266
|
+
} catch (err) {
|
|
267
|
+
const error = serializeError(err, verbose);
|
|
268
|
+
const suiteResult: TestSuiteResult = {
|
|
269
|
+
name: node.name,
|
|
270
|
+
testResult: { name: node.name, status: "failed", durationMs: 0, error },
|
|
271
|
+
status: "failed",
|
|
272
|
+
};
|
|
273
|
+
emit({ type: "test-suite-finished", name: node.name, result: suiteResult });
|
|
274
|
+
testSuitesResults.push(suiteResult);
|
|
275
|
+
counts = addCounts(counts, { total: 1, passed: 0, failed: 1 });
|
|
273
276
|
}
|
|
274
|
-
|
|
275
|
-
const error = serializeError(outcome.reason, verbose);
|
|
276
|
-
const testSuiteResult: TestSuiteResult = {
|
|
277
|
-
name: nodes[i].name,
|
|
278
|
-
testResult: { name: nodes[i].name, status: "failed", durationMs: 0, error },
|
|
279
|
-
status: "failed",
|
|
280
|
-
};
|
|
281
|
-
testSuitesResults.push(testSuiteResult);
|
|
282
|
-
counts = addCounts(counts, { total: 1, passed: 0, failed: 1 });
|
|
283
|
-
});
|
|
277
|
+
}
|
|
284
278
|
|
|
285
279
|
const afterAllError = await runTeardownHooks(rootHooks.afterAll, verbose);
|
|
286
280
|
if (afterAllError) {
|