forked from electricbubble/gidevice
-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
lockdown_test.go
107 lines (84 loc) · 2.03 KB
/
lockdown_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package giDevice
import (
"fmt"
"os"
"os/signal"
"path"
"testing"
"time"
)
var lockdownSrv Lockdown
func setupLockdownSrv(t *testing.T) {
setupDevice(t)
var err error
if lockdownSrv, err = dev.lockdownService(); err != nil {
t.Fatal(err)
}
}
func Test_lockdown_QueryType(t *testing.T) {
setupLockdownSrv(t)
lockdownType, err := lockdownSrv.QueryType()
if err != nil {
t.Fatal(err)
}
t.Log(lockdownType.Type)
}
func Test_lockdown_GetValue(t *testing.T) {
setupLockdownSrv(t)
// v, err := dev.GetValue("com.apple.mobile.iTunes", "")
// v, err := dev.GetValue("com.apple.mobile.internal", "")
v, err := dev.GetValue("com.apple.mobile.battery", "")
// v, err := lockdownSrv.GetValue("", "ProductVersion")
// v, err := lockdownSrv.GetValue("", "DeviceName")
// v, err := lockdownSrv.GetValue("com.apple.mobile.iTunes", "")
// v, err := lockdownSrv.GetValue("com.apple.mobile.battery", "")
// v, err := lockdownSrv.GetValue("com.apple.disk_usage", "")
if err != nil {
t.Fatal(err)
}
t.Log(v)
}
func Test_lockdown_SyslogRelayService(t *testing.T) {
setupLockdownSrv(t)
syslogRelaySrv, err := lockdownSrv.SyslogRelayService()
if err != nil {
t.Fatal(err)
}
syslogRelaySrv.Stop()
lines := syslogRelaySrv.Lines()
done := make(chan os.Signal, 1)
go func() {
for line := range lines {
fmt.Println(line)
}
done <- os.Interrupt
fmt.Println("DONE!!!")
}()
signal.Notify(done, os.Interrupt, os.Kill)
<-done
syslogRelaySrv.Stop()
time.Sleep(time.Second)
}
func Test_lockdown_CrashReportMoverService(t *testing.T) {
setupLockdownSrv(t)
crashReportMoverSrv, err := lockdownSrv.CrashReportMoverService()
if err != nil {
t.Fatal(err)
}
filenames := make([]string, 0, 36)
fn := func(cwd string, info *AfcFileInfo) {
if cwd == "." {
cwd = ""
}
filenames = append(filenames, path.Join(cwd, info.Name()))
// fmt.Println(path.Join(cwd, name))
}
err = crashReportMoverSrv.walkDir(".", fn)
if err != nil {
t.Fatal(err)
}
for _, n := range filenames {
fmt.Println(n)
}
t.Log(len(filenames))
}