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_swab_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_swab");
|
sl@0
|
38 |
close_log_file();
|
sl@0
|
39 |
}
|
sl@0
|
40 |
|
sl@0
|
41 |
void test_oil_swab_u16()
|
sl@0
|
42 |
{
|
sl@0
|
43 |
//uint16_t * d_n, const uint16_t * s_n, int n
|
sl@0
|
44 |
uint16_t output[SIZE];
|
sl@0
|
45 |
uint16_t input[SIZE];
|
sl@0
|
46 |
uint16_t linux_output[] = {768,1024,1280,1536,1792,2048,2304,2560,2816,3072,3328,3584,3840,4096,4352,4608,4864,5120,5376,5632};
|
sl@0
|
47 |
int i = 0;
|
sl@0
|
48 |
|
sl@0
|
49 |
for(i=0; i<SIZE; i++)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
output[i] = 0;
|
sl@0
|
52 |
input[i] = i+3;
|
sl@0
|
53 |
}
|
sl@0
|
54 |
|
sl@0
|
55 |
oil_swab_u16(output, input, SIZE);
|
sl@0
|
56 |
|
sl@0
|
57 |
for(i=0; i<SIZE; i++)
|
sl@0
|
58 |
{
|
sl@0
|
59 |
if(output[i] != linux_output[i])
|
sl@0
|
60 |
{
|
sl@0
|
61 |
std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,linux_output[i],output[i]);
|
sl@0
|
62 |
assert_failed = 1;
|
sl@0
|
63 |
}
|
sl@0
|
64 |
}
|
sl@0
|
65 |
}
|
sl@0
|
66 |
|
sl@0
|
67 |
void test_oil_swab_u32()
|
sl@0
|
68 |
{
|
sl@0
|
69 |
//uint32_t * d_n, const uint32_t * s_n, int n
|
sl@0
|
70 |
uint32_t output[SIZE];
|
sl@0
|
71 |
uint32_t input[SIZE];
|
sl@0
|
72 |
uint32_t linux_output[] = {50331648,67108864,83886080,100663296,117440512,134217728,150994944,167772160,184549376,201326592,218103808,234881024,251658240,268435456,285212672,301989888,318767104,335544320,352321536,369098752};
|
sl@0
|
73 |
int i = 0;
|
sl@0
|
74 |
|
sl@0
|
75 |
for(i=0; i<SIZE; i++)
|
sl@0
|
76 |
{
|
sl@0
|
77 |
output[i] = 0;
|
sl@0
|
78 |
input[i] = i+3;
|
sl@0
|
79 |
}
|
sl@0
|
80 |
|
sl@0
|
81 |
oil_swab_u32(output, input, SIZE);
|
sl@0
|
82 |
|
sl@0
|
83 |
for(i=0; i<SIZE; i++)
|
sl@0
|
84 |
{
|
sl@0
|
85 |
if(output[i] != linux_output[i])
|
sl@0
|
86 |
{
|
sl@0
|
87 |
std_log(LOG_FILENAME_LINE, "output[%d]: expected value - %d, actual value - %d", i,linux_output[i],output[i]);
|
sl@0
|
88 |
assert_failed = 1;
|
sl@0
|
89 |
}
|
sl@0
|
90 |
}
|
sl@0
|
91 |
}
|
sl@0
|
92 |
|
sl@0
|
93 |
int main (int argc, char *argv[])
|
sl@0
|
94 |
{
|
sl@0
|
95 |
oil_init ();
|
sl@0
|
96 |
|
sl@0
|
97 |
test_oil_swab_u16();
|
sl@0
|
98 |
test_oil_swab_u32();
|
sl@0
|
99 |
|
sl@0
|
100 |
if(assert_failed)
|
sl@0
|
101 |
std_log(LOG_FILENAME_LINE,"Test Failed");
|
sl@0
|
102 |
else
|
sl@0
|
103 |
std_log(LOG_FILENAME_LINE,"Test Successful");
|
sl@0
|
104 |
|
sl@0
|
105 |
create_xml(0);
|
sl@0
|
106 |
return 0;
|
sl@0
|
107 |
}
|
sl@0
|
108 |
|