@@ -21,6 +21,7 @@ import (
2121
2222 "github.com/go-kit/log"
2323 "github.com/google/pprof/profile"
24+ "github.com/google/uuid"
2425 "github.com/parca-dev/parca/pkg/storage/metastore"
2526 "github.com/prometheus/client_golang/prometheus"
2627 "github.com/stretchr/testify/require"
@@ -63,3 +64,50 @@ func TestGeneratePprof(t *testing.T) {
6364 require .NoError (t , f .Close ())
6465 require .NoError (t , resProf .CheckValid ())
6566}
67+
68+ func TestGeneratePprofNilMapping (t * testing.T ) {
69+ ctx := context .Background ()
70+
71+ pt := NewProfileTree ()
72+ pt .Insert (makeSample (2 , []uuid.UUID {
73+ uuid .MustParse ("00000000-0000-0000-0000-000000000002" ),
74+ uuid .MustParse ("00000000-0000-0000-0000-000000000001" ),
75+ }))
76+
77+ l := & fakeLocations {m : map [uuid.UUID ]* metastore.Location {
78+ uuid .MustParse ("00000000-0000-0000-0000-000000000001" ): {
79+ ID : uuid .MustParse ("00000000-0000-0000-0000-000000000001" ),
80+ Lines : []metastore.LocationLine {{
81+ Function : & metastore.Function {
82+ ID : uuid .MustParse ("00000000-0000-0000-0000-0000000000f1" ),
83+ FunctionKey : metastore.FunctionKey {Name : "1" },
84+ },
85+ }},
86+ },
87+ uuid .MustParse ("00000000-0000-0000-0000-000000000002" ): {
88+ ID : uuid .MustParse ("00000000-0000-0000-0000-000000000002" ),
89+ Lines : []metastore.LocationLine {{
90+ Function : & metastore.Function {
91+ ID : uuid .MustParse ("00000000-0000-0000-0000-0000000000f2" ),
92+ FunctionKey : metastore.FunctionKey {Name : "2" },
93+ },
94+ }},
95+ },
96+ }}
97+
98+ res , err := GeneratePprof (ctx , l , & Profile {Tree : pt })
99+ require .NoError (t , err )
100+
101+ tmpfile , err := ioutil .TempFile ("" , "pprof" )
102+ defer os .Remove (tmpfile .Name ())
103+ require .NoError (t , err )
104+ require .NoError (t , res .Write (tmpfile ))
105+ require .NoError (t , tmpfile .Close ())
106+
107+ f , err := os .Open (tmpfile .Name ())
108+ require .NoError (t , err )
109+ resProf , err := profile .Parse (f )
110+ require .NoError (t , err )
111+ require .NoError (t , f .Close ())
112+ require .NoError (t , resProf .CheckValid ())
113+ }
0 commit comments