Hello,
The aim of this patch series is to improve the resctrl selftest.
The first three patches clear redundant code.
The last two patches are bug fixes. Without the two fixes,
some unnecessary processing will be executed and test results
will be confusing. There is no behavior change in test themselves.
[patch 1] Because the default schemata is 100% , in MBM test
it is not necessary to reset schemata by write_schemata().
[patch 2] Delete CMT-related processing in write_schemata() which is
not called by CMT.
[patch 3] Before exiting each test CMT/CAT/MBM/MBA, clear test result
files function cat/cmt/mbm/mba_test_cleanup() are called twice.
Delete once.
[patch 4] If there is an exception occurs after creating a child
process with fork() in the CAT test, kill the child process
before terminating the parent process.
[patch 5] When a child process is created by fork(), the buffer of the
parent process is also copied. Flush the buffer before executing fork().
This patch series is based on Linux v6.0-rc5
Shaopeng Tan (5):
selftests/resctrl: Clear unused initalization code in MBM tests
selftests/resctrl: Clear unused common codes called by CAT/MBA tests
testing/selftests: Remove duplicate codes that clear each test result
file
selftests/resctrl: Kill the child process before exiting the parent
process if an exception occurs
selftests/resctrl: Flush stdout file buffer before executing fork()
tools/testing/selftests/resctrl/cat_test.c | 17 +++++++++--------
tools/testing/selftests/resctrl/cmt_test.c | 2 --
tools/testing/selftests/resctrl/mba_test.c | 2 --
tools/testing/selftests/resctrl/mbm_test.c | 19 ++++++-------------
tools/testing/selftests/resctrl/resctrl_val.c | 1 +
tools/testing/selftests/resctrl/resctrlfs.c | 7 +++----
6 files changed, 19 insertions(+), 29 deletions(-)
--
2.27.0
The wordings of step-by-step instructions on writing the first Kunit test
are instructing readers to write codes without knowing what these are about.
Rewrite these instructions to include the purpose of written code.
While at it, align the code blocks of these contents.
Signed-off-by: Bagas Sanjaya <bagasdotme(a)gmail.com>
---
This patch is based on Khalid's full path to .kunitconfig patch [1].
[1]: https://lore.kernel.org/linux-doc/20220929085332.4155-1-khalid.masum.92@gma…
Documentation/dev-tools/kunit/start.rst | 40 ++++++++++++++-----------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/Documentation/dev-tools/kunit/start.rst b/Documentation/dev-tools/kunit/start.rst
index 7999874dc4ddb3..9628360947507b 100644
--- a/Documentation/dev-tools/kunit/start.rst
+++ b/Documentation/dev-tools/kunit/start.rst
@@ -131,17 +131,19 @@ are built-in. Otherwise the module will need to be loaded.
Writing Your First Test
=======================
-In your kernel repository, let's add some code that we can test.
+In your kernel repository, let's add some code that we can test. For this
+purpose, we are going to add simple addition driver.
-1. Create a file ``drivers/misc/example.h``, which includes:
+1. Write the feature that will be tested. First, write the declaration
+ for ``misc_example_add()`` in ``drivers/misc/example.h``:
-.. code-block:: c
+ .. code-block:: c
int misc_example_add(int left, int right);
-2. Create a file ``drivers/misc/example.c``, which includes:
+ Then implement the function in ``drivers/misc/example.c``:
-.. code-block:: c
+ .. code-block:: c
#include <linux/errno.h>
@@ -152,24 +154,25 @@ In your kernel repository, let's add some code that we can test.
return left + right;
}
-3. Add the following lines to ``drivers/misc/Kconfig``:
+3. Add Kconfig menu entry for the feature to ``drivers/misc/Kconfig``:
-.. code-block:: kconfig
+ .. code-block:: kconfig
config MISC_EXAMPLE
bool "My example"
-4. Add the following lines to ``drivers/misc/Makefile``:
+4. Add the kbuild goal that will build the feature to
+ ``drivers/misc/Makefile``:
-.. code-block:: make
+ .. code-block:: make
obj-$(CONFIG_MISC_EXAMPLE) += example.o
Now we are ready to write the test cases.
-1. Add the below test case in ``drivers/misc/example_test.c``:
+1. Write the test in ``drivers/misc/example_test.c``:
-.. code-block:: c
+ .. code-block:: c
#include <kunit/test.h>
#include "example.h"
@@ -202,31 +205,32 @@ Now we are ready to write the test cases.
};
kunit_test_suite(misc_example_test_suite);
-2. Add the following lines to ``drivers/misc/Kconfig``:
+2. Add following Kconfig entry for the test to ``drivers/misc/Kconfig``:
-.. code-block:: kconfig
+ .. code-block:: kconfig
config MISC_EXAMPLE_TEST
tristate "Test for my example" if !KUNIT_ALL_TESTS
depends on MISC_EXAMPLE && KUNIT=y
default KUNIT_ALL_TESTS
-3. Add the following lines to ``drivers/misc/Makefile``:
+3. Add kbuild goal of the test to ``drivers/misc/Makefile``:
-.. code-block:: make
+ .. code-block:: make
obj-$(CONFIG_MISC_EXAMPLE_TEST) += example_test.o
-4. Add following configuration fragments to ``.kunit/.kunitconfig``:
+4. Add following configuration fragments for the test to
+ ``.kunit/.kunitconfig``:
-.. code-block:: none
+ .. code-block:: none
CONFIG_MISC_EXAMPLE=y
CONFIG_MISC_EXAMPLE_TEST=y
5. Run the test:
-.. code-block:: bash
+ .. code-block:: bash
./tools/testing/kunit/kunit.py run
--
An old man doll... just what I always wanted! - Clara
Hi!
>
> On 29.09.22 09:39, zhaogongyi wrote:
> > Hi,
> >
> > We can not get the EBUSY from " echo 0 >
> /sys/devices/system/memory/memoryxxx/online", maybe, redirect the error
> ouput to /dev/null is suitable when calling offline_memory_expect_success():
> >
> > # sh mem-on-off-test.sh -a
> > mem-on-off-test.sh: illegal option -- a Test scope: 2% hotplug memory
> > online all hot-pluggable memory in offline state:
> > SKIPPED - no hot-pluggable memory in offline state
> > offline 2% hot-pluggable memory in online state
> > trying to offline 4 out of 192 memory block(s):
> > online->offline memory0
> > online->offline memory10
> > online->offline memory100
> > online->offline memory101
> > online->offline memory102
> > online->offline memory103
> > online->offline memory104
> > online->offline memory105
> > online->offline memory106
> > online->offline memory107
> > online->offline memory108
> > online->offline memory109
> > online->offline memory11
> > online->offline memory110
> > online->offline memory111
> > online->offline memory112
> > online->offline memory113
> > online->offline memory114
> > online->offline memory115
> > online->offline memory116
> > online->offline memory117
> > online->offline memory118
> > online->offline memory119
> > online->offline memory12
> > online->offline memory120
> > online->offline memory121
> > online->offline memory122
> > online->offline memory123
> > online->offline memory124
>
> Can we have here an output like
>
> online->offline memory0
> -> Failure
> online->offline memory10
> -> Success
>
> That would make much more sense for debugging purposes and understanding
> what is happening here. I was primarily concerned about the misleading error
> message, that indicated that something is "unexpected" -- it's perfectly
> reasonable here to *expect* that offlining a random memory blocks just fails.
Yes, I will submit a new version of patches to implement it as your suggestiones:
1. Redirect misleading msg to /dev/null
2. Add an output for online->offline test
Thanks!
>
> --
> Thanks,
>
> David / dhildenb
Commit 6fc3a8636a7b ("kunit: tool: Enable virtio/PCI by default on UML")
made it so we enable these options by default for UML.
Specifying them here is now redundant.
Signed-off-by: Daniel Latypov <dlatypov(a)google.com>
---
tools/testing/kunit/configs/all_tests_uml.config | 2 --
1 file changed, 2 deletions(-)
diff --git a/tools/testing/kunit/configs/all_tests_uml.config b/tools/testing/kunit/configs/all_tests_uml.config
index bdee36bef4a3..f990cbb73250 100644
--- a/tools/testing/kunit/configs/all_tests_uml.config
+++ b/tools/testing/kunit/configs/all_tests_uml.config
@@ -16,8 +16,6 @@ CONFIG_EXT4_FS=y
CONFIG_MSDOS_FS=y
CONFIG_VFAT_FS=y
-CONFIG_VIRTIO_UML=y
-CONFIG_UML_PCI_OVER_VIRTIO=y
CONFIG_PCI=y
CONFIG_USB4=y
base-commit: 0b3acd1cc0222953035d18176b1e4aa06624fd6e
--
2.37.2.789.g6183377224-goog
Hi,
We can not get the EBUSY from " echo 0 > /sys/devices/system/memory/memoryxxx/online", maybe, redirect the error ouput to /dev/null is suitable when calling offline_memory_expect_success():
# sh mem-on-off-test.sh -a
mem-on-off-test.sh: illegal option -- a
Test scope: 2% hotplug memory
online all hot-pluggable memory in offline state:
SKIPPED - no hot-pluggable memory in offline state
offline 2% hot-pluggable memory in online state
trying to offline 4 out of 192 memory block(s):
online->offline memory0
online->offline memory10
online->offline memory100
online->offline memory101
online->offline memory102
online->offline memory103
online->offline memory104
online->offline memory105
online->offline memory106
online->offline memory107
online->offline memory108
online->offline memory109
online->offline memory11
online->offline memory110
online->offline memory111
online->offline memory112
online->offline memory113
online->offline memory114
online->offline memory115
online->offline memory116
online->offline memory117
online->offline memory118
online->offline memory119
online->offline memory12
online->offline memory120
online->offline memory121
online->offline memory122
online->offline memory123
online->offline memory124
online all hot-pluggable memory in offline state:
offline->online memory121
offline->online memory122
offline->online memory123
offline->online memory124
Test with memory notifier error injection
# echo $?
0
Thanks!
Gongyi
>
>
> >> Reviewed-by: David Hildenbrand <david(a)redhat.com>
> >>
> >>
> >> I am questioning the stability of the offlining test, though.
> >> Offlining a random memory block can fail easily, because
> >> "->removable" is not
> >> expressive:
> >>
> >> # tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
> >> Test scope: 2% hotplug memory
> >> online all hot-pluggable memory in offline state:
> >> SKIPPED - no hot-pluggable memory in offline state
> >> offline 2% hot-pluggable memory in online state
> >> trying to offline 2 out of 96 memory block(s):
> >> online->offline memory0
> >> tools/testing/selftests/memory-hotplug/mem-on-off-test.sh: line 78: echo:
> >> write error: Invalid argument offline_memory_expect_success 0:
> >> unexpected fail
> >> online->offline memory10
> >> online->offline memory11
> >>
> >>
> >> I guess this test will almost always fail nowadays.
> >
> > Offline some memory node maybe failed as expected, but the error message
> is a bit annoying.
>
> Ah, I see it now. We try offlining two and fail offlining the first one.
> Can we silence that warning in that case somehow?
>
> --
> Thanks,
>
> David / dhildenb
The numbered list contains full path to every files that need to be
modified or created in order to implement misc-example kunit test.
Except for .kunitconfig. Which might make a newcommer confused about
where the file exists. Since there are multiple .kunitconfig files.
Fix this by using the full path to .kunitconfig.
Signed-off-by: Khalid Masum <khalid.masum.92(a)gmail.com>
---
Documentation/dev-tools/kunit/start.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/dev-tools/kunit/start.rst b/Documentation/dev-tools/kunit/start.rst
index 867a4bba6bf6..69361065cda6 100644
--- a/Documentation/dev-tools/kunit/start.rst
+++ b/Documentation/dev-tools/kunit/start.rst
@@ -217,7 +217,7 @@ Now we are ready to write the test cases.
obj-$(CONFIG_MISC_EXAMPLE_TEST) += example_test.o
-4. Add the following lines to ``.kunitconfig``:
+4. Add the following lines to ``.kunit/.kunitconfig``:
.. code-block:: none
--
2.37.3
There is a spelling mistake in some help text. Fix it.
Signed-off-by: Colin Ian King <colin.i.king(a)gmail.com>
---
tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c b/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
index e19933ea34ca..62827d121c4f 100644
--- a/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
+++ b/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
@@ -211,7 +211,7 @@ static void help(char *name)
puts("");
printf("usage: %s [-h] [-p period_ms] [-t token]\n", name);
puts("");
- printf(" -p: The NX reclaim period in miliseconds.\n");
+ printf(" -p: The NX reclaim period in milliseconds.\n");
printf(" -t: The magic token to indicate environment setup is done.\n");
printf(" -r: The test has reboot permissions and can disable NX huge pages.\n");
puts("");
--
2.37.1
There is a spelling mistake in a printed message. Fix it.
Signed-off-by: Colin Ian King <colin.i.king(a)gmail.com>
---
tools/testing/selftests/sched/cs_prctl_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/sched/cs_prctl_test.c b/tools/testing/selftests/sched/cs_prctl_test.c
index 8109b17dc764..62b579b601bf 100644
--- a/tools/testing/selftests/sched/cs_prctl_test.c
+++ b/tools/testing/selftests/sched/cs_prctl_test.c
@@ -267,7 +267,7 @@ int main(int argc, char *argv[])
if (setpgid(0, 0) != 0)
handle_error("process group");
- printf("\n## Create a thread/process/process group hiearchy\n");
+ printf("\n## Create a thread/process/process group hierarchy\n");
create_processes(num_processes, num_threads, procs);
need_cleanup = 1;
disp_processes(num_processes, procs);
--
2.37.1