tests: posix: existence tests for standard POSIX includes

Add a trivial suite that simply ensures headers exist and that
they supply standard symbols and constants.

These tests are intended to be ordered exactly as the respective
feature appears in the respective specification at

https://pubs.opengroup.org/onlinepubs/9699919799

Over time, as POSIX support improves, we can enable additional
checks.

If `CONFIG_POSIX_API=n`, then we simply ensure that the header
can be included, that constants and structures exist, including
the existence of required fields in each structure.

We check that a constant exist, by comparing its value against
an arbitrary number. If the constant does not exist, it would
of course be a compile error.

```
zassert_not_equal(-1, POLLIN);
```

We check that a structure contains required fields by
comparing the field offset with an arbitrary number. If
the field does not exist, of course, there would be a
compile error.

```
zassert_not_equal(-1, offsetof(struct pollfd, fd));
```

For non-scalar constants, we simply attempt to assign
a value to the specific type:

```
struct in6_addr any6 = IN6ADDR_ANY_INIT;
```

If `CONFIG_POSIX_API=y`, then we additionally check that required
functions are non-NULL (limited to what is currently supported in
Zephyr).

```
zassert_not_null(pthread_create);
```

Note: functional verification tests should be done outside of this
test suite.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
This commit is contained in:
Chris Friedt 2022-10-27 15:47:04 -04:00 committed by Marti Bolivar
commit ab6102f70f
23 changed files with 1574 additions and 0 deletions

View file

@ -0,0 +1,20 @@
CONFIG_POSIX_API=y
CONFIG_ZTEST=y
CONFIG_ZTEST_NEW_API=y
# for POSIX_FS
CONFIG_FILE_SYSTEM=y
# for select to work
CONFIG_NET_TEST=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_SOCKETS=y
CONFIG_NETWORKING=y
# for when CONFIG_POSIX_API is not selected
CONFIG_PTHREAD_IPC=y
CONFIG_POSIX_FS=y
CONFIG_POSIX_CLOCK=y
CONFIG_POSIX_MQUEUE=y
CONFIG_EVENTFD=y
CONFIG_GETOPT=y