Hi,
This series separates tests using the RTC devices between the one
testing driver agnostic kernel facilities (timers) and the others that
are testing device drivers and hardware.
Then, rtctest is reworked to use the test harness and be much more
robust. Skipping tests is now easier and tests will not block
indefinitively.
I'm planning to send more improvements later this cycle.
Alexandre Belloni (4):
selftests: timers: move PIE tests out of rtctest
selftests: timers: rtcpie: restore previous PIE rate
selftests: move RTC tests to rtc subfolder
selftests: rtc: rework rtctest
MAINTAINERS | 2 +-
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/rtc/.gitignore | 2 +
tools/testing/selftests/rtc/Makefile | 9 +
tools/testing/selftests/rtc/rtctest.c | 238 +++++++++++
.../rtctest_setdate.c => rtc/setdate.c} | 0
tools/testing/selftests/timers/.gitignore | 3 +-
tools/testing/selftests/timers/Makefile | 4 +-
tools/testing/selftests/timers/rtcpie.c | 134 ++++++
tools/testing/selftests/timers/rtctest.c | 403 ------------------
10 files changed, 388 insertions(+), 408 deletions(-)
create mode 100644 tools/testing/selftests/rtc/.gitignore
create mode 100644 tools/testing/selftests/rtc/Makefile
create mode 100644 tools/testing/selftests/rtc/rtctest.c
rename tools/testing/selftests/{timers/rtctest_setdate.c => rtc/setdate.c} (100%)
create mode 100644 tools/testing/selftests/timers/rtcpie.c
delete mode 100644 tools/testing/selftests/timers/rtctest.c
--
2.17.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
If the cgroup destruction races with an exit() of a belonging
process(es), cg_kill_all() may fail. It's not a good reason to make
cg_destroy() fail and leave the cgroup in place, potentially causing
next test runs to fail.
Signed-off-by: Roman Gushchin <guro(a)fb.com>
Cc: Shuah Khan <shuah(a)kernel.org>
Cc: Tejun Heo <tj(a)kernel.org>
Cc: kernel-team(a)fb.com
Cc: linux-kselftest(a)vger.kernel.org
---
tools/testing/selftests/cgroup/cgroup_util.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c
index 14c9fe284806..eba06f94433b 100644
--- a/tools/testing/selftests/cgroup/cgroup_util.c
+++ b/tools/testing/selftests/cgroup/cgroup_util.c
@@ -227,9 +227,7 @@ int cg_destroy(const char *cgroup)
retry:
ret = rmdir(cgroup);
if (ret && errno == EBUSY) {
- ret = cg_killall(cgroup);
- if (ret)
- return ret;
+ cg_killall(cgroup);
usleep(100);
goto retry;
}
--
2.17.2
This patch set proposes KUnit, a lightweight unit testing and mocking
framework for the Linux kernel.
Unlike Autotest and kselftest, KUnit is a true unit testing framework;
it does not require installing the kernel on a test machine or in a VM
and does not require tests to be written in userspace running on a host
kernel. Additionally, KUnit is fast: From invocation to completion KUnit
can run several dozen tests in under a second. Currently, the entire
KUnit test suite for KUnit runs in under a second from the initial
invocation (build time excluded).
KUnit is heavily inspired by JUnit, Python's unittest.mock, and
Googletest/Googlemock for C++. KUnit provides facilities for defining
unit test cases, grouping related test cases into test suites, providing
common infrastructure for running tests, mocking, spying, and much more.
## What's so special about unit testing?
A unit test is supposed to test a single unit of code in isolation,
hence the name. There should be no dependencies outside the control of
the test; this means no external dependencies, which makes tests orders
of magnitudes faster. Likewise, since there are no external dependencies,
there are no hoops to jump through to run the tests. Additionally, this
makes unit tests deterministic: a failing unit test always indicates a
problem. Finally, because unit tests necessarily have finer granularity,
they are able to test all code paths easily solving the classic problem
of difficulty in exercising error handling code.
## Is KUnit trying to replace other testing frameworks for the kernel?
No. Most existing tests for the Linux kernel are end-to-end tests, which
have their place. A well tested system has lots of unit tests, a
reasonable number of integration tests, and some end-to-end tests. KUnit
is just trying to address the unit test space which is currently not
being addressed.
## More information on KUnit
There is a bunch of documentation near the end of this patch set that
describes how to use KUnit and best practices for writing unit tests.
For convenience I am hosting the compiled docs here:
https://google.github.io/kunit-docs/third_party/kernel/docs/
## Changes Since Last Version
- Updated patchset to apply cleanly on 4.19.
- Stripped down patchset to focus on just the core features (I dropped
mocking, spying, and the MMIO stuff for now; you can find these
patches here: https://kunit-review.googlesource.com/c/linux/+/1132),
as suggested by Rob.
- Cleaned up some of the commit messages and tweaked commit order a
bit based on suggestions.
--
2.19.1.568.g152ad8e336-goog
Hello Andrew Jones,
The patch 14c47b7530e2: "kvm: selftests: introduce ucall" from Sep
18, 2018, leads to the following static checker warning:
./tools/testing/selftests/kvm/lib/ucall.c:61 ucall_init()
warn: always true condition '(gpa >= 0) => (0-u64max >= 0)'
./tools/testing/selftests/kvm/lib/ucall.c
28 void ucall_init(struct kvm_vm *vm, ucall_type_t type, void *arg)
29 {
30 ucall_type = type;
31 sync_global_to_guest(vm, ucall_type);
32
33 if (type == UCALL_PIO)
34 return;
35
36 if (type == UCALL_MMIO) {
37 vm_paddr_t gpa, start, end, step;
vm_paddr_t is a u64.
38 bool ret;
39
40 if (arg) {
41 gpa = (vm_paddr_t)arg;
42 ret = ucall_mmio_init(vm, gpa);
43 TEST_ASSERT(ret, "Can't set ucall mmio address to %lx", gpa);
44 return;
45 }
46
47 /*
48 * Find an address within the allowed virtual address space,
49 * that does _not_ have a KVM memory region associated with it.
50 * Identity mapping an address like this allows the guest to
51 * access it, but as KVM doesn't know what to do with it, it
52 * will assume it's something userspace handles and exit with
53 * KVM_EXIT_MMIO. Well, at least that's how it works for AArch64.
54 * Here we start with a guess that the addresses around two
55 * thirds of the VA space are unmapped and then work both down
56 * and up from there in 1/6 VA space sized steps.
57 */
58 start = 1ul << (vm->va_bits * 2 / 3);
59 end = 1ul << vm->va_bits;
60 step = 1ul << (vm->va_bits / 6);
61 for (gpa = start; gpa >= 0; gpa -= step) {
^^^^^^^^
So this doesn't work.
62 if (ucall_mmio_init(vm, gpa & ~(vm->page_size - 1)))
63 return;
64 }
65 for (gpa = start + step; gpa < end; gpa += step) {
66 if (ucall_mmio_init(vm, gpa & ~(vm->page_size - 1)))
67 return;
68 }
69 TEST_ASSERT(false, "Can't find a ucall mmio address");
70 }
71 }
regards,
dan carpenter