summaryrefslogtreecommitdiffstats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* tests: cleanup creating test suitesThomas Haller2022-03-164-20/+20
|
* tests: refactor tests and add n-test-util helper libraryThomas Haller2022-03-168-11/+27
| | | | | | | | | | | | | | - we have "check-all.c" and "check-direct.c", which contains the main functions of the actual tests. On the other hand, the other "check-{addr,attr,ematch-tree-clone}.c" files only contained the test suites for "check-all.c". Rename the latter to have a separate name prefix. - rename "tests/util.h" to "tests/cksuite-all.h". It's really the header that declares all the suites. - add a "tests/nl-test-util.c" as a static helper library with test code.
* tests: add test for cloning cls:u32 objectThomas Haller2022-03-041-4/+50
|
* tests: cleanup tests and avoid leaksThomas Haller2022-03-041-12/+10
| | | | | | | It's important to have no leaks in tests. Otherwise, we cannot distinguish irrelevant leaks from actual bugs in valgrind. Do some cleanup.
* tests: replace libcheck's fail_if() macro by ck_assert*()Thomas Haller2022-03-043-25/+21
| | | | | | fail_if() is deprecated. See also commit 3d1fb006c859 ('tests/check-addr: replace deprecated fail_if() macro from libcheck with ck_assert_msg()').
* tests/check-addr: replace deprecated fail_if() macro from libcheck with ↵Thomas Haller2022-03-031-40/+40
| | | | | | | | | ck_assert_msg() fail_if() is long deprecated. Worse, it triggers a "-Wformat-extra-args" warning due to a trailing NULL. See [1]. [1] https://github.com/libcheck/check/commit/82540c5428d3818b64d6a8aefb601e722520651f
* tests: Add test for rtnl_addr_flags2strLeonard Crestez2020-12-141-0/+16
| | | | Signed-off-by: Leonard Crestez <cdleonard@gmail.com>
* route: add test for valid content of map_stat_id_from_IPSTATS_MIB_v2 arrayThomas Haller2020-04-161-0/+32
| | | | | When updating the linux header, it's easy to miss updating the type mapping. Add a test to avoid that.
* tests: add "check-direct" testThomas Haller2020-04-161-0/+34
| | | | | | | We already have check-all unit test, which links dynamically to the libraries. That means, certain symbols won't be accessible, because they are hidden by the linker symbol versioning file. Add "check-direct", which links statically against the libraries.
* gitignore: merge all gitignore files in top level directoryThomas Haller2020-04-161-33/+0
| | | | | | | The source tree of libnl3 is fairly simple. We can afford thinking and reasoning about it as one. Don't spread out the .gitignore files, instead ignore all files consistently via the ignore file in the top level directory.
* license: fix and add SPDX license identifiers and drop license commentsThomas Haller2020-04-165-35/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This also fixes a few wrong SPDX license identifiers, where the original license comment indicates GPL-2.0-only. This is not done manually, but by running the following script: --- #!/bin/bash # Tool to drop license comments, adding SPDX license identifiers, while preserving # copyright comments. The point is not to manually do this task, but perform some # hacked up string replacement. _cp() { /bin/cp "$@" } _cat() { /bin/cat "$@" } in_file() { local T=$(mktemp) _cp -f "$1" "$T" _cat "$T" rm -f "$T" } out_file() { local T=$(mktemp) _cat - > "$T" _cp -f "$T" "$1" rm -f "$T" } join() { _cat "$@" | awk '{ printf("%s#x#", $0)}' } unjoin() { _cat - | sed 's/#x#/\n/g' } files_all() { git ls-files | grep -v '\.png$' | grep -v '^include/linux-private/' } adjust() { NEWLINES='\(#x#\)\+' COPYRIGHTS='\(\( \* Copyright (c) 20..\(-20..\|, 20..\)\? [^#]\+#x#\)\+\( \*#x# \* \(Stolen[^#]*\|Based on [^#]*\)#x#\)\?\)' _cat - | \ sed '1s%^\(/\* SPDX-License-Identifier: LGPL-2.1-only \*/\|\)#x#/\*#x# \* [^#]*#x# \*#x# \*[ ]\+This library is free software; you can redistribute it and/or#x# \*[ ]\+modify it under the terms of the GNU Lesser General Public#x# \*[ ]\+License as published by the Free Software Foundation version 2.1#x# \*[ ]\+of the License.#x# \*#x#'"$COPYRIGHTS"' \*/'"$NEWLINES"'%/\* SPDX-License-Identifier: LGPL-2.1-only \*/#x#/*#x#\2 */#x##x#%' | \ sed '1s%^/\*#x# \* [^#]*#x# \*#x# \*[ ]\+This library is free software; you can redistribute it and/or#x# \*[ ]\+modify it under the terms of the GNU Lesser General Public#x# \*[ ]\+License as published by the Free Software Foundation version 2.1#x# \*[ ]\+of the License.#x# \*/'"$NEWLINES"'%/\* SPDX-License-Identifier: LGPL-2.1-only \*/#x##x#%' | \ sed '1s%^\(\)/\*#x# \* [^#]*#x# \*#x# \*[ ]\+This library is free software; you can redistribute it and/or#x# \*[ ]\+modify it under the terms of the GNU Lesser General Public#x# \*[ ]\+License as published by the Free Software Foundation version 2.1#x# \*[ ]\+of the License.#x# \*#x#'"$COPYRIGHTS"' \*/'"$NEWLINES"'%/\* SPDX-License-Identifier: LGPL-2.1-only \*/#x#/*#x#\2 */#x##x#%' | \ sed '1s%^\(/\* SPDX-License-Identifier: LGPL-2.1-only \*/\|\)#x#/\*#x# \* [^#]*#x# \*#x# \*[ ]\+This library is free software; you can redistribute it and/or#x# \*[ ]\+modify it under the terms of the GNU General Public License as#x# \*[ ]\+published by the Free Software Foundation version 2 of the License.#x# \*#x#'"$COPYRIGHTS"' \*/'"$NEWLINES"'%/\* SPDX-License-Identifier: GPL-2.0-only \*/#x#/*#x#\2 */#x##x#%' } FILES=( $(files_all) ) for f in "${FILES[@]}"; do echo "processing \"$f\"..." in_file "$f" | join | adjust | unjoin | out_file "$f" done
* license: cleanup copyright commentsThomas Haller2020-04-161-2/+2
| | | | Manually make copyright comments in a consistent format.
* xfrmi: introduce XFRM interfaces supportEyal Birger2019-09-012-0/+50
| | | | | | | XFRM interfaces were introduced in kernel 4.19. This commit adds link support for these interfaces. Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
* tests: use nl_send_auto() instead of deprecated nl_send_auto_complete() in ↵Byeonggon Lee2019-08-071-1/+1
| | | | | | test-genl.c https://github.com/thom311/libnl/pull/213
* Add support for cloning cgroup filter object.d0u92018-06-253-0/+145
| | | | | | | | | | | In this commit, we implement ematch_tree_clone(), which is basis of cgroup_clone() interface. The whole ematch tree is deep-copied except the e_ops filed. Also, a new unit test is added for testing the interface, which named as check-ematch-tree-clone.c located in tests directory. https://github.com/thom311/libnl/pull/176
* lib/rtnl: rename public define RTNL_GENEVE_ID_MAXThomas Haller2018-02-121-0/+2
| | | | | Public defines must have a libnl3 related prefix. Rename GENEVE_ID_MAX to RTNL_GENEVE_ID_MAX.
* link: add Geneve support.Wang Jian2018-02-121-0/+87
| | | | Signed-off-by: Wang Jian <jianjian.wang1@gmail.com>
* tests: Add test to {de}activate loopback interfaceMarcos Paulo de Souza2018-01-161-0/+54
| | | | | | | | | | This tests is much more like an example of how to do it, and also works as a test to check if rtnl_link_change is working as expected when it comes to loopback interface. Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com> https://github.com/thom311/libnl/pull/161