-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extended monitor API by adding and removing peers
Relates to: #187 Monitor signals are only sent to the creator of the monitor. The new Peer API enables to add and remove additional listener on the same monitor with its subscriptions. A user with sufficient priviledges to make methods calls to BlueChi's API can add and remove peers. The processes for the peers can be run by a different user with no access to BlueChi's API, but will still be able to receive events if added by a privileged process. Signed-off-by: Michael Engel <mengel@redhat.com>
- Loading branch information
Showing
12 changed files
with
577 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
||
subdir('utils') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* SPDX-License-Identifier: LGPL-2.1-or-later */ | ||
#include <stdbool.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#include "libbluechi/bus/utils.h" | ||
#include "libbluechi/common/string-util.h" | ||
|
||
bool test_bus_id_is_valid(const char *name, bool expected_is_valid) { | ||
bool got_is_valid = bus_id_is_valid(name); | ||
if (got_is_valid != expected_is_valid) { | ||
fprintf(stderr, | ||
"FAILED: expected bus name '%s' to be %s, but got %s\n", | ||
name, | ||
bool_to_str(expected_is_valid), | ||
bool_to_str(got_is_valid)); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
int main() { | ||
bool result = true; | ||
|
||
result = result && test_bus_id_is_valid(NULL, false); | ||
result = result && test_bus_id_is_valid("", false); | ||
result = result && test_bus_id_is_valid(":", false); | ||
result = result && test_bus_id_is_valid(":.", false); | ||
result = result && test_bus_id_is_valid(":1.", false); | ||
result = result && test_bus_id_is_valid(":1.3.", false); | ||
result = result && test_bus_id_is_valid("1", false); | ||
result = result && test_bus_id_is_valid("1.", false); | ||
result = result && test_bus_id_is_valid("1.3", false); | ||
result = result && test_bus_id_is_valid(":1..3", false); | ||
result = result && test_bus_id_is_valid("org.eclipse.bluechi", false); | ||
result = result && | ||
test_bus_id_is_valid( | ||
":1.1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", | ||
false); | ||
|
||
result = result && test_bus_id_is_valid(":1.1", true); | ||
result = result && test_bus_id_is_valid(":1.12345", true); | ||
result = result && test_bus_id_is_valid(":1.123.45", true); | ||
|
||
if (result) { | ||
return EXIT_SUCCESS; | ||
} | ||
return EXIT_FAILURE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
||
bus_src = [ | ||
'bus_id_is_valid_test', | ||
] | ||
|
||
foreach src : bus_src | ||
exec_test = executable(src, src + '.c', | ||
link_with: [ | ||
bluechi_lib, | ||
], | ||
include_directories: include_directories('../../../..'), | ||
) | ||
test(src, exec_test) | ||
endforeach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
||
subdir('bus') | ||
subdir('common') | ||
subdir('log') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.