summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* tests: optimize _nltst_assert_route_list_permutate() to short cut search ↵Thomas Haller2024-08-221-4/+16
| | | | through permutations
* tests: in _nltst_assert_route_list() accept arbitrary orderThomas Haller2024-08-222-51/+104
| | | | | | | | | | | | | | | | | | | | | | | | | _nltst_assert_route_list() compares the content of the cache with a list of expected routes. The cache does not have a well defined order. Well, maybe the cache *should* have a well defined order, because when we use `ip route replace`, it will replace some route that has certain similar attributes, but is otherwise another route (as far as route identity and caching is concerned). But on netlink, we are only told that one route was replaced, but not which one. Some kernel developers think that in face of that, we just iterate the cache (in the same order as kernel exports the route), find the first similar route and know that was the one that is replaced. Does that work? Dunno, I never saw anybody implementing that successfully. NetworkManager implements a similar cache and throws it's hands in the air and requests a new dump of all routes that it caches. Anyway. Unless somebody shows that the cache is always in a consistent and reproducible state, this unit test was wrong. Instead, permutate through all lists of routes, and try to find a one-to-one match with the expected routes.
* tests: ensure that there are all expected routes in _nltst_assert_route_list()Thomas Haller2024-08-221-14/+24
|
* tests: print route list before failure in _nltst_assert_route_list()Thomas Haller2024-08-221-8/+34
| | | | | It's hard to debug a failure. Print what we were comparing before crashing.
* tests: add _nltst_objects_to_string() helperThomas Haller2024-08-222-0/+47
|
* tests: add _nltst_malloc0() and _nltst_sprintf() helpersThomas Haller2024-08-221-0/+27
|
* tests: move definition of asserts in "tests/nl-test-util.h"Thomas Haller2024-08-221-38/+40
|
* tests: use _nl_ptrarray_len() helper in _nltst_assert_route_list()Thomas Haller2024-08-221-8/+1
|
* all: fix and enable "-Wsign-compare" warningThomas Haller2024-05-293-4/+5
|
* tests: add a very basic test for route cacheThomas Haller2024-05-173-1/+91
| | | | Hopefully more to come, and more to improve.
* tests: add NLTstSelectRoute test helperThomas Haller2024-05-173-0/+401
| | | | | Add functions for matching a route. Currently only a few trivial options are supported, like the destination address and the ifindex.
* tests: set NLTST_IN_CI for not skipping tests accidentallyThomas Haller2024-05-172-0/+13
| | | | | In CI, we know which tests should be skipped. Let github actions set NLTST_IN_CI=1, and disable certain skip checks.
* tests: add helper to detect availablility of iproute2Thomas Haller2024-05-172-0/+25
|
* tests: add helper functions for testsThomas Haller2024-05-171-0/+44
|
* tests: fix _nltst_object_to_string() to print one line onlyThomas Haller2024-05-172-3/+25
|
* format: reformat "tests/nl-test-util.h" fileThomas Haller2024-05-161-112/+112
|
* tests: add test for bridge vlan attributes.Cordell O'Leary2024-02-291-0/+127
|
* tests: add unit test for `nl_addr_parse("default", AF_INET6, &addr6)`Thomas Haller2024-02-021-0/+8
|
* tests: use thread-safe localtime_r() instead of localtime()Thomas Haller2023-08-181-1/+2
|
* tests: avoid srandom()/random() in favor of _nltst_rand_u32()Thomas Haller2023-08-181-7/+1
| | | | | | | | | | | | | | srandom() and random() are a code smell, because they are not thread safe. Avoid its usage, even if this was only for testing. Even in testing code, we don't want to find those functions and have to reason why they are fine for testing. Just don't. Arguably, _nltst_rand_u32() calls jrand48(), which (in glibc) is possibly not thread-safe either. But that is only one place for investigation, instead of 3. Also, _nltst_rand_u32() honors NLTST_SEED_RAND to generate a reproducible sequence of random numbers.
* lib: fix error handling in nl_str2ip_proto()Thomas Haller2023-08-181-2/+2
|
* tests: check nl_str2ip_proto()Thomas Haller2023-08-181-0/+9
|
* clang-format: reformat files with new formatThomas Haller2023-08-173-8/+8
| | | | $ ./tools/clang-format.sh
* include: use <linux/$file> instead of <linux-private/linux/$file>Thomas Haller2023-08-0822-28/+28
| | | | | | As we now copy all linux headers, and we have include/linux-private in our include search path, just include the linux headers as we commonly do.
* include: don't explicitly include headers from "nl-default.h"Thomas Haller2023-08-037-17/+0
|
* tests: cleanup include of netlink headersThomas Haller2023-08-031-3/+2
| | | | | For no strong reason, we include the public netlink headers with <> instead of "". Be consistent.
* include: include private linux headers with explicit pathThomas Haller2023-08-0322-33/+30
| | | | | | | We have copies of the linux headers in include/linux-private. For those files, include the copies explicitly. No practice there is no difference, since we build with :-Ilinux-private".
* include: drop "netlink-private/netlink.h" and move declarationsThomas Haller2023-08-028-16/+0
|
* all: cleanup includes and use "nm-default.h"Thomas Haller2023-08-0234-66/+196
|
* include: split and drop "netlink-private/types.h"Thomas Haller2023-08-021-1/+1
| | | | | Move all the declarations from "netlink-private/types.h" to places closer to where they are used.
* include: rename "nl-intern-route" to "nl-priv-static-route"Thomas Haller2023-08-021-1/+1
| | | | | Naming is just so important to understand what this is. This name is better.
* lib: move "include/netlink-private/cache-api" to include/nl-shared-coreThomas Haller2023-08-011-2/+0
|
* route: move hidden symbols from "include/netlink-private/route/tc-api.h"Thomas Haller2023-08-011-1/+0
| | | | | | | | | | | To new header "include/nl-hidden-route/nl-hidden-route.h". libnl-route-3 exports some symbols that are no in public headers. They are however used by other internal users in the source tree. Such usage seems bad. We should clearly see where this is done. Move the symbols to a separate header, where it's clear who may use this header, and what's its purpose.
* include: move "include/netlink-private/route/utils.h" to nl-intern-routeThomas Haller2023-07-311-1/+1
| | | | | | | | | | | | | | | | This header has a very specific purpose. To give access to the unit tests to some internals. It only is usable to parts that statically link with libnl-route-3 sources (e.g. "tests/check-direct") and libnl-route-3 itself. The point is that the symbol there is not exported by the libnl-route-3 shared library, so a test that dynamically links against libnl-route-3 couldn't access them. Hence the internal purpose of static linking the test with libnl-route-3 sources, and a special header for that. Move "include/netlink-private/route/utils.h" to a separate place, to make that usage clearer.
* nl-aux: add "include/nl-aux-{core,route}" headersThomas Haller2023-07-315-4/+11
| | | | | | | | | | | | | | | | | | | We have "include/netlink-private/netlink.h", which is private API used internally. However, it's confusing where "include/netlink-private/netlink.h" can be used. For example, it contains some "libnl-route-3.so" specific extensions like "link_lookup()", hence you would think that it can only be used with libraries that also use "libnl-route-3.so". Well, since it's a header, you actually can also use it for example under "lib/xfrm/", you couldn't just use those declarations because they are implemented and accessible only under "lib/route/" In a first step to clean this up, and move helper to separate headers, add "include/nl-aux-{core,route}" headers with certain clear usage. Clear in the sense who may use those headers, and what the implementation of those headers may use.
* base: move "netlink-private/utils.h" to "base/nl-base-utils.h"Thomas Haller2023-07-314-4/+4
| | | | | | | | | | "base/nl-base-utils.h" (formerly "netlink-private/utils.h") contains no libnl3 specific references, just a bunch of C helpers. It's also a header-only "library", so it can be freely used by all our C-code. Move it to a separate directory, to make that clear.
* test-cache-mngr: Flush output after object dumpsBenjamin Poirier2023-07-241-0/+2
| | | | | | Flush stdout after object dumps to have complete and immediate output when stdout is not line buffered, such as when piping the test-cache-mngr output to grep.
* test-cache-mngr: Add option to print timestampsBenjamin Poirier2023-07-241-1/+26
| | | | The format is the same as `ip -ts monitor` so the two can be compared.
* test-cache-mngr: Add an option to iterate over all supported address familiesBenjamin Poirier2023-07-241-5/+20
| | | | | Useful for some caches with multiple families in co_groups, such as the "route/link" cache.
* test-cache-mngr: Add dump interval optionsBenjamin Poirier2023-07-241-7/+45
| | | | | Some problems are related to change callbacks and those are much easier to see when they're not mixed with the cache dump.
* test-cache-mngr: Add an option to control which oo_dump function is usedBenjamin Poirier2023-07-241-11/+49
| | | | Many problems are only apparent when printing at level "details".
* tests: add unit tests for creating linksThomas Haller2022-05-091-0/+213
| | | | | | Based-on-patch-by: Susant Sahani <susant@redhat.com> https://src.fedoraproject.org/rpms/libnl3/pull-request/4
* tests: add test utilsThomas Haller2022-05-094-6/+777
|
* tests: reformat unit test files with clang-formatThomas Haller2022-05-064-100/+108
|
* tests: silently ignore EACCES for setting uid_map for test namespaceThomas Haller2022-04-221-1/+9
| | | | | | | Seems this can happen, but we probably can just continue with the unit test. Just ignore the error. https://github.com/thom311/libnl/issues/308
* tests: cleanup unshare_user() and use _nltst_fclose()Thomas Haller2022-04-212-9/+20
|
* tests: add _assert_nltst_netns() helperThomas Haller2022-04-211-2/+10
|
* tests: add unit test for nl_object_clone() and nl_object_diff()Thomas Haller2022-03-163-2/+214
|
* tests: add new "netns" test suiteThomas Haller2022-03-163-4/+23
| | | | | This suite has fixture/teardown which creates a new netns for the test. No tests implemented yet.
* tests: add fixture/teardown for tests to run in separate netnsThomas Haller2022-03-162-0/+147
| | | | | | | | | | | | | We run the unit tests as non-root user, so usually we wouldn't have CAP_NET_ADMIN permissions to change networking. Also, we wouldn't want that our unit tests depend on the networking of the test host (or changes it). For each test, enter a new network namespace (and user/mnt namespace). There we will have the necessary permissions, and we are in full control of the things in the namespace. Note yet used.