1 /* Copyright 2020-2021 IGEL Co., Ltd.
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
7 * 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.
16 #include "test-helpers.h"
23 int get_dummy_fd(void)
25 return dup(STDIN_FILENO);
28 void check_fd_equality(int fd1, int fd2)
31 ck_assert_int_eq(fstat(fd1, &s1), 0);
32 ck_assert_int_eq(fstat(fd2, &s2), 0);
33 ck_assert_int_eq(s1.st_dev, s2.st_dev);
34 ck_assert_int_eq(s1.st_ino, s2.st_ino);
37 void check_fd_is_open(int fd)
40 ck_assert_int_eq(fstat(fd, &st), 0);
43 void check_fd_is_closed(int fd)
46 ck_assert_int_ne(fstat(fd, &st), 0);
47 ck_assert_int_eq(errno, EBADF);
50 void check_uint_array_eq(const uint32_t *a, const uint32_t *b, int cnt)
52 for (int i = 0; i < cnt; i++) {
53 ck_assert_msg(a[i] == b[i], "Array diff at index %d (%u != %u)",