pax_global_header 0000666 0000000 0000000 00000000064 14574065775 0014536 g ustar 00root root 0000000 0000000 52 comment=e20d8d6bcd10e74d8cbdcd3f3efbd31ae695f4cc
aunit-25.0.0/ 0000775 0000000 0000000 00000000000 14574065775 0012742 5 ustar 00root root 0000000 0000000 aunit-25.0.0/.gitignore 0000664 0000000 0000000 00000000025 14574065775 0014727 0 ustar 00root root 0000000 0000000 *.o
*.ali
lib/aunit*
aunit-25.0.0/COPYING.RUNTIME 0000664 0000000 0000000 00000006374 14574065775 0015131 0 ustar 00root root 0000000 0000000 GCC RUNTIME LIBRARY EXCEPTION
Version 3.1, 31 March 2009
Copyright (C) 2009 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
This GCC Runtime Library Exception ("Exception") is an additional
permission under section 7 of the GNU General Public License, version
3 ("GPLv3"). It applies to a given file (the "Runtime Library") that
bears a notice placed by the copyright holder of the file stating that
the file is governed by GPLv3 along with this Exception.
When you use GCC to compile a program, GCC may combine portions of
certain GCC header files and runtime libraries with the compiled
program. The purpose of this Exception is to allow compilation of
non-GPL (including proprietary) programs to use, in this way, the
header files and runtime libraries covered by this Exception.
0. Definitions.
A file is an "Independent Module" if it either requires the Runtime
Library for execution after a Compilation Process, or makes use of an
interface provided by the Runtime Library, but is not otherwise based
on the Runtime Library.
"GCC" means a version of the GNU Compiler Collection, with or without
modifications, governed by version 3 (or a specified later version) of
the GNU General Public License (GPL) with the option of using any
subsequent versions published by the FSF.
"GPL-compatible Software" is software whose conditions of propagation,
modification and use would permit combination with GCC in accord with
the license of GCC.
"Target Code" refers to output from any compiler for a real or virtual
target processor architecture, in executable form or suitable for
input to an assembler, loader, linker and/or execution
phase. Notwithstanding that, Target Code does not include data in any
format that is used as a compiler intermediate representation, or used
for producing a compiler intermediate representation.
The "Compilation Process" transforms code entirely represented in
non-intermediate languages designed for human-written code, and/or in
Java Virtual Machine byte code, into Target Code. Thus, for example,
use of source code generators and preprocessors need not be considered
part of the Compilation Process, since the Compilation Process can be
understood as starting with the output of the generators or
preprocessors.
A Compilation Process is "Eligible" if it is done using GCC, alone or
with other GPL-compatible software, or if it is done without using any
work based on GCC. For example, using non-GPL-compatible Software to
optimize any GCC intermediate representations would not qualify as an
Eligible Compilation Process.
1. Grant of Additional Permission.
You have permission to propagate a work of Target Code formed by
combining the Runtime Library with Independent Modules, even if such
propagation would otherwise violate the terms of GPLv3, provided that
all Target Code was generated by Eligible Compilation Processes. You
may then convey such a combination under terms of your choice,
consistent with the licensing of the Independent Modules.
2. No Weakening of GCC Copyleft.
The availability of this Exception does not imply any general
presumption that third-party software is unaffected by the copyleft
requirements of the license of GCC.
aunit-25.0.0/COPYING3 0000664 0000000 0000000 00000104513 14574065775 0014064 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. 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
them 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 prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. 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.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey 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;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If 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 convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU 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 that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
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.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
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.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
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
state 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 3 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, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program 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, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU 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. But first, please read
.
aunit-25.0.0/Makefile 0000664 0000000 0000000 00000003433 14574065775 0014405 0 ustar 00root root 0000000 0000000 RTS =
TARGET =
GPRBUILD = gprbuild
GPRCLEAN = gprclean
GPRINSTALL = gprinstall
INSTALL:=$(shell exec=`which gprbuild`;if [ ! -x "$$exec" ]; then unset exec;fi;echo $$exec | sed -e 's/\/bin\/$(GPRBUILD).*//')
ifeq ($(RTS),)
RTS=full
RTS_CONF =
else
RTS_CONF = --RTS=$(RTS)
endif
ifeq ($(TARGET),)
TARGET=native
TARGET_CONF =
else
TARGET_CONF = --target=$(TARGET)
endif
MODE = Install
CONF_ARGS = $(TARGET_CONF) $(RTS_CONF)
GPROPTS = $(CONF_ARGS) -XAUNIT_BUILD_MODE=$(MODE) -XAUNIT_RUNTIME=$(RTS) \
-XAUNIT_PLATFORM=$(TARGET)
# For the 64 bits architectures, the large code model has to be used.
# with rtp-large, gprconfig ensures that -mcmodel=large is used,
# but it is managed here for the default (kernel).
GPROPTS_EXTRA=
ifneq ($(strip $(filter aarch64-wrs-vxworks7r2 powerpc64-wrs-vxworks7r2 x86_64-wrs-vxworks7r2,$(TARGET))),)
ifeq (${RTS_CONF},)
# This covers the kernel RTS because for rtp, the RTS_OPT variable is defined to --RTS=rtp.
# kernel is the default and the RTS_OPT is not set in that case.
GPROPTS_EXTRA+=-cargs -mcmodel=large -largs -mcmodel=large
endif
endif
.PHONY: all clean targets install_clean install
all:
$(GPRBUILD) -p $(GPROPTS) lib/gnat/aunit.gpr ${GPROPTS_EXTRA}
clean-lib:
$(RM) -fr lib/aunit lib/aunit-obj
clean: clean-lib
-${MAKE} -C doc clean
install-clean-legacy:
ifneq (,$(wildcard $(INSTALL)/lib/gnat/manifests/aunit))
-$(GPRINSTALL) $(GPROPTS) --uninstall --prefix=$(INSTALL) \
--project-subdir=lib/gnat aunit
endif
install-clean: install-clean-legacy
ifneq (,$(wildcard $(INSTALL)/share/gpr/manifests/aunit))
-$(GPRINSTALL) $(GPROPTS) --uninstall --prefix=$(INSTALL) aunit
endif
install: install-clean
$(GPRINSTALL) $(GPROPTS) -p -f --prefix=$(INSTALL) \
--no-build-var lib/gnat/aunit.gpr
.PHONY: doc
doc:
${MAKE} -C doc
RM = rm
aunit-25.0.0/README 0000664 0000000 0000000 00000002641 14574065775 0013625 0 ustar 00root root 0000000 0000000 AUnit README
This is the Ada unit test framework AUnit, derived
from the JUnit/CPPUnit frameworks for Java/C++. Read the AUnit Cookbook,
available in doc/ in a number of formats, for installation and usage.
AUnit is maintained by AdaCore. Please report problems at report@adacore.com
NOTE FOR CONTRIBUTORS
---------------------
AUnit is intended to be used on bareboard targets that have a very
limited runtime library, so many things like containers, finalization,
exception propagation and so on cannot be used in the main framework
unconditionally. For full list of restrictions see following parts of
GNAT User’s Guide Supplement for Cross Platforms:
* [4.2.2. Ada Restrictions in the Zero Footprint Profile](http://docs.adacore.com/live/wave/gnat_ugx/html/gnat_ugx/gnat_ugx/the_predefined_profiles.html#ada-restrictions-in-the-zero-footprint-profile)
* [4.2.3. Predefined Packages in the Zero Footprint Profile](http://docs.adacore.com/live/wave/gnat_ugx/html/gnat_ugx/gnat_ugx/the_predefined_profiles.html#predefined-packages-in-the-zero-footprint-profile)
Other language features and predefined packages may be used in conditional
way, by either providing the same API across different scenarios or adding
new units for full runtime scenario only. An example of such conditional usage
is FileIO variable from lib/gnat/aunit_shared.gpr that selects between
include/aunit/framework/fileio and include/aunit/framework/nofileio.
aunit-25.0.0/doc/ 0000775 0000000 0000000 00000000000 14574065775 0013507 5 ustar 00root root 0000000 0000000 aunit-25.0.0/doc/Makefile 0000664 0000000 0000000 00000005046 14574065775 0015154 0 ustar 00root root 0000000 0000000 # Makefile for Sphinx documentation
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = DOC_NAME=$* sphinx-build
PAPER =
BUILDDIR = build
SOURCEDIR = .
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) \
-c $(SOURCEDIR)/share \
-d $(BUILDDIR)/$*/doctrees \
$(SOURCEDIR)
DOC_LIST=aunit_cb
FMT_LIST=html pdf txt info
.PHONY: all help clean
all: $(foreach doc, $(DOC_LIST), $(doc).all)
help:
@echo "Please use \`make ' where is one of"
@echo " DOC_NAME.html to make standalone HTML files"
@echo " DOC_NAME.pdf to make LaTeX files and run them through pdflatex"
@echo " DOC_NAME.txt to make text files"
@echo " DOC_NAME.texinfo to make Texinfo files"
@echo " DOC_NAME.info to make info files"
@echo " DOC_NAME.all to build DOC_NAME for all previous formats"
@echo " all to build all documentations in all formats"
@echo " html-all same as previous rule but only for HTML format"
@echo " pdf-all same as previous rule but only for PDF format"
@echo " txt-all same as previous rule but only for text format"
@echo " texinfo-all same as previous rule but only for texinfo format"
@echo " info-all same as previous rule but only for info format"
@echo ""
@echo "DOC_NAME should be a documentation name in the following list:"
@echo " $(DOC_LIST)"
@echo ""
@echo "source and location can be overriden using SOURCEDIR and BUILDDIR variables"
clean:
-rm -rf $(BUILDDIR)/*/html \
$(BUILDDIR)/*/pdf \
$(BUILDDIR)/*/txt \
$(BUILDDIR)/*/info \
$(BUILDDIR)/*/doctrees \
share/__pycache__
%.html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/$*/html
%.pdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/$*/pdf
$(MAKE) -C $(BUILDDIR)/$*/pdf all-pdf LATEXOPTS="-interaction=nonstopmode"
%.txt:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/$*/txt
$(MAKE) -C $(BUILDDIR)/$*/txt plaintext
%.info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/$*/info
$(MAKE) -C $(BUILDDIR)/$*/info info
%.texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/$*/texinfo
html-all: $(foreach doc, $(DOC_LIST), $(doc).html)
pdf-all: $(foreach doc, $(DOC_LIST), $(doc).pdf)
txt-all: $(foreach doc, $(DOC_LIST), $(doc).txt)
texinfo-all: $(foreach doc, $(DOC_LIST), $(doc).texinfo)
%.all:
$(MAKE) $(foreach fmt, $(FMT_LIST), $*.$(fmt))
aunit-25.0.0/doc/aunit_cb.rst 0000664 0000000 0000000 00000001545 14574065775 0016032 0 ustar 00root root 0000000 0000000 AUnit Cookbook
==============
*Ada Unit Testing Framework*
| Version |version|
| Date: |today|
AdaCore
Permission is granted to copy, distribute and/or modify this document under the
terms of the GNU Free Documentation License, Version 1.3 or any later version
published by the Free Software Foundation; with no Invariant Sections, no
Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included
in the section entitled :ref:`gnu_fdl`.
.. toctree::
:numbered:
:maxdepth: 3
aunit_cb/introduction
aunit_cb/overview
aunit_cb/test_case
aunit_cb/fixture
aunit_cb/suite
aunit_cb/reporting
aunit_cb/test_organization
aunit_cb/restricted_runtimes
aunit_cb/installation_and_use
aunit_cb/gps_support
.. raw:: latex
\appendix
.. toctree::
:maxdepth: 3
share/gnu_free_documentation_license
aunit-25.0.0/doc/aunit_cb/ 0000775 0000000 0000000 00000000000 14574065775 0015273 5 ustar 00root root 0000000 0000000 aunit-25.0.0/doc/aunit_cb/fixture.rst 0000664 0000000 0000000 00000007631 14574065775 0017522 0 ustar 00root root 0000000 0000000 .. _Fixture:
*******
Fixture
*******
.. index::
see: Test fixture; Fixture
.. index:: Fixture
Tests need to run against the background of a set of known entities.
This set is called a *test fixture*. When you are
writing tests you will often find that you spend more time writing
code to set up the fixture than you do in actually testing values.
You can make writing fixture code easier by sharing it.
Often you will be able to use the same fixture for several different
tests. Each case will send slightly different messages or parameters to the
fixture and will check for different results.
When you have a common fixture, here is what you do:
* Create a *Test Case* package as in previous section.
* Declare variables or components for elements of the fixture either
as part of the test case type or in the package body.
* According to the Test_Case type used, override its ``Set_Up``
and/or ``Set_Up_Case`` subprogram:
.. index:: AUnit.Simple_Test_Cases.Set_Up procedure
* ``AUnit.Simple_Test_Cases``: ``Set_Up`` is called before
``Run_Test``.
.. index:: AUnit.Test_Cases.Set_Up procedure
.. index:: AUnit.Test_Cases.Set_Up_Case procedure
* ``AUnit.Test_Cases``: ``Set_Up`` is called before each test
routine while ``Set_Up_Case`` is called once before the routines are run.
.. index:: AUnit.Test_Fixtures.Set_Up_Case procedure
* ``AUnit.Test_Fixtures``: ``Set_Up`` is called before each
test case created using ``Aunit.Test_Caller``.
* You can also override ``Tear_Down`` and/or
``Tear_Down_Case`` that are executed after the test is run.
For example, to write several test cases that want to work with
different combinations of 12 Euros, 14 Euros, and 26 US Dollars, first
create a fixture. The package spec is now:
.. code-block:: ada
with AUnit; use AUnit;
package Money_Tests is
use Test_Results;
type Money_Test is new Test_Cases.Test_Case with null record;
procedure Register_Tests (T: in out Money_Test);
-- Register routines to be run
function Name (T : Money_Test) return Test_String;
-- Provide name identifying the test case
procedure Set_Up (T : in out Money_Test);
-- Set up performed before each test routine
-- Test Routines:
procedure Test_Simple_Add (T : in out Test_Cases.Test_Case'Class);
end Money_Tests;
The body becomes:
.. code-block:: ada
package body Money_Tests is
use Assertions;
-- Fixture elements
EU_12, EU_14 : Euro;
US_26 : US_Dollar;
-- Preparation performed before each routine
procedure Set_Up (T: in out Money_Test) is
begin
EU_12 := 12; EU_14 := 14;
US_26 := 26;
end Set_Up;
procedure Test_Simple_Add (T : in out Test_Cases.Test_Case'Class) is
X, Y : Some_Currency;
begin
Assert (EU_12 + EU_14 /= US_26,
"US and EU currencies not differentiated");
end Test_Simple_Add;
-- Register test routines to call
procedure Register_Tests (T: in out Money_Test) is
use Test_Cases.Registration;
begin
-- Repeat for each test routine:
Register_Routine (T, Test_Simple_Add'Access, "Test Addition");
end Register_Tests;
-- Identifier of test case
function Name (T: Money_Test) return Test_String is
begin
return Format ("Money Tests");
end Name;
end Money_Tests;
Once you have the fixture in place, you can write as many test
routines as you like. Calls to ``Set_Up`` and ``Tear_Down``
bracket the invocation of each test routine.
Once you have several test cases, organize them into a Suite.
.. index:: AUnit.Test_Fixtures
You can find a compilable example of fixture set up using
``AUnit.Test_Fixtures`` in your AUnit installation directory:
:samp:`{}/share/examples/aunit/test_fixture/`
or from the AUnit source distribution
:samp:`aunit-{}-src/examples/test_fixture/`.
aunit-25.0.0/doc/aunit_cb/gps_support.rst 0000664 0000000 0000000 00000000637 14574065775 0020420 0 ustar 00root root 0000000 0000000 *******************
GNAT Studio Support
*******************
.. index:: GNAT Studio support
The GNAT Studio IDE relies on the `gnattest` tool that creates unit-test
skeletons as well as a test driver infrastructure (harness). A harness can be
generated for a project hierarchy, a single project or a package.
The generation process can be launched from the `Analyze` -> `GNATtest` menu
or from a contextual menu.
aunit-25.0.0/doc/aunit_cb/installation_and_use.rst 0000664 0000000 0000000 00000010437 14574065775 0022231 0 ustar 00root root 0000000 0000000 .. _Installation_and_Use:
********************
Installation and Use
********************
.. index:: Installation of AUnit, ZFP profile, cert profile
AUnit 3 contains support for restricted runtimes such as the zero-foot-print
(ZFP) and certified (cert) profiles. It can now be installed simultaneously
for several targets and runtimes.
.. _Note_on_gprbuild:
Note on gprbuild
================
.. index:: gprbuild, gprinstall
In order to compile, install and use AUnit, you need `gprbuild` and `gprinstall`
version 2.2.0 or above.
.. _Support_for_other_platforms/run-times:
Support for other platforms/run-times
=====================================
AUnit should be built and installed separately for each target and runtime
it is meant to be used with. The necessary customizations are performed at
AUnit build time, so once the framework is installed, it is always referenced
simply by adding the line
::
with "aunit";
to your project.
.. _Installing_AUnit:
Installing AUnit
================
Normally AUnit comes preinstalled and ready-to-use for all runtimes in
your GNAT distribution. The following instructions are for rebuilding it from
sources for a custom configuration that the user may have.
* Extract the archive:
::
$ gunzip -dc aunit--src.tgz | tar xf -
* To build AUnit for a full Ada run-time:
::
$ cd aunit--src
$ make
.. index:: ZFP profile
* To build AUnit for a ZFP run-time targeting powerpc-elf platform:
::
$ cd aunit--src
$ make TARGET=powerpc-elf RTS=zfp
* To build AUnit for a reconfigurable runtime zfp-leon3 targeting leon3-elf
platform:
::
$ cd aunit--src
$ make TARGET=leon3-elf RTS=zfp RTS_CONF="--RTS=zfp-leon3"
Once the above build procedure has been performed for the desired platform, you
can install AUnit:
::
$ make install INSTALL=
.. index:: gprbuild
We recommend that you install AUnit into the standard location used by `gprbuild`
to find the libraries for a given configuration. For example for the case above
(runtime `zfp-leon3` targeting `leon3-elf`), the default location is
:samp:`{}/leon3-elf/zfp-leon3`. If the runtime is located in a custom
directory and specified by the full path, using this exact path also as
** is a sensible choice.
If ``INSTALL`` is not specified, then AUnit will use the root directory where
`gprbuild` is installed.
* Specific installation:
The AUnit makefile supports some specific options, activated using
environment variables. The following options are defined:
.. index:: INSTALL environment variable
* ``INSTALL``: defines the AUnit base installation directory, set to
gprbuild's base installation directory as found in the ``PATH``.
.. index:: TARGET environment variable
* ``TARGET``: defines the gnat tools prefix to use. For example, to compile
AUnit for powerpc VxWorks, ``TARGET`` should be set to ``powerpc-wrs-vxworks``. If not
set, the native compiler will be used.
.. index:: RTS environment variable
* ``RTS``: defines both the run-time used to compile AUnit and the value
given to the AUnit project as ``RUNTIME`` scenario variable.
.. index:: RTS_CONF environment variable
* ``RTS_CONF``: defines the `gprbuild` Runtime config flag. The value is
set to ``--RTS=$(RTS)`` by default. Can be used when compiling AUnit for a
configurable run-time.
* To test AUnit:
The AUnit test suite is in the test subdirectory of the source package.
::
$ cd test
$ make
The test suite's makefile supports the following variables:
* ``RTS``
* ``TARGET``
.. _Installed_files:
Installed files
===============
The AUnit library is installed in the specified directory (**
identifies the root installation directory as specified during the installation
procedures above):
.. index:: aunit.gpr project file
* the :file:`aunit.gpr` project is installed in :samp:`{}/lib/gnat`
* the AUnit source files are installed in :samp:`{}/include/aunit`
* the AUnit library files are installed in :samp:`{}/lib/aunit`
* the AUnit documentation is installed in :samp:`{}/share/doc/aunit`
* the AUnit examples are installed in :samp:`{}/share/examples/aunit`
aunit-25.0.0/doc/aunit_cb/introduction.rst 0000664 0000000 0000000 00000006307 14574065775 0020554 0 ustar 00root root 0000000 0000000 .. _Introduction:
************
Introduction
************
This is a short guide for using the AUnit test framework.
AUnit is an adaptation of the Java :index:`JUnit` (Kent Beck, Erich Gamma) and C++
:index:`CppUnit` (M. Feathers, J. Lacoste, E. Sommerlade, B. Lepilleur, B. Bakker,
S. Robbins) unit test frameworks for Ada code.
What's new in AUnit 3
=====================
AUnit 3 brings several enhancements over AUnit 2 and AUnit 1:
* Removal of the genericity of the AUnit framework, making the AUnit 3
API as close as possible to AUnit 1.
* Emulates dynamic memory management for limited run-time profiles.
* Provides a new XML reporter, and changes harness invocation to support
easy switching among text, XML and customized reporters.
* Provides new tagged types ``Simple_Test_Case``, ``Test_Fixture`` and ``Test_Caller``
that correspond to CppUnit's ``TestCase``, ``TestFixture`` and ``TestCaller`` classes.
.. index:: ZFP profile
.. index:: setjmp/longjmp
* Emulates exception propagation for restricted run-time profiles
(e.g. ZFP), by using the gcc builtin `setjmp` / `longjmp` mechanism.
* Reports the source location of an error when possible.
Typographic conventions
=======================
.. index:: notational convention
For notational convenience, `` will be used throughout
this document to stand for the AUnit product version number.
For example, aunit-**-src expands to aunit-|version|-src.
Examples
========
With this version, we have provided new examples illustrating the enhanced
features of the framework. These examples are in the AUnit
installation directory:
:file:`/share/examples/aunit`, and are also available in the source
distribution :samp:`aunit-{}-src/examples`.
The following examples are provided:
* simple_test: shows use of AUnit.Simple_Test_Cases
(see :ref:`AUnit.Simple_Test_Cases`).
* test_caller: shows use of AUnit.Test_Caller (see :ref:`AUnit.Test_Caller`).
* test_fixture: example of a test fixture (see :ref:`Fixture`).
* liskov: This suite tests conformance to the Liskov Substitution Principle
of a pair of simple tagged types. (see :ref:`OOP_considerations`)
* failures: example of handling and reporting failed tests
(see :ref:`Reporting`).
* calculator: a full example of test suite organization.
Note about limited run-time libraries
=====================================
AUnit allows a great deal of flexibility for the structure of test cases,
suites and harnesses. The templates and examples given in this document
illustrate how to use AUnit while staying within the constraints of the
GNAT Pro restricted and Zero Footprint (ZFP) run-time libraries. Therefore,
they avoid the use of dynamic allocation and some other features that would
be outside of the profiles corresponding to these libraries. Tests targeted
to the full Ada run-time library need not comply with these constraints.
Thanks
======
This document is adapted from the JUnit and CppUnit Cookbooks documents
contained in their respective release packages.
.. |c-cedilla-lc| unicode:: 0xE7
:trim:
Special thanks to Fran |c-cedilla-lc| ois Brun of Thales Avionics for his ideas about
support for OOP testing.
aunit-25.0.0/doc/aunit_cb/overview.rst 0000664 0000000 0000000 00000016454 14574065775 0017705 0 ustar 00root root 0000000 0000000 .. |nbsp| unicode:: 0xA0
:trim:
.. _Overview:
********
Overview
********
How do you write testing code?
The simplest approach is as an expression in a debugger. You can change
debug expressions without recompiling, and you can wait to decide
what to write until you have seen the running objects. You can also
write test expressions as statements that print to the standard
output stream. Both styles of tests are limited because they require
human judgment to analyze their results. Also, they don't compose
nicely - you can only execute one debug expression at a time and a
program with too many print statements causes the dreaded "Scroll
Blindness".
AUnit tests do not require human judgment to interpret, and it is
easy to run many of them at the same time. When you need to test
something, here is what you do:
.. index:: AUnit.Simple_Test_Cases.Test_Case type
.. index:: AUnit.Test_Cases.Test_Case type
.. index:: AUnit.Test_Fixtures.Test_Fixture type
* Derive a test case type from ``AUnit.Simple_Test_Cases.Test_Case``.
Several test case types are available:
* ``AUnit.Simple_Test_Cases.Test_Case``: the base type for all test
cases. Needs overriding of ``Name`` and ``Run_Test``.
* ``AUnit.Test_Cases.Test_Case``: the traditional AUnit test case type,
allowing multiple test routines to be registered, where each one is run
and reported independently.
* ``AUnit.Test_Fixtures.Test_Fixture``: used together with
``AUnit.Test_Caller``, this allows easy creation of test suites comprising
several test cases that share the same fixture (see :ref:`Fixture`).
See :ref:`Test_Case` for simple examples of using these types.
* When you want to check a value [#]_ use one of the following Assert [#]_ methods:
.. [#] While :index:`JUnit` and some other
members of the xUnit family of unit test frameworks provide specialized forms
of assertions (e.g. `assertEqual`), we took a design decision in AUnit
not to provide such forms. Ada has a much richer type system giving a
large number of possible scalar types, and leading to an explosion of possible
special forms of assert routines. This is exacerbated by the lack of a single
root type for most types, as is found in Java. With the introduction of
AUnit |nbsp| 2 for use with restricted run-time profiles, where even ``'Image`` is
missing, providing a comprehensive set of special assert routines in the
framework itself becomes even more unrealistic. Since AUnit is intended to
be an extensible toolkit, users can certainly write their own custom
collection of such assert routines to suit local usage.
.. index::
see: Assert subprogram; AUnit.Assertions.Assert
.. [#] Note that in AUnit |nbsp| 3, and contrary to
AUnit |nbsp| 2, the procedural form of `Assert` has the same behavior whatever
the underlying Ada run-time library: a failed assertion will cause the
execution of the calling test routine to be abandoned. The functional form of
`Assert` always continues on a failed assertion, and provides you
with a choice of behaviors.
.. index:: AUnit.Assertions.Assert
.. code-block:: ada
AUnit.Assertions.Assert (Boolean_Expression, String_Description);
or:
.. code-block:: ada
if not AUnit.Assertions.Assert (Boolean_Expression, String_Description) then
return;
end if;
.. index:: Assert_Exception subprogram
If you need to test that a subprogram raises an expected exception, there
is the procedure ``Assert_Exception`` that takes an access value designating the procedure
to be tested as a parameter:
.. code-block:: ada
type Throwing_Exception_Proc is access procedure;
procedure Assert_Exception
(Proc : Throwing_Exception_Proc;
Message : String;
Source : String := GNAT.Source_Info.File;
Line : Natural := GNAT.Source_Info.Line);
-- Test that Proc throws an exception and record "Message" if not.
Example:
.. code-block:: ada
-- Declared at library level:
procedure Test_Raising_Exception is
begin
call_to_the_tested_method (some_args);
end Test_Raising_Exception;
-- In test routine:
procedure My_Routine (...) is
begin
Assert_Exception (Test_Raising_Exception'Access, **String_Description**);
end My_Routine;
This procedure can handle exceptions with all run-time profiles (including
zfp). If you are using a run-time library capable of propagating exceptions,
you can use the following idiom instead:
.. code-block:: ada
procedure My_Routine (...) is
begin
...
-- Call subprogram expected to raise an exception:
Call_To_The_Tested_Method (some_args);
Assert (False, 'exception not raised');
exception
when desired_exception =>
null;
end My_Routine;
An unexpected exception will be recorded as such by the framework. If you want
your test routine to continue beyond verifying that an expected exception has
been raised, you can nest the call and handler in a block.
.. index:: ZFP profile
.. index:: cert profile
.. index:: AUnit.Memory.Utils.Gen_Alloc
.. index:: AUnit.Test_Caller.Create
.. index:: AUnit.Test_Suites.New_Suite
* Create a suite function inside a package to gather together test cases
and sub-suites. (If either the ZFP or the cert run-time profiles ia being
used, test cases and suites must be allocated using
``AUnit.Memory.Utils.Gen_Alloc``, ``AUnit.Test_Caller.Create``,
``AUnit.Test_Suites.New_Suite``, or else they must be statically allocated.)
.. index:: AUnit.Run.Test_Runner
.. index:: AUnit.Run.Test_Runner_With_Status
* At any level at which you wish to run tests, create a harness by
instantiating procedure ``AUnit.Run.Test_Runner`` or function
``AUnit.Run.Test_Runner_With_Status`` with the top-level suite
function to be executed. This instantiation provides a routine
that executes all of the tests in the suite. We will call this
user-instantiated routine `Run` in the text for backward compatibility
with tests developed for AUnit |nbsp| 1. Note that only one instance of `Run`
can execute at a time. This is a tradeoff made to reduce the stack requirement
of the framework by allocating test result reporting data structures
statically.
.. index::
see: Test_Runner; AUnit.Run.Test_Runner
.. index:: ZFP profile
It is possible to pass a filter to a `Test_Runner`, so that only a
subset of the tests run. In particular, this filter could be initialized from
a command line parameter. See the package ``AUnit.Test_Filters`` for an
example of such a filter. AUnit does not automatically initialize this filter
from the command line both because it would not be supported with some of the
limited run-time profiles (ZFP for instance), and because you might want to
pass the argument in different ways (as a parameter to switch, or a stand-alone
command line argument for instance).
.. index:: AUnit.Options package
It is also possible to control the contents of the output report by passing an
object of type ``AUnit_Options`` to the `Test_Runner`. See package
``AUnit.Options`` for details.
* Build the code that calls the harness `Run` routine using
`gnatmake` or `gprbuild`. The GNAT project file :file:`aunit.gpr` contains all
necessary switches, and should be imported into your root project file.
aunit-25.0.0/doc/aunit_cb/reporting.rst 0000664 0000000 0000000 00000006666 14574065775 0020054 0 ustar 00root root 0000000 0000000 .. _Reporting:
*********
Reporting
*********
.. index:: Reporting
.. index:: AUnit.Reporter.Text.Text_Reporter type
.. index:: AUnit.Reporter.XML.XML_Reporter type
.. index:: AUnit.Run.Test_Runner
Test results can be reported using several `Reporters`. By default, two
reporters are available in AUnit:
``AUnit.Reporter.Text.Text_Reporter`` and
``AUnit.Reporter.XML.XML_Reporter``. The first one is a simple
console reporting routine, while the second one outputs the result using
an XML format. These are invoked when the ``Run`` routine of an
instantiation of ``AUnit.Run.Test_Runner`` is called.
.. index:: AUnit.Reporter.Reporter
New reporters can be created using children of
``AUnit.Reporter.Reporter``.
The Reporter is selected by specifying it when calling ``Run``:
.. code-block:: ada
with A_Suite;
with AUnit.Run;
with AUnit.Reporter.Text;
procedure My_Tests is
procedure Run is new AUnit.Run.Test_Runner (A_Suite.Suite);
Reporter : AUnit.Reporter.Text.Text_Reporter;
begin
Run (Reporter);
end My_Tests;
.. index:: Test_Result type
The final report is output once all tests have been run, so that they can be
grouped depending on their status (passed or fail). If you need to output the
tests as they are run, you should consider extending the `Test_Result`
type and do some output every time a success or failure is registered.
Text output
===========
Here is an example where the test harness runs 4 tests, one reporting an
assertion failure, one reporting an unexpected error (exception):
::
--------------------
Total Tests Run: 4
Successful Tests: 2
Test addition
Test subtraction
Failed Assertions: 1
Test addition (failure expected)
Test should fail this assertion, as 5+3 /= 9
at math-test.adb:29
Unexpected Errors: 1
Test addition (error expected)
CONSTRAINT_ERROR
Time: 2.902E-4 seconds
.. index:: Colors (in report output)
This reporter can optionally use colors (green to report success, red to report
errors). Since not all consoles support it, this is off by default, but you can
call ``Set_Use_ANSI_Colors`` to activate support for colors.
.. index:: XML output
XML output
==========
Following is the same harness run using XML output. The XML format used
matches the one used by :index:`CppUnit`.
.. index:: UTF-8 character encoding
Note that text set in the `Assert` subprograms or as test case names should
be compatible with utf-8 character encoding, or the XML will not be
correctly formatted.
::
4
2
1
1
Test addition
Test subtraction
Test addition (failure expected)
Assertion
Test should fail this assertion, as 5+3 /= 9
math-test.adb
29
Test addition (error expected)
Error
CONSTRAINT_ERROR
aunit-25.0.0/doc/aunit_cb/restricted_runtimes.rst 0000664 0000000 0000000 00000007476 14574065775 0022141 0 ustar 00root root 0000000 0000000 .. |nbsp| unicode:: 0xA0
:trim:
.. |AUnit 3| replace:: AUnit |nbsp| 3
.. |AUnit 2| replace:: AUnit |nbsp| 2
.. _Using_AUnit_with_Restricted_Run-Time_Libraries:
**********************************************
Using AUnit with Restricted Run-Time Libraries
**********************************************
.. index:: Restricted run-time libraries (usage with AUnit)
.. index:: ZFP profile, cert profile
.. index:: VxWorks 653 (and restricted run-time profiles)
|AUnit 3| - like |AUnit 2| - is designed so that it can be used in
environments with restricted Ada run-time libraries, such as ZFP and the cert
run-time profile on Wind River's VxWorks 653. The patterns given in
this document for writing tests, suites and harnesses are not the only
patterns that can be used with AUnit, but they are compatible with the
restricted run-time libraries provided with GNAT Pro.
.. index:: Dynamic allocation (in test code)
In general, dynamic allocation and deallocation must be used carefully in test
code. For the cert profile on VxWorks 653, all dynamic allocation must be
done prior to setting the application partition into 'normal' mode.
Deallocation is prohibited in this profile. For some restricted profiles,
dynamic memory management is not provided as part of the run-time,
and should not be used unless you have provided implementations as described
in the GNAT User's Guide Supplement for GNAT Pro Safety-Critical and GNAT
Pro High-Security.
Starting with |AUnit 3|, a simple memory management mechanism has been
included in the framework, using a kind of storage pool. This memory
management mechanism uses a static array allocated at startup, and simulates
dynamic allocation afterwards by allocating parts of this array upon request.
Deallocation is not permitted.
By default, an array of 100KB is allocated. The size can be changed
by modifying the value in the file
:samp:`aunit-{}-src/aunit/framework/staticmemory/aunit-memory.adb`
before building AUnit.
.. index:: AUnit.Memory.Utils.Gen_Alloc
To allocate a new object, you use ``AUnit.Memory.Utils.Gen_Alloc``.
Additional restrictions relevant to the default ZFP profile include:
.. index:: __gnat_last_chance_handler (for ZFP)
.. index:: pragma Weak_External
* Normally the ZFP profile requires a user-defined
``__gnat_last_chance_handler`` routine
to handle raised exceptions. However, AUnit now provides a mechanism to
simulate exception propagation using gcc builtin :index:`setjmp/longjmp` mechanism.
This mechanism defines the ``__gnat_last_chance_handler`` routine, so it
should not be redefined elsewhere. In order to be compatible with this
restriction, the user-defined last chance handler routine can be defined as a
"weak" symbol; this way, it will still be linked into the standalone executable,
but will be replaced by the AUnit implementation when linked with the harness.
The pragma ``Weak_External`` can be used for that; e.g.:
.. code-block:: ada
pragma Weak_External (Last_Chance_Handler);
.. index:: GNAT.IO
.. index:: cert profile
* AUnit requires ``GNAT.IO`` provided in :samp:`g-io.ad{?}` in the full or cert
profile run-time library sources (or as implemented by the user). Since this
is a run-time library unit it must be compiled with the gnatmake :samp:`-a`
switch.
.. index:: Secondary stack, memcpy, memset
* The AUnit framework has been modified so that no call to the secondary
stack is performed, nor any call to ``memcpy`` or ``memset``. However, if the unit
under test, or the tests themselves require use of those routines, then the
application or test framework must define those symbols and provide the
requisite implementations.
.. index:: ZFP profile
.. index:: Ada.Calendar
* The timed parameter of the Harness ``Run`` routine has no effect when used
with the ZFP profile, and on profiles not supporting ``Ada.Calendar``.
aunit-25.0.0/doc/aunit_cb/suite.rst 0000664 0000000 0000000 00000007413 14574065775 0017163 0 ustar 00root root 0000000 0000000 .. _Suite:
*****
Suite
*****
Creating a Test Suite
=====================
How do you run several test cases at once?
.. index::
see: Test_Suite; AUnit.Test_Suites.Test_Suite
see: Test_Suites; AUnit.Test_Suites
.. index:: AUnit.Test_Suites package
.. index:: AUnit.Test_Suites.Test_Suite type
As soon as you have two tests, you'll want to run them together.
You could run the tests one at a time yourself, but you would quickly
grow tired of that. Instead, AUnit provides an object, ``Test_Suite``,
that runs any number of test cases together.
To create a suite of two test cases and run them together, first create
a test suite:
.. code-block:: ada
with AUnit.Test_Suites;
package My_Suite is
function Suite return AUnit.Test_Suites.Access_Test_Suite;
end My_Suite;
.. code-block:: ada
-- Import tests and sub-suites to run
with Test_Case_1, Test_Case_2;
package body My_Suite is
use AUnit.Test_Suites;
-- Statically allocate test suite:
Result : aliased Test_Suite;
-- Statically allocate test cases:
Test_1 : aliased Test_Case_1.Test_Case;
Test_2 : aliased Test_Case_2.Test_Case;
function Suite return Access_Test_Suite is
begin
Add_Test (Result'Access, Test_Case_1'Access);
Add_Test (Result'Access, Test_Case_2'Access);
return Result'Access;
end Suite;
end My_Suite;
.. index:: AUnit.Test_Suites.New_Suite, AUnit.Memory.Utils.Gen_Alloc
Instead of statically allocating test cases and suites,
you can also use ``AUnit.Test_Suites.New_Suite`` and/or
``AUnit.Memory.Utils.Gen_Alloc``. These routines emulate dynamic
memory management (see :ref:`Using_AUnit_with_Restricted_Run-Time_Libraries`).
Similarly, if you know that the tests will always be executed for a run-time
profile that supports dynamic memory management, you can allocate these
objects directly with the Ada ``new`` operation.
The harness is:
.. code-block:: ada
with My_Suite;
with AUnit.Run;
with AUnit.Reporter.Text;
procedure My_Tests is
procedure Run is new AUnit.Run.Test_Runner (My_Suite.Suite);
Reporter : AUnit.Reporter.Text.Text_Reporter;
begin
Run (Reporter);
end My_Tests;
.. index:: Composition of test suites
Composition of Suites
=====================
Typically, one will want the flexibility to execute a complete set
of tests, or some subset of them. In order to facilitate this, we can
compose both suites and test cases, and provide a harness for any given
suite:
.. code-block:: ada
-- Composition package:
with AUnit; use AUnit;
package Composite_Suite is
function Suite return Test_Suites.Access_Test_Suite;
end Composite_Suite;
-- Import tests and suites to run
with This_Suite, That_Suite;
with AUnit.Tests;
package body Composite_Suite is
use Test_Suites;
-- Here we dynamically allocate the suite using the New_Suite function
-- We use the 'Suite' functions provided in This_Suite and That_Suite
-- We also use Ada 2005 distinguished receiver notation to call Add_Test
function Suite return Access_Test_Suite is
Result : Access_Test_Suite := AUnit.Test_Suites.New_Suite;
begin
Result.Add_Test (This_Suite.Suite);
Result.Add_Test (That_Suite.Suite);
return Result;
end Suite;
end Composite_Suite;
The harness remains the same:
.. code-block:: ada
with Composite_Suite;
with AUnit.Run;
procedure My_Tests is
procedure Run is new AUnit.Run.Test_Runner (Composite_Suite.Suite);
Reporter : AUnit.Reporter.Text.Text_Reporter;
begin
Run (Reporter);
end My_Tests;
As can be seen, this is a very flexible way of composing test cases
into execution runs: any combination of test cases and sub-suites can
be collected into a suite.
aunit-25.0.0/doc/aunit_cb/test_case.rst 0000664 0000000 0000000 00000020201 14574065775 0017772 0 ustar 00root root 0000000 0000000 .. _Test_Case:
*********
Test Case
*********
In this chapter, we will introduce how to use the various forms of Test
Cases. We will illustrate with a very simple test routine, which verifies
that the sum of two Money values with the same currency unit is a value
that is the sum of the two values:
.. code-block:: ada
declare
X, Y: Some_Currency;
begin
X := 12; Y := 14;
Assert (X + Y = 26, "Addition is incorrect");
end;
The following sections will show how to use this test method using the
different test case types available in AUnit.
.. index:: AUnit.Simple_Test_Cases.Test_Case type
.. _AUnit-Simple_Test_Cases:
AUnit.Simple_Test_Cases
=======================
``AUnit.Simple_Test_Cases.Test_Case`` is the root type of all test
cases. Although generally not meant to be used directly, it provides a
simple and quick way to run a test.
This tagged type has several methods that need to be defined, or may be
overridden.
.. index:: Name abstract function
* ``function Name (T : Test_Case) return Message_String is abstract``:
This function returns the Test name. You can easily translate regular
strings to ``Message_String`` using ``AUnit.Format``. For example:
.. code-block:: ada
function Name (T : Money_Test) return Message_String is
begin
return Format ("Money Tests");
end Name;
.. index:: Run_Test abstract function
* ``procedure Run_Test (T : in out Test_Case) is abstract``:
This procedure contains the test code. For example:
.. code-block:: ada
procedure Run_Test (T : in out Money_Test) is
X, Y: Some_Currency;
begin
X := 12; Y := 14;
Assert (X + Y = 26, "Addition is incorrect");
end Run_Test;
.. index:: Set_Up procedure, Tear_Down procedure
* ``procedure Set_Up (T : in out Test_Case);`` and ``procedure Tear_Down (T : in out Test_Case);``
(default implementations do nothing):
These procedures are meant to respectively set up or tear down the
environment before running the test case. See :ref:`Fixture` for examples
of how to use these methods.
You can find a compilable example of
``AUnit.Simple_Test_Cases.Test_Case`` usage in your AUnit installation
directory: :samp:`{}/share/examples/aunit/simple_test/` or from the
source distribution :samp:`aunit-{}-src/examples/simple_test/`.
.. _AUnit-Test_Cases:
AUnit.Test_Cases
================
``AUnit.Test_Cases.Test_Case`` is derived from
``AUnit.Simple_Test_Cases.Test_Case`` and defines its
``Run_Test`` procedure.
It allows a very flexible composition of Test routines inside a single
test case, each being reported independently.
The following subprograms must be considered for inheritance, overriding or
completion:
.. index:: Name abstract function (for AUnit.Test_Cases.Test_Case)
* ``function Name (T : Test_Case) return Message_String is abstract;``
Inherited. See :ref:`AUnit.Simple_Test_Cases`.
.. index:: Set_Up procedure (for AUnit.Test_Cases.Test_Case)
.. index:: Tear_Down procedure (for AUnit.Test_Cases.Test_Case)
* | ``procedure Set_Up (T : in out Test_Case);``
| ``procedure Tear_Down (T : in out Test_Case);``
Inherited. See :ref:`AUnit.Simple_Test_Cases`.
.. index:: Set_Up_Case procedure (for AUnit.Test_Cases.Test_Case)
.. index:: Tear_Down_Case procedure (for AUnit.Test_Cases.Test_Case)
* | ``procedure Set_Up_Case (T : in out Test_Case);``
| ``procedure Tear_Down_Case (T : in out Test_Case);``
Default implementation does nothing.
These last two procedures provide an opportunity to set up and tear down the test
case before and after all test routines have been executed. In contrast, the
inherited ``Set_Up`` and ``Tear_Down`` are called before and after the
execution of each individual test routine.
.. index:: Register abstract procedure (for AUnit.Test_Cases.Test_Case)
* ``procedure Register_Tests (T : in out Test_Case) is abstract;``
.. index:: Registration.Register_Routine
.. index:: Specific_Test_Case.Register_Wrapper
This procedure must be overridden. It is responsible for registering all
the test routines that will be run. You need to use either
``Registration.Register_Routine`` or the generic
``Specific_Test_Case.Register_Wrapper`` subprograms defined in
``AUnit.Test_Cases`` to register a routine. A test routine has the
form:
.. code-block:: ada
procedure Test_Routine (T : in out Test_Case'Class);
or
.. code-block:: ada
procedure Test_Wrapper (T : in out Specific_Test_Case'Class);
The former procedure is used mainly for dispatching calls
(see :ref:`OOP_considerations`).
Using this type to test our money addition, the package spec is:
.. code-block:: ada
with AUnit; use AUnit;
with AUnit.Test_Cases; use AUnit.Test_Cases;
package Money_Tests is
type Money_Test is new Test_Cases.Test_Case with null record;
procedure Register_Tests (T: in out Money_Test);
-- Register routines to be run
function Name (T: Money_Test) return Message_String;
-- Provide name identifying the test case
-- Test Routines:
procedure Test_Simple_Add (T : in out Test_Cases.Test_Case'Class);
end Money_Tests
The package body is:
.. code-block:: ada
with AUnit.Assertions; use AUnit.Assertions;
package body Money_Tests is
procedure Test_Simple_Add (T : in out Test_Cases.Test_Case'Class) is
X, Y : Some_Currency;
begin
X := 12; Y := 14;
Assert (X + Y = 26, "Addition is incorrect");
end Test_Simple_Add;
-- Register test routines to call
procedure Register_Tests (T: in out Money_Test) is
use AUnit.Test_Cases.Registration;
begin
-- Repeat for each test routine:
Register_Routine (T, Test_Simple_Add'Access, "Test Addition");
end Register_Tests;
-- Identifier of test case
function Name (T: Money_Test) return Test_String is
begin
return Format ("Money Tests");
end Name;
end Money_Tests;
.. index:: AUnit.Test_Caller generic package
.. _AUnit-Test_Caller:
AUnit.Test_Caller
=================
.. index:: AUnit.Test_Fixtures.Test_Fixture type
``Test_Caller`` is a generic package that is used with
``AUnit.Test_Fixtures.Test_Fixture``. ``Test_Fixture`` is a very
simple type that provides only the ``Set_Up`` and ``Tear_Down``
procedures. This type is meant to contain a set of user-defined test
routines, all using the same set up and tear down mechanisms. Once those
routines are defined, the ``Test_Caller`` package is used to incorporate them
directly into a test suite.
With our money example, the ``Test_Fixture`` is:
.. code-block:: ada
with AUnit.Test_Fixtures;
package Money_Tests is
type Money_Test is new AUnit.Test_Fixtures.Test_Fixture with null record;
procedure Test_Simple_Add (T : in out Money_Test);
end Money_Tests;
The test suite (see :ref:`Suite`) calling the test cases created from
this Test_Fixture is:
.. code-block:: ada
with AUnit.Test_Suites;
package Money_Suite is
function Suite return AUnit.Test_Suites.Access_Test_Suite;
end Money_Suite;
Here is the corresponding body:
.. code-block:: ada
with AUnit.Test_Caller;
with Money_Tests;
package body Money_Suite is
package Money_Caller is new AUnit.Test_Caller
(Money_Tests.Money_Test);
function Suite return Aunit.Test_Suites.Access_Test_Suite is
Ret : AUnit.Test_Suites.Access_Test_Suite :=
AUnit.Test_Suites.New_Suite;
begin
Ret.Add_Test
(Money_Caller.Create
("Money Test : Test Addition",
Money_Tests.Test_Simple_Add'Access));
return Ret;
end Suite;
end Money_Suite;
Note that ``New_Suite`` and ``Create`` are fully compatible with
limited run-time libraries (in particular, those without dynamic allocation support).
However, for non-native run-time libraries, you cannot extend
``Test_Fixture`` with a controlled component.
You can find a compilable example of
``AUnit.Test_Caller`` usage in the AUnit installation
directory: :samp:`{}/share/examples/aunit/test_caller/` or from the
source distribution :samp:`aunit-{}-src/examples/test_caller/`.
aunit-25.0.0/doc/aunit_cb/test_organization.rst 0000664 0000000 0000000 00000035335 14574065775 0021601 0 ustar 00root root 0000000 0000000 .. index:: Test organization
.. _Test_Organization:
*****************
Test Organization
*****************
.. _General_considerations:
General considerations
======================
This section will discuss an approach to organizing an AUnit test harness,
considering some possibilities offered by Ada language features.
The general idea behind this approach to test organization is that making the
test case a child of the unit under test gives some useful facilities.
The test case gains visibility to the private part of the unit under test.
This offers a more 'white box' approach to examining the state of the unit
under test than would, for instance, accessor functions defined in a separate
fixture that is a child of the unit under test. Making the test case a child of
the unit under test also provides a way to make the test case share certain
characteristics of the unit under test. For instance, if the unit under test
is generic, then any child package (here the test case) must be also generic:
any instantiation of the parent package will require an instantiation of the
test case in order to accomplish its aims.
Another useful concept is matching the test case type to that of the unit
under test, for example:
* When testing a generic package, the test package should also be
generic.
* When testing a tagged type, then test routines should be
dispatching, and the test case type for a derived tagged type should be a
derivation of the test case type for the parent.
Maintaining such similarity of properties between the test case and unit under
test can facilitate the testing of units derived in various ways.
The following sections will concentrate on applying these concepts to
the testing of tagged type hierarchies and to the testing of generic units.
A full example of this kind of test organization is available in the AUnit
installation directory:
:samp:`{}/share/examples/aunit/calculator`, or
from the AUnit source distribution
:samp:`aunit-{}-src/examples/calculator`.
.. index:: OOP considerations (in test organization)
.. _OOP_considerations:
OOP considerations
==================
When testing a hierarchy of tagged types, one will often want to run tests
for parent types against their derivations without rewriting those tests.
We will illustrate some of the possible solutions available in AUnit,
using the following simple example that we want to test:
First we consider a ``Root`` package defining the ``Parent``
tagged type, with two procedures ``P1`` and ``P2``.
.. code-block:: ada
package Root is
type Parent is tagged private;
procedure P1 (P : in out Parent);
procedure P2 (P : in out Parent);
private
type Parent is tagged record
Some_Value : Some_Type;
end record;
end Root;
We will also consider a derivation from type ``Parent``:
.. code-block:: ada
with Root;
package Branch is
type Child is new Root.Parent with private;
procedure P2 (C : in out Child);
procedure P3 (C : in out Child);
private
type Child is new Root.Parent with null record;
end Branch;
Note that ``Child`` retains the parent implementation of ``P1``,
overrides ``P2`` and adds ``P3``. Its test will override
``Test_P2`` when we override ``P2`` (not necessary, but certainly
possible).
.. index:: AUnit.Test_Fixtures.Test_Fixture type
Using AUnit.Test_Fixtures
-------------------------
Using type ``Test_Fixture``, we first test ``Parent`` using the
following test case:
.. code-block:: ada
with AUnit; use AUnit;
with AUnit.Test_Fixtures; use AUnit.Test_Fixtures;
-- We make this package a child package of Parent so that it can have
-- visibility to its private part
package Root.Tests is
type Parent_Access is access all Root.Parent'Class;
-- Reference an object of type Parent'Class in the test object, so
-- that test procedures can have access to it.
type Parent_Test is new Test_Fixture with record
Fixture : Parent_Access;
end record;
-- This will initialize P.
procedure Set_Up (P : in out Parent_Test);
-- Test routines. If derived types are declared in child packages,
-- these can be in the private part.
procedure Test_P1 (P : in out Parent_Test);
procedure Test_P2 (P : in out Parent_Test);
end Root.Tests;
.. code-block:: ada
package body Root.Tests is
Fixture : aliased Parent;
-- We set Fixture in Parent_Test to an object of type Parent.
procedure Set_Up (P : in out Parent_Test) is
begin
P.Fixture := Parent_Access (Fixture'Access);
end Set_Up;
-- Test routines: References to the Parent object are made via
-- P.Fixture.all, and are thus dispatching.
procedure Test_P1 (P : in out Parent_Test) is ...;
procedure Test_P2 (P : in out Parent_Test) is ...;
end Root.Tests;
The associated test suite will be:
.. code-block:: ada
with AUnit.Test_Caller;
with Root.Tests;
package body Root_Suite is
package Caller is new AUnit.Test_Caller with (Root.Tests.Parent_Test);
function Suite return AUnit.Test_Suites.Access_Test_Suite is
Ret : Access_Test_Suite := AUnit.Test_Suites.New_Suite;
begin
AUnit.Test_Suites.Add_Test
(Ret, Caller.Create ("Test Parent : P1", Root.Tests.Test_P1'Access));
AUnit.Test_Suites.Add_Test
(Ret, Caller.Create ("Test Parent : P2", Root.Tests.Test_P2'Access));
return Ret;
end Suite;
end Root_Suite;
Now we define the test suite for the ``Child`` type. To do this,
we inherit a test fixture from ``Parent_Test``,
overriding the ``Set_Up`` procedure to initialize ``Fixture`` with
a ``Child`` object. We also override ``Test_P2`` to adapt it
to the new implementation. We define a new ``Test_P3`` to test
``P3``. And we inherit ``Test_P1``, since ``P1`` is unchanged.
.. code-block:: ada
with Root.Tests; use Root.Tests;
with AUnit; use AUnit;
with AUnit.Test_Fixtures; use AUnit.Test_Fixtures;
package Branch.Tests is
type Child_Test is new Parent_Test with null record;
procedure Set_Up (C : in out Child_Test);
-- Test routines:
-- Test_P2 is overridden
procedure Test_P2 (C : in out Child_Test);
-- Test_P3 is new
procedure Test_P3 (C : in out Child_Test);
end Branch.Tests;
.. code-block:: ada
package body Branch.Tests is
use Assertions;
Fixture : Child;
-- This could also be a field of Child_Test
procedure Set_Up (C : in out Child_Test) is
begin
-- The Fixture for this test will now be a Child
C.Fixture := Parent_Access (Fixture'Access);
end Set_Up;
-- Test routines:
procedure Test_P2 (C : in out Child_Test) is ...;
procedure Test_P3 (C : in out Child_Test) is ...;
end Branch.Tests;
The suite for Branch.Tests will now be:
.. code-block:: ada
with AUnit.Test_Caller;
with Branch.Tests;
package body Branch_Suite is
package Caller is new AUnit.Test_Caller with (Branch.Tests.Parent_Test);
-- In this suite, we use Ada 2005 distinguished receiver notation to
-- simplify the code.
function Suite return Access_Test_Suite is
Ret : Access_Test_Suite := AUnit.Test_Suites.New_Suite;
begin
-- We use the inherited Test_P1. Note that it is
-- Branch.Tests.Set_Up that will be called, and so Test_P1 will be run
-- against an object of type Child
Ret.Add_Test
(Caller.Create ("Test Child : P1", Branch.Tests.Test_P1'Access));
-- We use the overridden Test_P2
Ret.Add_Test
(Caller.Create ("Test Child : P2", Branch.Tests.Test_P2'Access));
-- We use the new Test_P2
Ret.Add_Test
(Caller.Create ("Test Child : P3", Branch.Tests.Test_P3'Access));
return Ret;
end Suite;
end Branch_Suite;
Using AUnit.Test_Cases
----------------------
.. index:: AUnit.Test_Cases.Test_Case type
Using an ``AUnit.Test_Cases.Test_Case`` derived type, we obtain the
following code for testing ``Parent``:
.. code-block:: ada
with AUnit; use AUnit;
with AUnit.Test_Cases;
package Root.Tests is
type Parent_Access is access all Root.Parent'Class;
type Parent_Test is new AUnit.Test_Cases.Test_Case with record
Fixture : Parent_Access;
end record;
function Name (P : Parent_Test) return Message_String;
procedure Register_Tests (P : in out Parent_Test);
procedure Set_Up_Case (P : in out Parent_Test);
-- Test routines. If derived types are declared in child packages,
-- these can be in the private part.
procedure Test_P1 (P : in out Parent_Test);
procedure Test_P2 (P : in out Parent_Test);
end Root.Tests;
.. index:: AUnit.Test_Cases.Specific_Test_Case_Registration generic package
The body of the test case will follow the usual pattern, declaring one or
more objects of type ``Parent``, and executing statements in the
test routines against them. However, in order to support dispatching to
overriding routines of derived test cases, we need to introduce class-wide
wrapper routines for each primitive test routine of the parent type that
we anticipate may be overridden. Instead of registering the parent's
overridable primitive operations directly using ``Register_Routine``,
we register the wrapper using ``Register_Wrapper``. This latter routine
is exported by instantiating
``AUnit.Test_Cases.Specific_Test_Case_Registration`` with the actual
parameter being the parent test case type.
.. code-block:: ada
with AUnit.Assertions; use AUnit.Assertions
package body Root.Tests is
-- Declare class-wide wrapper routines for any test routines that will be
-- overridden:
procedure Test_P1_Wrapper (P : in out Parent_Test'Class);
procedure Test_P2_Wrapper (P : in out Parent_Test'Class);
function Name (P : Parent_Test) return Message_String is ...;
-- Set the fixture in P
Fixture : aliased Parent;
procedure Set_Up_Case (P : in out Parent_Test) is
begin
P.Fixture := Parent_Access (Fixture'Access);
end Set_Up_Case;
-- Register Wrappers:
procedure Register_Tests (P : in out Parent_Test) is
package Register_Specific is
new Test_Cases.Specific_Test_Case_Registration (Parent_Test);
use Register_Specific;
begin
Register_Wrapper (P, Test_P1_Wrapper'Access, "Test P1");
Register_Wrapper (P, Test_P2_Wrapper'Access, "Test P2");
end Register_Tests;
-- Test routines:
procedure Test_P1 (P : in out Parent_Test) is ...;
procedure Test_P2 (C : in out Parent_Test) is ...;
-- Wrapper routines. These dispatch to the corresponding primitive
-- test routines of the specific types.
procedure Test_P1_Wrapper (P : in out Parent_Test'Class) is
begin
Test_P1 (P);
end Test_P1_Wrapper;
procedure Test_P2_Wrapper (P : in out Parent_Test'Class) is
begin
Test_P2 (P);
end Test_P2_Wrapper;
end Root.Tests;
The code for testing the `Child` type will now be:
.. code-block:: ada
with Parent_Tests; use Parent_Tests;
with AUnit; use AUnit;
package Branch.Tests is
type Child_Test is new Parent_Test with private;
function Name (C : Child_Test) return Message_String;
procedure Register_Tests (C : in out Child_Test);
-- Override Set_Up_Case so that the fixture changes.
procedure Set_Up_Case (C : in out Child_Test);
-- Test routines:
procedure Test_P2 (C : in out Child_Test);
procedure Test_P3 (C : in out Child_Test);
private
type Child_Test is new Parent_Test with null record;
end Branch.Tests;
.. code-block:: ada
with AUnit.Assertions; use AUnit.Assertions;
package body Branch.Tests is
-- Declare wrapper for Test_P3:
procedure Test_P3_Wrapper (C : in out Child_Test'Class);
function Name (C : Child_Test) return Test_String is ...;
procedure Register_Tests (C : in out Child_Test) is
package Register_Specific is
new Test_Cases.Specific_Test_Case_Registration (Child_Test);
use Register_Specific;
begin
-- Register parent tests for P1 and P2:
Parent_Tests.Register_Tests (Parent_Test (C));
-- Repeat for each new test routine (Test_P3 in this case):
Register_Wrapper (C, Test_P3_Wrapper'Access, "Test P3");
end Register_Tests;
-- Set the fixture in P
Fixture : aliased Child;
procedure Set_Up_Case (C : in out Child_Test) is
begin
C.Fixture := Parent_Access (Fixture'Access);
end Set_Up_Case;
-- Test routines:
procedure Test_P2 (C : in out Child_Test) is ...;
procedure Test_P3 (C : in out Child_Test) is ...;
-- Wrapper for new routine:
procedure Test_P3_Wrapper (C : in out Child_Test'Class) is
begin
Test_P3 (C);
end Test_P3_Wrapper;
end Branch.Tests;
Note that inherited and overridden tests do not need to be explicitly
re-registered in derived test cases - one just calls the parent version of
``Register_Tests``. If the application tagged type hierarchy is organized
into parent and child units, one could also organize the test cases into a
hierarchy that reflects that of the units under test.
.. index:: Generic units (testing)
.. _Testing_generic_units:
Testing generic units
=====================
When testing generic units, one would like to apply the same generic tests
to all instantiations in an application. A simple approach is to make the
test case a child package of the unit under test (which then must also be
generic).
For instance, suppose the generic unit under test is a package (it could
be a subprogram, and the same principle would apply):
.. code-block:: ada
generic
-- Formal parameter list
package Template is
-- Declarations
end Template;
The corresponding test case would be:
.. code-block:: ada
with AUnit; use AUnit;
with AUnit.Test_Fixtures;
generic
package Template.Gen_Tests is
type Template_Test is new AUnit.Test_Fixtures.Test_Fixture with ...;
-- Declare test routines
end Template.Gen_Tests;
The body will follow the usual patterns with the fixture based on the
parent package ``Template``. Note that due to an Ada AI, accesses to
test routines, along with the test routine specifications, must be defined
in the package specification rather than in its body.
Instances of ``Template`` will automatically define the ``Tests`` child
package that can be directly instantiated as follows:
.. code-block:: ada
with Template.Gen_Test;
with Instance_Of_Template;
package Instance_Of_Template.Tests is new Instance_Of_Template.Gen_Test;
The instantiated test case objects are added to a suite in the usual manner.
aunit-25.0.0/doc/share/ 0000775 0000000 0000000 00000000000 14574065775 0014611 5 ustar 00root root 0000000 0000000 aunit-25.0.0/doc/share/ada_pygments.py 0000664 0000000 0000000 00000016437 14574065775 0017651 0 ustar 00root root 0000000 0000000 """Alternate Ada and Project Files parsers for Sphinx/Rest"""
import re
from pygments.lexer import RegexLexer, bygroups
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
Number, Punctuation
def get_lexer_tokens(tag_highlighting=False, project_support=False):
"""Return the tokens needed for RegexLexer
:param tag_highlighting: if True we support tag highlighting. See
AdaLexerWithTags documentation
:type tag_highlighting: bool
:param project_support: if True support additional keywors associated
with project files.
:type project_support: bool
:return: a dictionary following the structure required by RegexLexer
:rtype: dict
"""
if project_support:
project_pattern = r'project\s+|'
project_pattern2 = r'project|'
else:
project_pattern = r''
project_pattern2 = r''
result = {
'root': [
# Comments
(r'--.*$', Comment),
# Character literal
(r"'.'", String.Char),
# Strings
(r'"[^"]*"', String),
# Numeric
# Based literal
(r'[0-9][0-9_]*#[0-9a-f][0-9a-f_]*#(E[\+-]?[0-9][0-9_]*)?',
Number.Integer),
(r'[0-9][0-9_]*#[0-9a-f][0-9a-f_]*'
r'\.[0-9a-f][0-9a-f_]*#(E[\+-]?[0-9][0-9_]*)?', Number.Float),
# Decimal literal
(r'[0-9][0-9_]*\.[0-9][0-9_](E[\+-]?[0-9][0-9_]*)?', Number.Float),
(r'[0-9][0-9_]*(E[\+-]?[0-9][0-9_]*)?', Number.Integer),
# Match use and with statements
# The first part of the pattern is be sure we don't match
# for/use constructs.
(r'(\n\s*|;\s*)(with|use)(\s+[\w\.]+)',
bygroups(Punctuation, Keyword.Reserved, Name.Namespace)),
# Match procedure, package and function declarations
(r'end\s+(if|loop|record)', Keyword),
(r'(package(?:\s+body)?\s+|' + project_pattern +
r'function\s+|end\s+|procedure\s+)([\w\.]+)',
bygroups(Keyword, Name.Function)),
# Ada 2012 standard attributes, GNAT specific ones and
# Spark 2014 ones ('Update and 'Loop_Entry)
# (reversed order to avoid having for
# example Max before Max_Alignment_For_Allocation).
(r'\'(Write|Width|Wide_Width|Wide_Wide_Width|Wide_Wide_Value|'
r'Wide_Wide_Image|Wide_Value|Wide_Image|Word_Size|Wchar_T_Size|'
r'Version|Value_Size|Value|Valid_Scalars|VADS_Size|Valid|Val|'
r'Update|Unrestricted_Access|Universal_Literal_String|'
r'Unconstrained_Array|Unchecked_Access|Unbiased_Rounding|'
r'Truncation|Type_Class|To_Address|Tick|Terminated|'
r'Target_Name|Tag|System_Allocator_Alignment|Succ|Stub_Type|'
r'Stream_Size|Storage_Unit|Storage_Size|Storage_Pool|Small|Size|'
r'Simple_Storage_Pool|Signed_Zeros|Scaling|Scale|'
r'Scalar_Storage_Order|Safe_Last|Safe_Large|Safe_First|'
r'Safe_Emax|Rounding|Round|Result|Remainder|Ref|Read|'
r'Range_Length|Range|Priority|Pred|'
r'Position|Pos|Pool_Address|Passed_By_Reference|Partition_Id|'
r'Overlaps_Storage|Output|Old|Object_Size|Null_Parameter|Modulus|'
r'Model_Small|Model_Mantissa|Model_Epsilon|Model_Emin|Model|Mod|'
r'Min|Mechanism_Code|Maximum_Alignment|'
r'Max_Size_In_Storage_Elements|Max_Priority|'
r'Max_Interrupt_Priority|Max_Alignment_For_Allocation|'
r'Max|Mantissa|Machine_Size|Machine_Rounds|Machine_Rounding|'
r'Machine_Radix|Machine_Overflows|Machine_Mantissa|Machine_Emin|'
r'Machine_Emax|Machine|Loop_Entry|Length|Length|Leading_Part|'
r'Last_Valid|Last_Bit|Last|Large|Invalid_Value|Integer_Value|'
r'Input|Image|Img|Identity|Has_Same_Storage|Has_Discriminants|'
r'Has_Access_Values|Fraction|Fore|Floor|Fixed_Value|First_Valid|'
r'First_Bit|First|External_Tag|Exponent|Epsilon|Enum_Val|'
r'Enum_Rep|Enabled|Emax|Elaborated|Elab_Subp_Body|Elab_Spec|'
r'Elab_Body|Descriptor_Size|Digits|Denorm|Delta|Definite|'
r'Default_Bit_Order|Count|Copy_Sign|Constrained|'
r'Compose|Component_Size|Compiler_Version|Code_Address|Class|'
r'Ceiling|Caller|Callable|Body_Version|Bit_Order|Bit_Position|'
r'Bit|Base|Asm_Output|Asm_Input|Alignment|Aft|Adjacent|'
r'Address_Size|Address|Access|Abort_Signal|AST_Entry)',
Name.Attribute),
# All Ada2012 reserved words
(r'(abort|abstract|abs|accept|access|aliased|all|and|array|at|'
r'begin|body|case|constant|declare|delay|delta|digits|do|'
r'else|elsif|end|entry|exception|exit|for|function|generic|goto|'
r'if|interface|in|is|limited|loop|mod|new|not|null|'
r'of|or|others|out|overriding|' + project_pattern2 +
r'package|pragma|private|procedure|protected|'
r'raise|range|record|rem|renames|requeue|return|reverse|'
r'select|separate|some|subtype|synchronized|'
r'tagged|task|terminate|then|type|until|use|when|while|with|xor'
r')([\s;,])',
bygroups(Keyword.Reserved, Punctuation)),
# Two characters operators
(r'=>|\.\.|\*\*|:=|/=|>=|<=|<<|>>|<>', Operator),
# One character operators
(r'&|\'|\(|\)|\*|\+|-|\.|/|:|<|=|>|\|', Operator),
(r',|;', Punctuation),
# Spaces
(r'\s+', Text),
# Builtin values
(r'False|True', Keyword.Constant),
# Identifiers
(r'[\w\.]+', Name)], }
# Insert tag highlighting before identifiers
if tag_highlighting:
result['root'].insert(-1, (r'\[[\w ]*\]', Name.Tag))
return result
class AdaLexer(RegexLexer):
"""Alternate Pygments lexer for Ada source code and project files
The default pygments lexer always fails causing disabling of syntax
highlighting in Sphinx. This lexer is simpler but safer.
In order to use this lexer in your Sphinx project add the following
code at the end of your conf.py
.. code-block:: python
import gnatpython.ada_pygments
def setup(app):
app.add_lexer('ada', gnatpython.ada_pygments.AdaLexer())
"""
name = 'Ada'
aliases = ['ada', 'ada83', 'ada95', 'ada2005', 'ada2012']
filenames = ['*.adb', '*.ads', '*.ada']
mimetypes = ['text/x-ada']
flags = re.MULTILINE | re.I # Ignore case
tokens = get_lexer_tokens()
class TaggedAdaLexer(AdaLexer):
"""Alternate Pygments lexer for Ada source code with tags
A tag is a string of the form::
[MY STRING]
Only alphanumerical characters and spaces are considered inside the
brackets.
"""
name = 'TaggedAda'
aliases = ['tagged_ada']
tokens = get_lexer_tokens(True)
class GNATProjectLexer(RegexLexer):
"""Pygment lexer for project files
This is the same as the AdaLexer but with support of ``project``
keyword.
"""
name = 'GPR'
aliases = ['gpr']
filenames = ['*.gpr']
mimetypes = ['text/x-gpr']
flags = re.MULTILINE | re.I # Ignore case
tokens = get_lexer_tokens(project_support=True)
aunit-25.0.0/doc/share/adacore-logo-white.png 0000664 0000000 0000000 00000114625 14574065775 0021002 0 ustar 00root root 0000000 0000000 ‰PNG
IHDR Ð ¤ i[¾” pHYs šœ ÐiTXtXML:com.adobe.xmp nãoN ’kIDATxìá€u?^Ÿ¹™H€:„. ¡÷"!¥†Q°€
—ßîêª+v]QA±¡BG"*ÄB¯Ò{—šJzæ]^–?Å$L&3wîó}>ç´uvvŠˆˆˆ#p“²Â81O
¡!"""""""""""""""4DDDDDDDDDDDDDDD„†ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆÐ"""""""""""""""BCDDDDDDDDDDDDDDDhˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ
¡!"""""""""""""""4DDDDDDDDDDDDDDD„†ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆÐÚEDDDDDDDD ,‰¥±4X
B,Åü«vÌö¯&¢Ó«æ`2¦c:&c&a¦a
f‹ˆˆˆˆˆ(L»ˆˆˆˆˆˆˆˆh¦~X+`–ÇÊXËb,‹e°c°Ö30000ÏâŸxÏàILÑ¢ÚEDDDDDDDDOZñ&VÇÊX«bu¬ˆ6Õ7 +`g:þ‰âi<ŠGð(Ãcx3DDDDDD4Y»ˆˆˆˆˆˆˆˆXX«a=lˆu±†c8–²8ÖÀìi<Œûq?îÇý¸‹ˆˆˆˆˆèí""""""""b^Ú°ÞŠM°6Äz(zÛ
X[ùWÓqîÆ¸wànÌÑMí""""""""b1¼›c3ŒÀFXR´¢Å±16Æ^5à¸7ã&<("""""¢ÚEôŒ%±ŽxŽ˜*""""""ZQ?l„í°56ÇÆhU×À:XûzÕDÜŒ›p®Á=èñí"zÆGñ5ñŠãq¢ˆˆˆˆˆˆhËb{ì€m°5‰:Œ]°‹WMÀ5ø;®Á5x^DDDDDÔZ[gg§ˆpÖ¯¸
oU27)Û(ŒQ¾aØ »`G¼m"ÞÜ?p®Âx<%"""""j¥]Ä¢Ûë‹×Ú›ãFÑۖ®‰‘x‹ˆîÙá/»Æ¥¸Ï‹ˆˆˆˆˆ¢µ‹Xtb^ÞEDDDDDDOk`s¼#±-ú‰èyëc}¹¸¿Çeø+戈ˆˆˆˆ¢´uvvŠX‹ã)oô