Source-Changes-HG archive

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

[src/trunk]: src/tests/lib/libc/string Make running this test conditional on ...



details:   https://anonhg.NetBSD.org/src/rev/ebe845846505
branches:  trunk
changeset: 760093:ebe845846505
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sun Dec 26 13:29:47 2010 +0000

description:
Make running this test conditional on the setting of atf configuration
variable "run_popcount".  This is a really long-running test (it takes
several hours on a qemu-emulation on a 2.8GHz AMD Pheno II) but could
still be useful if you want to run it manually, with the command

        atf-run -v run_popcount=YES

diffstat:

 tests/lib/libc/string/t_popcount.c |  45 +++++++++++++++++++++++--------------
 1 files changed, 28 insertions(+), 17 deletions(-)

diffs (101 lines):

diff -r 68dfd7a40988 -r ebe845846505 tests/lib/libc/string/t_popcount.c
--- a/tests/lib/libc/string/t_popcount.c        Sun Dec 26 12:39:54 2010 +0000
+++ b/tests/lib/libc/string/t_popcount.c        Sun Dec 26 13:29:47 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_popcount.c,v 1.2 2009/07/21 21:45:33 drochner Exp $  */
+/*     $NetBSD: t_popcount.c,v 1.3 2010/12/26 13:29:47 pgoyette Exp $  */
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_popcount.c,v 1.2 2009/07/21 21:45:33 drochner Exp $");
+__RCSID("$NetBSD: t_popcount.c,v 1.3 2010/12/26 13:29:47 pgoyette Exp $");
 
 #include <atf-c.h>
 #include <strings.h>
@@ -40,17 +40,26 @@
 static unsigned int byte_count[256];
 
 static void
-popcount_init(void)
+popcount_init(const char *cfg_var)
 {
        unsigned int i, j;
 
-       for (i = 0; i < 256; ++i) {
-               byte_count[i] = 0;
-               for (j = i; j != 0; j >>= 1) {
-                       if (j & 1)
-                               ++byte_count[i];
+       if (strcasecmp(cfg_var, "YES")  == 0 ||
+           strcasecmp(cfg_var, "Y")    == 0 ||
+           strcasecmp(cfg_var, "1")    == 0 ||
+           strcasecmp(cfg_var, "T")    == 0 ||
+           strcasecmp(cfg_var, "TRUE") == 0) {
+               for (i = 0; i < 256; ++i) {
+                       byte_count[i] = 0;
+                       for (j = i; j != 0; j >>= 1) {
+                               if (j & 1)
+                                       ++byte_count[i];
+                       }
                }
+               return;
        }
+
+       atf_tc_skip("config variable \"run_popcount\" not set to YES/TRUE");
 }
 
 unsigned int test_parts[256] = {
@@ -121,25 +130,19 @@
 };
 
 ATF_TC(t_popcount);
-ATF_TC(t_popcountll);
 
 ATF_TC_HEAD(t_popcount, tc)
 {
+
        atf_tc_set_md_var(tc, "descr", "Test popcount results");
        atf_tc_set_md_var(tc, "timeout", "0");
 }
 
-ATF_TC_HEAD(t_popcountll, tc)
-{
-       atf_tc_set_md_var(tc, "descr", "Test popcountll results");
-       atf_tc_set_md_var(tc, "timeout", "0");
-}
-
 ATF_TC_BODY(t_popcount, tc)
 {
        unsigned int i, r;
 
-       popcount_init();
+       popcount_init(atf_tc_get_config_var_wd(tc, "run_popcount", "NO"));
 
        for (i = 0; i < 0xffffffff; ++i) {
                r = byte_count[i & 255] + byte_count[(i >> 8) & 255]
@@ -151,12 +154,20 @@
        ATF_CHECK_EQ(popcount(0xffffffff), 32);
 }
 
+ATF_TC(t_popcountll);
+ATF_TC_HEAD(t_popcountll, tc)
+{
+
+       atf_tc_set_md_var(tc, "descr", "Test popcountll results");
+       atf_tc_set_md_var(tc, "timeout", "0");
+}
+
 ATF_TC_BODY(t_popcountll, tc)
 {
        unsigned int i, j, r, r2, p;
        unsigned long long v;
 
-       popcount_init();
+       popcount_init(atf_tc_get_config_var_wd(tc, "run_popcount", "NO"));
 
        for (j = 0; j < 256; ++j) {
                p = test_parts[j];



Home | Main Index | Thread Index | Old Index