1 /**
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #define _GNU_SOURCE
17 #include "expat.h"
18 #include <log/log.h>
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <sys/types.h>
22 #include <sys/wait.h>
23 
24 #define MAX_SIZE 20
25 
main(void)26 int main(void) {
27   XML_Parser parser;
28   int i;
29   int randomValues[MAX_SIZE];
30   int isDistinctive = 0;
31 
32   for (i = 0; i < MAX_SIZE; i++) {
33     parser = XML_ParserCreate("UTF-8");
34     XML_Parse(parser, "", 0, 1);
35     XML_ParserFree(parser);
36     randomValues[i] = rand();
37   }
38 
39   for (i = 1; i < MAX_SIZE; i++) {
40     if (randomValues[0] != randomValues[i]) {
41       isDistinctive |= 1;
42     }
43   }
44 
45   if (isDistinctive == 0) {
46     //encountered similar values
47     ALOGE("fail: encountered same random values!");
48     return -1;
49   }
50 
51   return 0;
52 }
53