github.com/alibaba/ilogtail/pkg@v0.0.0-20250526110833-c53b480d046c/helper/profile/meta_test.go (about)

     1  // Copyright 2023 iLogtail Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package profile
    16  
    17  import (
    18  	"github.com/stretchr/testify/require"
    19  
    20  	"testing"
    21  )
    22  
    23  func TestFormatPositionAndName(t *testing.T) {
    24  	str := "./node_modules/express/lib/router/index.js:process_params:338 /app/node_modules/express/lib/router/index.js"
    25  	str = FormatPositionAndName(str, PyroscopeNodeJs)
    26  	require.Equal(t, str, "./node_modules/express/lib/router/index.js:process_params:338 /app/node_modules/express/lib/router/index.js")
    27  	str = "compress/flate.NewWriter /usr/local/go/src/compress/flate/deflate.go"
    28  	str = FormatPositionAndName(str, PyroscopeGolang)
    29  	require.Equal(t, str, "compress/flate.NewWriter /usr/local/go/src/compress/flate/deflate.go")
    30  	str = "backtrace_rs.rs:23 - <pprof::backtrace::backtrace_rs::Trace as pprof::backtrace::Trace>::trace"
    31  	str = FormatPositionAndName(str, PyroscopeRust)
    32  	require.Equal(t, str, "pprof::backtrace::Trace>::trace backtrace_rs.rs:23")
    33  	str = "System.Threading.Tasks!Task.InternalWaitCore System.Private.CoreLib"
    34  	str = FormatPositionAndName(str, Unknown)
    35  	require.Equal(t, str, "System.Threading.Tasks!Task.InternalWaitCore System.Private.CoreLib")
    36  	str = "/usr/local/bundle/gems/pyroscope-0.3.0-x86_64-linux/lib/pyroscope.rb:63 - tag_wrapper"
    37  	str = FormatPositionAndName(str, PyroscopeRuby)
    38  	require.Equal(t, str, "tag_wrapper /usr/local/bundle/gems/pyroscope-0.3.0-x86_64-linux/lib/pyroscope.rb:63")
    39  	str = "lib/utility/utility.py:38 - find_nearest_vehicle"
    40  	str = FormatPositionAndName(str, PyroscopePython)
    41  	require.Equal(t, str, "find_nearest_vehicle lib/utility/utility.py:38")
    42  	str = "libjvm.so.AdvancedThresholdPolicy::method_back_branch_event"
    43  	str = FormatPositionAndName(str, PyroscopeJava)
    44  	require.Equal(t, str, "libjvm.so.AdvancedThresholdPolicy::method_back_branch_event")
    45  	str = "/usr/lib/systemd/systemd+0x93242"
    46  	str = FormatPositionAndName(str, PyroscopeEbpf)
    47  	require.Equal(t, str, "/usr/lib/systemd/systemd+0x93242")
    48  	str = "<internal> - sleep"
    49  	str = FormatPositionAndName(str, PyroscopePhp)
    50  	require.Equal(t, str, "sleep <internal>")
    51  }