summaryrefslogtreecommitdiff
path: root/tests/modules
diff options
context:
space:
mode:
authorpgoyette <pgoyette@NetBSD.org>2019-01-27 02:08:33 +0000
committerpgoyette <pgoyette@NetBSD.org>2019-01-27 02:08:33 +0000
commitcc17ee2ece085d7d746bcd8fa9be19170855aaac (patch)
tree5be40613f405cb081b2c44410b1506781927f8e3 /tests/modules
parent10dd4cc92542aa04b0e59469a484a48e4c3cdd24 (diff)
Merge the [pgoyette-compat] branch
Diffstat (limited to 'tests/modules')
-rw-r--r--tests/modules/t_builtin.c40
-rw-r--r--tests/modules/t_modctl.c16
2 files changed, 40 insertions, 16 deletions
diff --git a/tests/modules/t_builtin.c b/tests/modules/t_builtin.c
index 79845b85c55..0c7cae25edb 100644
--- a/tests/modules/t_builtin.c
+++ b/tests/modules/t_builtin.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_builtin.c,v 1.3 2017/01/13 21:30:42 christos Exp $ */
+/* $NetBSD: t_builtin.c,v 1.4 2019/01/27 02:08:50 pgoyette Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc. All rights reserved.
@@ -139,9 +139,10 @@ ATF_TC_HEAD(disabledstat, tc)
ATF_TC_BODY(disabledstat, tc)
{
- struct modstat ms[128];
+ modstat_t *ms;
struct iovec iov;
- size_t i;
+ size_t len;
+ int count;
bool found = false;
rump_init();
@@ -149,16 +150,35 @@ ATF_TC_BODY(disabledstat, tc)
RL(rump_sys_modctl(MODCTL_UNLOAD, kernfs));
- iov.iov_base = ms;
- iov.iov_len = sizeof(ms);
- RL(rump_sys_modctl(MODCTL_STAT, &iov));
+ for (len = 8192; ;) {
+ iov.iov_base = malloc(len);
+ iov.iov_len = len;
- for (i = 0; i < __arraycount(ms); i++) {
- if (strcmp(ms[i].ms_name, kernfs) == 0) {
- ATF_REQUIRE_EQ(ms[i].ms_refcnt, (u_int)-1);
- found = 1;
+ errno = 0;
+
+ if (rump_sys_modctl(MODCTL_STAT, &iov) != 0) {
+ int err = errno;
+ fprintf(stderr, "modctl(MODCTL_STAT) failed: %s\n",
+ strerror(err));
+ atf_tc_fail("Failed to query module status");
+ }
+ if (len >= iov.iov_len)
+ break;
+ free(iov.iov_base);
+ len = iov.iov_len;
+ }
+
+ count = *(int *)iov.iov_base;
+ ms = (modstat_t *)((char *)iov.iov_base + sizeof(int));
+ while ( count ) {
+ if (strcmp(ms->ms_name, kernfs) == 0) {
+ ATF_REQUIRE_EQ(ms->ms_refcnt, (u_int)-1);
+ found = true;
break;
}
+ ms++;
+ count--;
+
}
ATF_REQUIRE(found);
}
diff --git a/tests/modules/t_modctl.c b/tests/modules/t_modctl.c
index 50cd907f374..43ac6d4aea1 100644
--- a/tests/modules/t_modctl.c
+++ b/tests/modules/t_modctl.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_modctl.c,v 1.12 2012/08/20 08:07:52 martin Exp $ */
+/* $NetBSD: t_modctl.c,v 1.13 2019/01/27 02:08:50 pgoyette Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: t_modctl.c,v 1.12 2012/08/20 08:07:52 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: t_modctl.c,v 1.13 2019/01/27 02:08:50 pgoyette Exp $");
#include <sys/module.h>
#include <sys/sysctl.h>
@@ -84,11 +84,12 @@ get_modstat_info(const char *name, modstat_t *msdest)
{
bool found;
size_t len;
+ int count;
struct iovec iov;
modstat_t *ms;
check_permission();
- for (len = 4096; ;) {
+ for (len = 8192; ;) {
iov.iov_base = malloc(len);
iov.iov_len = len;
@@ -107,14 +108,17 @@ get_modstat_info(const char *name, modstat_t *msdest)
}
found = false;
- len = iov.iov_len / sizeof(modstat_t);
- for (ms = (modstat_t *)iov.iov_base; len != 0 && !found;
- ms++, len--) {
+ count = *(int *)iov.iov_base;
+ ms = (modstat_t *)((char *)iov.iov_base + sizeof(int));
+ while ( count ) {
if (strcmp(ms->ms_name, name) == 0) {
if (msdest != NULL)
*msdest = *ms;
found = true;
+ break;
}
+ ms++;
+ count--;
}
free(iov.iov_base);