Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove deprecated function #29

Merged
merged 4 commits into from
Mar 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func GetSyscallFnNameWithSymFile(name string, symFile string) (string, error) {
}

kallSymsLocker.Lock()
_, exist := kallsymsCache[name];
_, exist := kallsymsCache[name]
kallSymsLocker.Unlock()

if exist {
Expand All @@ -158,7 +158,7 @@ const defaultSymFile = "/proc/kallsyms"
// for older syscall functions to run on newer kernels
func getSyscallName(name string, symFile string) (string, error) {
// Get kernel symbols
syms, err := ioutil.ReadFile(symFile)
syms, err := os.ReadFile(symFile)
if err != nil {
return "", err
}
Expand Down
14 changes: 14 additions & 0 deletions utils_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package manager

import (
"strings"
"testing"
)

Expand Down Expand Up @@ -31,3 +32,16 @@ func TestGenerateEventName(t *testing.T) {
t.Errorf("Test should failed as event name length is too big for the kernel and free space for function Name is < %d", minFunctionNameLen)
}
}

func TestGetSyscallFnNameWithSymFile(t *testing.T) {
expectedFnName := "sys_exit"

fnName, err := GetSyscallFnNameWithSymFile(expectedFnName, "")
if err != nil {
t.Error(err)
}
if !strings.HasSuffix(fnName, expectedFnName) {
t.Errorf("Expected function name %s, but got %s", expectedFnName, fnName)
}
t.Logf("Expected function name %s, got %s", expectedFnName, fnName)
}