|
| 1 | + |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | +/* |
| 4 | +Copyright (C) 2025 The Falco Authors. |
| 5 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +you may not use this file except in compliance with the License. |
| 7 | +You may obtain a copy of the License at |
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 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 | + |
| 16 | +#include <sinsp_with_test_input.h> |
| 17 | +#include <vector> |
| 18 | + |
| 19 | +TEST_F(sinsp_with_test_input, POLL_success) { |
| 20 | + add_default_init_thread(); |
| 21 | + open_inspector(); |
| 22 | + |
| 23 | + constexpr int64_t return_value = 55; |
| 24 | + const std::vector<uint8_t> fds{0x1, 0x0, 0x16, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0}; |
| 25 | + constexpr int64_t timeout = 1000; |
| 26 | + const auto evt = add_event_advance_ts(increasing_ts(), |
| 27 | + INIT_TID, |
| 28 | + PPME_SYSCALL_POLL_X, |
| 29 | + 3, |
| 30 | + return_value, |
| 31 | + scap_const_sized_buffer{fds.data(), fds.size()}, |
| 32 | + timeout); |
| 33 | + |
| 34 | + // Check that the returned value is as expected. |
| 35 | + ASSERT_EQ(evt->get_param_by_name("res")->as<int64_t>(), return_value); |
| 36 | + |
| 37 | + // Check that the fds value is as expected. |
| 38 | + ASSERT_EQ(evt->get_param_by_name("fds")->as<std::vector<uint8_t>>(), fds); |
| 39 | + |
| 40 | + // Check that the timeout value is as expected. |
| 41 | + ASSERT_EQ(evt->get_param_by_name("timeout")->as<int64_t>(), timeout); |
| 42 | +} |
0 commit comments