Skip to content

Commit 8ef1d02

Browse files
committed
test(userspace/libsinsp/parsers): add setgid parsing test
Signed-off-by: Tero Kauppinen <tero.kauppinen@est.tech>
1 parent c0771ab commit 8ef1d02

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
/*
3+
Copyright (C) 2024 The Falco Authors.
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS,
10+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the License for the specific language governing permissions and
12+
limitations under the License.
13+
*/
14+
15+
#include <sinsp_with_test_input.h>
16+
17+
TEST_F(sinsp_with_test_input, SETGID_success) {
18+
add_default_init_thread();
19+
open_inspector();
20+
21+
int64_t return_value = 0;
22+
uint32_t gid = 66;
23+
24+
const auto evt = add_event_advance_ts(increasing_ts(),
25+
INIT_TID,
26+
PPME_SYSCALL_SETGID_X,
27+
2,
28+
return_value,
29+
gid);
30+
31+
// Check that the returned value is as expected.
32+
ASSERT_EQ(evt->get_param_by_name("res")->as<int64_t>(), return_value);
33+
34+
// Check that the gid value is as expected.
35+
ASSERT_EQ(evt->get_param_by_name("gid")->as<uint32_t>(), gid);
36+
}

0 commit comments

Comments
 (0)