feat: capture pcap file with PID/ProcName/bundleID

This commit is contained in:
debugtalk
2022-12-22 00:37:02 +08:00
parent 2c1f98b1ef
commit 22a300d9b3
12 changed files with 243 additions and 38 deletions
+66
View File
@@ -0,0 +1,66 @@
//go:build localtest
package gidevice
import (
"fmt"
"testing"
"time"
)
func TestPcapWithPID(t *testing.T) {
setupLockdownSrv(t)
data, err := dev.PcapStart(WithPcapPID(1234))
if err != nil {
t.Fatal(err)
}
timer := time.NewTimer(time.Duration(time.Second * 10))
for {
select {
case <-timer.C:
dev.PcapStop()
return
case d := <-data:
fmt.Println(string(d))
}
}
}
func TestPcapWithProcName(t *testing.T) {
setupLockdownSrv(t)
data, err := dev.PcapStart(WithPcapProcName("Awe"))
if err != nil {
t.Fatal(err)
}
timer := time.NewTimer(time.Duration(time.Second * 10))
for {
select {
case <-timer.C:
dev.PcapStop()
return
case d := <-data:
fmt.Println(string(d))
}
}
}
func TestPcapWithBundleID(t *testing.T) {
setupLockdownSrv(t)
data, err := dev.PcapStart(WithPcapBundleID("com.ss.iphone.ugc.Aweme"))
if err != nil {
t.Fatal(err)
}
timer := time.NewTimer(time.Duration(time.Second * 10))
for {
select {
case <-timer.C:
dev.PcapStop()
return
case d := <-data:
fmt.Println(string(d))
}
}
}