Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/pgoyette-compat]: src/tests/modules Adapt this test to the new MODCTL_ST...
details: https://anonhg.NetBSD.org/src/rev/5f6c95187c13
branches: pgoyette-compat
changeset: 830616:5f6c95187c13
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Wed Sep 05 21:53:45 2018 +0000
description:
Adapt this test to the new MODCTL_STAT, too.
diffstat:
tests/modules/t_builtin.c | 36 +++++++++++++++++++++++++++---------
1 files changed, 27 insertions(+), 9 deletions(-)
diffs (60 lines):
diff -r 95b532da38ce -r 5f6c95187c13 tests/modules/t_builtin.c
--- a/tests/modules/t_builtin.c Wed Sep 05 09:53:57 2018 +0000
+++ b/tests/modules/t_builtin.c Wed Sep 05 21:53:45 2018 +0000
@@ -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.3.12.1 2018/09/05 21:53:45 pgoyette Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc. All rights reserved.
@@ -139,9 +139,11 @@
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,14 +151,30 @@
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;
+
+ errno = 0;
- 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;
+ 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;
}
}
Home |
Main Index |
Thread Index |
Old Index