|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <liboil/liboil.h> |
|
20 #include <liboil/liboilfunction.h> |
|
21 #include <stdio.h> |
|
22 #include <stdlib.h> |
|
23 |
|
24 #include <liboil/globals.h> |
|
25 |
|
26 #define LOG_FILE "c:\\logs\\testsuite_function_log.txt" |
|
27 #include "std_log_result.h" |
|
28 #define LOG_FILENAME_LINE __FILE__, __LINE__ |
|
29 |
|
30 #define SIZE 20 |
|
31 |
|
32 void create_xml(int result) |
|
33 { |
|
34 if(result) |
|
35 assert_failed = 1; |
|
36 |
|
37 testResultXml("testsuite_function"); |
|
38 close_log_file(); |
|
39 } |
|
40 |
|
41 void abs_f32_f32_test(float * dest, int dstr, const float * src, int sstr, int n) |
|
42 { |
|
43 int i = 0; |
|
44 std_log(LOG_FILENAME_LINE,"abs_f32_f32_test is called"); |
|
45 assert_failed = 0; |
|
46 |
|
47 for(i=0; i<SIZE; i++) |
|
48 dest[i] = 10; |
|
49 } |
|
50 |
|
51 void test_oil_class_register_impl_by_name() |
|
52 { |
|
53 float output[SIZE]; |
|
54 float input[SIZE]; |
|
55 |
|
56 OilFunctionImpl *impl; |
|
57 |
|
58 impl = (OilFunctionImpl*)calloc(sizeof(OilFunctionImpl), 0); |
|
59 if(impl != NULL) |
|
60 { |
|
61 impl->func = (void*)abs_f32_f32_test; |
|
62 impl->name = "abs_f32_f32_test"; |
|
63 |
|
64 oil_class_register_impl_by_name("abs_f32_f32", impl); |
|
65 |
|
66 assert_failed = 1; //will be set to 0, if abs_f32_f32_test is called |
|
67 oil_abs_f32_f32(output, 1, input, 2, SIZE); |
|
68 } |
|
69 else |
|
70 { |
|
71 std_log(LOG_FILENAME_LINE,"memory allocation failed. errno = %d", errno); |
|
72 assert_failed = 1; |
|
73 } |
|
74 } |
|
75 |
|
76 void test_oil_class_register_impl() |
|
77 { |
|
78 float output[SIZE]; |
|
79 float input[SIZE]; |
|
80 |
|
81 OilFunctionClass *klass; |
|
82 OilFunctionImpl *impl; |
|
83 |
|
84 if(impl != NULL) |
|
85 { |
|
86 impl = (OilFunctionImpl*)calloc(sizeof(OilFunctionImpl), 0); |
|
87 impl->func = (void *)abs_f32_f32_test; |
|
88 impl->name = "abs_f32_f32_test"; |
|
89 |
|
90 klass = (OilFunctionClass *)oil_class_get ("abs_f32_f32"); |
|
91 |
|
92 if(klass != NULL) |
|
93 { |
|
94 oil_class_register_impl(klass, impl); |
|
95 |
|
96 assert_failed = 1; //will be set to 0, if abs_f32_f32_test is called |
|
97 oil_abs_f32_f32(output, 1, input, 2, SIZE); |
|
98 } |
|
99 else |
|
100 { |
|
101 std_log(LOG_FILENAME_LINE,"oil_class_get returned NULL. errno = %d", errno); |
|
102 assert_failed = 1; |
|
103 } |
|
104 } |
|
105 else |
|
106 { |
|
107 std_log(LOG_FILENAME_LINE,"memory allocation failed. errno = %d", errno); |
|
108 assert_failed = 1; |
|
109 } |
|
110 } |
|
111 |
|
112 void test_oil_class_register_impl_full() |
|
113 { |
|
114 float output[SIZE]; |
|
115 float input[SIZE]; |
|
116 OilFunctionClass *klass; |
|
117 |
|
118 klass = (OilFunctionClass *)oil_class_get ("abs_f32_f32"); |
|
119 |
|
120 if(klass != NULL) |
|
121 { |
|
122 oil_class_register_impl_full(klass, (void*)abs_f32_f32_test, "abs_f32_f32_test", OIL_IMPL_FLAG_OPT); |
|
123 |
|
124 assert_failed = 1; //will be set to 0, if abs_f32_f32_test is called |
|
125 oil_abs_f32_f32(output, 1, input, 2, SIZE); |
|
126 } |
|
127 else |
|
128 { |
|
129 std_log(LOG_FILENAME_LINE,"oil_class_get returned NULL. errno = %d", errno); |
|
130 assert_failed = 1; |
|
131 } |
|
132 } |
|
133 |
|
134 int main (int argc, char *argv[]) |
|
135 { |
|
136 oil_init(); |
|
137 oil_init_no_optimize(); |
|
138 oil_optimize("abs_f32_f32"); |
|
139 |
|
140 |
|
141 test_oil_class_register_impl_by_name(); |
|
142 test_oil_class_register_impl(); |
|
143 test_oil_class_register_impl_full(); |
|
144 |
|
145 if(assert_failed) |
|
146 std_log(LOG_FILENAME_LINE,"Test Failed"); |
|
147 else |
|
148 std_log(LOG_FILENAME_LINE,"Test Successful"); |
|
149 create_xml(0); |
|
150 return 0; |
|
151 } |
|
152 |