Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: tests/random/random_test.c

Issue 537543003: Add a get_random_bytes() syscall to replace the SRPC-based implementation (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Fix glibc tests Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/random/nacl.scons ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <string.h> 9 #include <string.h>
10 10
11 #include <nacl/nacl_random.h> 11 #include <nacl/nacl_random.h>
12 12
13 #include "native_client/src/include/nacl_assert.h" 13 #include "native_client/src/include/nacl_assert.h"
14 #include "native_client/src/shared/srpc/nacl_srpc.h"
15 #include "native_client/tests/inbrowser_test_runner/test_runner.h" 14 #include "native_client/tests/inbrowser_test_runner/test_runner.h"
16 15
17 int TestMain(void) { 16 int TestMain(void) {
18 #if !TESTS_USE_IRT
19 NaClSrpcModuleInit();
20 #endif
21
22 int result = 0; 17 int result = 0;
23 18
24 uint8_t byte1 = 0; 19 uint8_t byte1 = 0;
25 uint8_t byte2 = 0; 20 uint8_t byte2 = 0;
26 size_t nread; 21 size_t nread;
27 int error = nacl_secure_random(&byte1, sizeof(byte1), &nread); 22 int error = nacl_secure_random(&byte1, sizeof(byte1), &nread);
28 if (error != 0) { 23 if (error != 0) {
29 fprintf(stderr, "get_random_bytes failed for size %u: %s\n", 24 fprintf(stderr, "get_random_bytes failed for size %u: %s\n",
30 sizeof(byte1), strerror(error)); 25 sizeof(byte1), strerror(error));
31 result = 1; 26 result = 1;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 */ 84 */
90 int init_result = nacl_secure_random_init(); 85 int init_result = nacl_secure_random_init();
91 ASSERT_EQ(init_result, 0); 86 ASSERT_EQ(init_result, 0);
92 87
93 return result; 88 return result;
94 } 89 }
95 90
96 int main(void) { 91 int main(void) {
97 return RunTests(TestMain); 92 return RunTests(TestMain);
98 } 93 }
OLDNEW
« no previous file with comments | « tests/random/nacl.scons ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698