From 311e3d4637a98f75792ff3a56f1de43e04f9048e Mon Sep 17 00:00:00 2001 From: Anita Zhang Date: Fri, 23 Oct 2020 15:47:07 -0700 Subject: [PATCH 1/2] test: make TEST-56-OOMD service unit files static --- test/units/testsuite-56-testbloat.service | 9 +++++ test/units/testsuite-56-testchill.service | 6 ++++ test/units/testsuite-56-workload.slice | 10 ++++++ test/units/testsuite-56.sh | 40 ++++------------------- 4 files changed, 31 insertions(+), 34 deletions(-) create mode 100644 test/units/testsuite-56-testbloat.service create mode 100644 test/units/testsuite-56-testchill.service create mode 100644 test/units/testsuite-56-workload.slice diff --git a/test/units/testsuite-56-testbloat.service b/test/units/testsuite-56-testbloat.service new file mode 100644 index 0000000000..40cf5a9f36 --- /dev/null +++ b/test/units/testsuite-56-testbloat.service @@ -0,0 +1,9 @@ +[Unit] +Description=Create a lot of memory pressure + +[Service] +# A very small memory.high will cause the script (trying to use a lot of memory) +# to throttle and be put under heavy pressure +MemoryHigh=2M +Slice=testsuite-56-workload.slice +ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-56-slowgrowth.sh diff --git a/test/units/testsuite-56-testchill.service b/test/units/testsuite-56-testchill.service new file mode 100644 index 0000000000..6cae3d852a --- /dev/null +++ b/test/units/testsuite-56-testchill.service @@ -0,0 +1,6 @@ +[Unit] +Description=No memory pressure + +[Service] +Slice=testsuite-56-workload.slice +ExecStart=sleep infinity diff --git a/test/units/testsuite-56-workload.slice b/test/units/testsuite-56-workload.slice new file mode 100644 index 0000000000..3d542ec2ba --- /dev/null +++ b/test/units/testsuite-56-workload.slice @@ -0,0 +1,10 @@ +[Unit] +Description=Test slice for memory pressure kills + +[Slice] +CPUAccounting=true +MemoryAccounting=true +IOAccounting=true +TasksAccounting=true +ManagedOOMMemoryPressure=kill +ManagedOOMMemoryPressureLimitPercent=50% diff --git a/test/units/testsuite-56.sh b/test/units/testsuite-56.sh index 5be6658972..37d62d943c 100755 --- a/test/units/testsuite-56.sh +++ b/test/units/testsuite-56.sh @@ -14,54 +14,26 @@ if [[ "$cgroup_type" != *"cgroup2"* ]] && [[ "$cgroup_type" != *"0x63677270"* ]] fi [[ -e /skipped ]] && exit 0 || true -cat > /etc/systemd/system/testworkload.slice < /etc/systemd/system/testbloat.service < /etc/systemd/system/testchill.service < Date: Tue, 27 Oct 2020 00:16:25 -0700 Subject: [PATCH 2/2] docs: update coding style for `return (void) func(...)` Seems that people think it's useful for brevity so make it explicit in the CODING_STYLE. --- docs/CODING_STYLE.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/CODING_STYLE.md b/docs/CODING_STYLE.md index 8f9b2d43b8..851676bc2b 100644 --- a/docs/CODING_STYLE.md +++ b/docs/CODING_STYLE.md @@ -318,6 +318,14 @@ layout: default unlink("/foo/bar/baz"); ``` + When returning from a `void` function, you may also want to shorten the error + path boilerplate by returning a function invocation cast to `(void)` like so: + + ```c + if (condition_not_met) + return (void) log_tests_skipped("Cannot run ..."); + ``` + Don't cast function calls to `(void)` that return no error conditions. Specifically, the various `xyz_unref()` calls that return a `NULL` object shouldn't be cast to `(void)`, since not using the return value