Mon Jul 20 18:24:01 2009 UTC ()
Use __RCSID.


(joerg)
diff -r1.1 -r1.2 src/tests/lib/libc/stdlib/t_mi_vector_hash.c

cvs diff -r1.1 -r1.2 src/tests/lib/libc/stdlib/t_mi_vector_hash.c (switch to unified diff)

--- src/tests/lib/libc/stdlib/t_mi_vector_hash.c 2009/07/20 17:03:38 1.1
+++ src/tests/lib/libc/stdlib/t_mi_vector_hash.c 2009/07/20 18:24:01 1.2
@@ -1,93 +1,96 @@ @@ -1,93 +1,96 @@
1/* $NetBSD: t_mi_vector_hash.c,v 1.1 2009/07/20 17:03:38 joerg Exp $ */ 1/* $NetBSD: t_mi_vector_hash.c,v 1.2 2009/07/20 18:24:01 joerg Exp $ */
2/*- 2/*-
3 * Copyright (c) 2009 The NetBSD Foundation, Inc. 3 * Copyright (c) 2009 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Joerg Sonnenberger. 7 * by Joerg Sonnenberger.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 12 *
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in 16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the 17 * the documentation and/or other materials provided with the
18 * distribution. 18 * distribution.
19 * 19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE. 31 * SUCH DAMAGE.
32 */ 32 */
33 33
 34#include <sys/cdefs.h>
 35__RCSID("$NetBSD: t_mi_vector_hash.c,v 1.2 2009/07/20 18:24:01 joerg Exp $");
 36
34#include <atf-c.h> 37#include <atf-c.h>
35#include <stdlib.h> 38#include <stdlib.h>
36#include <string.h> 39#include <string.h>
37 40
38ATF_TC(t_mi_vector_hash); 41ATF_TC(t_mi_vector_hash);
39 42
40ATF_TC_HEAD(t_mi_vector_hash, tc) 43ATF_TC_HEAD(t_mi_vector_hash, tc)
41{ 44{
42 atf_tc_set_md_var(tc, "descr", 45 atf_tc_set_md_var(tc, "descr",
43 "Test mi_vector_hash_vector_hash for consistent results"); 46 "Test mi_vector_hash_vector_hash for consistent results");
44} 47}
45 48
46static const struct testvector { 49static const struct testvector {
47 const char *vector; 50 const char *vector;
48 uint32_t hashes[3]; 51 uint32_t hashes[3];
49} testv[] = { 52} testv[] = {
50 { "hello, world", { 0xd38f7f21, 0xbf6be9ab, 0x37a0e989 } }, 53 { "hello, world", { 0xd38f7f21, 0xbf6be9ab, 0x37a0e989 } },
51 { "", { 0x9b2ec03d, 0xdb2b69ae, 0xbd49d10d } }, 54 { "", { 0x9b2ec03d, 0xdb2b69ae, 0xbd49d10d } },
52 { "a", { 0x9454baa3, 0xb711c708, 0x29eec818 } }, 55 { "a", { 0x9454baa3, 0xb711c708, 0x29eec818 } },
53 { "ab", { 0x9a5dca90, 0xdd212644, 0x9879ac41 } }, 56 { "ab", { 0x9a5dca90, 0xdd212644, 0x9879ac41 } },
54 { "abc", { 0x0b91c470, 0x4770cdf5, 0x251e4793 } }, 57 { "abc", { 0x0b91c470, 0x4770cdf5, 0x251e4793 } },
55 { "abcd", { 0x5f128df3, 0xf5a667a6, 0x5ae61fa5 } }, 58 { "abcd", { 0x5f128df3, 0xf5a667a6, 0x5ae61fa5 } },
56 { "abcde", { 0x4cbae281, 0x799c0ed5, 0x03a96866 } }, 59 { "abcde", { 0x4cbae281, 0x799c0ed5, 0x03a96866 } },
57 { "abcdef", { 0x507a54c8, 0xb6bd06f4, 0xde922732 } }, 60 { "abcdef", { 0x507a54c8, 0xb6bd06f4, 0xde922732 } },
58 { "abcdefg", { 0xae2bca5d, 0x61e960ef, 0xb9e6762c } }, 61 { "abcdefg", { 0xae2bca5d, 0x61e960ef, 0xb9e6762c } },
59 { "abcdefgh", { 0xd1021264, 0x87f6988f, 0x053f775e } }, 62 { "abcdefgh", { 0xd1021264, 0x87f6988f, 0x053f775e } },
60 { "abcdefghi", { 0xe380defc, 0xfc35a811, 0x3a7b0a5f } }, 63 { "abcdefghi", { 0xe380defc, 0xfc35a811, 0x3a7b0a5f } },
61 { "abcdefghij", { 0x9a504408, 0x70d2e89d, 0xc9cac242 } }, 64 { "abcdefghij", { 0x9a504408, 0x70d2e89d, 0xc9cac242 } },
62 { "abcdefghijk", { 0x376117d0, 0x89f434d4, 0xe52b8e4c } }, 65 { "abcdefghijk", { 0x376117d0, 0x89f434d4, 0xe52b8e4c } },
63 { "abcdefghijkl", { 0x92253599, 0x7b6ff99e, 0x0b1b3ea5 } }, 66 { "abcdefghijkl", { 0x92253599, 0x7b6ff99e, 0x0b1b3ea5 } },
64 { "abcdefghijklm", { 0x92ee6a52, 0x55587d47, 0x3122b031 } }, 67 { "abcdefghijklm", { 0x92ee6a52, 0x55587d47, 0x3122b031 } },
65 { "abcdefghijklmn", { 0x827baf08, 0x1d0ada73, 0xfec330e0 } }, 68 { "abcdefghijklmn", { 0x827baf08, 0x1d0ada73, 0xfec330e0 } },
66 { "abcdefghijklmno", { 0x06ab787d, 0xc1ad17c2, 0x11dccf31 } }, 69 { "abcdefghijklmno", { 0x06ab787d, 0xc1ad17c2, 0x11dccf31 } },
67 { "abcdefghijklmnop", { 0x2cf18103, 0x638c9268, 0xfa1ecf51 } }, 70 { "abcdefghijklmnop", { 0x2cf18103, 0x638c9268, 0xfa1ecf51 } },
68}; 71};
69 72
70ATF_TC_BODY(t_mi_vector_hash, tc) 73ATF_TC_BODY(t_mi_vector_hash, tc)
71{ 74{
72 size_t i, j, len; 75 size_t i, j, len;
73 uint32_t hashes[3]; 76 uint32_t hashes[3];
74 char buf[256]; 77 char buf[256];
75 78
76 for (j = 0; j < 8; ++j) { 79 for (j = 0; j < 8; ++j) {
77 for (i = 0; i < sizeof(testv) / sizeof(testv[0]); ++i) { 80 for (i = 0; i < sizeof(testv) / sizeof(testv[0]); ++i) {
78 len = strlen(testv[i].vector); 81 len = strlen(testv[i].vector);
79 strcpy(buf + j, testv[i].vector); 82 strcpy(buf + j, testv[i].vector);
80 mi_vector_hash(buf + j, len, 0, hashes); 83 mi_vector_hash(buf + j, len, 0, hashes);
81 ATF_CHECK_EQ(hashes[0], testv[i].hashes[0]); 84 ATF_CHECK_EQ(hashes[0], testv[i].hashes[0]);
82 ATF_CHECK_EQ(hashes[1], testv[i].hashes[1]); 85 ATF_CHECK_EQ(hashes[1], testv[i].hashes[1]);
83 ATF_CHECK_EQ(hashes[2], testv[i].hashes[2]); 86 ATF_CHECK_EQ(hashes[2], testv[i].hashes[2]);
84 } 87 }
85 } 88 }
86} 89}
87 90
88ATF_TP_ADD_TCS(tp) 91ATF_TP_ADD_TCS(tp)
89{ 92{
90 ATF_TP_ADD_TC(tp, t_mi_vector_hash); 93 ATF_TP_ADD_TC(tp, t_mi_vector_hash);
91 94
92 return atf_no_error(); 95 return atf_no_error();
93} 96}