mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 07:26:55 +08:00
feat: capture pcap file with PID/ProcName/bundleID
This commit is contained in:
@@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user