Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests Make random garbage more widely available.



details:   https://anonhg.NetBSD.org/src/rev/fe0f2f8194cf
branches:  trunk
changeset: 757146:fe0f2f8194cf
user:      pooka <pooka%NetBSD.org@localhost>
date:      Mon Aug 16 10:46:19 2010 +0000

description:
Make random garbage more widely available.

diffstat:

 tests/fs/puffs/t_fuzz.c |  20 +++-----------------
 tests/h_macros.h        |  16 +++++++++++++++-
 2 files changed, 18 insertions(+), 18 deletions(-)

diffs (76 lines):

diff -r 1167339c8b92 -r fe0f2f8194cf tests/fs/puffs/t_fuzz.c
--- a/tests/fs/puffs/t_fuzz.c   Mon Aug 16 10:23:25 2010 +0000
+++ b/tests/fs/puffs/t_fuzz.c   Mon Aug 16 10:46:19 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_fuzz.c,v 1.2 2010/08/02 09:44:23 pooka Exp $ */
+/*     $NetBSD: t_fuzz.c,v 1.3 2010/08/16 10:46:20 pooka Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -60,20 +60,6 @@
 #define ITERATIONS 100
 
 static void
-makegarbage(void *space, size_t len)
-{
-       long *sb = space;
-       long randval;
-
-       while (len >= sizeof(long)) {
-               *sb++ = random();
-               len -= sizeof(long);
-       }
-       randval = random();
-       memcpy(sb, &randval, len);
-}
-
-static void
 fixversion(struct puffs_kargs *kargs)
 {
 
@@ -226,7 +212,7 @@
        ATF_REQUIRE(rump_sys_mkdir("/mnt", 0777) == 0);
 
        for (i = 0; i < ITERATIONS; i++) {
-               makegarbage(&kargs, sizeof(kargs));
+               tests_makegarbage(&kargs, sizeof(kargs));
                fixup(nfix, &kargs);
                if (rump_sys_mount(MOUNT_PUFFS, "/mnt", 0,
                    &kargs, sizeof(kargs)) == 0) {
@@ -251,7 +237,7 @@
 #define MAKETEST(_n_)                                                  \
 ATF_TC(mountfuzz##_n_);                                                        \
 ATF_TC_HEAD(mountfuzz##_n_, tc)                                                \
-{atf_tc_set_md_var(tc, "descr", "garbage kargs, " # _n_ " fix");}      \
+{atf_tc_set_md_var(tc, "descr", "garbage kargs, " # _n_ " fix(es)");}  \
 ATF_TC_BODY(mountfuzz##_n_, tc) {testbody(_n_);}
 
 MAKETEST(0);
diff -r 1167339c8b92 -r fe0f2f8194cf tests/h_macros.h
--- a/tests/h_macros.h  Mon Aug 16 10:23:25 2010 +0000
+++ b/tests/h_macros.h  Mon Aug 16 10:46:19 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: h_macros.h,v 1.3 2010/07/25 22:29:15 pooka Exp $ */
+/* $NetBSD: h_macros.h,v 1.4 2010/08/16 10:46:19 pooka Exp $ */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,4 +61,18 @@
        atf_tc_fail(buf);
 }
 
+static __inline void
+tests_makegarbage(void *space, size_t len)
+{
+       uint16_t *sb = space;
+       uint16_t randval;
+
+       while (len >= sizeof(randval)) {
+               *sb++ = (random() & 0xffff);
+               len -= sizeof(*sb);
+       }
+       randval = (uint16_t)random();
+       memcpy(sb, &randval, len);
+}
+
 #endif



Home | Main Index | Thread Index | Old Index