pax_global_header 0000666 0000000 0000000 00000000064 12216015072 0014506 g ustar 00root root 0000000 0000000 52 comment=25bfbf2ebbd1010305d94301da4aba9c942804ea
api-sanity-checker-1.98.6/ 0000775 0000000 0000000 00000000000 12216015072 0015273 5 ustar 00root root 0000000 0000000 api-sanity-checker-1.98.6/INSTALL 0000664 0000000 0000000 00000004554 12216015072 0016334 0 ustar 00root root 0000000 0000000
Copyright (C) 2009-2010 The Linux Foundation
Copyright (C) 2009-2011 Institute for System Programming, RAS
Copyright (C) 2011-2013 ROSA Laboratory
All rights reserved.
RELEASE INFORMATION
Project: API Sanity Checker
Version: 1.98.6
Date: 2013-09-17
This file explains how to install and setup environment
for the tool in your computer.
Content:
1. Requirements for Linux and FreeBSD
2. Requirements for Mac OS X
3. Requirements for MS Windows
4. Configuring and Installing
5. Running the Tool
1. REQUIREMENTS FOR LINUX AND FREEBSD
=====================================
1. ABI Compliance Checker (1.98.7 or newer)
2. G++ (3.0-4.7, recommended 4.5 or newer)
3. GNU Binutils (c++filt, readelf, objdump)
4. Perl 5 (5.8 or newer)
5. Ctags (5.8 or newer)
2. REQUIREMENTS FOR MAC OS X
============================
1. ABI Compliance Checker (1.98.7 or newer)
2. Xcode (gcc, c++filt, nm)
3. Ctags (5.8 or newer)
3. REQUIREMENTS FOR MS WINDOWS
==============================
1. ABI Compliance Checker (1.98.7 or newer)
2. MinGW (3.0-4.7, recommended 4.5 or newer)
3. MS Visual C++ (dumpbin, undname, cl)
4. Active Perl 5 (5.8 or newer)
5. Ctags (5.8 or newer)
3.1 Setup environment
1. Add tool locations to the PATH environment variable
2. Run vsvars32.bat script (C:\Microsoft Visual Studio 9.0\Common7\Tools\)
4. CONFIGURING AND INSTALLING
===================================================
This command will install an api-sanity-checker program in the
PREFIX/bin system directory:
sudo perl Makefile.pl -install --prefix=PREFIX [/usr, /usr/local, ...]
4.1 Update
sudo perl Makefile.pl -update --prefix=PREFIX
4.2 Remove
sudo perl Makefile.pl -remove --prefix=PREFIX
5. RUNNING THE TOOL
===================
1. Create an XML-descriptor
for your library (VERSION.xml):
1.0
/path1/to/header(s)/
/path2/to/header(s)/
...
/path1/to/library(ies)/
/path2/to/library(ies)/
...
2. api-sanity-checker -lib NAME -d VERSION.xml -gen -build -run
3. For advanced usage, see doc/Readme.html or --help option
Enjoy!
api-sanity-checker-1.98.6/LICENSE 0000664 0000000 0000000 00000125243 12216015072 0016307 0 ustar 00root root 0000000 0000000 This program is free software. You may use, redistribute and/or modify it
under the terms of either the GNU General Public License (GPL) or the GNU
Lesser General Public License (LGPL).
---------------------------------------------------------------------------
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
---------------------------------------------------------------------------
GNU LIBRARY GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Library General Public License, applies to some
specially designated Free Software Foundation software, and to any
other libraries whose authors decide to use it. You can use it for
your libraries, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if
you distribute copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide
complete object files to the recipients so that they can relink them
with the library, after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright
the library, and (2) offer you this license which gives you legal
permission to copy, distribute and/or modify the library.
Also, for each distributor's protection, we want to make certain
that everyone understands that there is no warranty for this free
library. If the library is modified by someone else and passed on, we
want its recipients to know that what they have is not the original
version, so that any problems introduced by others will not reflect on
the original authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that companies distributing free
software will individually obtain patent licenses, thus in effect
transforming the program into proprietary software. To prevent this,
we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary
GNU General Public License, which was designed for utility programs. This
license, the GNU Library General Public License, applies to certain
designated libraries. This license is quite different from the ordinary
one; be sure to read it in full, and don't assume that anything in it is
the same as in the ordinary license.
The reason we have a separate public license for some libraries is that
they blur the distinction we usually make between modifying or adding to a
program and simply using it. Linking a program with a library, without
changing the library, is in some sense simply using the library, and is
analogous to running a utility program or application program. However, in
a textual and legal sense, the linked executable is a combined work, a
derivative of the original library, and the ordinary General Public License
treats it as such.
Because of this blurred distinction, using the ordinary General
Public License for libraries did not effectively promote software
sharing, because most developers did not use the libraries. We
concluded that weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the
users of those programs of all benefit from the free status of the
libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while
preserving your freedom as a user of such programs to change the free
libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards
changes in the actual functions of the Library.) The hope is that this
will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, while the latter only
works together with the library.
Note that it is possible for a library to be covered by the ordinary
General Public License rather than by this special one.
GNU LIBRARY GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library which
contains a notice placed by the copyright holder or other authorized
party saying it may be distributed under the terms of this Library
General Public License (also called "this License"). Each licensee is
addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also compile or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
d) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the source code distributed need not include anything that is normally
distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Library General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
Copyright (C)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
api-sanity-checker-1.98.6/Makefile.pl 0000775 0000000 0000000 00000020260 12216015072 0017350 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl
###########################################################################
# Makefile for API Sanity Checker
# Install/remove the tool for GNU/Linux, FreeBSD and Mac OS X
#
# Copyright (C) 2009-2010 The Linux Foundation
# Copyright (C) 2009-2011 Institute for System Programming, RAS
# Copyright (C) 2011-2013 ROSA Lab
#
# Written by Andrey Ponomarenko
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License or the GNU Lesser
# General Public License as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# and the GNU Lesser General Public License along with this program.
# If not, see .
###########################################################################
use Getopt::Long;
Getopt::Long::Configure ("posix_default", "no_ignore_case");
use File::Path qw(mkpath rmtree);
use File::Spec qw(catfile file_name_is_absolute);
use File::Copy qw(copy);
use File::Basename qw(dirname);
use Cwd qw(abs_path);
use File::Find;
use Config;
use strict;
my $TOOL_SNAME = "api-sanity-checker";
my $ARCHIVE_DIR = abs_path(dirname($0));
my $ABICC = "abi-compliance-checker";
my $ABICC_VERSION = "1.98.7";
my $HELP_MSG = "
NAME:
Makefile for API Sanity Checker
DESCRIPTION:
Install $TOOL_SNAME command and private modules.
USAGE:
sudo perl $0 -install -prefix /usr
sudo perl $0 -update -prefix /usr
sudo perl $0 -remove -prefix /usr
OPTIONS:
-h|-help
Print this help.
--prefix=PREFIX
Install files in PREFIX [/usr/local].
-install
Command to install the tool.
-update
Command to update existing installation.
-remove
Command to remove the tool.
EXTRA OPTIONS:
--destdir=DESTDIR
This option is for maintainers to build
RPM or DEB packages inside the build root.
The environment variable DESTDIR is also
supported.
\n";
if(not @ARGV)
{
print $HELP_MSG;
exit(0);
}
my ($PREFIX, $DESTDIR, $Help, $Install, $Update, $Remove);
GetOptions(
"h|help!" => \$Help,
"prefix=s" => \$PREFIX,
"destdir=s" => \$DESTDIR,
"install!" => \$Install,
"update!" => \$Update,
"remove!" => \$Remove
) or exit(1);
sub scenario()
{
if($Help)
{
print $HELP_MSG;
exit(0);
}
if(not $Install and not $Update and not $Remove)
{
print STDERR "ERROR: command is not selected (-install, -update or -remove)\n";
exit(1);
}
if(my $Version = `$ABICC -dumpversion`)
{
if(cmpVersions($Version, $ABICC_VERSION)<0)
{
print STDERR "ERROR: requires $ABICC_VERSION or newer version of \'$ABICC\'\n";
exit(1);
}
}
else
{
print STDERR "ERROR: cannot find \'$ABICC\'\n";
exit(1);
}
if($PREFIX ne "/") {
$PREFIX=~s/[\/]+\Z//g;
}
if(not $PREFIX)
{ # default prefix
if($Config{"osname"}!~/win/i) {
$PREFIX = "/usr/local";
}
}
if(my $Var = $ENV{"DESTDIR"})
{
print "Using DESTDIR environment variable\n";
$DESTDIR = $Var;
}
if($DESTDIR)
{
if($DESTDIR ne "/") {
$DESTDIR=~s/[\/]+\Z//g;
}
if(not isAbs($DESTDIR))
{
print STDERR "ERROR: destdir is not absolute path\n";
exit(1);
}
if(not -d $DESTDIR)
{
print STDERR "ERROR: you should create destdir directory first\n";
exit(1);
}
$PREFIX = $DESTDIR.$PREFIX;
if(not -d $PREFIX)
{
print STDERR "ERROR: you should create installation directory first (destdir + prefix):\n mkdir -p $PREFIX\n";
exit(1);
}
}
else
{
if(not isAbs($PREFIX))
{
print STDERR "ERROR: prefix is not absolute path\n";
exit(1);
}
if(not -d $PREFIX)
{
print STDERR "ERROR: you should create prefix directory first\n";
exit(1);
}
}
print "INSTALL PREFIX: $PREFIX\n";
# paths
my $EXE_PATH = catFile($PREFIX, "bin");
my $MODULES_PATH = catFile($PREFIX, "share", $TOOL_SNAME);
my $REL_PATH = catFile("..", "share", $TOOL_SNAME);
my $TOOL_PATH = catFile($EXE_PATH, $TOOL_SNAME);
if(not -w $PREFIX)
{
print STDERR "ERROR: you should be root\n";
exit(1);
}
if($Remove or $Update)
{
if(-e $EXE_PATH."/".$TOOL_SNAME)
{ # remove executable
print "-- Removing $TOOL_PATH\n";
unlink($EXE_PATH."/".$TOOL_SNAME);
}
if(-d $MODULES_PATH)
{ # remove modules
print "-- Removing $MODULES_PATH\n";
rmtree($MODULES_PATH);
}
}
if($Install or $Update)
{
if(-e $EXE_PATH."/".$TOOL_SNAME or -e $MODULES_PATH)
{ # check installed
if(not $Remove)
{
print STDERR "ERROR: you should remove old version first (`perl $0 -remove --prefix=$PREFIX`)\n";
exit(1);
}
}
# configure
my $Content = readFile($ARCHIVE_DIR."/".$TOOL_SNAME.".pl");
if($DESTDIR) { # relative path
$Content=~s/MODULES_INSTALL_PATH/$REL_PATH/;
}
else { # absolute path
$Content=~s/MODULES_INSTALL_PATH/$MODULES_PATH/;
}
# copy executable
print "-- Installing $TOOL_PATH\n";
mkpath($EXE_PATH);
writeFile($EXE_PATH."/".$TOOL_SNAME, $Content);
chmod(0775, $EXE_PATH."/".$TOOL_SNAME);
if($Config{"osname"}=~/win/i) {
writeFile($EXE_PATH."/".$TOOL_SNAME.".cmd", "\@perl \"$TOOL_PATH\" \%*");
}
# copy modules
if(-d $ARCHIVE_DIR."/modules")
{
print "-- Installing $MODULES_PATH\n";
mkpath($MODULES_PATH);
copyDir($ARCHIVE_DIR."/modules", $MODULES_PATH);
}
# check PATH
my $Warn = "WARNING: your PATH variable doesn't include \'$EXE_PATH\'\n";
if($Config{"osname"}=~/win/i)
{
if($ENV{"PATH"}!~/(\A|[:;])\Q$EXE_PATH\E[\/\\]?(\Z|[:;])/i) {
print $Warn;
}
}
else
{
if($ENV{"PATH"}!~/(\A|[:;])\Q$EXE_PATH\E[\/\\]?(\Z|[:;])/) {
print $Warn;
}
}
}
exit(0);
}
sub cmpVersions($$)
{ # compare two versions in dotted-numeric format
my ($V1, $V2) = @_;
return 0 if($V1 eq $V2);
my @V1Parts = split(/\./, $V1);
my @V2Parts = split(/\./, $V2);
for (my $i = 0; $i <= $#V1Parts && $i <= $#V2Parts; $i++)
{
return -1 if(int($V1Parts[$i]) < int($V2Parts[$i]));
return 1 if(int($V1Parts[$i]) > int($V2Parts[$i]));
}
return -1 if($#V1Parts < $#V2Parts);
return 1 if($#V1Parts > $#V2Parts);
return 0;
}
sub catFile(@) {
return File::Spec->catfile(@_);
}
sub isAbs($) {
return File::Spec->file_name_is_absolute($_[0]);
}
sub copyDir($$)
{
my ($From, $To) = @_;
my %Files;
find(\&wanted, $From);
sub wanted {
$Files{$File::Find::dir."/$_"} = 1 if($_ ne ".");
}
foreach my $Path (sort keys(%Files))
{
my $Inst = $Path;
$Inst=~s/\A\Q$ARCHIVE_DIR\E/$To/;
if(-d $Path)
{ # directories
mkpath($Inst);
}
else
{ # files
mkpath(dirname($Inst));
copy($Path, $Inst);
}
}
}
sub readFile($)
{
my $Path = $_[0];
return "" if(not $Path or not -f $Path);
open(FILE, $Path) || die ("can't open file \'$Path\': $!\n");
local $/ = undef;
my $Content = ;
close(FILE);
return $Content;
}
sub writeFile($$)
{
my ($Path, $Content) = @_;
return if(not $Path);
open(FILE, ">".$Path) || die ("can't open file \'$Path\': $!\n");
print FILE $Content;
close(FILE);
}
scenario(); api-sanity-checker-1.98.6/README 0000664 0000000 0000000 00000001116 12216015072 0016152 0 ustar 00root root 0000000 0000000 NAME:
API Sanity Checker - an automatic generator of basic unit tests for a C/C++ library API.
INSTALL:
sudo perl Makefile.pl -install --prefix=/usr
REQUIRES:
ABI Compliance Checker 1.99 or newer: https://github.com/lvc/abi-compliance-checker
USAGE:
api-sanity-checker -lib NAME -d VERSION.xml -gen -build -run
VERSION.xml is XML-descriptor:
1.0
/path/to/headers/
/path/to/libraries/
ADV. USAGE:
For advanced usage, see doc/Readme.html or output of --help option. api-sanity-checker-1.98.6/api-sanity-checker.pl 0000775 0000000 0000000 00002052435 12216015072 0021326 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl
###########################################################################
# API Sanity Checker 1.98.6
# An automatic generator of basic unit tests for a C/C++ library API
#
# Copyright (C) 2009-2010 The Linux Foundation
# Copyright (C) 2009-2011 Institute for System Programming, RAS
# Copyright (C) 2011-2013 ROSA Laboratory
#
# Written by Andrey Ponomarenko
#
# PLATFORMS
# =========
# Linux, FreeBSD, Mac OS X, MS Windows
#
# REQUIREMENTS
# ============
# Linux
# - ABI Compliance Checker (1.99 or newer)
# - G++ (3.0-4.7, recommended 4.5 or newer)
# - GNU Binutils (readelf, c++filt, objdump)
# - Perl 5 (5.8 or newer)
# - Ctags (5.8 or newer)
#
# Mac OS X
# - ABI Compliance Checker (1.99 or newer)
# - Xcode (gcc, c++filt, nm)
# - Ctags (5.8 or newer)
#
# MS Windows
# - ABI Compliance Checker (1.99 or newer)
# - MinGW (3.0-4.7, recommended 4.5 or newer)
# - MS Visual C++ (dumpbin, undname, cl)
# - Active Perl 5 (5.8 or newer)
# - Ctags (5.8 or newer)
# - Add tool locations to the PATH environment variable
# - Run vsvars32.bat (C:\Microsoft Visual Studio 9.0\Common7\Tools\)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License or the GNU Lesser
# General Public License as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# and the GNU Lesser General Public License along with this program.
# If not, see .
###########################################################################
use Getopt::Long;
Getopt::Long::Configure ("posix_default", "no_ignore_case");
use POSIX qw(setsid);
use File::Path qw(mkpath rmtree);
use File::Temp qw(tempdir);
use File::Copy qw(copy);
use Cwd qw(abs_path cwd realpath);
use Config;
my $TOOL_VERSION = "1.98.6";
my $OSgroup = get_OSgroup();
my $ORIG_DIR = cwd();
my $TMP_DIR = tempdir(CLEANUP=>1);
my $ABICC = "abi-compliance-checker";
my $ABICC_VERSION = "1.99";
# Internal modules
my $MODULES_DIR = get_Modules();
push(@INC, get_dirname($MODULES_DIR));
my ($Help, $InfoMsg, $TargetLibraryName, $GenerateTests, $TargetInterfaceName,
$BuildTests, $RunTests, $CleanTests, $DisableReuse, $LongVarNames, %Descriptor,
$UseXvfb, $TestTool, $MinimumCode, $TestDataPath, $MaximumCode, $RandomCode,
$GenerateDescriptorTemplate, $GenerateSpecTypeTemplate, $InterfacesListPath,
$SpecTypes_PackagePath, $CheckReturn, $DisableDefaultValues, $ShowRetVal,
$CheckHeadersOnly, $Template2Code, $Standalone, $ShowVersion, $MakeIsolated,
$ParameterNamesFilePath, $CleanSources, $DumpVersion, $TargetHeaderName,
$RelativeDirectory, $TargetLibraryFullName, $TargetVersion, $StrictGen,
$StrictBuild, $StrictRun, $Strict, $Debug, $UseCache, $NoInline, $Browse,
$OpenReport, $UserLang, $OptimizeIncludes, $KeepInternal, $TargetCompiler);
my $CmdName = get_filename($0);
my %OS_LibExt=(
"linux"=>"so",
"macos"=>"dylib",
"windows"=>"dll",
"symbian"=>"dso",
"default"=>"so"
);
my %ERROR_CODE = (
# Passed
"Success"=>0,
# Failed
"Failed"=>1,
# Undifferentiated error code
"Error"=>2,
# Cannot access input files
"Access_Error"=>4,
# Cannot find a module
"Module_Error"=>9
);
my %HomePage = (
"Wiki"=>"http://ispras.linuxbase.org/index.php/API_Sanity_Checker",
"Dev"=>"https://github.com/lvc/api-sanity-checker"
);
my $ShortUsage = "API Sanity Checker $TOOL_VERSION
Unit test generator for a C/C++ library API
Copyright (C) 2013 ROSA Lab
License: GNU LGPL or GNU GPL
Usage: $CmdName [options]
Example: $CmdName -lib NAME -d VER.xml -gen -build -run
VER.xml is XML-descriptor:
1.0
/path/to/headers/
/path/to/libraries/
More info: $CmdName --help\n";
if($#ARGV==-1)
{
print $ShortUsage;
exit(0);
}
my @INPUT_OPTIONS = @ARGV;
GetOptions("h|help!" => \$Help,
"info!" => \$InfoMsg,
"v|version!" => \$ShowVersion,
"dumpversion!" => \$DumpVersion,
# general options
"l|lib|library=s" => \$TargetLibraryName,
"d|descriptor=s" => \$Descriptor{"Path"},
"gen|generate!" => \$GenerateTests,
"build|make!" => \$BuildTests,
"run!" => \$RunTests,
"clean!" => \$CleanTests,
# extra options
"d-tmpl|descriptor-template!" =>\$GenerateDescriptorTemplate,
"s-tmpl|specialized-type-template!" =>\$GenerateSpecTypeTemplate,
"vnum=s" =>\$TargetVersion,
"s|symbol|f|function|i|interface=s" => \$TargetInterfaceName,
"symbols-list|functions-list|interfaces-list=s" => \$InterfacesListPath,
"header=s" => \$TargetHeaderName,
"xvfb!" => \$UseXvfb,
"t2c|template2code" => \$Template2Code,
"strict-gen!" => \$StrictGen,
"strict-build!" => \$StrictBuild,
"strict-run!" => \$StrictRun,
"strict!" => \$Strict,
"r|random!" =>\$RandomCode,
"min!" =>\$MinimumCode,
"max!" =>\$MaximumCode,
"show-retval!" => \$ShowRetVal,
"check-retval!" => \$CheckReturn,
"st|specialized-types=s" => \$SpecTypes_PackagePath,
"td|test-data=s" => \$TestDataPath,
"headers-only!" => \$CheckHeadersOnly,
"no-inline!" => \$NoInline,
"keep-internal!" => \$KeepInternal,
"isolated!" => \$MakeIsolated,
"view-only!" => \$CleanSources,
"disable-default-values!" => \$DisableDefaultValues,
"optimize-includes=s" => \$OptimizeIncludes,
"p|params=s" => \$ParameterNamesFilePath,
"l-full|lib-full=s" => \$TargetLibraryFullName,
"relpath|reldir=s" => \$RelativeDirectory,
"lang=s" => \$UserLang,
"target=s" => \$TargetCompiler,
"debug!" => \$Debug,
"cache!" => \$UseCache,
# other options
"test!" => \$TestTool,
"disable-variable-reuse!" => \$DisableReuse,
"long-variable-names!" => \$LongVarNames,
"b|browse=s" => \$Browse,
"open!" => \$OpenReport
) or ERR_MESSAGE();
sub ERR_MESSAGE()
{
print $ShortUsage;
exit(1);
}
my $LIB_EXT = $OS_LibExt{$OSgroup}?$OS_LibExt{$OSgroup}:$OS_LibExt{"default"};
my $HelpMessage="
NAME:
API Sanity Checker ($CmdName)
Generate basic unit tests for a C/C++ library API
DESCRIPTION:
API Sanity Checker is an automatic generator of basic unit tests for a C/C++
library. It helps to quickly generate simple (\"sanity\" or \"shallow\"
quality) tests for every function in an API using their signatures, data type
definitions and relationships between functions straight from the library
header files (\"Header-Driven Generation\"). Each test case contains a function
call with reasonable (in most, but unfortunately not all, cases) input
parameters. The quality of generated tests allows to check absence of critical
errors in simple use cases and can be greatly improved by involving of highly
reusable specialized types for the library.
The tool can execute generated tests and detect crashes, aborts, all kinds of
emitted signals, non-zero program return code, program hanging and requirement
failures (if specified). The tool can be considered as a tool for out-of-box
low-cost sanity checking of library API or as a test development framework for
initial generation of templates for advanced tests. Also it supports universal
Template2Code format of tests, splint specifications, random test generation
mode and other useful features.
This tool is free software: you can redistribute it and/or modify it
under the terms of the GNU LGPL or GNU GPL.
USAGE:
$CmdName [options]
EXAMPLE:
$CmdName -lib NAME -d VER.xml -gen -build -run
VERSION.xml is XML-descriptor:
1.0
/path1/to/header(s)/
/path2/to/header(s)/
...
/path1/to/library(ies)/
/path2/to/library(ies)/
...
INFORMATION OPTIONS:
-h|-help
Print this help.
-info
Print complete info.
-v|-version
Print version information.
-dumpversion
Print the tool version ($TOOL_VERSION) and don't do anything else.
GENERAL OPTIONS:
-l|-lib|-library NAME
Library name (without version).
-d|-descriptor PATH
Path to the library descriptor (VER.xml file):
1.0
/path1/to/header(s)/
/path2/to/header(s)/
...
/path1/to/library(ies)/
/path2/to/library(ies)/
...
... (XML-descriptor template
can be generated by -d-tmpl option)
For more information, please see:
http://ispras.linuxbase.org/index.php/Library_Descriptor
-gen|-generate
Generate test(s). Options -l and -d should be specified.
To generate test for the particular function use it with -f option.
Exit code: number of test cases failed to build.
-build|-make
Build test(s). Options -l and -d should be specified.
To build test for the particular function use it with -f option.
Exit code: number of test cases failed to generate.
-run
Run test(s), create test report. Options -l and -d should be specified.
To run test for the particular function use it with -f option.
Exit code: number of failed test cases.
-clean
Clean test(s). Options -l and -d should be specified.
To clean test for the particular function use it with -f option.\n";
sub HELP_MESSAGE() {
print $HelpMessage."
MORE INFO:
$CmdName --info\n\n";
}
sub INFO_MESSAGE()
{
printMsg("INFO", "$HelpMessage
EXTRA OPTIONS:
-d-tmpl|-descriptor-template
Create XML-descriptor template ./VERSION.xml
-s-tmpl|specialized-type-template
Create specialized type template ./SPECTYPES.xml
-vnum NUM
Specify library version outside the descriptor.
-s|-symbol NAME
Generate/Build/Run test for the specified function
(mangled name in C++).
-symbols-list PATH
This option allows to specify a file with a list of functions
(one per line, mangled name in C++) that should be tested,
other library functions will not be tested.
-header NAME
This option allows to restrict a list of functions that should be tested
by providing a header file name in which they are declared. This option
is intended for step-by-step tests development.
-xvfb
Use Xvfb-server instead of current X-server (default)
for running tests.
-t2c|-template2code
Generate tests in the universal Template2Code format.
For more information, please see:
http://sourceforge.net/projects/template2code/
-strict-gen
Terminate the process of generating tests and return
error code '1' if cannot generate at least one test case.
-strict-build
Terminate the process of building tesst and return
error code '1' if cannot build at least one test case.
-strict-run
Terminate the process of running tests and return
error code '1' if at least one test case failed.
-strict
This option enables all -strict-* options.
-r|-random
Random test generation mode.
-min
Generate minimun code, call functions with minimum number of parameters
to initialize parameters of other functions.
-max
Generate maximum code, call functions with maximum number of parameters
to initialize parameters of other functions.
-show-retval
Show the function return type in the report.
-check-retval
Insert requirements on return values (retval!=NULL) for each
called function.
-st|-specialized-types PATH
Path to the file with the collection of specialized types.
For more information, please see:
http://ispras.linuxbase.org/index.php/Specialized_Type
-td|-test-data PATH
Path to the directory with the test data files.
For more information, please see:
http://ispras.linuxbase.org/index.php/Specialized_Type
-headers-only
If the library consists of inline functions only and has no shared
objects then you should specify this option.
-no-inline
Don't generate tests for inline functions.
-keep-internal
Generate tests for internal symbols (functions with '__' prefix and
methods of classes declared inside other classes).
-isolated
Allow to restrict functions usage by the lists specified by the
-functions-list option or by the group devision in the descriptor.
-view-only
Remove all files from the test suite except *.html files. This option
allows to create a lightweight html-index for all tests.
-disable-default-values
Disable usage of default values for function parameters.
-optimize-includes LEVEL
Enable optimization of the list of included headers in each test case.
Available levels:
High (default)
Medium
Low
None - disable
-p|-params PATH
Path to file with the function parameter names. It can be used for
improving generated tests if the library header files don't contain
parameter names. File format:
func1;param1;param2;param3 ...
func2;param1;param2;param3 ...
...
-l-full|-lib-full NAME
Library name in the report title.
-relpath|-reldir PATH
Replace {RELPATH} in the library descriptor by PATH.
-lang LANG
Set library language (C or C++). You can use this option if the tool
cannot auto-detect a language.
-target COMPILER
The compiler that should be used to build generated tests under Windows.
Supported:
gcc - GNU compiler
cl - MS compiler (default)
-debug
Write extended log for debugging.
-cache
Cache the ABI dump and use it on the next run.
OTHER OPTIONS:
-test
Run internal tests. Create a simple library and run the tool on it.
This option allows to check if the tool works correctly on the system.
-disable-variable-reuse
Disable reusing of previously created variables in the test.
-long-variable-names
Enable long (complex) variable names instead of short names.
-b|-browse PROGRAM
Open report(s) in the browser (firefox, opera, etc.).
-open
Open report(s) in the default browser.
EXIT CODES:
0 - Successful tests. The tool has run without any errors.
non-zero - Tests failed or the tool has run with errors.
REPORT BUGS TO:
Andrey Ponomarenko
MORE INFORMATION:
".$HomePage{"Wiki"}."
".$HomePage{"Dev"}."\n");
}
my $Descriptor_Template = "
/* XML-descriptor template */
/* Primary sections */
/* Version of the library */
/* The list of paths to header files and/or
directories with header files, one per line */
/* The list of paths to shared libraries and/or
directories with libraries, one per line */
/* Optional sections */
/* The list of paths to be searched for header files
needed for compiling of library headers, one per line.
NOTE: If you define this section then the tool
will not automatically detect include paths */
/* The list of include paths that should be added
to the automatically detected include paths, one per line */
/* Additional GCC options, one per line */
/* The list of header files that should be
included before other headers, one per line */
/* The list of header files that should be
included in each test case before other
headers, one per line */
/* The list of paths to libraries that should be
provided to gcc for resolving undefined symbols
(if NEEDED elf section doesn't include them) */
/* The list of opaque types, one per line */
/* The list of functions (mangled names in C++)
that should not be called in the tests, one per line */
/* The list of header files and/or directories with header files
that should not be processed, one name per line */
/* The list of shared libraries and/or directories with shared libraries
that should not be processed, one name per line */
/* Add defines at the headers compiling stage, one per line:
#define A B
#define C D */
/* Add defines to test cases */
/* Name of the libgroup */
/* The list of symbols (mangled names in C++)
in the group that should be tested, one per line */
/* Associating of out(returned)-parameters
with symbols, one entry per line:
symbol:param_name
or
symbol:param_number
Examples:
dbus_parse_address:entry
dbus_parse_address:2 */
/* The list of warnings that should not be shown in the report, one pattern per line */
";
my $SpecType_Template="
/* Kind of the specialized type.
Select it from the following list:
normal
common_param
common_retval
env
common_env */
/* Name of the corresponding real data type.
You can specify several data types if kind is 'common_param'
or 'common_retval', one per line. This section is not used
if kind is 'env' or 'common_env' */
/* Value for initialization (true, 1.0, \"string\", ...) */
/* Precondition on associated function parameter.
Example: \$0!=NULL */
/* Postcondition on associated function return value or parameter.
Example: \$0!=NULL && \$obj.style()==Qt::DotLine */
/* Code that will be pasted instead of parameter automatic declaration.
Example: char \$0[16]; */
/* Code that should be invoked before function call.
Example: \$0->start(); */
/* Code that should be invoked after function call
Example: \$0->end(); */
/* Declarations of auxiliary functions
and global variables, header includes */
/* Several \"associating\" sections
are allowed simultaneously */
/* List of symbols (mangled names in C++)
that will be associated with the specialized type, one per line */
/* List of symbols (mangled names in C++)
that will not be associated with the specialized type, one per line.
This section is used if kind is 'common_env', 'common_param'
or 'common_return' */
/* Associations with the return value, parameters
or/and object, one per line:
param1
param2
param3
...
object
retval */
/* Associations with the parameters by name, one per line:
param_name1
param_name2
param_name3
...
*/
/* Name of the specialized type */
/* External shared libraries, one per line.
If spectype contains call of the functions from
some external shared libraries then these objects
should be listed here. Corresponding external
header files should be included in global_code */
/* Other specialized type */
";
# Constants
my $BUFF_SIZE = 256;
my $DEFAULT_ARRAY_AMOUNT = 4;
my $MAX_PARAMS_INLINE = 3;
my $MAX_PARAMS_LENGTH_INLINE = 60;
my $HANGED_EXECUTION_TIME = 7;
my $TOOL_SIGNATURE;
my $MIN_PARAMS_MATRIX = 8;
my $MATRIX_WIDTH = 4;
my $MATRIX_MAX_ELEM_LENGTH = 7;
my $LIBRARY_PREFIX_MAJORITY = 10;
my %Operator_Indication = (
"not" => "~",
"assign" => "=",
"andassign" => "&=",
"orassign" => "|=",
"xorassign" => "^=",
"or" => "|",
"xor" => "^",
"addr" => "&",
"and" => "&",
"lnot" => "!",
"eq" => "==",
"ne" => "!=",
"lt" => "<",
"lshift" => "<<",
"lshiftassign" => "<<=",
"rshiftassign" => ">>=",
"call" => "()",
"mod" => "%",
"modassign" => "%=",
"subs" => "[]",
"land" => "&&",
"lor" => "||",
"rshift" => ">>",
"ref" => "->",
"le" => "<=",
"deref" => "*",
"mult" => "*",
"preinc" => "++",
"delete" => " delete",
"vecnew" => " new[]",
"vecdelete" => " delete[]",
"predec" => "--",
"postinc" => "++",
"postdec" => "--",
"plusassign" => "+=",
"plus" => "+",
"minus" => "-",
"minusassign" => "-=",
"gt" => ">",
"ge" => ">=",
"new" => " new",
"multassign" => "*=",
"divassign" => "/=",
"div" => "/",
"neg" => "-",
"pos" => "+",
"memref" => "->*",
"compound" => "," );
my %IsKeyword= map {$_=>1} (
"delete",
"if",
"else",
"for",
"public",
"private",
"new",
"protected",
"main",
"sizeof",
"malloc",
"return",
"include",
"true",
"false",
"const",
"int",
"long",
"void",
"short",
"float",
"unsigned",
"char",
"double",
"class",
"struct",
"union",
"enum",
"volatile",
"restrict"
);
my %ShortTokens=(
"err"=>"error",
"warn"=>"warning" );
# Global variables
my $ST_ID=0;
my $REPORT_PATH;
my $TEST_SUITE_PATH;
my $DEBUG_PATH;
my $CACHE_PATH;
my $LOG_PATH;
my %Interface_TestDir;
my %LibsDepend;
my $CompilerOptions_Libs;
my $CompilerOptions_Cflags;
my %Language;
my %Cache;
my $TestedInterface;
my $COMMON_LANGUAGE;
my %SubClass_Created;
my %Constants;
my $MaxTypeId_Start;
my $STAT_FIRST_LINE;
# Mangling
my %tr_name;
# Types
my %TypeInfo;
my %OpaqueTypes;
my %TName_Tid;
my %StructUnionPName_Tid;
my %Class_Constructors;
my %Class_Destructors;
my %ReturnTypeId_Interface;
my %BaseType_PLevel_Return;
my %OutParam_Interface;
my %BaseType_PLevel_OutParam;
my %Interface_OutParam;
my %Interface_OutParam_NoUsing;
my %OutParamInterface_Pos;
my %OutParamInterface_Pos_NoUsing;
my %Class_SubClasses;
my %Type_Typedef;
my %Typedef_BaseName;
my %NameSpaces;
my %NestedNameSpaces;
my %EnumMembers;
my %SubClass_Instance;
my %SubClass_ObjInstance;
my %BaseType_PLevel_Type;
my %Struct_SubClasses;
my %Struct_Parent;
my %Library_Prefixes;
my %Struct_Mapping;
# Interfaces
my %SymbolInfo;
my %CompleteSignature;
my %SkipInterfaces;
my %SkipInterfaces_Pattern;
my %Library_Class;
my %Library_Symbol;
my %DepLibrary_Symbol;
my %Symbol_Library;
my %DepSymbol_Library;
my %UndefinedSymbols;
my %Library_Needed;
my %Class_PureVirtFunc;
my %Class_Method;
my %Class_PureMethod;
my %Interface_Overloads;
my %OverloadedInterface;
my %InterfacesList;
my %MethodNames;
my %FuncNames;
my %GlobalDataNames;
my %Func_TypeId;
my %Header_Interface;
my %SoLib_IntPrefix;
my $NodeInterface;
my %LibGroups;
my %Interface_LibGroup;
my %AddIntParams;
my %Func_ShortName_MangledName;
my %UserDefinedOutParam;
my $LibraryMallocFunc;
my %LibraryInitFunc;
my %LibraryExitFunc;
# Headers
my @Include_Preamble;
my %SpecTypeHeaders;
my %SkipWarnings;
my %SkipWarnings_Pattern;
my %Include_Order;
my %Include_RevOrder;
my $IncludeString;
my %IncludePrefix;
my %SkipHeaders;
my %RegisteredHeaders;
my %RegisteredHeaders_R;
my %RegisteredIncludes;
my %RegisteredIncludes_R;
my %DirectIncludes;
my %RecursiveIncludes;
my %RecursiveIncludes_R;
my %KnownHeaders;
my %Include_Redirect;
my $MAX_INC = 0;
# Shared objects
my %UsedSharedObjects;
my %RegisteredLibs;
my $LibString;
my %KnownLibs;
# Default paths
my @DefaultLibPaths = (); # /usr/lib
my @DefaultIncPaths = (); # /usr/include
# Test results
my %GenResult;
my %BuildResult;
my %RunResult;
my %ResultCounter;
#Signals
my %SigNo;
my %SigName;
# Recursion locks
my @RecurTypeId;
my @RecurInterface;
my @RecurSpecType;
# Global state
my (%ValueCollection, %Block_Variable, %UseVarEveryWhere, %SpecEnv, %Block_InsNum, $MaxTypeId, %Wrappers,
%Wrappers_SubClasses, %IntSubClass, %IntrinsicNum, %AuxType, %AuxFunc, %UsedConstructors,
%ConstraintNum, %RequirementsCatalog, %UsedProtectedMethods, %Create_SubClass, %SpecCode,
%SpecLibs, %UsedInterfaces, %OpenStreams, %IntSpecType, %Block_Param, %Class_SubClassTypedef, %AuxHeaders,
%Template2Code_Defines, %TraceFunc);
# Block initialization
my $CurrentBlock;
# Special types
my %SpecType;
my %InterfaceSpecType;
my %Common_SpecEnv;
my %Common_SpecType_Exceptions;
my %ProxyValue = ();
# Report
my $ContentSpanStart = "[+]\n";
my $ContentSpanStart_Title = "[+]\n";
my $ContentSpanEnd = "\n";
my $ContentDivStart = "
\n";
my $ContentDivEnd = "
\n";
my $ContentID = 1;
my $Content_Counter = 0;
# Test Case
my $TestFormat;
# Recursion Locks
my @RecurLib;
# Debug
my %DebugInfo;
sub get_Modules()
{
my $TOOL_DIR = get_dirname($0);
if(not $TOOL_DIR)
{ # patch for MS Windows
$TOOL_DIR = ".";
}
my @SEARCH_DIRS = (
# tool's directory
abs_path($TOOL_DIR),
# relative path to modules
abs_path($TOOL_DIR)."/../share/api-sanity-checker",
# install path
'MODULES_INSTALL_PATH'
);
foreach my $DIR (@SEARCH_DIRS)
{
if(not is_abs($DIR))
{ # relative path
$DIR = abs_path($TOOL_DIR)."/".$DIR;
}
if(-d $DIR."/modules") {
return $DIR."/modules";
}
}
exitStatus("Module_Error", "can't find modules");
}
my %LoadedModules = ();
sub loadModule($)
{
my $Name = $_[0];
if(defined $LoadedModules{$Name}) {
return;
}
my $Path = $MODULES_DIR."/Internals/$Name.pm";
if(not -f $Path) {
exitStatus("Module_Error", "can't access \'$Path\'");
}
require $Path;
$LoadedModules{$Name} = 1;
}
sub readModule($$)
{
my ($Module, $Name) = @_;
my $Path = $MODULES_DIR."/Internals/$Module/".$Name;
if(not -f $Path) {
exitStatus("Module_Error", "can't access \'$Path\'");
}
return readFile($Path);
}
sub is_abs($) {
return ($_[0]=~/\A(\/|\w+:[\/\\])/);
}
sub get_abs_path($)
{ # abs_path() should NOT be called for absolute inputs
# because it can change them
my $Path = $_[0];
if(not is_abs($Path)) {
$Path = abs_path($Path);
}
return $Path;
}
sub get_OSgroup()
{
if($Config{"osname"}=~/macos|darwin|rhapsody/i) {
return "macos";
}
elsif($Config{"osname"}=~/freebsd|openbsd|netbsd/i) {
return "bsd";
}
elsif($Config{"osname"}=~/haiku|beos/i) {
return "beos";
}
elsif($Config{"osname"}=~/symbian|epoc/i) {
return "symbian";
}
elsif($Config{"osname"}=~/win/i) {
return "windows";
}
else {
return $Config{"osname"};
}
}
sub detectDisplay()
{
my $DISPLAY_NUM = 9; # default display number
# use xprop to get a free display number
foreach my $DNUM (9, 8, 7, 6, 5, 4, 3, 2, 10, 11, 12)
{ # try these display numbers only
system("xprop -display :$DNUM".".0 -root >$TMP_DIR/null 2>&1");
if($? ne 0)
{ # no properties found for this display, guess it is free
$DISPLAY_NUM = $DNUM;
last;
}
}
return ":$DISPLAY_NUM.0";
}
sub runXvfb()
{
# Find a free display to use for Xvfb
my $XT_DISPLAY = detectDisplay();
my $TEST_DISPLAY = $XT_DISPLAY;
my $running = `pidof Xvfb`;
chomp($running);
if(not $running or $OSgroup!~/\A(linux|bsd)\Z/)
{
printMsg("INFO", "starting X Virtual Frame Buffer on the display $TEST_DISPLAY");
system("Xvfb -screen 0 1024x768x24 $TEST_DISPLAY -ac +bs +kb -fp /usr/share/fonts/misc/ >$TMP_DIR/null 2>&1 & sleep 1");
if($?) {
exitStatus("Error", "can't start Xvfb: $?");
}
$ENV{"DISPLAY"} = $TEST_DISPLAY;
$ENV{"G_SLICE"} = "always-malloc";
return 1;
}
else
{
# Xvfb is running, determine the display number
my $CMD_XVFB = `ps -p "$running" -f | tail -n 1`;
chomp($CMD_XVFB);
$CMD_XVFB=~/(\:\d+\.0)/;
$XT_DISPLAY = $1;
$ENV{"DISPLAY"} = $XT_DISPLAY;
$ENV{"G_SLICE"} = "always-malloc";
printMsg("INFO", "Xvfb is already running (display: $XT_DISPLAY), so it will be used");
return 0;
}
}
sub stopXvfb($)
{
if($_[0]==1)
{
my $pid = `pidof Xvfb`;
chomp($pid);
if($pid) {
kill(9, $pid);
}
}
}
sub parseTag($$)
{
my ($CodeRef, $Tag) = @_;
return "" if(not $CodeRef or not ${$CodeRef} or not $Tag);
if(${$CodeRef}=~s/\<\Q$Tag\E\>((.|\n)+?)\<\/\Q$Tag\E\>//)
{
my $Content = $1;
$Content=~s/\A[\n]+//g;
while($Content=~s/\A([ \t]+[\n]+)//g){}
$Content=~s/\A[\n]+//g;
$Content=~s/\s+\Z//g;
if($Content=~/\n/) {
$Content = alignSpaces($Content);
}
else {
$Content=~s/\A[ \t]+//g;
}
return $Content;
}
else {
return "";
}
}
sub add_os_spectypes()
{
if($OSgroup eq "beos")
{ # http://www.haiku-os.org/legacy-docs/bebook/TheKernelKit_Miscellaneous.html
readSpecTypes("
disable debugger in Haiku
common_env
#include
disable_debugger(1);
libroot.so
disable_debugger
");
}
}
sub register_out_param($$$$)
{
my ($Interface, $ParamPos, $ParamName, $ParamTypeId) = @_;
$OutParamInterface_Pos{$Interface}{$ParamPos}=1;
$Interface_OutParam{$Interface}{$ParamName}=1;
$BaseType_PLevel_OutParam{get_FoundationTypeId($ParamTypeId)}{get_PointerLevel($ParamTypeId)-1}{$Interface}=1;
foreach my $TypeId (get_OutParamFamily($ParamTypeId, 0)) {
$OutParam_Interface{$TypeId}{$Interface}=$ParamPos;
}
}
sub cmpVersions($$)
{ # compare two versions in dotted-numeric format
my ($V1, $V2) = @_;
return 0 if($V1 eq $V2);
my @V1Parts = split(/\./, $V1);
my @V2Parts = split(/\./, $V2);
for (my $i = 0; $i <= $#V1Parts && $i <= $#V2Parts; $i++)
{
return -1 if(int($V1Parts[$i]) < int($V2Parts[$i]));
return 1 if(int($V1Parts[$i]) > int($V2Parts[$i]));
}
return -1 if($#V1Parts < $#V2Parts);
return 1 if($#V1Parts > $#V2Parts);
return 0;
}
sub numToStr($)
{
my $Number = int($_[0]);
if($Number>3) {
return $Number."th";
}
elsif($Number==1) {
return "1st";
}
elsif($Number==2) {
return "2nd";
}
elsif($Number==3) {
return "3rd";
}
else {
return $Number;
}
}
sub readSpecTypes($)
{
my $Package = $_[0];
return if(not $Package);
$Package=~s/\/\*(.|\n)+?\*\///g; # remove C++ comments
$Package=~s/<\!--(.|\n)+?-->//g; # remove XML comments
if($Package!~// or $Package!~/<\/collection>/)
{ # add tag (support for old spectype packages)
$Package = "\n".$Package."\n";
}
while(my $Collection = parseTag(\$Package, "collection"))
{
# import specialized types
while(my $SpecType = parseTag(\$Collection, "spec_type"))
{
$ST_ID+=1;
my (%Attr, %DataTypes) = ();
$Attr{"Kind"} = parseTag(\$SpecType, "kind");
$Attr{"Kind"} = "normal" if(not $Attr{"Kind"});
foreach my $DataType (split(/\n/, parseTag(\$SpecType, "data_type")),
split(/\n/, parseTag(\$SpecType, "data_types")))
{ # data_type==data_types, support of <= 1.5 versions
$DataTypes{$DataType} = 1;
if(not get_TypeIdByName($DataType)) {
printMsg("ERROR", "unknown data type \'$DataType\' in one of the \'".$Attr{"Kind"}."\' spectypes, try to define it more exactly");
}
}
if(not keys(%DataTypes) and $Attr{"Kind"}=~/\A(normal|common_param|common_retval)\Z/)
{
printMsg("ERROR", "missed \'data_type\' attribute in one of the \'".$Attr{"Kind"}."\' spectypes");
next;
}
$Attr{"Name"} = parseTag(\$SpecType, "name");
$Attr{"Value"} = parseTag(\$SpecType, "value");
$Attr{"PreCondition"} = parseTag(\$SpecType, "pre_condition");
$Attr{"PostCondition"} = parseTag(\$SpecType, "post_condition");
if(not $Attr{"PostCondition"})
{ # constraint==post_condition, support of <= 1.6 versions
$Attr{"PostCondition"} = parseTag(\$SpecType, "constraint");
}
$Attr{"InitCode"} = parseTag(\$SpecType, "init_code");
$Attr{"DeclCode"} = parseTag(\$SpecType, "decl_code");
$Attr{"FinalCode"} = parseTag(\$SpecType, "final_code");
$Attr{"GlobalCode"} = parseTag(\$SpecType, "global_code");
foreach my $Lib (split(/\n/, parseTag(\$SpecType, "libs"))) {
$Attr{"Libs"}{$Lib} = 1;
}
if($Attr{"Kind"} eq "common_env") {
$Common_SpecEnv{$ST_ID} = 1;
}
while(my $Associating = parseTag(\$SpecType, "associating"))
{
my (%Interfaces, %Except) = ();
foreach my $Interface (split(/\n/, parseTag(\$Associating, "interfaces")),
split(/\n/, parseTag(\$Associating, "symbols")))
{
$Interface=~s/\A\s+|\s+\Z//g;
$Interfaces{$Interface} = 1;
$Common_SpecType_Exceptions{$Interface}{$ST_ID} = 0;
if($Interface=~/\*/)
{
$Interface=~s/\*/.*/;
foreach my $Int (keys(%CompleteSignature))
{
if($Int=~/\A$Interface\Z/)
{
$Common_SpecType_Exceptions{$Int}{$ST_ID} = 0;
$Interfaces{$Interface} = 1;
}
}
}
elsif(not defined $CompleteSignature{$Interface}
or not $CompleteSignature{$Interface}{"ShortName"}) {
printMsg("ERROR", "unknown symbol $Interface");
}
}
foreach my $Interface (split(/\n/, parseTag(\$Associating, "except")))
{
$Interface=~s/\A\s+|\s+\Z//g;
$Except{$Interface} = 1;
$Common_SpecType_Exceptions{$Interface}{$ST_ID} = 1;
if($Interface=~/\*/)
{
$Interface=~s/\*/.*/;
foreach my $Int (keys(%CompleteSignature))
{
if($Int=~/\A$Interface\Z/)
{
$Common_SpecType_Exceptions{$Int}{$ST_ID} = 1;
$Except{$Int} = 1;
}
}
}
}
if($Attr{"Kind"} eq "env")
{
foreach my $Interface (keys(%Interfaces))
{
next if($Except{$Interface});
$InterfaceSpecType{$Interface}{"SpecEnv"} = $ST_ID;
}
}
else
{
foreach my $Link (split(/\n/, parseTag(\$Associating, "links").parseTag(\$Associating, "param_num")))
{
$Link=~s/\A\s+|\s+\Z//g;
if(lc($Link)=~/\Aparam(\d+)\Z/)
{
my $Param_Num = $1;
foreach my $Interface (keys(%Interfaces))
{
next if($Except{$Interface});
if(defined $InterfaceSpecType{$Interface}{"SpecParam"}{$Param_Num - 1}) {
printMsg("ERROR", "more than one spectypes have been linked to ".numToStr($Param_Num)." parameter of $Interface");
}
$InterfaceSpecType{$Interface}{"SpecParam"}{$Param_Num - 1} = $ST_ID;
}
}
elsif(lc($Link)=~/\Aobject\Z/)
{
foreach my $Interface (keys(%Interfaces))
{
next if($Except{$Interface});
if(defined $InterfaceSpecType{$Interface}{"SpecObject"}) {
printMsg("ERROR", "more than one spectypes have been linked to calling object of $Interface");
}
$InterfaceSpecType{$Interface}{"SpecObject"} = $ST_ID;
}
}
elsif(lc($Link)=~/\Aretval\Z/)
{
foreach my $Interface (keys(%Interfaces))
{
next if($Except{$Interface});
if(defined $InterfaceSpecType{$Interface}{"SpecReturn"}) {
printMsg("ERROR", "more than one spectypes have been linked to return value of $Interface");
}
$InterfaceSpecType{$Interface}{"SpecReturn"} = $ST_ID;
}
}
else {
printMsg("ERROR", "unrecognized link \'$Link\' in one of the \'".$Attr{"Kind"}."\' spectypes");
}
}
foreach my $Name (split(/\n/, parseTag(\$Associating, "param_name")))
{
$Name=~s/\A\s+|\s+\Z//g;
if(keys(%Interfaces))
{
foreach my $Interface (keys(%Interfaces))
{
next if($Except{$Interface});
foreach my $ParamPos (keys(%{$CompleteSignature{$Interface}{"Param"}}))
{
if($Name eq $CompleteSignature{$Interface}{"Param"}{$ParamPos}{"name"}) {
$InterfaceSpecType{$Interface}{"SpecParam"}{$ParamPos} = $ST_ID;
}
}
}
}
else
{
foreach my $Interface (keys(%CompleteSignature))
{
next if($Except{$Interface});
foreach my $ParamPos (keys(%{$CompleteSignature{$Interface}{"Param"}}))
{
if($Name eq $CompleteSignature{$Interface}{"Param"}{$ParamPos}{"name"})
{
my $TypeId_Param = $CompleteSignature{$Interface}{"Param"}{$ParamPos}{"type"};
my $FTypeId_Param = get_FoundationTypeId($TypeId_Param);
my $FTypeType_Param = get_TypeType($FTypeId_Param);
foreach my $DataType (keys(%DataTypes))
{
my $TypeId = get_TypeIdByName($DataType);
if(my $FTypeId = get_FoundationTypeId($TypeId) and $FTypeId_Param)
{
if($FTypeType_Param eq "Intrinsic"?$TypeId==$TypeId_Param:$FTypeId==$FTypeId_Param) {
$InterfaceSpecType{$Interface}{"SpecParam"}{$ParamPos} = $ST_ID;
}
}
}
}
}
}
}
}
}
}
if($Attr{"Kind"}=~/\A(common_param|common_retval)\Z/)
{
foreach my $DataType (keys(%DataTypes))
{
$Attr{"DataType"} = $DataType;
%{$SpecType{$ST_ID}} = %Attr;
$ST_ID+=1;
}
}
elsif($Attr{"Kind"} eq "normal")
{
$Attr{"DataType"} = (keys(%DataTypes))[0];
%{$SpecType{$ST_ID}} = %Attr;
}
else {
%{$SpecType{$ST_ID}} = %Attr;
}
}
}
}
sub join_P($$)
{
my $S = "/";
if($OSgroup eq "windows") {
$S = "\\";
}
return join($S, @_);
}
sub registerHeader($$)
{
my ($Path, $To) = @_;
my $Name = get_filename($Path);
if(not defined $To->{$Name})
{
$To->{$Name} = $Path;
if(my $Prefix = getFilePrefix($Path)) {
$To->{join_P($Prefix, $Name)} = $Path;
}
}
}
sub registerDir($)
{
my $Path = $_[0];
foreach my $P (sort {length($b)<=>length($a)} cmd_find($Path,"f","",""))
{ # NOTE: duplicated
registerHeader($P, \%RegisteredHeaders);
$RegisteredHeaders_R{$P} = 1;
}
}
sub getFilePrefix($)
{
if(my $Dir = get_dirname($_[0]))
{
if($Dir = get_filename($Dir))
{
if($Dir ne "include"
and $Dir=~/\A[a-z]+\Z/i) {
return $Dir;
}
}
}
return undef;
}
sub registerHeaders($)
{
my $Path = $_[0];
if(-d $Path) {
registerDir($Path);
}
elsif(-f $Path)
{
registerHeader($Path, \%RegisteredHeaders);
$RegisteredHeaders_R{$Path} = 1;
if(my $Dir = get_dirname($Path)) {
registerDir($Dir);
}
}
}
sub registerLibs($)
{
my $Path = $_[0];
$Path = get_abs_path($Path);
if(-d $Path)
{
foreach my $P (cmd_find($Path,"f","","")) {
$RegisteredLibs{get_filename($P)} = $P;
}
}
elsif(-f $Path) {
$RegisteredLibs{get_filename($Path)} = $Path;
}
}
sub push_U($@)
{ # push unique
if(my $Array = shift @_)
{
if(@_)
{
my %Exist = map {$_=>1} @{$Array};
foreach my $Elem (@_)
{
if(not defined $Exist{$Elem})
{
push(@{$Array}, $Elem);
$Exist{$Elem} = 1;
}
}
}
}
}
sub readDescriptor($)
{
my $Path = $_[0];
my $Content = readFile($Path);
if(not $Content) {
exitStatus("Error", "library descriptor is empty");
}
if($Content!~/\) {
exitStatus("Error", "incorrect descriptor (see -d option)");
}
$Content=~s/\/\*(.|\n)+?\*\///g;
$Content=~s/<\!--(.|\n)+?-->//g;
$Descriptor{"Version"} = parseTag(\$Content, "version");
$Descriptor{"Version"} = $TargetVersion if($TargetVersion);
if(not $Descriptor{"Version"}) {
exitStatus("Error", "version in the descriptor is not specified (section )");
}
if($Content=~/{RELPATH}/)
{
if($RelativeDirectory) {
$Content =~ s/{RELPATH}/$RelativeDirectory/g;
}
else {
exitStatus("Error", "you have not specified -relpath option, but the descriptor contains {RELPATH} macro");
}
}
$Descriptor{"Headers"} = parseTag(\$Content, "headers");
$Descriptor{"Libs"} = parseTag(\$Content, "libs");
$Descriptor{"SkipHeaders"} = parseTag(\$Content, "skip_headers");
$Descriptor{"SkipIncluding"} = parseTag(\$Content, "skip_including");
foreach my $Header (split(/\s*\n\s*/, parseTag(\$Content, "test_include_preamble")))
{
push_U(\@Include_Preamble, $Header);
}
foreach my $Order (split(/\s*\n\s*/, parseTag(\$Content, "include_order")))
{
if($Order=~/\A(.+):(.+)\Z/) {
$Include_Order{$2} = $1;
}
}
# $Include_Order{"freetype.h"} = "ft2build.h";
%Include_RevOrder = reverse(%Include_Order);
foreach my $Interface_Name (split(/\s*\n\s*/, parseTag(\$Content, "skip_interfaces")),
split(/\s*\n\s*/, parseTag(\$Content, "skip_symbols")))
{
if($Interface_Name=~s/\*/.*/g) {
$SkipInterfaces_Pattern{$Interface_Name} = 1;
}
else {
$SkipInterfaces{$Interface_Name} = 1;
}
}
foreach my $Type_Name (split(/\s*\n\s*/, parseTag(\$Content, "opaque_types")))
{
$OpaqueTypes{$Type_Name} = 1;
}
foreach my $Warning (split(/\s*\n\s*/, parseTag(\$Content, "skip_warnings")))
{
if($Warning=~s/\*/.*/g) {
$SkipWarnings_Pattern{$Warning} = 1;
}
else {
$SkipWarnings{$Warning} = 1;
}
}
while(my $LibGroupTag = parseTag(\$Content, "libgroup"))
{
my $LibGroupName = parseTag(\$LibGroupTag, "name");
foreach my $Interface (split(/\s*\n\s*/, parseTag(\$LibGroupTag, "interfaces")),
split(/\s*\n\s*/, parseTag(\$LibGroupTag, "symbols")))
{
$LibGroups{$LibGroupName}{$Interface} = 1;
$Interface_LibGroup{$Interface}=$LibGroupName;
}
}
if(keys(%Interface_LibGroup))
{
if(keys(%InterfacesList)) {
%InterfacesList=();
}
foreach my $LibGroup (keys(%LibGroups))
{
foreach my $Interface (keys(%{$LibGroups{$LibGroup}})) {
$InterfacesList{$Interface}=1;
}
}
}
foreach my $Option (split(/\s*\n\s*/, parseTag(\$Content, "gcc_options")))
{
if($Option=~/\A\-(Wl|l|L)/
or $Option=~/\.$LIB_EXT[0-9.]*\Z/)
{ # to linker
$CompilerOptions_Libs .= " ".$Option;
}
else {
$CompilerOptions_Cflags .= " ".$Option;
}
}
if(my $DDefines = parseTag(\$Content, "test_defines"))
{
$Descriptor{"Defines"} .= "\n".$DDefines;
}
foreach my $Dep (split(/\s*\n\s*/, parseTag(\$Content, "libs_depend")))
{
if(not -f $Dep) {
exitStatus("Access_Error", "can't access \'$Dep\': no such file");
}
$Dep = abs_path($Dep) if($Dep!~/\A(\/|\w+:[\/\\])/);
$LibsDepend{$Dep} = 1;
}
foreach my $IntParam (split(/\s*\n\s*/, parseTag(\$Content, "out_params")))
{
if($IntParam=~/(.+)(:|;)(.+)/) {
$UserDefinedOutParam{$1}{$3} = 1;
}
}
}
sub getArch()
{
my $Arch = $ENV{"CPU"};
if(not $Arch)
{
if($OSgroup=~/linux|bsd|macos/)
{
$Arch = `uname -m`;
chomp($Arch);
if(not $Arch)
{
$Arch = `uname -p`;
chomp($Arch);
}
}
}
if(not $Arch) {
$Arch = $Config{"archname"};
}
$Arch = "x86" if($Arch=~/i[3-7]86/);
if($OSgroup eq "windows")
{
$Arch = "x86" if($Arch=~/win32/i);
$Arch = "x86-64" if($Arch=~/win64/i);
}
$Arch=~s/\-multi\-thread(-|\Z)//g;
return $Arch;
}
sub get_Summary()
{
my $Summary = "