summaryrefslogtreecommitdiffstats
path: root/test/message
Commit message (Collapse)AuthorAgeFilesLines
* native_types: Fix string_wrapper overloadsWilliam A. Kennington III2019-06-141-0/+19
| | | | | | | | | | We should only coalesce to an r-value reference to our internal string if our object is a move reference. This fixes ambiguous overloads with gcc9. This also ensures that const references cannot be ambiguous with move references by requiring a const volatile reference. Change-Id: I31ed529c015cc311c9933acbc0f0a4aa50fed3a6 Signed-off-by: William A. Kennington III <wak@google.com>
* std::variant: Remove uses of the variant_nsWilliam A. Kennington III2019-04-052-22/+20
| | | | | | | | | | | Now that we are using std::variant we should reference it directly instead of using our own namespace alias. Tested: Built and ran through unit tests. Change-Id: Ic3fd62ea74cf808b85ad7b7ffcce8c0a0bfb125d Signed-off-by: William A. Kennington III <wak@google.com>
* message: Fix variant api usageWilliam A. Kennington III2018-10-052-6/+10
| | | | | | | | | | | This makes our use of the mapbox variant consistent with std::variant. We need this cleanup for the conversion to std::variant. Tested: Ran unit tests to make sure they still pass. Change-Id: I990013eaaa2ec27f2fda71bfadd9a5369d50c187 Signed-off-by: William A. Kennington III <wak@google.com>
* clang-format: Fix pointer alignmentWilliam A. Kennington III2018-08-312-55/+54
| | | | | | | | | | Oenbmc documentation specifies a left alignment for pointers. Our current format tries to left align if neither alignment is strictly followed, but will allow right aligned files to exist. Lets make this more strict so that all of our files are consistent. Change-Id: I3a50043d28a9c25d0cf1ffb752800d05eb7615e1 Signed-off-by: William A. Kennington III <wak@google.com>
* clang-format: always break template declarationsPatrick Venture2018-08-313-3/+6
| | | | | | | To better match the defined openbmc style. Change-Id: I68cda43857768bae4c904c367942cb1f0efa3e0c Signed-off-by: Patrick Venture <venture@google.com>
* update .clang-format header inclusion orderPatrick Venture2018-08-314-10/+16
| | | | | | | | Added the header inclusion order to the .clang-format file generated these changes. Change-Id: Ia31b21d7ea451cac0309828006bc17c27cbd5bd5 Signed-off-by: Patrick Venture <venture@google.com>
* test/message/read: Test that our error handling cases workWilliam A. Kennington III2018-07-091-6/+236
| | | | | | | | | | | | This improves our test coverage of sd_bus_message read functionality to 100%. Tested: Ran through the usual unit test scripts including valgrind and code coverage. Change-Id: Ifa849d05364349e27e39c6dda5e4cab4efa35476 Signed-off-by: William A. Kennington III <wak@google.com>
* test/message/read: Add missing variant skipWilliam A. Kennington III2018-07-091-0/+18
| | | | | | | | | | | | | We were missing a test of the variant code which is used when the type of the variant provided by the caller does not contain the type needed at runtime to store the data in the message. This tests to make sure that the skip is issued correctly when we can't read out the member. Tested: Unit tests still build and pass Change-Id: I41fdc3e40589f1feedfadc3ab33fe808ff3a6d16 Signed-off-by: William A. Kennington III <wak@google.com>
* test/message/read: Use googletest and mocksWilliam A. Kennington III2018-07-091-431/+300
| | | | | | | | | | | | | | | | Similar to the append test, this test case relied on an ad-hoc system using a separate daemon thread for echoing the messages back to each of the unit tests. We don't want to depend on a system dbus instance if we can avoid it. Instead, use the mocking system to make sure the correct dbus calls are made when reading messages and ensure the resulting output is built as expected. Tested: Build still works and all test cases pass. Ensured that the coverage of the tests is the same as the old test cases. Change-Id: I8d71c031391b962f1de6684d927b81e132c0886d Signed-off-by: William A. Kennington III <wak@google.com>
* test/message/append: Use googletest and mocksWilliam A. Kennington III2018-07-091-604/+305
| | | | | | | | | | | | | | | | | | | | | The current test case depends on the system running a dbus daemon that our test case can register and run a service with. It runs in multiple threads and requires using raw sd_bus_message calls to determine if the appends worked correctly. When systemd 237 becomes the minimum version we could rely on message sealing and other new public members to deal with the daemon issues. However, it will be a while before we can make that the default version. Lets mock out the expectations for the underlying sd_bus_message calls to validate that we will build correct objects when using our message.append() calls. Tested: Converted the tests from the old test cases to this new format keeping very similar test functionality. Tests still pass. Change-Id: Iafc8662389fe60ca2d519abfe472c61292f3239a Signed-off-by: William A. Kennington III <wak@google.com>
* tests: Write our own assert()William A. Kennington III2018-06-272-152/+177
| | | | | | | | | | | | | | | | The cassert `assert()` function is only provided when NDEBUG is not defined. Otherwise `assert()` becomes a no-op breaking our test cases. Since we rely on the behavior of assert to validate the tests, we always want to provide one for the test implementation. This functionality will be useful once code coverage is added since that forces NDEBUG to be passed to the preprocessor. Tested: Test cases still work correctly if unmodified, and any changes that should cause the asserts to fail still fail as expected. Change-Id: I8d4132058308566310c58b7ae3e121eae55d37f5 Signed-off-by: William A. Kennington III <wak@google.com>
* tests: Fix memory leak from sd_bus callsWilliam A. Kennington III2018-06-272-4/+13
| | | | | | | | | | | | Some of the calls into sd_bus leak memory because they never unreference the bus or messages. Fix this so we can eventually enable leak checking from valgrind. Tested: Ran through valgrind and the errors went away. Change-Id: Icc3d5d0860b3852401219c1ca511a1bc26aa1c48 Signed-off-by: William A. Kennington III <wak@google.com>
* Allow reading and appending of more complex typesEd Tanous2018-03-072-0/+191
| | | | | | | | | | | | | | | | | | | | | This commit makes sdbusplus compatible with most containers that meet a few requirements. This includes: std::unordered_map std::array std::set boost::flat_set boost::flat_map Read requires a container to support emplace or emplace_back methods. Append requires a container to suport a const iterator Tested: The top level OpenBMC compiles properly, and the sdbusplus unit tests compile and pass, and unit tests have been updated with a few new types to ensure we see any breakages. Signed-off-by: Ed Tanous <ed.tanous@intel.com> Change-Id: I5eb1cf7dc07bacc7aca62d87844794223ad4de80 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
* Update repo to conform to openbmc code standardAndrew Geissler2018-02-054-58/+45
| | | | | Change-Id: If1d6b1f04514367cc544c2507a845b3e9d6d3435 Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
* test: convert message_native_types to gtestPatrick Williams2017-05-021-12/+28
| | | | | Change-Id: I8aa9e996505d3083ff5650c3fa5107d4143ff482 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* test: convert message_types to gtestPatrick Williams2017-05-021-21/+27
| | | | | Change-Id: Ifb5d2b9f4cb5c6700f5c0164466cc5289ee40a26 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* message-append: Add more string test casesPatrick Williams2017-02-151-4/+45
| | | | | | | Add cases uncovered by openbmc/openbmc#1025. Change-Id: I680b95b2127d50837dccd3ea1ff655fc1eb19ec9 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* Allow implicit string_wrapper conversionsBrad Bishop2017-01-301-0/+10
| | | | | | | | | | | | | Add comparison operators to allow string_wrappers to be implicity converted to strings for comparisons to cut down on casting and/or str member access. Do not allow std::string to be impliclitly converted to object_path to avoid a temporary string copy. Change-Id: I2e45a4fc3ee07d1df55f6fab2cfa35da205c150e Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com> Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* message: allow obj-path and sig in STL containersPatrick Williams2017-01-101-0/+12
| | | | | | | | Allow object_path and signatures to be used in std::vector, std::map, and std::unordered_map. Change-Id: Ieb592aa518bfae08da393632a1dd0ed0dd684c7a Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* message-read: support obj-path and signaturePatrick Williams2017-01-091-0/+28
| | | | | Change-Id: Iafc2f26a10f0c5c84805e1d28bea8f17eaadc03c Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* message-append: support obj-path and signaturePatrick Williams2017-01-091-0/+27
| | | | | Change-Id: I44d5195eba14c17f38cf2bf2b09eb071d54f59d8 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* message-types: support obj-path and signaturePatrick Williams2017-01-091-0/+7
| | | | | Change-Id: I7cb1563af3375f2a8b22c78ac59f7e69f176933f Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* message: Add class for object-path and signaturesPatrick Williams2017-01-091-0/+13
| | | | | Change-Id: I1ca54ecc5d4033c41738bd224399f80b95094430 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* append/read: additional testcases for bool formsPatrick Williams2016-11-282-8/+16
| | | | | | | | Added test-cases for false r-value reference and l-values, in addition to existing false value. Change-Id: I36952f06d84f9da157a618fbe093a8ca63662ceb Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* message: testcase to read missing variant typePatrick Williams2016-11-041-0/+26
| | | | | | | | | | | Commit ac52113 fixed an issue where reading a variant from a message when the C++ variant did not contain the type of the dbus variant caused the message to get into an invalid state. Add a testcase for this condition. Change-Id: Iea58a4440d72a1d2969d80f782ec1f316cb5ff29 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* message: fix parallel test issuePatrick Williams2016-11-042-2/+2
| | | | | | | | | Both message/append and message/read were using the same service name for testcases. Ensure they use different service names to allow parallel execution of test cases. Change-Id: I060c03f69db0484b863af7cb45578f183cdff331 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* message: compile warning in testcasesPatrick Williams2016-11-042-0/+4
| | | | | | | Thread functions (non-void) were missing a return. Change-Id: Ib7804d92f79b96428285058101e64dceea7ad66e Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* message: write testcase to confirm bool and doublePatrick Williams2016-10-202-0/+50
| | | | | Change-Id: I631046f3e6d46c299f5907ad811656be3d66ea60 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* variant support for append/readPatrick Williams2016-09-122-0/+138
| | | | | Change-Id: I682275405e3c4f7c798317a60ea070b3b1a0846c Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* std::tuple support for append/readPatrick Williams2016-09-122-0/+62
| | | | | Change-Id: If914032fa4f655af509ac58a5e0057968f71aa32 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* std::map support for append/readPatrick Williams2016-09-122-0/+88
| | | | | Change-Id: I3b5510b8ba400cf4d3f936f01708cb17aa009e62 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* std::vector support for append/readPatrick Williams2016-09-122-0/+69
| | | | | Change-Id: I1820ee2213feb37fab10a491b1099032fd48c18d Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* Add message read functionalityPatrick Williams2016-09-121-0/+219
| | | | | | | C++ bindings for sd_bus_message_read* functions. Similar compile-time type deduction as the message::append interfaces. Change-Id: I88639bedb9703266f7282642ce261c28b736adfc
* bus::process: use message::messagePatrick Williams2016-09-121-1/+1
| | | | | Change-Id: I00f913695d0db75a07d1b0520f507ee7dc469129 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* Add verification to append testcasesPatrick Williams2016-09-121-1/+86
| | | | | Change-Id: Ida08a84e5a7844ed1afd80d3319d2dfc8b77c5e1 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* Migrate bus to message bindingsPatrick Williams2016-09-121-18/+18
| | | | | Change-Id: I29a03b146d5c050a13b4bab690d450612797f2ce Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* Add bus bindingsPatrick Williams2016-09-121-29/+22
| | | | | | | | | Add C++ bindings for the sd_bus_(bus) class interfaces. This binding creates a unique_ptr wrapper around sd_bus*, using the appropriate sd_bus deref calls when the unique_ptr leaves scope. Change-Id: I0bb3842e384217ac5606bb3bf350d7fc3babf1ad Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* Add message append functionalityPatrick Williams2016-09-081-0/+140
| | | | | | | | | | | | | | | | | | | Adds C++ binding to sd_bus_message_append* class functions. Uses type deduction to identify all of the parameters passed to the append function and, at compile-time, creates the appropriate dbus type string. Example: sdbusplus::message::append(m, "asdf"s); Is equal to: sd_bus_message_append_basic(m, 's', ("asdf"s).c_str()); Rather than use a naive sequence of ..._append_basic calls, the implementation will attempt to group multiple basic types into a single sd_bus_message_append call. Change-Id: I1341a0299573c61588fe225c07174b743cb3a282 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
* Add type_id templatesPatrick Williams2016-09-021-0/+33
C++ templates to assist in type conversions between C++ types and dbus types. These templates provide a compile-time conversion between built-in types and a C-string of dbus types. Example: uint32_t a = 0; const char* b = "a string"; auto t = sdbusplus::message::types::type_id(a, b); This results in a tuple equal to std::make_tuple('u','s', '\0')', which can be converted to a C-string("us") by tuple_to_array. In a subsequent commit this interface will be used to do a compile-time transformation from something like: msg->append(a, b) To: sd_bus_message_append(msg, "us", a, b); The type_id template can be extended to support tuples, STL containers, and user-defined types as needed. Change-Id: I913501b51ffc24bcf4219f4297a1e0f8ebed97b5 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
OpenPOWER on IntegriCloud