1/*
2  Copyright (C) 2008-2008 Google Inc
3     opensource@google.com
4
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License as
7  published by the Free Software Foundation; either version 2 of the
8  License, or (at your option) any later version.
9
10  This program is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  General Public License for more details.
14
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18  02111-1307, USA.
19
20  The GNU General Public License is contained in the file COPYING.
21*/
22
23/* Author: Konstantin Serebryany <opensource@google.com>
24
25 This file contains a set of unit tests for a data race detection tool.
26
27 These tests can be compiled with pthreads (default) or
28 with any other library that supports threads, locks, cond vars, etc.
29
30*/
31
32#include "old_test_suite.h"
33#include "test_utils.h"
34
35#include <gtest/gtest.h>
36
37
38namespace OptIgnoreTests {  // {{{1 Test how the tool works with indirect calls to fun_r functions
39int GLOB = 0;
40
41void NOINLINE NotIgnoredRacey() {
42  GLOB++;
43}
44
45void NOINLINE IntermediateJumpHereFunction() {
46  NotIgnoredRacey();
47  usleep(1);  // Prevent tail call optimization.
48}
49
50void NOINLINE DoTailCall() {
51  IntermediateJumpHereFunction();  // This tail call should be optimized.
52}
53
54// Test that a function that is called using jump is ignored.
55TEST(IgnoreTests, DISABLED_TailCall) {
56  MyThreadArray mta(DoTailCall, DoTailCall);
57  mta.Start();
58  mta.Join();
59  usleep(1);
60}
61
62}
63