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