Update contrib.
2 * LIBOIL - Library of Optimized Inner Loops
3 * Copyright (c) 2004 David A. Schleef <ds@schleef.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
33 #include <liboil/liboil.h>
34 #include <liboil/liboilfunction.h>
37 #include <liboil/globals.h>
39 #define LOG_FILE "c:\\logs\\testsuite_md5_log.txt"
40 #include "std_log_result.h"
41 #define LOG_FILENAME_LINE __FILE__, __LINE__
43 void create_xml(int result)
48 testResultXml("testsuite_md5");
52 char *message = "liboil md5 test";
55 #ifdef WORDS_BIGENDIAN
56 #define uint32_from_host(a) \
57 ((((a)&0xff)<<24)|(((a)&0xff00)<<8)|(((a)&0xff0000)>>8)|(((a)>>24)&0xff))
59 #define uint32_from_host(a) (a)
69 state[0] = 0x67452301;
70 state[1] = 0xefcdab89;
71 state[2] = 0x98badcfe;
72 state[3] = 0x10325476;
75 len = strlen (message);
76 memcpy (src, message, len);
77 ((uint8_t *)src)[len] = 0x80;
78 src[14] = uint32_from_host(len << 3);
83 std_log(LOG_FILENAME_LINE,"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n",
84 state[0]&0xff, (state[0]>>8)&0xff, (state[0]>>16)&0xff,
86 state[1]&0xff, (state[1]>>8)&0xff, (state[1]>>16)&0xff,
88 state[2]&0xff, (state[2]>>8)&0xff, (state[2]>>16)&0xff,
90 state[3]&0xff, (state[3]>>8)&0xff, (state[3]>>16)&0xff,
92 sprintf(buf,"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
93 state[0]&0xff, (state[0]>>8)&0xff, (state[0]>>16)&0xff,
95 state[1]&0xff, (state[1]>>8)&0xff, (state[1]>>16)&0xff,
97 state[2]&0xff, (state[2]>>8)&0xff, (state[2]>>16)&0xff,
99 state[3]&0xff, (state[3]>>8)&0xff, (state[3]>>16)&0xff,
100 (state[3]>>24)&0xff);
101 if(strcasecmp(buf, "4311e9ad205ad575539c1d7e208ee53a")){
102 std_log(LOG_FILENAME_LINE,"buf = %s\n", buf);
107 int main (int argc, char *argv[])
109 OilFunctionClass *klass;
110 OilFunctionImpl *impl;
112 std_log(LOG_FILENAME_LINE,"Test started testsuite_md5");
115 klass = oil_class_get ("md5");
116 oil_class_optimize(klass);
118 std_log(LOG_FILENAME_LINE,"class=%s\n", klass->name);
119 for (impl = klass->first_impl; impl; impl=impl->next) {
120 std_log(LOG_FILENAME_LINE,"impl=%p\n", impl);
121 std_log(LOG_FILENAME_LINE," func=%p\n", impl->func);
122 std_log(LOG_FILENAME_LINE," name=%s\n", impl->name);
123 std_log(LOG_FILENAME_LINE," flags=%08x\n", impl->flags);
126 oil_class_choose_by_name (klass, "md5_c");
127 impl = klass->chosen_impl;
128 std_log(LOG_FILENAME_LINE,"chosen=%p\n", impl);
129 impl = klass->reference_impl;
130 std_log(LOG_FILENAME_LINE,"ref=%p\n", impl);
133 oil_class_choose_by_name (klass, "md5_asm1");
134 impl = klass->chosen_impl;
135 std_log(LOG_FILENAME_LINE,"chosen=%p\n", impl);
136 impl = klass->reference_impl;
137 std_log(LOG_FILENAME_LINE,"ref=%p\n", impl);
140 oil_class_choose_by_name (klass, "md5_asm2");
141 impl = klass->chosen_impl;
142 std_log(LOG_FILENAME_LINE,"chosen=%p\n", impl);
143 impl = klass->reference_impl;
144 std_log(LOG_FILENAME_LINE,"ref=%p\n", impl);
148 std_log(LOG_FILENAME_LINE,"Test Fail");
150 std_log(LOG_FILENAME_LINE,"Test Successful");