Hi all,
There is a minor issue that prevents self test net/af_unix to run on my platform:
# ./test_unix_oob
Connect failed: No such file or directory
Terminated
Tracing reveals that bind tried to open a shorter AF_UNIX socket address:
# strace -f ./test_unix_oob
.
.
.
socket(AF_UNIX, SOCK_STREAM, 0) = 3
getpid() = 453059
unlink("unix_oob_453059") = -1 ENOENT (No such file or directory)
bind(3, {sa_family=AF_UNIX, sun_path="unix_oob_453059"}, 110) = 0
pipe2([4, 5], 0) = 0
listen(3, 1) = 0
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fa6a6577a10) = 453060
rt_sigaction(SIGURG, {sa_handler=0x5601e2d014c9, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO,
sa_restorer=0x7fa6a623bcf0}, NULL, 8) = 0
write(5, "S", 1) = 1
accept(3, strace: Process 453060 attached
<unfinished ...>
[pid 453060] set_robust_list(0x7fa6a6577a20, 24) = 0
[pid 453060] socket(AF_UNIX, SOCK_STREAM, 0) = 6
[pid 453060] read(4, "S", 5) = 1
[pid 453060] connect(6, {sa_family=AF_UNIX, sun_path="unix_oob_45305"}, 16) = -1 ENOENT (No such file or directory)
.
.
.
NOTE: bind used UNIX_AF addr "unix_oob_453059", while producer tries to connect to "unix_oob_45305".
When pids were up to 5 digits it probably did not manifest, but logically the size of the
consumer_addr is sizeof(struct sockaddr_un).
Please find the patch attached:
Thanks,
Mirsad
------------------------------------------------------------------------------------------------
diff --git a/tools/testing/selftests/net/af_unix/test_unix_oob.c b/tools/testing/selftests/net/af_unix/test_unix_oob.c
index b57e91e1c3f2..7ea733239cd9 100644
--- a/tools/testing/selftests/net/af_unix/test_unix_oob.c
+++ b/tools/testing/selftests/net/af_unix/test_unix_oob.c
@@ -124,7 +124,7 @@ void producer(struct sockaddr_un *consumer_addr)
wait_for_signal(pipefd[0]);
if (connect(cfd, (struct sockaddr *)consumer_addr,
- sizeof(struct sockaddr)) != 0) {
+ sizeof(struct sockaddr_un)) != 0) {
perror("Connect failed");
kill(0, SIGTERM);
exit(1);
--
Mirsad Goran Todorovac
Sistem inženjer
Grafički fakultet | Akademija likovnih umjetnosti
Sveučilište u Zagrebu
--
System engineer
Faculty of Graphic Arts | Academy of Fine Arts
University of Zagreb, Republic of Croatia
The European Union
This series provides a bunch of quick updates which should make the
coverage from pcm-test a bit more useful, it adds some support for
skipping tests when the hardware/driver is unable to support the
requested configuration, support for providing user visible descriptions
and then expands the set of cases we cover to include more sample rates
and channel counts. This should exercise switching between 8kHz and
44.1kHz based rates and ensure that clocking doesn't get confused by
non-stereo channel counts, both of which are I expect common real world
errors, at least for embedded cards.
v4:
- Rebase onto v6.2-rc1.
v3:
- "Rebase" onto Takashi's current tree (with a revert).
- Include Jaroslav's changes to specify all tests in the configuration
file parsing.
- Add a new "description" field to the configuration instead of trying
to name the tests.
- Always run both default and per-system tests, logging our success at
setting the per-system configurations as a separate test since they
shouldn't fail.
v2:
- Rebase onto Takashi's current tree.
- Tweak the buffer sizes for the newly added cases, don't be quite
so ambitious in how big a buffer we request for 96kHz and don't
go quite so small for 8kHz since some devices start hitting lower
limits on period size and struggle to deliver accurate timing.
To: Takashi Iwai <tiwai(a)suse.com>
To: Jaroslav Kysela <perex(a)perex.cz>
To: Shuah Khan <shuah(a)kernel.org>
Cc: alsa-devel(a)alsa-project.org
Cc: linux-kselftest(a)vger.kernel.org
Cc: linux-kernel(a)vger.kernel.org
Signed-off-by: Mark Brown <broonie(a)kernel.org>
---
Jaroslav Kysela (1):
kselftest/alsa: pcm - move more configuration to configuration files
Mark Brown (6):
kselftest/alsa: pcm - Drop recent coverage improvement changes
kselftest/alsa: pcm - Always run the default set of tests
kselftest/alsa: pcm - skip tests when we fail to set params
kselftest/alsa: pcm - Support optional description for tests
kselftest/alsa: pcm - Provide descriptions for the default tests
kselftest/alsa: pcm - Add more coverage by default
tools/testing/selftests/alsa/Makefile | 2 +-
tools/testing/selftests/alsa/alsa-local.h | 3 +
tools/testing/selftests/alsa/conf.c | 26 ++-
.../alsa/conf.d/Lenovo_ThinkPad_P1_Gen2.conf | 43 +++--
tools/testing/selftests/alsa/pcm-test.c | 205 ++++++++++++++-------
tools/testing/selftests/alsa/pcm-test.conf | 63 +++++++
6 files changed, 250 insertions(+), 92 deletions(-)
---
base-commit: 1b929c02afd37871d5afb9d498426f83432e71c2
change-id: 20221208-alsa-pcm-test-hacks-f6c1aa76bd2c
Best regards,
--
Mark Brown <broonie(a)kernel.org>
Add a test to assert that we can mremap() and expand a mapping starting
from an offset within an existing mapping. We unmap the last page in a 3
page mapping to ensure that the remap should always succeed, before
remapping from the 2nd page.
This is additionally a regression test for the issue solved in "mm, mremap:
fix mremap() expanding vma with addr inside vma" and confirmed to fail
prior to the change and pass after it.
Finally, this patch updates the existing mremap expand merge test to check
error conditions and reduce code duplication between the two tests.
Signed-off-by: Lorenzo Stoakes <lstoakes(a)gmail.com>
---
tools/testing/selftests/vm/mremap_test.c | 111 +++++++++++++++++++----
1 file changed, 93 insertions(+), 18 deletions(-)
diff --git a/tools/testing/selftests/vm/mremap_test.c b/tools/testing/selftests/vm/mremap_test.c
index 9496346973d4..28a17d4e8afd 100644
--- a/tools/testing/selftests/vm/mremap_test.c
+++ b/tools/testing/selftests/vm/mremap_test.c
@@ -119,30 +119,19 @@ static unsigned long long get_mmap_min_addr(void)
}
/*
- * This test validates that merge is called when expanding a mapping.
- * Mapping containing three pages is created, middle page is unmapped
- * and then the mapping containing the first page is expanded so that
- * it fills the created hole. The two parts should merge creating
- * single mapping with three pages.
+ * Using /proc/self/maps, assert that the specified address range is contained
+ * within a single mapping.
*/
-static void mremap_expand_merge(unsigned long page_size)
+static bool is_range_mapped(void *start, void *end)
{
- char *test_name = "mremap expand merge";
FILE *fp;
char *line = NULL;
size_t len = 0;
bool success = false;
- char *start = mmap(NULL, 3 * page_size, PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-
- munmap(start + page_size, page_size);
- mremap(start, page_size, 2 * page_size, 0);
fp = fopen("/proc/self/maps", "r");
- if (fp == NULL) {
- ksft_test_result_fail("%s\n", test_name);
- return;
- }
+ if (fp == NULL)
+ return false;
while (getline(&line, &len, fp) != -1) {
char *first = strtok(line, "- ");
@@ -150,16 +139,101 @@ static void mremap_expand_merge(unsigned long page_size)
char *second = strtok(NULL, "- ");
void *second_val = (void *) strtol(second, NULL, 16);
- if (first_val == start && second_val == start + 3 * page_size) {
+ if (first_val <= start && second_val >= end) {
success = true;
break;
}
}
+
+ fclose(fp);
+ return success;
+}
+
+/*
+ * This test validates that merge is called when expanding a mapping.
+ * Mapping containing three pages is created, middle page is unmapped
+ * and then the mapping containing the first page is expanded so that
+ * it fills the created hole. The two parts should merge creating
+ * single mapping with three pages.
+ */
+static void mremap_expand_merge(unsigned long page_size)
+{
+ char *test_name = "mremap expand merge";
+ bool success = false;
+ int errsv = 0;
+ char *remap;
+ char *start = mmap(NULL, 3 * page_size, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+
+ if (start == MAP_FAILED) {
+ errsv = errno;
+ goto error;
+ }
+
+ munmap(start + page_size, page_size);
+ remap = mremap(start, page_size, 2 * page_size, 0);
+ if (remap == MAP_FAILED) {
+ errsv = errno;
+ munmap(start, page_size);
+ munmap(start + 2 * page_size, page_size);
+ goto error;
+ }
+
+ success = is_range_mapped(start, start + 3 * page_size);
+
+ munmap(start, 3 * page_size);
+ goto out;
+
+error:
+ ksft_print_msg("Unexpected mapping/remapping error: %s\n",
+ strerror(errsv));
+out:
+ if (success)
+ ksft_test_result_pass("%s\n", test_name);
+ else
+ ksft_test_result_fail("%s\n", test_name);
+}
+
+/*
+ * Similar to mremap_expand_merge() except instead of removing the middle page,
+ * we remove the last then attempt to remap offset from the second page. This
+ * should result in the mapping being restored to its former state.
+ */
+static void mremap_expand_merge_offset(unsigned long page_size)
+{
+
+ char *test_name = "mremap expand merge offset";
+ bool success = false;
+ int errsv = 0;
+ char *remap;
+ char *start = mmap(NULL, 3 * page_size, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+
+ if (start == MAP_FAILED) {
+ errsv = errno;
+ goto error;
+ }
+
+ /* Unmap final page to ensure we have space to expand. */
+ munmap(start + 2 * page_size, page_size);
+ remap = mremap(start + page_size, page_size, 2 * page_size, 0);
+ if (remap == MAP_FAILED) {
+ errsv = errno;
+ munmap(start, 2 * page_size);
+ goto error;
+ }
+
+ success = is_range_mapped(start, start + 3 * page_size);
+ goto out;
+
+error:
+ ksft_print_msg("Unexpected mapping/remapping error: %s\n",
+ strerror(errsv));
+out:
if (success)
ksft_test_result_pass("%s\n", test_name);
else
ksft_test_result_fail("%s\n", test_name);
- fclose(fp);
}
/*
@@ -459,6 +533,7 @@ int main(int argc, char **argv)
pattern_seed);
mremap_expand_merge(page_size);
+ mremap_expand_merge_offset(page_size);
if (run_perf_tests) {
ksft_print_msg("\n%s\n",
--
2.38.1
This patchset will fix a false-positive issue caused by the command in
cleanup_v6() of the arp_ndisc_evict_nocarrier test.
Also, it will make the test to return a non-zero value for any failure
reported in the test for us to avoid false-negative results.
Po-Hsu Lin (2):
selftests: net: fix cleanup_v6() for arp_ndisc_evict_nocarrier
selftests: net: return non-zero for failures reported in
arp_ndisc_evict_nocarrier
tools/testing/selftests/net/arp_ndisc_evict_nocarrier.sh | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
--
2.7.4