@cryptotaxi247 / kubo / commits / 0bea7ce6a

test(sharness): test profile dump

Steven Allen committed Jul 21, 2021 at 17:59 UTC 0bea7ce6a96eeb2632eb2803f3541845c5d45f0b
2 files changed +30 -5
test/sharness/lib/test-lib.sh
+1
@@ -98,6 +98,7 @@ test "$TEST_NO_PLUGIN" != 1 && test "$TEST_OS" = "LINUX" && test_set_prereq PLUG
98
99 # this may not be available, skip a few dependent tests
100 type socat >/dev/null 2>&1 && test_set_prereq SOCAT
101 +type unzip >/dev/null 2>&1 && test_set_prereq UNZIP
102
103
104 # Set a prereq as error messages are often different on Windows/Cygwin
test/sharness/t0152-profile.sh
+29 -5
@@ -16,8 +16,8 @@ test_expect_success "profiling requires a running daemon" '
16
17 test_launch_ipfs_daemon
18
19 -test_expect_success "test profiling" '
20 - ipfs diag profile --cpu-profile-time=1s > cmd_out
19 +test_expect_success "test profiling (without CPU)" '
20 + ipfs diag profile --cpu-profile-time=0 > cmd_out
21 '
22
23 test_expect_success "filename shows up in output" '
@@ -28,13 +28,37 @@ test_expect_success "profile file created" '
28 test -e "$(sed -n -e "s/.*\(ipfs-profile.*\.zip\)/\1/p" cmd_out)"
29 '
30
31 -test_expect_success "test profiling with -o (without CPU profiling)" '
32 - ipfs diag profile --cpu-profile-time=0 -o test-profile.zip
31 +test_expect_success "test profiling with -o" '
32 + ipfs diag profile --cpu-profile-time=1s -o test-profile.zip
33 '
34
35 test_expect_success "test that test-profile.zip exists" '
36 test -e test-profile.zip
37 '
38 -
38 test_kill_ipfs_daemon
39 +
40 +if ! test_have_prereq UNZIP; then
41 + test_done
42 +fi
43 +
44 +test_expect_success "unpack profiles" '
45 + unzip -d profiles test-profile.zip
46 +'
47 +
48 +test_expect_success "cpu profile is valid" '
49 + go tool pprof -top profiles/ipfs "profiles/cpu.pprof" | grep -q "Type: cpu"
50 +'
51 +
52 +test_expect_success "heap profile is valid" '
53 + go tool pprof -top profiles/ipfs "profiles/heap.pprof" | grep -q "Type: inuse_space"
54 +'
55 +
56 +test_expect_success "goroutines profile is valid" '
57 + go tool pprof -top profiles/ipfs "profiles/goroutines.pprof" | grep -q "Type: goroutine"
58 +'
59 +
60 +test_expect_success "goroutines stacktrace is valid" '
61 + grep -q "goroutine" "profiles/goroutines.stacks"
62 +'
63 +
64 test_done