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_random_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_random");
|
sl@0
|
38 |
close_log_file();
|
sl@0
|
39 |
}
|
sl@0
|
40 |
|
sl@0
|
41 |
void test_oil_random_s64()
|
sl@0
|
42 |
{
|
sl@0
|
43 |
int i = 0;
|
sl@0
|
44 |
int pos = SIZE;
|
sl@0
|
45 |
|
sl@0
|
46 |
oil_type_s64 output1[SIZE];
|
sl@0
|
47 |
oil_type_s64 output2[SIZE];
|
sl@0
|
48 |
|
sl@0
|
49 |
oil_random_s64(output1, SIZE);
|
sl@0
|
50 |
oil_random_s64(output2, SIZE);
|
sl@0
|
51 |
|
sl@0
|
52 |
for(i=0; i<SIZE; i++)
|
sl@0
|
53 |
{
|
sl@0
|
54 |
if(output1[i] != output2[i])
|
sl@0
|
55 |
pos = i;
|
sl@0
|
56 |
}
|
sl@0
|
57 |
|
sl@0
|
58 |
if(pos == SIZE)
|
sl@0
|
59 |
{
|
sl@0
|
60 |
std_log(LOG_FILENAME_LINE,"oil_random_s64 returns same array everytime");
|
sl@0
|
61 |
assert_failed = 1;
|
sl@0
|
62 |
}
|
sl@0
|
63 |
}
|
sl@0
|
64 |
|
sl@0
|
65 |
void test_oil_random_u64()
|
sl@0
|
66 |
{
|
sl@0
|
67 |
int i = 0;
|
sl@0
|
68 |
int pos = SIZE;
|
sl@0
|
69 |
|
sl@0
|
70 |
oil_type_u64 output1[SIZE];
|
sl@0
|
71 |
oil_type_u64 output2[SIZE];
|
sl@0
|
72 |
|
sl@0
|
73 |
oil_random_u64(output1, SIZE);
|
sl@0
|
74 |
oil_random_u64(output2, SIZE);
|
sl@0
|
75 |
|
sl@0
|
76 |
for(i=0; i<SIZE; i++)
|
sl@0
|
77 |
{
|
sl@0
|
78 |
if(output1[i] != output2[i])
|
sl@0
|
79 |
pos = i;
|
sl@0
|
80 |
}
|
sl@0
|
81 |
|
sl@0
|
82 |
if(pos == SIZE)
|
sl@0
|
83 |
{
|
sl@0
|
84 |
std_log(LOG_FILENAME_LINE,"oil_random_s64 returns same array everytime");
|
sl@0
|
85 |
assert_failed = 1;
|
sl@0
|
86 |
}
|
sl@0
|
87 |
}
|
sl@0
|
88 |
|
sl@0
|
89 |
int main (int argc, char *argv[])
|
sl@0
|
90 |
{
|
sl@0
|
91 |
oil_init ();
|
sl@0
|
92 |
|
sl@0
|
93 |
test_oil_random_s64();
|
sl@0
|
94 |
test_oil_random_u64();
|
sl@0
|
95 |
|
sl@0
|
96 |
if(assert_failed)
|
sl@0
|
97 |
std_log(LOG_FILENAME_LINE,"Test Failed");
|
sl@0
|
98 |
else
|
sl@0
|
99 |
std_log(LOG_FILENAME_LINE,"Test Successful");
|
sl@0
|
100 |
|
sl@0
|
101 |
create_xml(0);
|
sl@0
|
102 |
return 0;
|
sl@0
|
103 |
}
|
sl@0
|
104 |
|