1*1424dfb3Schristos // ver_test_main.cc -- a test case for gold
2*1424dfb3Schristos 
3*1424dfb3Schristos // Copyright (C) 2007-2020 Free Software Foundation, Inc.
4*1424dfb3Schristos // Written by Cary Coutant <ccoutant@google.com>.
5*1424dfb3Schristos 
6*1424dfb3Schristos // This file is part of gold.
7*1424dfb3Schristos 
8*1424dfb3Schristos // This program is free software; you can redistribute it and/or modify
9*1424dfb3Schristos // it under the terms of the GNU General Public License as published by
10*1424dfb3Schristos // the Free Software Foundation; either version 3 of the License, or
11*1424dfb3Schristos // (at your option) any later version.
12*1424dfb3Schristos 
13*1424dfb3Schristos // This program is distributed in the hope that it will be useful,
14*1424dfb3Schristos // but WITHOUT ANY WARRANTY; without even the implied warranty of
15*1424dfb3Schristos // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*1424dfb3Schristos // GNU General Public License for more details.
17*1424dfb3Schristos 
18*1424dfb3Schristos // You should have received a copy of the GNU General Public License
19*1424dfb3Schristos // along with this program; if not, write to the Free Software
20*1424dfb3Schristos // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21*1424dfb3Schristos // MA 02110-1301, USA.
22*1424dfb3Schristos 
23*1424dfb3Schristos #include <cassert>
24*1424dfb3Schristos 
25*1424dfb3Schristos #include "ver_test.h"
26*1424dfb3Schristos 
27*1424dfb3Schristos int
main()28*1424dfb3Schristos main()
29*1424dfb3Schristos {
30*1424dfb3Schristos   assert(t1());
31*1424dfb3Schristos   assert(t2());
32*1424dfb3Schristos   assert(t3());
33*1424dfb3Schristos   assert(t4());
34*1424dfb3Schristos   return 0;
35*1424dfb3Schristos }
36*1424dfb3Schristos 
37*1424dfb3Schristos // Calls a function in file2 that has two versions and verifies
38*1424dfb3Schristos // that the default version is called.
39*1424dfb3Schristos 
40*1424dfb3Schristos bool
t2()41*1424dfb3Schristos t2()
42*1424dfb3Schristos {
43*1424dfb3Schristos   TRACE
44*1424dfb3Schristos   return t2_2() == 22;
45*1424dfb3Schristos }
46*1424dfb3Schristos 
47*1424dfb3Schristos // Call a function in a shared library that calls explicitly
48*1424dfb3Schristos // the version of t1_2() defined in another shared library.
49*1424dfb3Schristos 
50*1424dfb3Schristos bool
t3()51*1424dfb3Schristos t3()
52*1424dfb3Schristos {
53*1424dfb3Schristos   TRACE
54*1424dfb3Schristos   return t3_2() == 12;
55*1424dfb3Schristos }
56*1424dfb3Schristos 
57*1424dfb3Schristos // Call a function in a shared library that calls a function which is
58*1424dfb3Schristos // defined in the main program and defined with a default version in
59*1424dfb3Schristos // the shared library.  The symbol in the main program should override
60*1424dfb3Schristos // even though it doesn't have a version.
61*1424dfb3Schristos 
62*1424dfb3Schristos bool
t4()63*1424dfb3Schristos t4()
64*1424dfb3Schristos {
65*1424dfb3Schristos   TRACE
66*1424dfb3Schristos   return t4_2() == 42;
67*1424dfb3Schristos }
68*1424dfb3Schristos 
69*1424dfb3Schristos int
t4_2a()70*1424dfb3Schristos t4_2a()
71*1424dfb3Schristos {
72*1424dfb3Schristos   TRACE
73*1424dfb3Schristos   return 42;
74*1424dfb3Schristos }
75