2023-04-06 20:32:23 +05:30
|
|
|
/*
|
2024-07-10 10:42:47 +02:00
|
|
|
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
2023-04-06 20:32:23 +05:30
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
2021-08-19 11:03:37 +02:00
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <sys/fcntl.h>
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
#include "unity.h"
|
|
|
|
|
#include "test_utils.h"
|
|
|
|
|
|
|
|
|
|
TEST_CASE("fstat() sets st_mode to socket type", "[vfs][lwip]")
|
|
|
|
|
{
|
|
|
|
|
test_case_uses_tcpip();
|
|
|
|
|
int socket_fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
2024-07-10 10:42:47 +02:00
|
|
|
TEST_ASSERT(socket_fd >= 0);
|
2021-08-19 11:03:37 +02:00
|
|
|
struct stat stat = { 0 };
|
2024-07-10 10:42:47 +02:00
|
|
|
TEST_ASSERT_EQUAL(0, fstat(socket_fd, &stat));
|
2021-08-19 11:03:37 +02:00
|
|
|
|
|
|
|
|
TEST_ASSERT_TRUE(S_ISSOCK(stat.st_mode));
|
|
|
|
|
TEST_ASSERT_FALSE(S_ISBLK(stat.st_mode));
|
|
|
|
|
TEST_ASSERT_FALSE(S_ISCHR(stat.st_mode));
|
|
|
|
|
TEST_ASSERT_FALSE(S_ISDIR(stat.st_mode));
|
|
|
|
|
TEST_ASSERT_FALSE(S_ISREG(stat.st_mode));
|
|
|
|
|
TEST_ASSERT_FALSE(S_ISLNK(stat.st_mode));
|
|
|
|
|
|
2024-07-10 10:42:47 +02:00
|
|
|
TEST_ASSERT_EQUAL(0, close(socket_fd));
|
2021-08-19 11:03:37 +02:00
|
|
|
}
|