New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: use mock-gpio.py in enable-disable-units-gpio test #6153
Changes from all commits
bb52e33
ebc24a1
56b2ff3
92b9f51
6e0331f
e64d4c1
b873173
887a98c
3761b82
e1f4a2c
7a78d3d
4e89e7c
974c28f
72a802a
219bf60
3833bf5
7059849
450f18f
f77767e
f0397c8
fe8919b
3a36250
735d0b0
62221a7
9b77c6a
780017e
a020053
f09177f
6194ca9
b679fd4
898377b
85425cb
d74e3ff
21a72d6
72392a5
16fc551
d471616
6d22368
5999b1e
5f3a016
c527031
fe2a88d
b2de03e
06d2977
add2cda
5f733f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,31 @@ systemd_create_and_start_unit() { | |
systemctl start "$1" | ||
} | ||
|
||
# Create and start a persistent systemd unit that survives reboots. Use as: | ||
# systemd_create_and_start_persistent_unit "name" "my-service --args" | ||
# The third arg supports "overrides" which allow to customize the service | ||
# as needed, e.g.: | ||
# systemd_create_and_start_persistent_unit "name" "start" "[Unit]\nAfter=foo" | ||
systemd_create_and_start_persistent_unit() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
printf '[Unit]\nDescription=For testing purposes\n[Service]\nType=simple\nExecStart=%s\n[Install]\nWantedBy=multi-user.target\n' "$2" > "/etc/systemd/system/$1.service" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we could automatically insert the name of current test into the description, that would be a nice touch, perahps spread exposes it somehow? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this a lot, will do a followup with this idea. |
||
if [ -n "${3:-}" ]; then | ||
mkdir -p "/etc/systemd/system/$1.service.d" | ||
# shellcheck disable=SC2059 | ||
printf "$3" >> "/etc/systemd/system/$1.service.d/override.conf" | ||
mvo5 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fi | ||
systemctl daemon-reload | ||
systemctl enable "$1" | ||
systemctl start "$1" | ||
wait_for_service "$1" | ||
} | ||
|
||
system_stop_and_remove_persistent_unit() { | ||
systemctl stop "$1" || true | ||
systemctl disable "$1" || true | ||
rm -f "/etc/systemd/system/$1.service" | ||
rm -rf "/etc/systemd/system/$1.service.d" | ||
} | ||
|
||
# Use like systemd_stop_and_destroy_unit(fakestore) | ||
systemd_stop_and_destroy_unit() { | ||
if systemctl is-active "$1"; then | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, double newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added those because pep8 wants double newlines between functions that are not part of a class.