1
0
mirror of https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git synced 2026-10-24 00:48:53 +03:00
Commit Graph

407 Commits

Author SHA1 Message Date
Bartosz Golaszewski
7a768dc5b7 tests: gpiosim: revert minimum kernel version back to v5.17.4
Commit b4009e2e67 ("tests: gpiosim: provide
gpiosim_bank_set_line_valid()") added support for marking simulated GPIO
lines as valid/invalid using a new attribute of the kernel configfs
interface of the gpio-sim module. In the process it bumped the minimum
kernel version required to use it to v6.17 where this feature first
appeared. The test cases we added later only appear in gpiod-test which
is the test suite for the core C library. However with the kernel
version change in libgpiosim other test suites have also seen their
minimum kernel versions implicitly increase.

Since the libgpiosim library will simply return an error in the event
that the attribute in question doesn't exist when the new function is
called, we can revert the required kernel version to what it was before
and allow just the individual test suites to bump their respective
minimums separately.

Reported-by: Vincent Fazio <vfazio@gmail.com>
Tested-by: Vincent Fazio <vfazio@gmail.com>
Link: https://lore.kernel.org/r/20251010094951.18927-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-13 09:54:31 +02:00
Bartosz Golaszewski
f4fe71e940 tests: add a test case for checking invalid lines
Add a test case for validating kernel's behavior when user-space tries
to request an invalid GPIO line.

Link: https://lore.kernel.org/r/20251006-gpiosim-valid-lines-v1-7-b399373e90a9@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-09 10:12:59 +02:00
Bartosz Golaszewski
d6fd0a065a tests: harness: support setting invalid lines
Wrap the new gpiosim_bank_set_line_valid() symbol exported by libgpiosim
in a GLib property and allow libgpiod tests to mark simulated lines as
invalid.

Link: https://lore.kernel.org/r/20251006-gpiosim-valid-lines-v1-6-b399373e90a9@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-09 10:12:59 +02:00
Bartosz Golaszewski
b4009e2e67 tests: gpiosim: provide gpiosim_bank_set_line_valid()
Provide a function allowing to mark a GPIO at given offset as valid or
invalid (all lines are valid by default). This will make it impossible
for any user to request it once the simulator is up.

Link: https://lore.kernel.org/r/20251006-gpiosim-valid-lines-v1-5-b399373e90a9@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-09 10:12:59 +02:00
Bartosz Golaszewski
8379438130 tests: gpiosim: selftests: add more test cases
Add simple self tests for libgpiosim functions that were not tested
before.

Link: https://lore.kernel.org/r/20251006-gpiosim-valid-lines-v1-4-b399373e90a9@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-09 10:12:59 +02:00
Bartosz Golaszewski
43d100a49c tests: gpiosim: selftests: shrink the self-test code
Most tests failures end with a perror() print and an exit(1) so wrap it
in a helper function and a macro and shrink the code.

Link: https://lore.kernel.org/r/20251006-gpiosim-valid-lines-v1-3-b399373e90a9@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-09 10:12:59 +02:00
Bartosz Golaszewski
1aca992f8b tests: gpiosim: don't allow clearing hogs on active devices
Check if the GPIO device is pending in gpiosim_bank_clear_hog() before
actually trying to remove the hog directory.

Fixes: a2f6e8cd35 ("libgpiosim: new library for controlling the gpio-sim module")
Link: https://lore.kernel.org/r/20251006-gpiosim-valid-lines-v1-2-b399373e90a9@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-09 10:12:59 +02:00
Bartosz Golaszewski
347adbd698 tests: harness: use correct type to capture a boolean retval
Unlike the libgpiosim functions used in g_gpiosim_glib_apply_properties(),
the return value of g_gpiosim_chip_apply_line_names() is a gboolean so
add a second local variable of the correct type to capture it.

Fixes: daaa6964c9 ("tests: rework error handling and stop overusing g_error()")
Link: https://lore.kernel.org/r/20251006-gpiosim-valid-lines-v1-1-b399373e90a9@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-10-09 10:12:59 +02:00
Bartosz Golaszewski
d30bcd7b2e tests: update library API version string tests
The version string returned by gpiod_api_version() is now stricter and
will always be of the form: x.y.z where x, y and z are unsigned integer
numbers. We no longer have to parse various suffixes so update the test
cases tree-wide.

Acked-by: Erik Wierich <erik@riscstar.com>
Link: https://lore.kernel.org/r/20250903-api-version-detach-v1-4-027ca5928518@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-09-09 10:24:00 +02:00
Bartosz Golaszewski
c116b6f6f1 tests: add a test-case checking line-config memory usage
Add a test case making sure that repeatedly adding line settings to a
line-config object doesn't continuously inflate its size until OOM.

Link: https://lore.kernel.org/r/20250424-line_config_mem_use-v1-2-fa0abdcf0cdf@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-04-30 10:36:06 +02:00
Bartosz Golaszewski
41231df28c tests: uapi: add test-cases for open-drain and open-source emulation
The kernel GPIO subsystem can emulate open-drain and open-source by not
actively driving the line for active and inactive output values
respectively. The kernel does it by setting the line to input in these
cases but this still must be reported as output to user-space. Add new
test-cases that verify this behavior.

Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://lore.kernel.org/r/20250410-open-drain-source-tests-v1-1-a062d2280cc5@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-04-16 17:59:04 +02:00
Bartosz Golaszewski
e3c641ec7c gpiosim: selftests: check that a disabled device can be re-enabled
Extend the test sequence to check that a device can be disabled and
re-enabled without problems.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-02-17 09:15:13 +01:00
Bartosz Golaszewski
3dac2c5d9c gpiosim: defer removal of bank entries when device is not disabled
Linux kernel commit 8bd76b3d3f3a ("gpio: sim: lock up configfs that an
instantiated device depends on") has uncovered an issue in libgpiosim:
we use reference counting for all objects (to make RAII easier for
bindings) but, with the above change, if the user doesn't explicitly
disable the device before dropping the last reference to a bank object,
the parent device will never get correctly cleaned up.

This is because we remove the hog and line directories in bank's
release() callback unconditionally. With the directories being locked
now, this fails if device is active and then when we eventually call the
device object's release(), we'll end up stuck with leftover bank
directories and never actually clean-up correctly.

Extend the gpiosim device with a list of deferred banks. When releasing
a bank on an active device, defer any actual cleanup until the time the
device gets deactivated which may be triggered by the user explictly or
will happen automatically when the last reference to the device object is
dropped. For inactive devices, there's no functional change.

Link: https://lore.kernel.org/r/20250214102648.71382-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-02-17 09:14:54 +01:00
Bartosz Golaszewski
47e14b2cef tests: don't use g_value_set_static_string() for non-static strings
As pointed out by Philip Withnall, g_value_set_static_string() must only
be used with actual static strings and not with ones whose life-time is
tied to that of their owner. Use g_value_set_string() to get the gpiosim
properties and rework the existing getter functions returning const
gchar * to return the address provided by libgpiosim directly instead of
passing through the GObject property path.

Suggested-by: Philip Withnall <philip@tecnocode.co.uk>
Link: https://lore.kernel.org/r/20240813093025.94980-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-08-16 09:56:16 +02:00
Bartosz Golaszewski
ad325c0b65 tests: split out the common test code for bash scripts
In order to allow the upcoming DBus command-line client tests to reuse the
existing bash test harness, let's put the common code into an importable
file and rename run_tool to run_prog to reflect that it now can run any
program.

Tested-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
Link: https://lore.kernel.org/r/20240812-dbus-v5-2-ead288509217@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-08-13 10:38:40 +02:00
Bartosz Golaszewski
e60e38375c tests: split out reusable test code into a local static library
In order to allow the upcoming GLib and DBus bindings to reuse the test
code, let's put all common elements into reusable libtool objects and
export the relevant symbols in internal headers.

Tested-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
Link: https://lore.kernel.org/r/20240812-dbus-v5-1-ead288509217@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-08-13 10:38:40 +02:00
Kent Gibson
0a552e7908 tests: add enable_debounce_then_edge_detection
A bug was recently discovered in the kernel that can result in the edge
event fifo not being correctly initialised and stack contents being
returned in edge events. The trigger for the bug is requesting a line with
debounce, but not edge detection, and then reconfiguring the line to
enable edge detection.

Add a test case that triggers the bug.  This will fail on kernels that
do not contain the fix for the bug.  The test is located in a new test
file, tests-kernel-uapi.c, intended to contain tests specifically
testing some aspect of the kernel uAPI, not libgpiod itself.

Signed-off-by: Kent Gibson <warthog618@gmail.com>
Link: https://lore.kernel.org/r/20240513160031.309139-1-warthog618@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-05-15 10:59:52 +02:00
Bartosz Golaszewski
f054a7099d tests: fix version parsing (again)
This time we missed the fact that the last part is optional. Fix it
treewide.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-11-03 17:17:34 +01:00
Bartosz Golaszewski
ec76ea717b tests: don't use the same chip object from different threads
There are no thread-safety guarantees in libgpiod. Let's not reuse the
chip object created in one thread to generate info events in another but
create a second chip for that purpose instead.

Reported-by: Erik Schilling <erik.schilling@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Erik Schilling <erik.schilling@linaro.org>
2023-09-25 09:00:10 +02:00
Bartosz Golaszewski
2dc9cc08f1 tests: add missing return value check
One of the line-request test cases is missing the return value check
after the call to gpiod_line_request_set_values_subset(). Add it.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-08-06 22:16:15 +02:00
Bartosz Golaszewski
856989c770 tests: add a test-case for gpiod_line_request_get_chip_name()
Add a test case for the chip name getter on line-request objects.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-07-21 20:33:39 +02:00
Bartosz Golaszewski
37b3ac4bb5 build: remove redundant SOURCES assignments
For any given target (let's say foobar), automake defaults to looking for
foobar.c if foobar_SOURCES are not specified. Remove redundant assignments
as we've seen multiple hidden typos in makefiles already.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Kent Gibson <warthog618@gmail.com>
2023-06-30 14:51:34 +02:00
Erik Schilling
370bf6825d gpiosim: fix data race that corrupts heap
Hit this while seeing some heap corruptions when running cargo test on
the Rust bindings.

Took a bit to track down since I first used address sanitizers, but with
the thread sanitizer it becomes obvious immediately (output simplified):

    ==================
    WARNING: ThreadSanitizer: data race (pid=288119)
      Write of size 8 at 0x0000018f1e78 by thread T6:
        #0 id_free /libgpiod/tests/gpiosim/gpiosim.c:141:17
        #1 dev_release /libgpiod/tests/gpiosim/gpiosim.c:600:2
        #2 refcount_dec /libgpiod/tests/gpiosim/gpiosim.c:176:3
        #3 gpiosim_dev_unref /libgpiod/tests/gpiosim/gpiosim.c:671:2
        #4 bank_release /libgpiod/tests/gpiosim/gpiosim.c:873:2
        #5 refcount_dec /libgpiod/tests/gpiosim/gpiosim.c:176:3
        #6 gpiosim_bank_unref /libgpiod/tests/gpiosim/gpiosim.c:941:2
        [...]

      Previous write of size 8 at 0x0000018f1e78 by thread T1:
        #0 id_free /libgpiod/tests/gpiosim/gpiosim.c:141:17
        #1 bank_release /libgpiod/tests/gpiosim/gpiosim.c:878:2
        #2 refcount_dec /libgpiod/tests/gpiosim/gpiosim.c:176:3
        #3 gpiosim_bank_unref /libgpiod/tests/gpiosim/gpiosim.c:941:2
        [...]

      Location is global 'id_del_ctx' of size 16 at 0x0000018f1e70

      Thread T6 'chip::verify::f' (tid=288126, running) created by main thread at:
        #7 test::run_tests::hd53a07a011bd771f /.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:407:21
        [...]

      Thread T1 'chip::open::gpi' (tid=288121, finished) created by main thread at:
        #7 test::run_tests::hd53a07a011bd771f /.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/test/src/lib.rs:407:21
        [...]

    SUMMARY: ThreadSanitizer: data race /libgpiod/tests/gpiosim/gpiosim.c:141:17 in id_free
    ==================

This eventually can either lead to leaks or double free's that corrupt
the heap and lead to crashes.

The issue got introduced when a previously local variable that did not
require protection was turned into a global variable.

Fixes: 5e111df2fc ("gpiosim: use twalk() instead of twalk_r()")
Signed-off-by: Erik Schilling <erik.schilling@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-06-26 16:31:39 +02:00
Bartosz Golaszewski
a62c5fbc63 tests: move the test case for duplicate configured offsets
This test case lives in tests-line-request.c but it doesn't really test
request functionality but rather only the behavior of line-config. Limit
it to only testing struct gpiod_line_config and move it to
tests-line-config.c.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-04-27 15:28:18 +02:00
Bartosz Golaszewski
0fdc1a11c9 tests: don't segfault if gpio-sim is unavailable
The GLib wrapper for libgpiosim tries to create the gpiosim context and
bank objects in the class's init() function but the constructed()
callback doesn't check if that operation succeeded, leading to a crash
when it dereferences the bank pointer.

As init() should only perform operations that cannot fail, let's move all
the gpiosim initialization code to constructed() and bail-out of it if
any of the steps fails.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-04-20 09:32:56 +02:00
Bartosz Golaszewski
e622ed2327 tests: don't install test executables
I'm not sure what historical reasons there were to install test programs
if they are built but now I can't see any anymore. Tests can be run from
the build directory and users such as meta-openembedded can install them
and the relevant libraries (libgpiosim) manually into the filesystem as
they don't usually live in ${bindir} anyway. Installing test binaries just
pollutes the filesystem now so stop doing it.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-04-17 11:16:42 +02:00
Bartosz Golaszewski
010207cd0e tests: check the return value of gpiod_line_config_add_line_settings()
The call to gpiod_line_config_add_line_settings() can fail in the thread
function used by info-event test cases so check its return value and act
accordingly.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-04-13 16:49:58 +02:00
Bartosz Golaszewski
ee96540ec8 tests: fix the test case for gpiod_line_config_get_line_settings()
We should compare the values stored by the 'retrieved' line settings
object, not the original 'settings'.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-04-12 15:10:45 +02:00
Bartosz Golaszewski
b740f64daf tests: simplify and reduce the strictness of version string regex patterns
It seems like every release there's some new problem with parsing the
version strings in tests. Let's reduce the strictness of the patterns
to avoid future test failures and accept the following version schemes:

X.Y
X.Y.Z
X.Y-devel
X.Y-rcZ

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-04-11 17:54:57 +02:00
Bartosz Golaszewski
7936f50218 tests: fix version regex treewide
The square bracket is in the wrong place which makes the regex not match
version strings of the form: x.y.z. Fix the pattern in core and bindings
tests.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-04-11 13:56:23 +02:00
Bartosz Golaszewski
a5cf1d6164 tests: provide and use gpiod_test_chip_watch_line_info_or_fail()
We can shrink the code a bit by wrapping the call to
gpiod_chip_watch_line_info() and the subsequent checks in a helper macro.
This also fixes a potential null-pointer dereference in one of the info
event test cases.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-04-07 16:32:22 +02:00
Bartosz Golaszewski
318db06b5f tests: fix inconsistent naming of test helpers
Some of the helpers' names don't refer to the objects they're acting
upon. Make the naming consistent. While at it: fix line breaking in the
helpers header.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-04-07 13:27:52 +02:00
Bartosz Golaszewski
dc746daef2 tests: drop the profiling CFLAGS from tests' Makefile
We only need the profiling flags on the library, we don't need to
generate gcov data for the test objects.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-03-16 09:24:47 +01:00
Bartosz Golaszewski
b81978716c tests: fix the test case for gpiod_line_request_reconfigure_lines()
We need to actually pass the line config with different offsets to
gpiod_line_request_reconfigure_lines() for the test to make sense.

Fixes: 8ef0ca0fae ("tests: add more test cases for gpiod_line_request_reconfigure_lines()")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-03-15 22:04:06 +01:00
Bartosz Golaszewski
305a68d70b tests: add a test case for gpiod_chip_request_lines()
Add a test case which verifies that gpiod_chip_request_lines() fails
when supplied with a NULL line config.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-03-15 21:53:00 +01:00
Bartosz Golaszewski
4d72b11f05 tests: extend the test case for gpiod_request_config_set_consumer()
Also check that passing a NULL consumer string works as expected.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-03-15 21:40:04 +01:00
Bartosz Golaszewski
8ef0ca0fae tests: add more test cases for gpiod_line_request_reconfigure_lines()
Add two new test cases for gpiod_line_request_reconfigure_lines(). One
verifies that NULL line config is handled correctly, the other checks
that reconfigured offsets must be the same as the ones requested.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-03-15 21:36:46 +01:00
Bartosz Golaszewski
64c9a6c6c1 tests: remove commented-out code
This is a leftover line and can be removed.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-03-15 21:36:46 +01:00
Bartosz Golaszewski
c167300b59 tests: add a test case for gpiod_line_config_get_num_configured_offsets()
There are no tests calling gpiod_line_config_get_num_configured_offsets()
yet so add a simple one for more coverage.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-03-15 21:36:40 +01:00
Bartosz Golaszewski
8bf7b0c46f tests: add a test case for incorrect retrieving of edge events from buffer
Add a test case that makes sure we don't crash when trying to access an
out-of-bounds edge event in an edge event buffer.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-03-15 20:56:21 +01:00
Bartosz Golaszewski
10febcbe0b tests: add a test case for gpiod_line_config_add_line_settings()
Add a more detailed test case for input arguments sanitization for
gpiod_line_config_add_line_settings().

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-03-15 20:56:21 +01:00
Bartosz Golaszewski
b9851e07c2 tests: add more test cases for gpiod_line_config_set_output_values()
Add test cases that check proper sanitization of input arguments of
gpiod_line_config_set_output_values().

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-03-15 20:56:21 +01:00
Bartosz Golaszewski
20c83a55b4 core: sanitize the output values in gpiod_line_config_set_output_values()
We check the output values for invalid ones in
gpiod_line_settings_set_output_value() but in
gpiod_line_config_set_output_values() we just accept all indiscriminately.
Factor out the common checking code into a helper function, use it in both
functions and add a relevant test case.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-03-03 17:23:38 +01:00
Bartosz Golaszewski
19c6942f0c tests: add a test-case for looking up non-standard GPIO line names
Make sure line names with whitespaces or some less common characters (that
can be found in real-life names in mainline .dts files) can be correctly
mapped to offsets.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-03-03 15:04:32 +01:00
Bartosz Golaszewski
8e3ca35d12 tests: fix a potential assert() abort()
If info is NULL in one of the line-info test cases, we'll still try to
read its property leading to an abort() triggered from assert(info). Just
bail out of the test function if gpiod_chip_get_line_info() fails.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-02-19 21:39:03 +01:00
Bartosz Golaszewski
968c7c8752 gpiosim: remove unused define
ARRAY_SIZE() is defined but unused so remove it.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-02-17 14:05:30 +01:00
Bartosz Golaszewski
4ebf629e35 tests: fix the enum type in line-request tests
Use the correct enumeration type for GPIO simulator line values.

Fixes: 67ffa262e3 ("tests: add line value enums for gpiosim GLib wrapper")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-02-15 13:46:30 +01:00
Bartosz Golaszewski
67ffa262e3 tests: add line value enums for gpiosim GLib wrapper
libgpiosim has a dedicated enum type for line values but the GLib wrapper
still uses magic numbers (0 and 1). Add an enum type for the wrapper and
use it across all test cases.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-02-15 13:29:09 +01:00
Bartosz Golaszewski
96b686aacb tests: use GLib typedef conventions for line names and hogs
The GVariant packaging works in the context of GLib unit testing so use
GLib conventions for declaring data types.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-02-15 13:21:56 +01:00
Bartosz Golaszewski
5e111df2fc gpiosim: use twalk() instead of twalk_r()
twalk_r() is a GNU extension for the binary search tree API. Musl libc
doesn't provide it and after inquiring with the maintainer it turned out
it won't provide it anytime soon as musl strives to only implement well
standardized functions.

In order to not limit building libgpiosim and tests to glibc only, let's
replace twalk_r() with twalk() and use global variables for the state.
It's not a big deal as we're already using a global root node and a mutex
to protect it.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-02-14 09:13:59 +01:00