History log of /openbmc/sdbusplus/test/message/types.cpp (Results 1 – 15 of 15)
Revision Date Author Comments
# 8db46a0f 05-May-2021 William A. Kennington III <wak@google.com>

native_types: string_path_wrapper: Don't escape all strings

Not all strings require escaping when appending them to a path. This
allows us to now append `openbmc_project` to `/xyz` and h

native_types: string_path_wrapper: Don't escape all strings

Not all strings require escaping when appending them to a path. This
allows us to now append `openbmc_project` to `/xyz` and have
expected behavior.

Change-Id: I49a2ee100455cff4067dcf3df61f3e145231eeba
Signed-off-by: William A. Kennington III <wak@google.com>

show more ...


# 285f78b1 01-May-2021 William A. Kennington III <wak@google.com>

native_types: Reduce append allocation

This builds the string from left to right, instead of dealing with
string inserts, optimizing for allocations. Uses our own hex encoder
instead

native_types: Reduce append allocation

This builds the string from left to right, instead of dealing with
string inserts, optimizing for allocations. Uses our own hex encoder
instead of relying on systemd libraries. This maintains explicit
compatability with the systemd encoding scheme.

Change-Id: Ia6c2f4fb19984f549c6bac2d67d0b5d610022038
Signed-off-by: William A. Kennington III <wak@google.com>

show more ...


# e39b3dcb 05-May-2021 William A. Kennington III <wak@google.com>

test/message/types: Convert ASSERTs to EXPECTs

None of the comparisons made in this test prevent the continuation of
the test. This makes it easier to debug changes since all errors will

test/message/types: Convert ASSERTs to EXPECTs

None of the comparisons made in this test prevent the continuation of
the test. This makes it easier to debug changes since all errors will
now be reported instead of early termination.

Change-Id: Ifd849f5a7585ff13cb314980a1128e0f126723b6
Signed-off-by: William A. Kennington III <wak@google.com>

show more ...


# d06072e7 21-Apr-2021 Ed Tanous <edtanous@google.com>

Fix #60 by adding encoding/decoding rules

This commit attempts to make encoding more compatible with things within
openbmc that don't encode paths per the systemd method. It does this b

Fix #60 by adding encoding/decoding rules

This commit attempts to make encoding more compatible with things within
openbmc that don't encode paths per the systemd method. It does this by
forcing the first character of every path segment to be encoded, so /abc
would be encoded as /_61bc. This is then used as a mechanism to
determine if the path needs to be decoded per systemds rules.

The decode mechanisms are also modified to check whether the first
element is encoded before decoding the portion.

Looking for input on whether this is an OK path. The hope would be that
we slowly transition the system over to using the encoding mechanisms
that can handle all ascii characters, and can round trip through
encode/decode without loss. The hope is that this patch can be reversed
at some point in the future.

As an aside, I tried reverting some of the patches, but they're somewhat
ungainly to revert at this point, and would require reverting some
bmcweb patches, which, if this patch is determined to be bad, I'm happy
to do, but I'm hoping this will get us something in the interim

Tested:
unit tests added and updated to cover some of the cases. Unit tests
pass.

Change-Id: Ie9c8cd0627b8b086e8b0bb2287f28dd86eb98ee9
Signed-off-by: Ed Tanous <edtanous@google.com>

show more ...


# 74a27118 07-Apr-2021 Ed Tanous <edtanous@google.com>

Implement operator /= for object_path

This probably should've been implemented as part of
fa0fa3b0fa5a9d59c37b6edbc53cc21b7c2a16b0 Implement path encoding and
decoding but alas, it w

Implement operator /= for object_path

This probably should've been implemented as part of
fa0fa3b0fa5a9d59c37b6edbc53cc21b7c2a16b0 Implement path encoding and
decoding but alas, it was not. This commit adds the relatively simple
operator/= overloads to object_path. This allows calling code to do
operations like:

object_path myPath("/foo");
myPath /= "bar";

Which would result in the object path /foo/bar.

In the implementation, this actually just calls into operator/, and does
a relatively naive replace of the content in the new object. Given how
the sd_bus_path_encode API is organized, there doesn't appear to be a
way to call into it and "append" to an existing thing, so constructing a
new string and assigning it to the current object was the best I could
come up with in terms of efficiency.

This includes overloads for both const char* and const std::string&,
both of which have essentially the same behavior.

Tested:
New unit tests included in commit, and pass.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Idfb7f7f2dc94ea3773841c9ae62cd671327db2cd

show more ...


# fa0fa3b0 31-Mar-2021 Ed Tanous <edtanous@google.com>

Implement path encoding and decoding

sdbus has methods for encoding and decoding paths in a lossless way.
This commit adds those methods to object_path in such a way that those
funct

Implement path encoding and decoding

sdbus has methods for encoding and decoding paths in a lossless way.
This commit adds those methods to object_path in such a way that those
functions are called implicitly when building strings, the hope being
that any API choosing to use object_path need not write its own escaping
functions, and said escaping will happen implicitly.

The explicit changes to make this happen are.
1. filename() now calls into sd_bus_path_decode, rather than writing its
own method. This means that the strings returned from the method now no
longer need decoding explicitly, and can largely be used as-is. For
paths that did not require escaping, the behavior should be identical.
For paths that did require escaping, this method will now return the raw
version of the path. Existing usages should remain the same, and impact
is unlikely, given that most sdbusplus users don't explicitly escape
strings, and filename() is relatively new.

2. a operator/ method is added to the object_path object. Similar to
operator/ on std::filesystem::path, this allows generating a new
object_path from an existing one, by adding a new leaf node to the path.
Functionally this allows nearly any value to be escaped into a dbus
path. An example of a common usage of this might be

object_path myPath = "/";
object_path myNewPath = myPath / "Foo-bar";

The above line will implicitly escape the - in the name. Overloads for
both const std::string& and const char* have been added.

One motivating example where the above would be useful is to remove the
escapePathForDbus method in bmcweb.
https://github.com/openbmc/bmcweb/blob/88b3dd12851cd7bdd4b5c065ba99f40feafb775e/include/dbus_utility.hpp#L47

and the similarly named method in dbus-sensors
https://github.com/openbmc/dbus-sensors/blob/6cb732a31b7664089124b00e806311768bc24a87/src/SensorPaths.cpp#L49
both written by the same author (not me), and centralize them in
sdbusplus where they belong.

Functionally this commit also includes a new utility/memory.hpp, that
allows for C-style RAII using freep, mfree and the _cleanup_free_
attributes. These were largely copied as-is from alloc-util.h in
systemd on latest patchset recommendations.

Tested:
Unit tests have been updated to include all new code paths, and some
common items that might need escaped. Unit tests pass.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: If77b8bc5f75709b59353570a9c14383cac44dcd4

show more ...


# eb4bd724 17-Dec-2020 Ed Tanous <edtanous@google.com>

Add filename() and parent_path() methods to object_path

In practice, one very common operation done on a dbus path is to get the
final member name in the dbus path, to use as unique IDs,

Add filename() and parent_path() methods to object_path

In practice, one very common operation done on a dbus path is to get the
final member name in the dbus path, to use as unique IDs, or to pass
items to public interfaces. This tends to lead to something like:

size_t pos = object_path.str.rfind('/');
if(pos == std::string::npos){
// handle error
}
pos++;
if (pos >= object_path.str.size()){
// handle error
}

std::string name = object_path.str.substr(pos);

As an aside, what I've written above is one of several "right" ways to
do it, and is among many other wrong ways that I've seen people try to
check in. The goal of this patchset is to add the above code as a
method within object_path, to help people to use it, and to avoid using
object_path.str, which ideally would be a private member of that class.

Functionally, accomplishing the above this requires splitting
string_wrapper into two separate classes, as we continue to need the
string_wrapper instance to handle the signature type, but filename() and
parent_path() on signature are non-sensical. Therefore, this splits the
functionality into string_wrapper and string_path_wrapper, each of which
no longer need to be a template, given there is only one use. We could
also get rid of the using, and move these classes out of details, but
that seemed better reserved for a later patch.

Tested:
Unit tests written and passing.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I242d1965875ba1fe76a32fd78e381e90796706fc

show more ...


# b98bdc6f 16-Jun-2020 Patrick Williams <patrick@stwcx.xyz>

sdbus++: add support for 'set'

Add 'set' as a supported type to `sdbus++` and set as `std::set`.
The use of ordered-set is to match 'dict' as `std::map` and because
'struct' is `std:

sdbus++: add support for 'set'

Add 'set' as a supported type to `sdbus++` and set as `std::set`.
The use of ordered-set is to match 'dict' as `std::map` and because
'struct' is `std::tuple`, which has `operator<=>` but not `std::hash`.
This ensures better compatiblilty with possible property type choices
by users.

Also, add a few test cases to ensure `std::set` and `std::unordered_set`
are well-covered.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I59605db1b22d54f783d807eda1e1ec1f9eb6792f

show more ...


# 78b7803b 20-May-2020 Patrick Williams <patrick@stwcx.xyz>

clean up more pedantic compile warnings

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I84790e29a24c73a65c9770c6836b482386cc0ab7


# 2b238afb 31-Aug-2018 Patrick Venture <venture@google.com>

clang-format: always break template declarations

To better match the defined openbmc style.

Change-Id: I68cda43857768bae4c904c367942cb1f0efa3e0c
Signed-off-by: Patrick Venture <

clang-format: always break template declarations

To better match the defined openbmc style.

Change-Id: I68cda43857768bae4c904c367942cb1f0efa3e0c
Signed-off-by: Patrick Venture <venture@google.com>

show more ...


# 95269dbc 31-Aug-2018 Patrick Venture <venture@google.com>

update .clang-format header inclusion order

Added the header inclusion order to the .clang-format file generated
these changes.

Change-Id: Ia31b21d7ea451cac0309828006bc17c27cbd5

update .clang-format header inclusion order

Added the header inclusion order to the .clang-format file generated
these changes.

Change-Id: Ia31b21d7ea451cac0309828006bc17c27cbd5bd5
Signed-off-by: Patrick Venture <venture@google.com>

show more ...


# 072da3ea 18-Jan-2018 Andrew Geissler <geissonator@yahoo.com>

Update repo to conform to openbmc code standard

Change-Id: If1d6b1f04514367cc544c2507a845b3e9d6d3435
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>


# 450d0ecb 28-Apr-2017 Patrick Williams <patrick@stwcx.xyz>

test: convert message_types to gtest

Change-Id: Ifb5d2b9f4cb5c6700f5c0164466cc5289ee40a26
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>


# 44982981 06-Jan-2017 Patrick Williams <patrick@stwcx.xyz>

message-types: support obj-path and signature

Change-Id: I7cb1563af3375f2a8b22c78ac59f7e69f176933f
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>


# 51103a41 20-Jul-2016 Patrick Williams <patrick@stwcx.xyz>

Add type_id templates

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-

Add type_id templates

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>

show more ...