summaryrefslogtreecommitdiffstats
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* util: Use standard ether functions for conversionWilliam A. Kennington III2019-04-091-1/+1
| | | | | | | | This should be slightly faster and is more standard for interop with other programs using the same conversion functions. Change-Id: I4d7a2cb4df2173afda421c5b41ee5e98e722d6c6 Signed-off-by: William A. Kennington III <wak@google.com>
* test: rtnetlink: use manager interface queryPatrick Venture2019-03-122-11/+2
| | | | | | | | Use the new interface query method provided by manager to know if the interface was added instead of inspecting the manager itself. Change-Id: I94600199fd60a014d6b376155555449f7af617f5 Signed-off-by: Patrick Venture <venture@google.com>
* test: use mocked sdbus interface for sdbusplusPatrick Venture2019-03-051-2/+3
| | | | | | | | | | | | | Use mocked sdbus interface for sdbusplus such that it doesn't require talking to the real dbus interfaces. The warnings for the unexpected calls on the sdbus interface can be ignored in the cases for this test as returning 0 is the desired behavior. The warnings can be trivially handled by expecting the calls, or setting up "ON_CALL" statements. Change-Id: I8c72eaec957fb6a68eeaac982c1f45998487c35f Signed-off-by: Patrick Venture <venture@google.com>
* test: use system-first search for dbus interfacesPatrick Venture2019-02-182-2/+2
| | | | | | | Use system-first search for inclusion of dbus interface headers. Change-Id: I9953ca047c09c1003c86b1ffaf929698c157139c Signed-off-by: Patrick Venture <venture@google.com>
* test: use expect_throw to catch expected exceptionsPatrick Venture2019-02-181-11/+1
| | | | | | | Use expect_throw to catch expected exceptions in tests. Change-Id: I410655a43328d44c5b9f95dff509c132499bcd07 Signed-off-by: Patrick Venture <venture@google.com>
* test: use real manager object for testingPatrick Venture2019-02-182-18/+5
| | | | | | | | Use the real manager object for testing the manager object instead of a derived object. Change-Id: I3b4a401d43457bffb22de8fac5e29b2e2887c6c6 Signed-off-by: Patrick Venture <venture@google.com>
* util: Add a MacAddr population functionWilliam A. Kennington III2019-02-141-0/+13
| | | | | | | | | | | | This one is pretty trivial since there is only one size of mac address, but we want to be sure we validate the buffer. Tested: Built and runs through unit tests. Works when integrated into neighbor parsing code. Change-Id: Iaf58fc398b51a3bcbbf70968cbe353beeb7b9f54 Signed-off-by: William A. Kennington III <wak@google.com>
* util: Add InAddrAny population functionWilliam A. Kennington III2019-02-141-0/+24
| | | | | | | | | | | | We commonly want to be able to turn netlink network order address data into the corresponding InAddrAny when parsing netlink data. This makes it trivial given the address family and data buffer. Tested: Ran throgh unit tests and builds fine in a BMC image. Change-Id: I4ebe1dbd284f150ea03ee091cddda5a06806c01f Signed-off-by: William A. Kennington III <wak@google.com>
* util: Add a function for converting IP bytes to stringsWilliam A. Kennington III2019-02-141-0/+30
| | | | | | | | | | We need this for future work which turns netlink data into IP addresses. Tested: Run through unit tests. Change-Id: If078b28246509ca2ebd3bf7bab652b84258df0bd Signed-off-by: William A. Kennington III <wak@google.com>
* util: Add a function for converting MAC addressesWilliam A. Kennington III2019-02-141-0/+22
| | | | | | | | | | | We need to be able to convert a mac addresses from byte form into our typical human readable string form. Tested: Unit tests pass. Change-Id: I6e68cfefd4d5962e1125c1b5229e61fce475729a Signed-off-by: William A. Kennington III <wak@google.com>
* Re-enable unit testRatan Gupta2018-11-307-17/+51
| | | | | | | | | | | | Unit test were broken after sd bus calls started throwing exception, In this repo we start the systemd-networkd with the use of sd bus calls, which throws exception and it was not handled in the test case. This commit fixes the problem by mocking the network manager which mock the functionality of function which makes the sdbus call. Change-Id: I5b60a2117a661cffa36200415ca611b85dd2fda1 Signed-off-by: Ratan Gupta <ratagupt@linux.vnet.ibm.com>
* Migrate to a common timer classWilliam A. Kennington III2018-09-273-6/+7
| | | | | | | | | | | | This change pulls in sdeventplus and uses the timer implementation as a drop in for the currently included timer. Tested: Unit tests still build but are not currently running. Manually tested this change on a zaius machine and made sure timers went off. Change-Id: I2808196581fc766843931403b83fead16926b0ae Signed-off-by: William A. Kennington III <wak@google.com>
* clang-format: Update to match docs repoGunnar Mills2018-09-159-456/+405
| | | | | | | | | Update the .clang-format file and run clang-format-6.0. This .clang-format matches the example one in https://github.com/openbmc/docs/blob/master/cpp-style-and-conventions.md#clang-formatting Change-Id: Ia331c9a5b040e1a3c45a0ebf1b8d776d93b05ae5 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
* reorder headersPatrick Venture2018-08-271-1/+0
| | | | | | | | | | | | | | | | | | Reordering all the headers to the following structure: header file: local c cpp (including openbmc libraries) source file: source.hpp (if applicable) local c cpp Change-Id: Ia74a5c761a3029819366159de3cfd40c5e4c4a2c Signed-off-by: Patrick Venture <venture@google.com>
* test: Change tmp file names to fix racesAndrew Jeffery2018-03-153-5/+6
| | | | | | | | | | | | | | With MAKEFLAGS=-jN for N > 1 we hit race conditions in the test suite. Multiple independent tests use the same absolute path under /tmp for test case IO. This leads to corruption across the tests manifesting as intermittent failures. Make the file-names semi-unique. This solution is poor in that it makes no attempt at ensuring the file names are absolutely unique, but they are at least unique wither respect to the other test file names, which is an improvement. Change-Id: I6b312093a2d9cd52261d02821566b69e874e7770 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* test_rtnetlink: Increase interations in WithSingleInterfaceAndrew Jeffery2018-03-151-1/+1
| | | | | | | | | | | | | We were hitting test failures caused by EXPECT_EQ(true, isInterfaceAdded("igb5")); at the end of the WithSingleInterface case. There appears to be a race condition between the netlink handling and the timer expiry, so increment the number of retries for test stability. Change-Id: I6cd2e4e95ee4d183466c73fa8a36a5580f566227 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* test_rtnetlink: Improve exception handling by not handling themAndrew Jeffery2018-03-151-36/+27
| | | | | | | | | All the test was doing was verifying that an exception hadn't occurred. The test would fail if one had, so we're better off just not doing the dance. Change-Id: Iff7d9e4947e86b24f4cf99ddbac3e9c42e63f1d3 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* test_rtnetlink: Force bus object to outlive TestRtNetlink lifetimeAndrew Jeffery2018-03-151-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We were hitting a SEGFAULT by nullptr dereference in the WithSingleInterface test when calling sd_bus_ref() via the timer callback with code generated at -O2 from Ubuntu Artful's gcc-7.2.0: Running main() from gtest_main.cc Note: Google Test filter = TestRtNetlink.WithSingleInterface [==========] Running 1 test from 1 test case. [----------] Global test environment set-up. [----------] 1 test from TestRtNetlink [ RUN ] TestRtNetlink.WithSingleInterface ASAN:DEADLYSIGNAL ================================================================= ==19427==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f8a944922ca bp 0x0fffd7e37fc2 sp 0x7ffebf1bfda8 T0) ==19427==The signal is caused by a READ memory access. ==19427==Hint: address points to the zero page. #0 0x7f8a944922c9 in sd_bus_ref (/lib/x86_64-linux-gnu/libsystemd.so.0+0x2e2c9) #1 0x7f8a93a5c616 in sdbusplus::bus::bus::bus(sd_bus*) /usr/local/include/sdbusplus/bus.hpp:340 #2 0x7f8a93a5c616 in sdbusplus::server::interface::interface::interface(sdbusplus::bus::bus&, char const*, char const*, sd_bus_vtable const*, void*) /usr/local/include/sdbusplus/server/interface.hpp:61 ... #16 0x559d611755e7 in phosphor::network::Manager::createInterfaces() ../network_manager.cpp:151 #17 0x559d61178e12 in phosphor::network::Manager::createChildObjects() ../network_manager.cpp:166 #18 0x559d611ed59b in std::function<void ()>::operator()() const /usr/include/c++/7/bits/std_function.h:706 #19 0x559d611ed59b in phosphor::network::Timer::timeoutHandler(sd_event_source*, unsigned long, void*) ../timer.cpp:72 #20 0x7f8a9448e80d (/lib/x86_64-linux-gnu/libsystemd.so.0+0x2a80d) #21 0x7f8a944903e9 in sd_event_dispatch (/lib/x86_64-linux-gnu/libsystemd.so.0+0x2c3e9) #22 0x7f8a94490566 in sd_event_run (/lib/x86_64-linux-gnu/libsystemd.so.0+0x2c566) #23 0x559d610e122e in phosphor::network::TestRtNetlink_WithSingleInterface_Test::TestBody() /tmp/openbmc-build-scripts.wUcrvx/phosphor-networkd/test/test_rtnetlink.cpp:135 ... AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV (/lib/x86_64-linux-gnu/libsystemd.so.0+0x2e2c9) in sd_bus_ref ==19427==ABORTING Move the bus storage to namespace scope alongside the Manager to avoid it getting cleaned up before the callback fires. Change-Id: I3126d0b7b92fb6e66d82f9e32b43a52e44356884 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
* Reduce journal logsRatan Gupta2018-03-153-36/+34
| | | | | | | | | | | | | | | | | | | | Presently the code was creating the elog during reading of the values from the config parser which creates the journal log internally("Internal error Occured") Apart from creating elog,Code also logs into the journal more descriptive message saying which section and key was not found. The code which catches the exception that also logs into the journal. In the changed approach instead of throwing exception we are returning the return code as not finding a section or key in the network config file is not an error. Change-Id: Ib89a3af6541fdf93fb5fa9a8e583d6c6ed88da79 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
* Added new unit testcasesNagaraju Goruganti2018-01-304-3/+233
| | | | | | | | | | 1. Added testcases to validate IP/PrefixLengnth/MACAddress. 2. Added test to rtnetlink. Resolves openbmc/openbmc#2546 Change-Id: I61efbf69682a50f7479b68e32d9714e9c81a32d7 Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
* Test: Add test cases for static DNS processingRatan Gupta2017-11-071-0/+34
| | | | | | | Fixes openbmc/openbmc#2107 Change-Id: Id6810be3527e4861430077364a5af4dc00e52f3b Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
* Integrate inotify watcher into network daemonVishwanatha Subbanna2017-10-241-1/+1
| | | | | | | | | This commit integrates watching for DNS entries and updating /etc/resolv.conf functionality into network manager daemon as opposed to having another daemon doing just that. Change-Id: Id858815675ed4a23ee8c6a31ba3ae6e5ee0054fd Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
* Add inotify watch supportVishwanatha Subbanna2017-10-242-1/+97
| | | | | | | | Added code to register for inotify events on the needed path and the user callback on events Change-Id: I90529f8e96fcbecfe0a1b943c3c435dab79222c3 Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
* Add function to write DNS entriesVishwanatha Subbanna2017-10-242-13/+103
| | | | | | | | Added function to write DNS entries to specified file Also, added test case Change-Id: I64250c7ee3cf7db3e7f8b5cf1669c7b4a7738637 Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
* IP Address use case validationNagaraju Goruganti2017-10-111-4/+13
| | | | | | | | | | | -validates IPAddress/gateway using inet_pton api. -validates prefix length for ipv4/ipv6. -if dhcp is enabled, it won't allow to set ip/gateway. Resolves openbmc/openbmc#1671 Change-Id: I76c1d9d11dfb59002eb1310d87e94ee622714a4a Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
* Test: Add test cases for NTPRatan Gupta2017-10-111-1/+13
| | | | | | | Resolves openbmc/openbmc#2106 Change-Id: I93bbbb1178dc47fa94f98719185630020e00edda Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
* Reduce the number of restarts of systemd-networkdRatan Gupta2017-10-111-1/+3
| | | | | | | | | | | | | Start the timer once we get the dbus request and wait for timeout if we get the dbus request in meanwhile, reset the timer and wait for timeout. Listen for ipv6 rtnetlink address also. Resolves openbmc/openbmc#2227 Change-Id: I3f448e84107826defafb9ada523c1ab08ec1b971 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
* Restart the network through networkManagerRatan Gupta2017-10-032-0/+3
| | | | | | | | | | | | | | | Extend the refresh timer once we get the Dbus request which requires network restart. Detaching the network restart from the writeConfiguration func. Write the configuration file for the vlan interface in writeConfiguration func. During creation of vlan,vlan interface should come up with dhcp as false. Change-Id: Iadc7b44554aca412d211d13e9569cc601ad04074 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
* Add test cases for VlanInterfaceRatan Gupta2017-08-132-4/+202
| | | | | Change-Id: Ifd2507b12f39c44857af8bcf6ea57f7d1daa7ac3 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
* Move the implementation for writing conf to interface classRatan Gupta2017-08-131-1/+3
| | | | | | | | implementation of writing interface conf to the ethernet interface class. Change-Id: I279afff45a82ca92c4e50810664f7a7c69a66a61 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
* Create the VLAN Interface ObjectRatan Gupta2017-08-131-0/+1
| | | | | Change-Id: I118fc4bbcad2a478a8aad976e0619537780c1227 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
* Pass the network conf dir to network manager constructorRatan Gupta2017-08-132-4/+44
| | | | | | | | | when the network manager comes up,it should have its conf dir path which caller wants,instead of calling one more function to set the desired conf dir. Change-Id: I282c1d5e1c6edb2b6e77d16518d2204a6ac41a45 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
* Implement the Vlan InterfaceRatan Gupta2017-08-131-0/+1
| | | | | Change-Id: I6085868ba4e30bb9e1c6f6d9895a40ebff82804f Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
* Convert the .cpp to .o in test makefile ldaddRatan Gupta2017-08-131-9/+9
| | | | | | | | | As compiler was not able to pick the override function definition. Make works fine but make check was having problem. Change-Id: I030b89065c2929019e36f8d30f6103289cd07344 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
* Implement the DHCP configuration interfaceRatan Gupta2017-07-251-0/+1
| | | | | | | | | | This commit implements the below dhcp options 1) DNS 2) NTP 3) HostName Change-Id: Ifb66fbc86ce38abc79454ecbbf6fb3c65f892c19 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
* Implement the INI config parserRatan Gupta2017-06-212-1/+101
| | | | | | | | Parse the systemd.network file to get the configuration parameter. Change-Id: Ic9c15a46158d2f1c0948e6eca729663e87051491 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
* Create the system conf Dbus ObjectRatan Gupta2017-06-211-0/+1
| | | | | | | | Also put extra checks while writing the gateway and the destination to the conf file. Change-Id: I8f24b3f293e6f978b655f061a198a32690dd44f3 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
* Implement the ipaddress origin and gateway propertyRatan Gupta2017-06-091-0/+2
| | | | | | | Resolves openbmc/openbmc#1590 Change-Id: I76328e596336f8b8f1394b1927d48ce52f819a66 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
* Fetch the network portion of the IP addressRatan Gupta2017-06-082-2/+29
| | | | | | | eg 192.168.2.24/24 ==> 192.168.2.0 Change-Id: I5e46ce7b371360c90ef74fac175c8379c6f31d4c Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
* test: add test cases for ethernet interfaceRatan Gupta2017-06-082-1/+153
| | | | | Change-Id: Ibf3a2b3513c784a56540488fa7de5a638a83a833 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
* test: Add test cases for network managerRatan Gupta2017-06-084-4/+209
| | | | | | | Resolves openbmc/openbmc#1462 Change-Id: Ib4cb6fc52dca05c9af38fe5197d9d7dff2031af7 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
* test: Add unit test cases for utilRatan Gupta2017-06-082-0/+107
Change-Id: I75cc1c1642bd4160191853d6ebfa5427e7f534c3 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
OpenPOWER on IntegriCloud