summaryrefslogtreecommitdiffstats
path: root/tests/lib (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #4514 from opensourcerouting/warnings-20190612Donald Sharp2019-06-172-0/+8
|\ | | | | *: kill more warnings
| * *: config.h or zebra.h is the first #includeDavid Lamparter2019-06-132-0/+8
| | | | | | | | | | | | | | | | This is mostly relevant for Solaris, where config.h sets up some #define that affect overall header behaviour, so it needs to be before anything else. Signed-off-by: David Lamparter <equinox@diac24.net>
* | eliminate snprintf from AF_INET/AF_INET6 prefix2str, add prefix2str test (#4521)David Lamparter2019-06-142-0/+86
|\ \ | | | | | | eliminate snprintf from AF_INET/AF_INET6 prefix2str, add prefix2str test
| * | tests: add prefix2str testQuentin Young2019-06-132-0/+86
| | | | | | | | | | | | | | | | | | Only tests IPv4 and IPv6 right now. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* | | Merge pull request #4509 from opensourcerouting/spanish-intquisitionQuentin Young2019-06-131-0/+2
|\ \ \ | |/ / |/| | lib: make printfrr int64_t usable
| * | lib: make "%Ld" work for int64_tDavid Lamparter2019-06-121-0/+2
| |/ | | | | | | | | | | ... without compiler plugins. Signed-off-by: David Lamparter <equinox@diac24.net>
* / lib: const-unaware container_of for C++David Lamparter2019-06-111-0/+13
|/ | | | | | | | This version of container_of() should work on C++, by ditching the unavailable builtins (at the cost of no longer checking for "const" violations.) Signed-off-by: David Lamparter <equinox@diac24.net>
* tests: exercise frr_inet_ntop()David Lamparter2019-06-062-0/+93
| | | | Signed-off-by: David Lamparter <equinox@diac24.net>
* tests: exercise printfrr()David Lamparter2019-06-032-0/+154
| | | | Signed-off-by: David Lamparter <equinox@diac24.net>
* lib: Add '--command-log-always` to all daemons startupDonald Sharp2019-05-312-2/+2
| | | | | | | | | | | Add 'no log commands' cli and at the same time add a --command-log-always to the daemon startup cli. If --command-log-always is specified then all commands are auto-logged and the 'no log commands' form of the command is now ignored. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* tests: update list of headers in the cxx compat testRenato Westphal2019-05-211-0/+2
| | | | | | | Now, whenever a new header is added to libfrr, this test needs to be updated manually (unless we automate this somehow in the future). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* *: rename new ForEach macros from the typesafe APIRenato Westphal2019-05-212-7/+7
| | | | | | | | | This is necessary to avoid a name collision with std::for_each from C++. Fixes the compilation of the gRPC northbound module. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* tests: more datastructure testsDavid Lamparter2019-05-213-46/+106
| | | | | | A little something for everybody in here. Signed-off-by: David Lamparter <equinox@diac24.net>
* tests: extend DECLARE_* testsDavid Lamparter2019-05-213-11/+255
| | | | | | | The unsorted datastructures (LIST, DLIST) had no test before this. Also add a hash check (mostly to make testing the unsorted lists easier.) Signed-off-by: David Lamparter <equinox@diac24.net>
* tests: test DECLARE_HASH with good and bad hashfnDavid Lamparter2019-05-213-8/+26
| | | | | | | | The hash table test was previously (intentionally) using a bad hash function to test the code in the face of hash collisions. Add a test with a good hash function to see some performance numbers. Signed-off-by: David Lamparter <equinox@diac24.net>
* lib: hashing functions should take const argumentsQuentin Young2019-05-141-2/+2
| | | | | | | | | | It doesn't make much sense for a hash function to modify its argument, so const the hash input. BGP does it in a couple places, those cast away the const. Not great but not any worse than it was. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* Revert "lib: remove pqueue_*"David Lamparter2019-04-293-0/+3
| | | | This reverts commit 798ac49d06b6619adb4c5ac765b092397bc50a6c.
* lib: remove fifo implementationDavid Lamparter2019-04-271-1/+0
|
* lib: remove pqueue_*David Lamparter2019-04-273-3/+0
| | | | | | | All users of the pqueue_* implementations have been migrated to use TYPEDSKIP_* skiplists. Remove. Signed-off-by: David Lamparter <equinox@diac24.net>
* tests: exercise the typesafe list wrappersDavid Lamparter2019-04-273-0/+428
| | | | | | | | Since all of these list implementations provide almost the same API, we can run and validate them against the same test code. 9 tests for the price of one! Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: atomlist & atomsortDavid Lamparter2019-04-272-0/+410
| | | | | | | | These two are lock-free linked list implementations, the plain one is primarily intended for queues while the sorted one is for general data storage. Signed-off-by: David Lamparter <equinox@diac24.net>
* lib: add "seqlock" wait/broadcast primitiveDavid Lamparter2019-04-181-0/+122
| | | | | | | | | | Manually tested rather extensively in addition to included unit tests, should work as intended. NB: The OpenBSD futex() code is "future"; it's not actually in OpenBSD (yet?) and thus untested. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: remove event_counter.[ch]Quentin Young2019-04-031-1/+0
| | | | | | goodbye spooky code Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: use array_size instead of raw divisionQuentin Young2019-02-262-2/+2
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: return bool from boolean functionsQuentin Young2019-02-261-1/+1
| | | | | | Not 1 or 0. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: Rename backet to bucketTim Bray2019-02-251-4/+4
| | | | | | Presume typo from original author Signed-off-by: Tim Bray <tim@kooky.org>
* tests: add C++ header compatibility smoke testDavid Lamparter2019-02-121-0/+113
| | | | | | | | | | Compiling an empty C file with most headers included and -Wc++-compat gives us a build error if we introduce some stupid C++-incompatible change. While this won't catch everything, it's a good start. Signed-off-by: David Lamparter <equinox@diac24.net>
* Treewide: use ANSI function definitionsRuben Kerkhof2019-01-244-6/+6
| | | | Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
* lib, tests: add support for keyless YANG listsRenato Westphal2018-12-091-35/+0
| | | | | | | | | | | | | | | | | | | | | | YANG allows lists without keys for operational data, in which case the list elements are uniquely identified using a positional index (starting from one). This commit does the following: * Remove the need to implement the 'get_keys' and 'lookup_entry' callbacks for keyless lists. * Extend nb_oper_data_iter_list() so that it special-cases keyless lists appropriately. Since both the CLI and the sysrepo plugin use nb_oper_data_iterate() to fetch operational data, both these northbound clients automatically gain the ability to understand keyless lists without additional changes. * Extend the confd plugin to special-case keyless lists as well. This was a bit painful to implement given ConfD's clumsy API, but keyless lists should work ok now. * Update the "test_oper_data" unit test to test keyless YANG lists in addition to regular lists. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* Merge pull request #3452 from opensourcerouting/reprobuild-masterDonald Sharp2018-12-092-0/+3
|\ | | | | [master] build reproducibility
| * tests: fix domainname dependencyDavid Lamparter2018-12-072-0/+3
| | | | | | | | | | | | | | | | These are causing random test failures when the host's domainname is actually set to something (as opposed to empty/unset, which it is 99% of times.) Signed-off-by: David Lamparter <equinox@diac24.net>
* | lib: add support for confirmed commitsRenato Westphal2018-12-073-3/+3
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Confirmed commits allow the user to request an automatic rollback to the previous configuration if the commit operation is not confirmed within a number of minutes. This is particularly useful when the user is accessing the CLI through the network (e.g. using SSH) and any configuration change might cause an unexpected loss of connectivity between the user and the managed device (e.g. misconfiguration of a routing protocol). By using a confirmed commit, the user can rest assured the connectivity will be restored after the given timeout expires, avoiding the need to access the router physically to fix the problem. When "commit confirmed TIMEOUT" is used, a new "commit" command is expected to confirm the previous commit before the given timeout expires. If "commit confirmed TIMEOUT" is used while there's already a confirmed-commit in progress, the confirmed-commit timeout is reset to the new value. In the current implementation, if other users perform commits while there's a confirmed-commit in progress, all commits are rolled back when the confirmed-commit timeout expires. It's recommended to use the "configure exclusive" configuration mode to prevent unexpected outcomes when using confirmed commits. When an user exits from the configuration mode while there's a confirmed-commit in progress, the commit is automatically rolled back and the user is notified about it. In the future we might want to prompt the user if he or she really wants to exit from the configuration mode when there's a pending confirmed commit. Needless to say, confirmed commit only work for configuration commands converted to the new northbound model. vtysh support will be implemented at a later time. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib, tests: major rework in the operational-data callbacksRenato Westphal2018-11-264-0/+590
| | | | | | | | | | | | | | | | | | | | | | | | The northbound infrastructure for operational data was subpar compared to the infrastructure for configuration data. This commit addresses most of the existing problems, making it possible to write operational-data callbacks for more complex YANG models. Summary of the changes: * Add support for nested YANG lists. * Add support for leaf-lists. * Add support for leafs of type "empty". * Introduce the "show yang operational-data XPATH" command, and write an unit test for it. The main purpose of this command is to make it easier to test the operational-data northbound callbacks. * Introduce the nb_oper_data_iterate() function, that can be used to iterate over operational data. Make the CLI and sysrepo use this function. * Since ConfD has a very peculiar API, it can't reuse the nb_oper_data_iterate() like the other northbound clients. In this case, adapt the existing ConfD callbacks to support the new features (and make some performance improvements in the process). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* tests: fix warning related to change in the hash APIRenato Westphal2018-11-261-1/+1
| | | | | | The hash_cmp functions need to return bool since commit 74df8d6d9d6. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: Implement an allocator for 32 bit ID numbersMitch Skiba2018-11-092-0/+199
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit introduces lib/id_alloc, which has facilities for both an ID number allocator, and less efficient ID holding pools. The pools are meant to be a temporary holding area for ID numbers meant to be re-used, and are implemented as a linked-list stack. The allocator itself is much more efficient with memory. Based on sizeof values on my 64 bit desktop, the allocator requires around 155 KiB per million IDs tracked. IDs are ultimately tracked in a bit-map split into many "pages." The allocator tracks a list of pages that have free bits, and which sections of each page have free IDs, so there isn't any scanning required to find a free ID. (The library utility ffs, or "Find First Set," is generally a single CPU instruction.) At the moment, totally empty pages will not be freed, so the memory utilization of this allocator will remain at the high water mark. The initial intended use case is for BGP's TX Addpath IDs to be pulled from an allocator that tracks which IDs are in use, rather than a free running counter. The allocator reserves ID #0 as a sentinel value for an invalid ID numbers, and BGP will want ID #1 reserved as well. To support this, the allocator allows for IDs to be explicitly reserved, though be aware this is only practical to use with low numbered IDs because the allocator must allocate pages in order. Signed-off-by Mitchell Skiba <mskiba@amazon.com>
* lib: introduce new northbound APIRenato Westphal2018-10-273-0/+10
| | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: add libunwind support for backtracesDavid Lamparter2018-10-181-1/+30
| | | | | | | | | | | | | | libunwind provides an alternate to backtrace() for printing out the call stack of a particular location. It doesn't use the frame pointer, it goes by the DWARF debug info. In most cases the traces have exactly the same information, but there are some situations where libunwind traces are better. (On some platforms, the libc backtrace() also uses the DWARF debug info [e.g.: ARM backtraces are impossible without it] but this is not the case everywhere, especially not on BSD libexecinfo.) Signed-off-by: David Lamparter <equinox@diac24.net>
* bgpd lib ospf6d pbrd tests zebra: shadowing fixesF. Aragon2018-09-132-4/+3
| | | | | | This fixes all remaining local variable shadowing cases Signed-off-by: F. Aragon <paco@voltanet.io>
* tests: properly locate files in builddirDavid Lamparter2018-09-081-0/+1
| | | | | | | test_cli.refout is written by configure into the build directory, thus we need a little special glue to find it correctly. Signed-off-by: David Lamparter <equinox@diac24.net>
* build: non-recursive testsDavid Lamparter2018-09-081-1/+1
| | | | | | May SUBDIRS rest in pieces... er, peace. Signed-off-by: David Lamparter <equinox@diac24.net>
* isisd, ospfd, tests: Switch to using stream_resize_inplaceDonald Sharp2018-08-221-1/+1
| | | | | | Switch code and tests to use new stream_resize_inplace functionality. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: use frr_elevate_privs() (2/2: manual)David Lamparter2018-08-141-8/+6
| | | | Signed-off-by: David Lamparter <equinox@diac24.net>
* tests: Cleanup assumption that ALLOC could fail.Donald Sharp2018-08-112-23/+5
| | | | Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* tests: Fix const changeDonald Sharp2018-07-251-1/+2
| | | | | | | Some of the parameters for lib/srcdest.. have changed to consts, make the test cases respect that. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* tests: align with srcdest lib changes, remove bgp binaryMark Stapp2018-07-121-8/+9
| | | | | | | | Align the srcdest table test with recent api changes that use 'const' more strictly. Remove test_bgp_table binary - looks as if it was committed by mistake. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* eigrpd, lib, tests, vtysh: security (cppcheck)paco2018-06-191-3/+1
| | | | Signed-off-by: F. Aragon <paco@voltanet.io>
* babeld, lib, ospfd, tests: fmt fixes (cppcheck)paco2018-06-183-4/+4
| | | | Signed-off-by: F. Aragon <paco@voltanet.io>
* lib: add string utilitiesQuentin Young2018-06-061-2/+2
| | | | | | | | I see lots of the same code being copy-pasted and slightly tweaked for string processing all over the codebase. Time to start aggregating these pieces into something consistent and correct. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib: add DFS + DOT dumping to graph datastructureQuentin Young2018-04-193-0/+145
| | | | | | | | * Add general-purpose DFS traversal code * Add ability to dump any graph to DOT language * Add tests for graph datastructure Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: use C99 standard fixed-width integer typesQuentin Young2018-03-271-48/+48
| | | | | | | | | | | | | | | | | | | | | | The following types are nonstandard: - u_char - u_short - u_int - u_long - u_int8_t - u_int16_t - u_int32_t Replace them with the C99 standard types: - uint8_t - unsigned short - unsigned int - unsigned long - uint8_t - uint16_t - uint32_t Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>