| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
| |
Addresses https://github.com/systemd/systemd/pull/22338#discussion_r796741033.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
C macros are nasty. We use them, but we try to be conservative with
them. In particular passing literal, complex code blocks as argument is
icky, because of "," handling of C, and also because it's quite a
challange for most code highlighters and similar. Hence, let's avoid
that. Using macros for genreating functions is OK but if so, the
parameters should be simple words, not full code blocks.
hence, rework DEFINE_CUSTOM_TEST_MAIN() to take a function name instead
of code block as argument.
As side-effect this also fixes a bunch of cases where we might end up
returning a negative value from main().
Some uses of DEFINE_CUSTOM_TEST_MAIN() inserted local variables into the
main() functions, these are replaced by static variables, and their
destructors by the static destructor logic.
This doesn't fix any bugs or so, it's just supposed to make the code
easier to work with and improve it easthetically.
Or in other words: let's use macros where it really makes sense, but
let's not go overboard with it.
(And yes, FOREACH_DIRENT() is another one of those macros that take
code, and I dislike that too and regret I ever added that.)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This converts to TEST macro in less trivial cases. This is mostly
due to having an intro or outro before/after the actual tests.
Some notable changes:
- add a "test" to make sure the hashmap and ordered_hashmap tests
from different compilation units are actually run in test-hashmap.c
- make root arg a global var in test-install-root.c
- slightly rework an EFI specific test in test-proc-cmdline.c
- usage of saved_argv/saved_argc in test-process-util.c
- splitting test-rlimit-util.c into several tests
- moving the hwdb open check into intro in test-sd-hwdb.c
- condense several "tests" into one in test-udev-util.c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This macro is like JSON_BUILD_STRING() but uses our json library's
ability to use literal strings directly as JsonVariant objects.
The changes all our codebase to use this new macro whenever we build
JSON objects from literal strings.
(I tried to make this automatic, i.e. to detect in JSON_BUILD_STRING()
whether something is a literal string nicely and thus do this stuff
automatically, but I couldn't find a way.)
This should reduce memory usage of our JSON code a bit. Constant strings
we use very often will now be shared and mapped directly from the ELF
image.
|
|
|
|
|
|
|
|
|
|
|
|
| |
In some cases it's useful to explicitly generate the JSON field names to
generate for table columns, instead of auto-mangling them from table
header names that are intended for human consumption.
This adds the infra and a test for it.
It's intended to be used by #20544, for the first column, which in text
mode should have an empty header field, but have an explicit name in
json output mode.
|
| |
|
|
|
|
| |
Fixes #18415.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The idea is that we have strvs like list of server names or addresses, where
the majority of strings is rather short, but some are long and there can
potentially be many strings. So formattting them either all on one line or all
in separate lines leads to output that is either hard to read or uses way too
many rows. We want to wrap them, but relying on the pager to do the wrapping is
not nice. Normal text has a lot of redundancy, so when the pager wraps a line
in the middle of a word the read can understand what is going on without any
trouble. But for a high-density zero-redundancy text like an IP address it is
much nicer to wrap between words. This also makes c&p easier.
This adds a variant of TABLE_STRV which is wrapped on output (with line breaks
inserted between different strv entries).
The change table_print() is quite ugly. A second pass is added to re-calculate
column widths. Since column size is now "soft", i.e. it can adjust based on
available columns, we need to two passes:
- first we figure out how much space we want
- in the second pass we figure out what the actual wrapped columns
widths will be.
To avoid unnessary work, the second pass is only done when we actually have
wrappable fields.
A test is added in test-format-table.
|
| |
|
|
|
|
| |
This adds native support for multiline cells.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixes #13461.
Before:
$ systemd-inhibit --no-pager
WHO UID USER PID COMM WHAT WHY MODE
ModemManager 0 root 1093 ModemManager sleep ModemManage… delay
NetworkManager 0 root 1400 NetworkManager sleep NetworkMana… delay
UPower 0 root 5141 upowerd sleep Pause devic… delay
zbyszek 1000 zbyszek 10036 gsd-power handle-lid-switch External mo… block
zbyszek 1000 zbyszek 10035 gsd-media-keys handle-power-key:handle-suspend-key:… GNOME handl… block
zbyszek 1000 zbyszek 10035 gsd-media-keys sleep GNOME handl… delay
zbyszek 1000 zbyszek 10036 gsd-power sleep GNOME needs… delay
7 inhibitors listed.
$ systemd-inhibit --no-pager|grep suspend
$ systemd-inhibit --no-pager|cat
WHO UID USER PID COMM WHAT WHY MODE
ModemManager 0 root 1093 ModemManager sleep Mode… delay
NetworkManager 0 root 1400 NetworkManager sleep Netw… delay
UPower 0 root 5141 upowerd sleep Paus… delay
zbyszek 1000 zbyszek 10036 gsd-power handle-lid-switch Exte… block
zbyszek 1000 zbyszek 10035 gsd-media-keys handle-power-key:h… GNOM… block
zbyszek 1000 zbyszek 10035 gsd-media-keys sleep GNOM… delay
zbyszek 1000 zbyszek 10036 gsd-power sleep GNOM… delay
After:
$ build/systemd-inhibit --no-pager
(same as above)
$ build/systemd-inhibit --no-pager|grep suspend
zbyszek 1000 zbyszek 10035 gsd-media-keys handle-power-key:handle-suspend-key:handle-hibernate-key GNOME handling keypresses block
$ build/systemd-inhibit --no-pager|cat
WHO UID USER PID COMM WHAT WHY MODE
ModemManager 0 root 1093 ModemManager sleep ModemManager needs to reset devices delay
NetworkManager 0 root 1400 NetworkManager sleep NetworkManager needs to turn off networks delay
UPower 0 root 5141 upowerd sleep Pause device polling delay
zbyszek 1000 zbyszek 10036 gsd-power handle-lid-switch External monitor attached or configuration changed recently block
zbyszek 1000 zbyszek 10035 gsd-media-keys handle-power-key:handle-suspend-key:handle-hibernate-key GNOME handling keypresses block
zbyszek 1000 zbyszek 10035 gsd-media-keys sleep GNOME handling keypresses delay
zbyszek 1000 zbyszek 10036 gsd-power sleep GNOME needs to lock the screen delay
7 inhibitors listed.
Note that this affect all tools that use format-table.c: machinectl, busctl,
loginctl, systemd-analyze, networkctl, portablectl.
|
| |
|
| |
|
| |
|
| |
|
|
We have plenty of code in our codebase that outputs tables to the
console, and all is homegrown and awful. Let's replace it with a generic
implementation that can do automatically what the old implementations
did manually.
Features:
1. Ellipsation (for fields overly long) and alignment (for
fields overly short)
2. Sorting of rows
3. automatically copies formatting from the same cell in the row above
4. Heavy use of varargs to make putting together tables easy
5. can expand and compress tables, with weights
6. Has a minimal understanding of unicode wide characters in order to
match unicode strings to character cell terminals.
7. Columns can be reordered and individually turned off.
8. pretty printing for various data types
And more.
|