1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
|
------------------------------------------------------------------------------
-- --
-- POSIX.5b VALIDATION TEST SUITE --
-- --
-- P O S I X _ R E P O R T --
-- --
-- B o d y --
-- --
-- --
-- Copyright (c) 1997-1998 Florida State University (FSU). All Rights --
-- Reserved. --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. This software 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 distributed with GNARL; see --
-- file COPYING. If not, write to the Free Software Foundation, 59 --
-- Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- Under contract GS-35F-4506G, the U. S. Government obtained unlimited --
-- rights in the software and documentation contained herein. Unlimited --
-- rights are defined in DFAR 252,227-7013(a)(19). By making this public --
-- release, the Government intends to confer upon all recipients --
-- unlimited rights equal to those held by the Government. These rights --
-- include rights to use, duplicate, release or disclose the released --
-- data an computer software in whole or in part, in any manner and for --
-- any purpose whatsoever, and to have or permit others to do so. --
-- --
-- DISCLAIMER -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE --
-- AVAILABLE OR DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR --
-- IMPLIED WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS --
-- OF THE SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE --
-- AVAILABLE OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS --
-- FOR A PARTICULAR PURPOSE OF SAID MATERIAL. --
-- --
------------------------------------------------------------------------------
-- [$Revision: 110555 $]
with Ada.Exceptions,
POSIX,
POSIX_Process_Identification,
POSIX_Process_Primitives;
package POSIX_Report is
-- This package contains utility routines which are useful for
-- running tests.
Verbose : Boolean := False;
-- set to True if "-v" is on command line.
Terse : Boolean := False;
-- set to True if "-t" is on command line.
Child : Natural := 0;
-- set to 1 if "-child" is on command line
-- set to NNN if "-child NNN" is on command line, where NNN is a number
Test_Identifier : String := "POSIX Ada Validation Tests, Version 1.2a";
-- Call this once for each test program, at the beginning.
-- It prints a message indicating that a test is about to be
-- performed, regardless of whether verbose is turned on.
-- User Root_OK = True if the test is one that makes sense to
-- run as root.
procedure Header (Label : String; Root_OK : Boolean := False);
-- Call this once for each section of the test program.
-- It prints a message indicating that a test is about to be
-- performed, if verbose is turned on.
-- The label should be unique so that if the test fails it is
-- possible to find the code for the test by grepping through
-- the source.
procedure Test (Label : String);
-- ....
-- Fail is obsolescent. Use the more specific procedures.
-- Call this to record the fact that a test failed.
procedure Fail (Message : String);
-- Call this from an exception handler for "others", to catch
-- completion of test casem by an unhandled exception.
procedure Fail
(E : Ada.Exceptions.Exception_Occurrence;
Message : String);
-- Call this to check a condition that should be true.
-- The test fails if the argument is false.
procedure Assert (Condition : Boolean; Message : String);
type POSIX_Option is
(Asynchronous_IO_Option,
Change_Owner_Restriction_Option,
Filename_Truncation_Option,
File_Synchronization_Option,
Memory_Mapped_Files_Option,
Memory_Locking_Option,
Memory_Range_Locking_Option,
Memory_Protection_Option,
Message_Queues_Option,
Mutex_Priority_Ceiling_Option,
Mutex_Priority_Inheritance_Option,
Mutex_Option,
Prioritized_IO_Option,
Priority_Process_Scheduling_Option,
Priority_Task_Scheduling_Option,
Process_Shared_Option,
Realtime_Signals_Option,
Job_Control_Option,
Saved_IDs_Option,
Semaphores_Option,
Shared_Memory_Objects_Option,
Signal_Entries_Option,
Synchronized_IO_Option,
Timers_Option);
function Is_Supported (Option : POSIX_Option) return Boolean;
-- Call this near the beginning of a test program
-- that entirely depends on an option. It will end the test
-- if the required option is not supported.
procedure Optional
(Option : POSIX_Option;
Message : String);
-- Call this inside an exception handler for an
-- exception that may be raised in response to an
-- attempt to use an optional feature that is not
-- supported, where the feature depends on one option.
procedure Optional
(Option : POSIX_Option;
Expected : POSIX.Error_Code;
E : Ada.Exceptions.Exception_Occurrence;
Message : String);
-- Call this inside an exception handler for an
-- exception that may be raised in response to an
-- attempt to use an optional feature that is not
-- supported, where the feature depends on two options.
procedure Optional
(Option_1 : POSIX_Option;
Option_2 : POSIX_Option;
Expected : POSIX.Error_Code;
E : Ada.Exceptions.Exception_Occurrence;
Message : String);
-- Call this inside an exception handler for an
-- exception that may be raised in response to an
-- attempt to use an optional feature that is not
-- supported, where POSIX_Error should be raised
-- with a different error code if the option is supported.
procedure Optional
(Option : POSIX_Option;
Expected_If_Not_Supported : POSIX.Error_Code;
Expected_If_Supported : POSIX.Error_Code;
E : Ada.Exceptions.Exception_Occurrence;
Message : String);
type POSIX_Privilege is
(Memory_Locking_Privilege,
Semaphore_Initialization_Privilege,
Set_Time_Privilege);
-- add more of these values as we discover more privileges
-- Call this inside an exception handler for an
-- exception that may be raised in response to an
-- attempt to use an optional feature that is not
-- supported, where the feature depends on one option
-- and also depends on having appropriate privilege.
procedure Privileged
(Privilege : POSIX_Privilege;
Option : POSIX_Option;
Expected : POSIX.Error_Code;
E : Ada.Exceptions.Exception_Occurrence;
Message : String);
procedure Privileged
(Privilege : POSIX_Privilege;
Message : String);
-- Call this if the test is supposed to raise an exception,
-- other than for nonsupport or lack of privilege.
procedure Privileged
(Privilege : POSIX_Privilege;
Option : POSIX_Option;
Expected_If_Not_Supported : POSIX.Error_Code;
Expected_If_Supported : POSIX.Error_Code;
E : Ada.Exceptions.Exception_Occurrence;
Message : String);
-- Call this at a point where control should not reach
-- because an exception should have been raised.
procedure Expect_Exception (Message : String);
-- Call this inside an exception handler for an unexpected
-- exception.
procedure Unexpected_Exception
(E : Ada.Exceptions.Exception_Occurrence;
Message : String);
-- Call this inside an exception handler for POSIX_Error,
-- to validate that the expected error code is set.
procedure Check_Error_Code
(EC : POSIX.Error_Code;
Message : String);
-- Call this inside an exception handler for POSIX_Error,
-- to validate that the expected error code is set.
procedure Check_Error_Code
(EC : POSIX.Error_Code;
E : Ada.Exceptions.Exception_Occurrence;
Message : String);
-- Call this inside an exception handler for any exception
-- to check that the exception message is correct.
procedure Check_Message
(E : Ada.Exceptions.Exception_Occurrence;
Expected_Message : String;
Message : String);
-- Call this from an exception handler for "others", to catch
-- completion of test program by an unhandled exception.
procedure Fatal_Exception
(E : Ada.Exceptions.Exception_Occurrence;
Message : String);
-- Call this to print out a an informational message,
-- iff Verbose = True.
-- It does not imply that anything went wrong.
procedure Comment (Msg : String);
-- Call this to get a printable string for a Timepsec value.
function Image (T : POSIX.Timespec) return String;
-- This is equivalent to Comment (Msg & " = " & Image (T));
procedure Comment (Msg : String; T : POSIX.Timespec);
-- Call this to add to this package's internal error count.
procedure Increment_Error_Count (Number : Integer);
-- Call this to get this package's internal error count.
function Get_Error_Count return Integer;
-- Call this once, before exiting, when the testing is complete,
-- for normal completion of a main program.
procedure Done;
-- Call this to terminate a test immediately.
procedure Fatal (Msg : String);
-- Add to the given argument list the necessary values to pass
-- through the verbose/normal/terse state of the parent process.
procedure Pass_Through_Verbosity (Args : in out POSIX.POSIX_String_List);
-- Check Termination_Status value of child process, to verify
-- that the child exited and exited with the anticipated status.
-- Add the error count of the child process to that of the parent.
procedure Check_Child_Status
(Status : POSIX_Process_Primitives.Termination_Status;
Child_ID : POSIX_Process_Identification.Process_ID;
Expected : POSIX_Process_Primitives.Exit_Status;
Message : String);
private
-- name of the executable file for this program
Program_Name : String (1 .. 128) := (others => ' ');
Program_Name_Length : Integer := 0;
-- label from the last Test subprogram call
Test_Label : String (1 .. 128) := (others => ' ');
Test_Label_Length : Integer := 0;
-- an option has been found to be unsupported
Nonsupport : array (POSIX_Option) of Boolean := (others => False);
pragma Atomic_Components (Nonsupport);
-- an operation has failed due to insufficient privilege
Privilege_Failure : Boolean := False;
pragma Atomic (Privilege_Failure);
-- number of errors so far
Error_Count : Natural := 0;
pragma Atomic (Error_Count);
end POSIX_Report;
|