Python 3.10.0 contains:
9e09849d20 ("bpo-41006: importlib.util no longer imports typing (GH-20938)")
It causes importlib.util to no longer import importlib.abs, which leads
to the following error when trying to use kunit with qemu:
AttributeError: module 'importlib' has no attribute 'abc'. Did you mean: '_abc'?
Add the missing import.
Signed-off-by: Michał Winiarski <michal.winiarski(a)intel.com>
---
tools/testing/kunit/kunit_kernel.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py
index 44bbe54f25f1..3c4196cef3ed 100644
--- a/tools/testing/kunit/kunit_kernel.py
+++ b/tools/testing/kunit/kunit_kernel.py
@@ -6,6 +6,7 @@
# Author: Felix Guo <felixguoxiuping(a)gmail.com>
# Author: Brendan Higgins <brendanhiggins(a)google.com>
+import importlib.abc
import importlib.util
import logging
import subprocess
--
2.34.1
*** BLURB HERE ***
Every KUNIT_ASSERT/EXPECT() invocation puts a `kunit_assert` object onto
the stack. The most common one is `kunit_binary_assert` which is 88
bytes on UML. So in the cases where the compiler doesn't optimize this
away, we can very quickly blow up the stack size.
This series implements Linus' suggestion in [1].
Namely, we split out the file, line number, and assert_type
(EXPECT/ASSERT) out of kunit_assert.
We can also drop the entirely unused `struct kunit *test` field, saving
a bit more space as well.
All together, sizeof(struct kunit_assert) went from 48 to 24 on UML.
Note: the other assert types are bigger, see [2].
This series also adds in an example test that uses all the base
KUNIT_EXPECT macros to both advertise their existence to new users and
serve as a smoketest for all these changes here.
[1] https://groups.google.com/g/kunit-dev/c/i3fZXgvBrfA/m/VULQg1z6BAAJ
[2] e.g. consider the most commonly used assert (also the biggest)
struct kunit_binary_assert {
struct kunit_assert assert;
const char *operation;
const char *left_text;
long long left_value;
const char *right_text;
long long right_value;
};
So sizeof(struct kunit_binary_assert) = went from 88 to 64.
I.e. only a 27% reduction instead of 50% in the most common case.
All 3 of the `const char*` could be split out into a `static` var as well,
but that's a bit trickier to do with how all the macros are written.
=== Changelog ===
v1 -> v2:
* made the new example test more focused on documenting the macros
rather than using them all as a smoketest
* s/kunit_failed_assertion()/kunit_do_failed_assertion()
* added `unlikely()` to `if(!(pass))` check in KUNIT_ASSERTION()
v2 -> v3:
* elaborate on intermediate TODO in patch 5 (deleted in patch 6)
* update with more Reviewed-by's
Daniel Latypov (6):
kunit: add example test case showing off all the expect macros
kunit: move check if assertion passed into the macros
kunit: drop unused kunit* field in kunit_assert
kunit: factor out kunit_base_assert_format() call into kunit_fail()
kunit: split out part of kunit_assert into a static const
kunit: drop unused assert_type from kunit_assert and clean up macros
include/kunit/assert.h | 88 +++++++++++-----------------------
include/kunit/test.h | 53 ++++++++++----------
lib/kunit/assert.c | 15 ++----
lib/kunit/kunit-example-test.c | 42 ++++++++++++++++
lib/kunit/test.c | 27 +++++------
5 files changed, 117 insertions(+), 108 deletions(-)
base-commit: ad659ccb5412874c6a89d3588cb18857c00e9d0f
--
2.34.1.703.g22d0c6ccf7-goog
Note: this series applies on top of the series reducing stack usage,
https://lore.kernel.org/linux-kselftest/20220113165931.451305-1-dlatypov@go…
There's no real smenatic dependency between these, just potential for
merge conflicts.
The current layout of the assertion macros is confusing.
Here's the call chain for KUNIT_EXPECT_EQ() and KUNIT_EXPECT_EQ_MSG()
KUNIT_EXPECT_EQ =>
KUNIT_BINARY_EQ_ASSERTION => # note: not shared with the _MSG variant
KUNIT_BINARY_EQ_MSG_ASSERTION =>
KUNIT_BASE_EQ_MSG_ASSERTION =>
KUNIT_BASE_BINARY_ASSERTION
KUNIT_EXPECT_EQ_MSG =>
KUNIT_BINARY_EQ_MSG_ASSERTION =>
KUNIT_BASE_EQ_MSG_ASSERTION =>
KUNIT_BASE_BINARY_ASSERTION
After this series
KUNIT_EXPECT_EQ =>
KUNIT_EXPECT_EQ_MSG =>
KUNIT_BINARY_INT_ASSERTION =>
KUNIT_BASE_BINARY_ASSERTION
The current macro layout tries hard to reduce duplication, but comes at
the cost of a lot of intermediates that can simply vanish.
The same call-chain again, but annotated with the info we add:
KUNIT_EXPECT_EQ => specify we're an EXPECT, not an ASSERT
KUNIT_BINARY_EQ_ASSERTION => specify we have a NULL msg
KUNIT_BINARY_EQ_MSG_ASSERTION => specify we work with ints, not ptrs
KUNIT_BASE_EQ_MSG_ASSERTION => specify that the op is '=='
KUNIT_BASE_BINARY_ASSERTION
We can see that each level of the chain only specifes one parameter at
a time. We've taken the concept of DRY too far.
The following is a full snippet of all the macros needed for
KUNIT_EXPECT_EQ, showing that a bit of repetition is just fine:
#define KUNIT_BINARY_INT_ASSERTION(test, \
assert_type, \
left, \
op, \
right, \
fmt, \
...) \
KUNIT_BASE_BINARY_ASSERTION(test, \
kunit_binary_assert, \
KUNIT_INIT_BINARY_ASSERT_STRUCT, \
assert_type, \
left, op, right, \
fmt, \
##__VA_ARGS__)
#define KUNIT_EXPECT_EQ(test, left, right) \
KUNIT_EXPECT_EQ_MSG(test, left, right, NULL)
#define KUNIT_EXPECT_EQ_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_INT_ASSERTION(test, \
KUNIT_EXPECTATION, \
left, ==, right, \
fmt, \
##__VA_ARGS__)
as opposed to our current DRYer version
#define KUNIT_BASE_EQ_MSG_ASSERTION(test, \
assert_class, \
ASSERT_CLASS_INIT, \
assert_type, \
left, \
right, \
fmt, \
...) \
KUNIT_BASE_BINARY_ASSERTION(test, \
assert_class, \
ASSERT_CLASS_INIT, \
assert_type, \
left, ==, right, \
fmt, \
##__VA_ARGS__)
#define KUNIT_BINARY_EQ_MSG_ASSERTION(test, assert_type, left, right, fmt, ...)\
KUNIT_BASE_EQ_MSG_ASSERTION(test, \
kunit_binary_assert, \
KUNIT_INIT_BINARY_ASSERT_STRUCT, \
assert_type, \
left, \
right, \
fmt, \
##__VA_ARGS__)
#define KUNIT_BINARY_EQ_ASSERTION(test, assert_type, left, right) \
KUNIT_BINARY_EQ_MSG_ASSERTION(test, \
assert_type, \
left, \
right, \
NULL)
#define KUNIT_EXPECT_EQ(test, left, right) \
KUNIT_BINARY_EQ_ASSERTION(test, KUNIT_EXPECTATION, left, right)
#define KUNIT_EXPECT_EQ_MSG(test, left, right, fmt, ...) \
KUNIT_BINARY_EQ_MSG_ASSERTION(test, \
KUNIT_EXPECTATION, \
left, \
right, \
fmt, \
##__VA_ARGS__)
Daniel Latypov (5):
kunit: make KUNIT_EXPECT_EQ() use KUNIT_EXPECT_EQ_MSG(), etc.
kunit: drop unused intermediate macros for ptr inequality checks
kunit: reduce layering in string assertion macros
kunit: decrease macro layering for integer asserts
kunit: decrease macro layering for EQ/NE asserts
include/kunit/test.h | 660 ++++++++++---------------------------------
1 file changed, 142 insertions(+), 518 deletions(-)
--
2.34.1.703.g22d0c6ccf7-goog
KUnit unifies the test structure and provides helper tools that simplify
the development. Basic use case allows running tests as regular processes,
leveraging User Mode Linux.
For example, to execute all DRM unit tests:
./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm
(the tool also allows using QEMU instead of UML by adding e.g. --arch=x86_64)
For developers - it means that it's easier to run unit tests on the development
machine, tightening the feedback loop. When using UML, it also simplifies using
gdb for debug (since the kernel is just a regular process).
For CI systems - DRM tests can be moved from being executed on device under
test (that's also running IGTs and so on) to being executed on buildsystem
during build (just like checkpatch.pl).
All tests were renamed - IGT prefix is no longer used.
Compared to selftests executed by CI using IGT, there's one functional
regression - KUnit test runner is not catching WARNs.
To solve this, we could either go in the similar direction that UBSAN went in:
1195505 ("kunit: ubsan integration")
Or we could expand the test runner to catch WARN signature in dmesg.
Pastebin to preview the output and execution times:
https://gitlab.freedesktop.org/-/snippets/4139
-Michał
Michał Winiarski (10):
drm: test-drm_cmdline_parser: Convert to KUnit
drm: test-drm_plane_helper: Convert to KUnit
drm: test-drm_format: Convert to KUnit
drm: test-drm_framebuffer: Convert to KUnit
drm: test-drm_damage_helper: Convert to KUnit
drm: test-drm_dp_mst_helper: Convert to KUnit
drm: test-drm_rect: Convert to KUnit
drm: test-drm_mm: Convert to KUnit
drm: selftests: Convert to KUnit
drm: test: Simplify testing on UML with kunit.py
drivers/gpu/drm/.kunitconfig | 3 +
drivers/gpu/drm/Kconfig | 22 +-
drivers/gpu/drm/Makefile | 2 +-
drivers/gpu/drm/i915/Kconfig.debug | 1 -
drivers/gpu/drm/selftests/Makefile | 7 -
.../gpu/drm/selftests/drm_cmdline_selftests.h | 68 -
drivers/gpu/drm/selftests/drm_mm_selftests.h | 28 -
.../gpu/drm/selftests/drm_modeset_selftests.h | 40 -
drivers/gpu/drm/selftests/drm_selftest.c | 109 -
drivers/gpu/drm/selftests/drm_selftest.h | 41 -
.../drm/selftests/test-drm_cmdline_parser.c | 1141 --------
.../drm/selftests/test-drm_damage_helper.c | 667 -----
.../drm/selftests/test-drm_dp_mst_helper.c | 273 --
drivers/gpu/drm/selftests/test-drm_format.c | 280 --
drivers/gpu/drm/selftests/test-drm_mm.c | 2487 -----------------
.../drm/selftests/test-drm_modeset_common.c | 32 -
.../drm/selftests/test-drm_modeset_common.h | 52 -
.../gpu/drm/selftests/test-drm_plane_helper.c | 223 --
drivers/gpu/drm/selftests/test-drm_rect.c | 223 --
drivers/gpu/drm/test/Makefile | 7 +
.../gpu/drm/test/test-drm_cmdline_parser.c | 1027 +++++++
drivers/gpu/drm/test/test-drm_damage_helper.c | 667 +++++
drivers/gpu/drm/test/test-drm_dp_mst_helper.c | 429 +++
drivers/gpu/drm/test/test-drm_format.c | 356 +++
.../test-drm_framebuffer.c | 109 +-
drivers/gpu/drm/test/test-drm_mm.c | 2426 ++++++++++++++++
drivers/gpu/drm/test/test-drm_plane_helper.c | 312 +++
drivers/gpu/drm/test/test-drm_rect.c | 249 ++
drivers/video/Kconfig | 4 +
29 files changed, 5558 insertions(+), 5727 deletions(-)
create mode 100644 drivers/gpu/drm/.kunitconfig
delete mode 100644 drivers/gpu/drm/selftests/Makefile
delete mode 100644 drivers/gpu/drm/selftests/drm_cmdline_selftests.h
delete mode 100644 drivers/gpu/drm/selftests/drm_mm_selftests.h
delete mode 100644 drivers/gpu/drm/selftests/drm_modeset_selftests.h
delete mode 100644 drivers/gpu/drm/selftests/drm_selftest.c
delete mode 100644 drivers/gpu/drm/selftests/drm_selftest.h
delete mode 100644 drivers/gpu/drm/selftests/test-drm_cmdline_parser.c
delete mode 100644 drivers/gpu/drm/selftests/test-drm_damage_helper.c
delete mode 100644 drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
delete mode 100644 drivers/gpu/drm/selftests/test-drm_format.c
delete mode 100644 drivers/gpu/drm/selftests/test-drm_mm.c
delete mode 100644 drivers/gpu/drm/selftests/test-drm_modeset_common.c
delete mode 100644 drivers/gpu/drm/selftests/test-drm_modeset_common.h
delete mode 100644 drivers/gpu/drm/selftests/test-drm_plane_helper.c
delete mode 100644 drivers/gpu/drm/selftests/test-drm_rect.c
create mode 100644 drivers/gpu/drm/test/Makefile
create mode 100644 drivers/gpu/drm/test/test-drm_cmdline_parser.c
create mode 100644 drivers/gpu/drm/test/test-drm_damage_helper.c
create mode 100644 drivers/gpu/drm/test/test-drm_dp_mst_helper.c
create mode 100644 drivers/gpu/drm/test/test-drm_format.c
rename drivers/gpu/drm/{selftests => test}/test-drm_framebuffer.c (91%)
create mode 100644 drivers/gpu/drm/test/test-drm_mm.c
create mode 100644 drivers/gpu/drm/test/test-drm_plane_helper.c
create mode 100644 drivers/gpu/drm/test/test-drm_rect.c
--
2.34.1
Build of several selftests fail if separate output directory is
specified by the following methods:
1) make -C tools/testing/selftests O=<build_dir>
2) export KBUILD_OUTPUT="build_dir"; make -C tools/testing/selftests
Build fails because of several reasons:
1) The kernel headers aren't found.
2) The path of output objects is wrong and hence unaccessible.
These problems can be solved by:
1) Including the correct path of uapi header files
2) By setting the BUILD variable correctly inside Makefile
Following different build scenarios have been tested after making these
changes to verify that nothing gets broken with these changes:
make -C tools/testing/selftests
make -C tools/testing/selftests/futex
make -C tools/testing/selftests/kvm
make -C tools/testing/selftests/landlock
make -C tools/testing/selftests/net
make -C tools/testing/selftests/net/mptcp
make -C tools/testing/selftests/vm
make -C tools/testing/selftests O=build
make -C tools/testing/selftests o=/opt/build
export KBUILD_OUTPUT="/opt/build"; make -C tools/testing/selftests
export KBUILD_OUTPUT="build"; make -C tools/testing/selftests
cd <any_dir>; make -C <src_path>/tools/testing/selftests
cd <any_dir>; make -C <src_path>/tools/testing/selftests O=build
---
Changes in V2:
Revert the excessive cleanup which was breaking the individual
test build.
Muhammad Usama Anjum (10):
selftests: set the BUILD variable to absolute path
selftests: Add and export a kernel uapi headers path
selftests: Correct the headers install path
selftests: futex: Add the uapi headers include variable
selftests: kvm: Add the uapi headers include variable
selftests: landlock: Add the uapi headers include variable
selftests: net: Add the uapi headers include variable
selftests: mptcp: Add the uapi headers include variable
selftests: vm: Add the uapi headers include variable
selftests: vm: remove dependecy from internal kernel macros
tools/testing/selftests/Makefile | 32 +++++++++++++------
.../selftests/futex/functional/Makefile | 5 ++-
tools/testing/selftests/kvm/Makefile | 2 +-
tools/testing/selftests/landlock/Makefile | 2 +-
tools/testing/selftests/net/Makefile | 2 +-
tools/testing/selftests/net/mptcp/Makefile | 2 +-
tools/testing/selftests/vm/Makefile | 2 +-
tools/testing/selftests/vm/userfaultfd.c | 3 ++
8 files changed, 32 insertions(+), 18 deletions(-)
--
2.30.2
Synchronous Ethernet networks use a physical layer clock to syntonize
the frequency across different network elements.
Basic SyncE node defined in the ITU-T G.8264 consist of an Ethernet
Equipment Clock (EEC) and have the ability to synchronize to reference
frequency sources.
This patch series is a prerequisite for EEC object and adds ability
to enable recovered clocks in the physical layer of the netdev object.
Recovered clocks can be used as one of the reference signal by the EEC.
Further work is required to add the DPLL subsystem, link it to the
netdev object and create API to read the EEC DPLL state.
v5:
- rewritten the documentation
- fixed doxygen headers
v4:
- Dropped EEC_STATE reporting (TBD: DPLL subsystem)
- moved recovered clock configuration to ethtool netlink
v3:
- remove RTM_GETRCLKRANGE
- return state of all possible pins in the RTM_GETRCLKSTATE
- clarify documentation
v2:
- improved documentation
- fixed kdoc warning
RFC history:
v2:
- removed whitespace changes
- fix issues reported by test robot
v3:
- Changed naming from SyncE to EEC
- Clarify cover letter and commit message for patch 1
v4:
- Removed sync_source and pin_idx info
- Changed one structure to attributes
- Added EEC_SRC_PORT flag to indicate that the EEC is synchronized
to the recovered clock of a port that returns the state
v5:
- add EEC source as an optiona attribute
- implement support for recovered clocks
- align states returned by EEC to ITU-T G.781
v6:
- fix EEC clock state reporting
- add documentation
- fix descriptions in code comments
Maciej Machnikowski (4):
ice: add support detecting features based on netlist
ethtool: Add ability to configure recovered clock for SyncE feature
ice: add support for monitoring SyncE DPLL state
ice: add support for recovered clocks
Documentation/networking/ethtool-netlink.rst | 62 ++++
drivers/net/ethernet/intel/ice/ice.h | 7 +
.../net/ethernet/intel/ice/ice_adminq_cmd.h | 70 ++++-
drivers/net/ethernet/intel/ice/ice_common.c | 224 +++++++++++++++
drivers/net/ethernet/intel/ice/ice_common.h | 20 +-
drivers/net/ethernet/intel/ice/ice_devids.h | 3 +
drivers/net/ethernet/intel/ice/ice_ethtool.c | 96 +++++++
drivers/net/ethernet/intel/ice/ice_lib.c | 6 +-
drivers/net/ethernet/intel/ice/ice_ptp.c | 35 +++
drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 49 ++++
drivers/net/ethernet/intel/ice/ice_ptp_hw.h | 36 +++
drivers/net/ethernet/intel/ice/ice_type.h | 1 +
include/linux/ethtool.h | 9 +
include/uapi/linux/ethtool_netlink.h | 21 ++
net/ethtool/Makefile | 3 +-
net/ethtool/netlink.c | 20 ++
net/ethtool/netlink.h | 4 +
net/ethtool/synce.c | 267 ++++++++++++++++++
18 files changed, 929 insertions(+), 4 deletions(-)
create mode 100644 net/ethtool/synce.c
--
2.26.3
Build of several selftests fail if separate output directory is
specified by the following methods:
1) make -C tools/testing/selftests O=<build_dir>
2) export KBUILD_OUTPUT="build_dir"; make -C tools/testing/selftests
Build fails because of several reasons:
1) The kernel headers aren't found.
2) The path of output objects is wrong and hence unaccessible.
These problems can be solved by:
1) Including the correct path of uapi header files
2) By setting the BUILD variable correctly inside Makefile
Following different build scnerios have been tested after making these
changes:
make -C tools/testing/selftests
make -C tools/testing/selftests O=build
make -C tools/testing/selftests o=/opt/build
export KBUILD_OUTPUT="/opt/build"; make -C tools/testing/selftests
export KBUILD_OUTPUT="build"; make -C tools/testing/selftests
cd <any_dir>; make -C <src_path>/tools/testing/selftests
cd <any_dir>; make -C <src_path>/tools/testing/selftests O=build
Muhammad Usama Anjum (10):
selftests: set the BUILD variable to absolute path
selftests: Add and export a kernel uapi headers path
selftests: Correct the headers install path
selftests: futex: Add the uapi headers include variable
selftests: kvm: Add the uapi headers include variable
selftests: landlock: Add the uapi headers include variable
selftests: net: Add the uapi headers include variable
selftests: mptcp: Add the uapi headers include variable
selftests: vm: Add the uapi headers include variable
selftests: vm: remove dependecy from internal kernel macros
tools/testing/selftests/Makefile | 32 +++++++++++++------
.../selftests/futex/functional/Makefile | 5 ++-
tools/testing/selftests/kvm/Makefile | 6 ++--
tools/testing/selftests/landlock/Makefile | 11 ++-----
tools/testing/selftests/net/Makefile | 2 +-
tools/testing/selftests/net/mptcp/Makefile | 3 +-
tools/testing/selftests/vm/Makefile | 2 +-
tools/testing/selftests/vm/userfaultfd.c | 3 ++
8 files changed, 35 insertions(+), 29 deletions(-)
--
2.30.2