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

Side by Side Diff: tests/threads/race_test.c

Issue 639113003: Add nacl-clang testing to SCons (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 6 years, 2 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
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 <assert.h> 7 #include <assert.h>
8 #include <pthread.h> 8 #include <pthread.h>
9 #include <semaphore.h> 9 #include <semaphore.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 } 43 }
44 for (i = 0; i < n; i++) { 44 for (i = 0; i < n; i++) {
45 pthread_join(t[i], NULL); 45 pthread_join(t[i], NULL);
46 } 46 }
47 } 47 }
48 48
49 /* Don't let various optimizations (e.g. tail call elimination) to happen. */ 49 /* Don't let various optimizations (e.g. tail call elimination) to happen. */
50 NOINLINE void break_optimization(void) { 50 NOINLINE void break_optimization(void) {
51 #if defined(__pnacl__) 51 #if defined(__pnacl__)
52 volatile int foo; 52 volatile int foo;
53 foo = 0; 53 foo = 0;
jvoung (off chromium) 2014/10/08 22:40:23 Could just make this one case w/out __asm__?
Derek Schuff 2014/10/09 16:55:42 I dunno, an asm seems like a lot more reliable way
54 #else 54 #else
55 asm volatile (""); 55 __asm__ volatile ("");
56 #endif 56 #endif
57 } 57 }
58 58
59 /* -------------------------------------------------------------------------- */ 59 /* -------------------------------------------------------------------------- */
60 /* positive_race_on_global_test 60 /* positive_race_on_global_test
61 Simle race on a global variable between three threads. 61 Simle race on a global variable between three threads.
62 We have few stack frames here to test ThreadSanitizer's output. */ 62 We have few stack frames here to test ThreadSanitizer's output. */
63 int simple_race_obj; 63 int simple_race_obj;
64 NOINLINE void simple_race_write_frame_2(void) { 64 NOINLINE void simple_race_write_frame_2(void) {
65 break_optimization(); 65 break_optimization();
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 /* -------------------------------------------------------------------------- */ 233 /* -------------------------------------------------------------------------- */
234 int main(void) { 234 int main(void) {
235 if (1) positive_race_on_global_test(); 235 if (1) positive_race_on_global_test();
236 if (1) positive_race_on_heap_test(); 236 if (1) positive_race_on_heap_test();
237 if (1) positive_wrong_lock_test(); 237 if (1) positive_wrong_lock_test();
238 if (1) negative_locked_access_test(); 238 if (1) negative_locked_access_test();
239 if (1) negative_posix_sem_test(); 239 if (1) negative_posix_sem_test();
240 if (1) thread_create_and_join_test(); 240 if (1) thread_create_and_join_test();
241 return 0; 241 return 0;
242 } 242 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698