diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-20 23:42:12 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-20 23:42:12 +0300 |
| commit | be6d4e8ffc722bf0d36c5b01ff46f817539a1525 (patch) | |
| tree | 7bb0aeb51e29cfbc6735af15bb812b888f4b3574 /internal/generate/classify_test.go | |
| parent | 2156d6e51b18e29fe8dfe8e1a519e1a84e0a1fe6 (diff) | |
task-47: add KindExec for execve paths
Diffstat (limited to 'internal/generate/classify_test.go')
| -rw-r--r-- | internal/generate/classify_test.go | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/internal/generate/classify_test.go b/internal/generate/classify_test.go index 2a12911..5d6424b 100644 --- a/internal/generate/classify_test.go +++ b/internal/generate/classify_test.go @@ -231,10 +231,17 @@ func TestClassifyPathnameMknod(t *testing.T) { } } -func TestClassifyPathnameExecve(t *testing.T) { +func TestClassifyExecExecve(t *testing.T) { r := classifyFromData(t, FormatExecve) - if r.Kind != KindPathname { - t.Errorf("execve: got kind %d, want KindPathname", r.Kind) + if r.Kind != KindExec { + t.Errorf("execve: got kind %d, want KindExec", r.Kind) + } +} + +func TestClassifyExecExecveat(t *testing.T) { + r := classifyFromData(t, FormatExecveat) + if r.Kind != KindExec { + t.Errorf("execveat: got kind %d, want KindExec", r.Kind) } } @@ -694,6 +701,24 @@ func TestClassifyKillRequiresGenerationFallback(t *testing.T) { } } +func TestClassifyNullExitByName(t *testing.T) { + tests := []string{"sys_enter_exit", "sys_enter_exit_group"} + for _, name := range tests { + t.Run(name, func(t *testing.T) { + r := ClassifyFormat(&Format{ + Name: name, + ExternalFields: []Field{ + {Type: "long", Name: "__syscall_nr"}, + {Type: "int", Name: "error_code"}, + }, + }) + if r.Kind != KindNull { + t.Errorf("%s: got kind %d, want KindNull", name, r.Kind) + } + }) + } +} + // --- End-to-end classification with enter+exit pairs --- func TestClassifySyscallPairAccepted(t *testing.T) { @@ -722,7 +747,8 @@ func TestClassifySyscallPairAccepted(t *testing.T) { {"pread64", FormatPread64, FormatExitPread64, KindFd}, {"symlink", FormatSymlink, FormatExitSymlink, KindName}, {"mknod", FormatMknod, FormatExitMknod, KindPathname}, - {"execve", FormatExecve, FormatExitExecve, KindPathname}, + {"execve", FormatExecve, FormatExitExecve, KindExec}, + {"execveat", FormatExecveat, FormatExitExecveat, KindExec}, {"accept", FormatAccept, FormatExitAccept, KindAccept}, {"accept4", FormatAccept4, FormatExitAccept4, KindAccept}, {"socket", FormatSocket, FormatExitSocket, KindSocket}, @@ -760,6 +786,8 @@ func TestClassifySyscallPairAccepted(t *testing.T) { {"swapon", FormatSwapon, FormatExitSwapon, KindPathname}, {"swapoff", FormatSwapoff, FormatExitSwapoff, KindPathname}, {"kill", FormatKill, FormatExitKill, KindNull}, + {"exit", syntheticEnter("exit", 9310), syntheticExit("exit", 9309), KindNull}, + {"exit_group", syntheticEnter("exit_group", 9312), syntheticExit("exit_group", 9311), KindNull}, } for _, tt := range tests { @@ -782,6 +810,7 @@ func TestClassifySyscallPairEmitsAllFamilies(t *testing.T) { }{ {"mknod", FormatMknod, FormatExitMknod, FamilyFS}, {"execve", FormatExecve, FormatExitExecve, FamilyProcess}, + {"execveat", FormatExecveat, FormatExitExecveat, FamilyProcess}, {"accept", FormatAccept, FormatExitAccept, FamilyNetwork}, {"accept4", FormatAccept4, FormatExitAccept4, FamilyNetwork}, {"socket", FormatSocket, FormatExitSocket, FamilyNetwork}, @@ -816,6 +845,7 @@ func TestClassifySyscallPairEmitsAllFamilies(t *testing.T) { {"swapon", FormatSwapon, FormatExitSwapon, FamilyFS}, {"swapoff", FormatSwapoff, FormatExitSwapoff, FamilyFS}, {"kill", FormatKill, FormatExitKill, FamilySignals}, + {"exit_group", syntheticEnter("exit_group", 9316), syntheticExit("exit_group", 9315), FamilyProcess}, } for _, tt := range tests { |
