]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/util/testsuite_abi_check.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / util / testsuite_abi_check.cc
1 // -*- C++ -*-
2
3 // Copyright (C) 2004-2019 Free Software Foundation, Inc.
4
5 // This library 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 3, or (at
8 // your option) any later version.
9
10 // This library 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 library; see the file COPYING3. If not see
17 // <http://www.gnu.org/licenses/>.
18
19
20 // Benjamin Kosnik <bkoz@redhat.com>
21 // Blame subsequent hacks on Loren J. Rittle <ljrittle@acm.org>, Phil
22 // Edwards <pme@gcc.gnu.org>, and a cast of dozens at libstdc++@gcc.gnu.org.
23
24 #include "testsuite_abi.h"
25 #include <iostream>
26 #include <cstdlib>
27 #include <unistd.h> // for access(2)
28
29 int
30 main(int argc, char** argv)
31 {
32 using namespace std;
33
34 // Get arguments. (Heading towards getopt_long, I can feel it.)
35 string argv1 = argc > 1 ? argv[1] : "";
36 if (argv1 == "--help" || argc < 4)
37 {
38 cerr << "usage: abi_check --check current baseline\n"
39 " --check-verbose current baseline\n"
40 " --examine symbol current\n"
41 " --help\n"
42 "\n"
43 "All arguments are string literals.\n"
44 "CURRENT is a file generated byextract_symvers.\n"
45 "BASELINE is a file from config/abi.\n"
46 "SYMBOL is a mangled name.\n"
47 << endl;
48 exit(1);
49 }
50
51 if (argv1.find("--check") != string::npos)
52 {
53 bool verbose = false;
54 if (argv1 == "--check-verbose")
55 verbose = true;
56
57 // Quick sanity/setup check for arguments.
58 const char* test_file = argv[2];
59 const char* baseline_file = argv[3];
60 if (access(test_file, R_OK) != 0)
61 {
62 cerr << "Cannot read symbols file " << test_file
63 << ", did you forget to build first?" << endl;
64 exit(1);
65 }
66 if (access(baseline_file, R_OK) != 0)
67 {
68 cerr << "Cannot read baseline file " << baseline_file << endl;
69 exit(1);
70 }
71 if (!compare_symbols(baseline_file, test_file, verbose))
72 exit (1);
73 }
74
75 if (argv1 == "--examine")
76 {
77 const char* file = argv[3];
78 if (access(file, R_OK) != 0)
79 {
80 cerr << "Cannot read symbol file " << file << endl;
81 exit(1);
82 }
83 examine_symbol(argv[2], file);
84 }
85 return 0;
86 }