3 * Test-vector framework timeout extension
5 * (c) 2024 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of the mLib utilities library.
12 * mLib is free software: you can redistribute it and/or modify it under
13 * the terms of the GNU Library General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or (at
15 * your option) any later version.
17 * mLib is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
20 * License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with mLib. If not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
28 #ifndef MLIB_TVEC_TIMEOUT_H
29 #define MLIB_TVEC_TIMEOUT_H
35 /*----- Header files ------------------------------------------------------*/
43 /*----- Test environment --------------------------------------------------*/
45 struct tvec_timeoutenv {
46 /* Timeout environment definition. */
49 int timer; /* the timer (@ITIMER_...@) */
50 double t; /* time to wait (in seconds) */
51 const struct tvec_env *env; /* subsidiary environment */
54 struct tvec_timeoutctx {
55 /* Timeout environment context; private. */
57 const struct tvec_timeoutenv *te; /* saved environment description */
58 int timer; /* timer code (as overridden) */
59 double t; /* time to wait (as overridden) */
60 unsigned f; /* flags */
61 #define TVTF_SETTMO 1u /* set `@timeout' */
62 #define TVTF_SETTMR 2u /* set `@timer' */
63 #define TVTF_SETMASK (TVTF_SETTMO | TVTF_SETTMR)
64 /* mask of @TVTF_SET...@ */
65 void *subctx; /* subordinate environment context */
68 /* --- Environment implementation --- *
70 * The following special variables are supported.
72 * * %|@timeout|% is the duration to wait before killing the process.
74 * * %|@timer|% is the timer to use to measure the duration.
76 * Unrecognized variables are passed to the subordinate environment, if there
77 * is one. Other events are passed through to the subordinate environment.
80 extern tvec_envsetupfn tvec_timeoutsetup;
81 extern tvec_envfindvarfn tvec_timeoutfindvar;
82 extern tvec_envbeforefn tvec_timeoutbefore;
83 extern tvec_envrunfn tvec_timeoutrun;
84 extern tvec_envafterfn tvec_timeoutafter;
85 extern tvec_envteardownfn tvec_timeoutteardown;
87 #define TVEC_TIMEOUTENV \
88 { sizeof(struct tvec_timeoutctx), \
90 tvec_timeoutfindvar, \
94 tvec_timeoutteardown }
95 #define TVEC_TIMEOUTINIT(timer, t) TVEC_TIMEOUTENV, timer, t
97 /*----- That's all, folks -------------------------------------------------*/