1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/liboil/tsrc/testsuite/random/src/random.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,104 @@
1.4 +/*
1.5 +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include <liboil/liboil.h>
1.23 +#include <liboil/liboilfunction.h>
1.24 +#include <stdio.h>
1.25 +#include <stdlib.h>
1.26 +
1.27 +#include <liboil/globals.h>
1.28 +
1.29 +#define LOG_FILE "c:\\logs\\testsuite_random_log.txt"
1.30 +#include "std_log_result.h"
1.31 +#define LOG_FILENAME_LINE __FILE__, __LINE__
1.32 +
1.33 +#define SIZE 20
1.34 +
1.35 +void create_xml(int result)
1.36 +{
1.37 + if(result)
1.38 + assert_failed = 1;
1.39 +
1.40 + testResultXml("testsuite_random");
1.41 + close_log_file();
1.42 +}
1.43 +
1.44 +void test_oil_random_s64()
1.45 + {
1.46 + int i = 0;
1.47 + int pos = SIZE;
1.48 +
1.49 + oil_type_s64 output1[SIZE];
1.50 + oil_type_s64 output2[SIZE];
1.51 +
1.52 + oil_random_s64(output1, SIZE);
1.53 + oil_random_s64(output2, SIZE);
1.54 +
1.55 + for(i=0; i<SIZE; i++)
1.56 + {
1.57 + if(output1[i] != output2[i])
1.58 + pos = i;
1.59 + }
1.60 +
1.61 + if(pos == SIZE)
1.62 + {
1.63 + std_log(LOG_FILENAME_LINE,"oil_random_s64 returns same array everytime");
1.64 + assert_failed = 1;
1.65 + }
1.66 + }
1.67 +
1.68 +void test_oil_random_u64()
1.69 + {
1.70 + int i = 0;
1.71 + int pos = SIZE;
1.72 +
1.73 + oil_type_u64 output1[SIZE];
1.74 + oil_type_u64 output2[SIZE];
1.75 +
1.76 + oil_random_u64(output1, SIZE);
1.77 + oil_random_u64(output2, SIZE);
1.78 +
1.79 + for(i=0; i<SIZE; i++)
1.80 + {
1.81 + if(output1[i] != output2[i])
1.82 + pos = i;
1.83 + }
1.84 +
1.85 + if(pos == SIZE)
1.86 + {
1.87 + std_log(LOG_FILENAME_LINE,"oil_random_s64 returns same array everytime");
1.88 + assert_failed = 1;
1.89 + }
1.90 + }
1.91 +
1.92 +int main (int argc, char *argv[])
1.93 +{
1.94 + oil_init ();
1.95 +
1.96 + test_oil_random_s64();
1.97 + test_oil_random_u64();
1.98 +
1.99 + if(assert_failed)
1.100 + std_log(LOG_FILENAME_LINE,"Test Failed");
1.101 + else
1.102 + std_log(LOG_FILENAME_LINE,"Test Successful");
1.103 +
1.104 + create_xml(0);
1.105 + return 0;
1.106 +}
1.107 +