| 1 |
/* |
| 2 |
* @progname st_aux.li |
| 3 |
* @version 1.0 |
| 4 |
* @author Perry Rapp |
| 5 |
* @category self-test |
| 6 |
* @output none |
| 7 |
* @description |
| 8 |
* |
| 9 |
* auxiliary functions for all self-test modules |
| 10 |
* |
| 11 |
*/ |
| 12 |
|
| 13 |
/* This file is all ASCII, so we don't need to choose a codeset */ |
| 14 |
char_encoding("ASCII") |
| 15 |
|
| 16 |
require("lifelines-reports.version:1.3") |
| 17 |
option("explicitvars") /* Disallow use of undefined variables */ |
| 18 |
|
| 19 |
|
| 20 |
global(testok) |
| 21 |
global(testfail) |
| 22 |
global(testskip) |
| 23 |
global(logout) |
| 24 |
global(section) |
| 25 |
|
| 26 |
/* report failure to screen, & to file if logging */ |
| 27 |
proc reportfail(str) |
| 28 |
{ |
| 29 |
if (gt(strlen(section),0)) { |
| 30 |
print(concat(section, nl())) |
| 31 |
} |
| 32 |
print(str) |
| 33 |
print(nl()) |
| 34 |
if (logout) { |
| 35 |
if (gt(strlen(section),0)) { |
| 36 |
section nl() |
| 37 |
} |
| 38 |
str nl() |
| 39 |
} |
| 40 |
set(section,"") |
| 41 |
incr(testfail) |
| 42 |
} |
| 43 |
|
| 44 |
/* clear counters at start of subsection */ |
| 45 |
proc initSubsection() |
| 46 |
{ |
| 47 |
set(testok, 0) |
| 48 |
set(testfail, 0) |
| 49 |
set(testskip, 0) |
| 50 |
} |
| 51 |
|
| 52 |
/* report results of just completed subsectioin (testok...) */ |
| 53 |
proc reportSubsection(title) |
| 54 |
{ |
| 55 |
set(res, concat("Passed ", d(testok), "/", d(add(testok,testfail)), " ")) |
| 56 |
if (gt(testskip, 0)) { |
| 57 |
set(res, concat(res, "(skipped ", d(testskip), ") ")) |
| 58 |
} |
| 59 |
set(res, concat(res, title, "\n")) |
| 60 |
print(res) |
| 61 |
set(testok, 0) |
| 62 |
set(testfail, 0) |
| 63 |
} |
| 64 |
|
| 65 |
func set_and_check_locale(locstr, locname) |
| 66 |
{ |
| 67 |
set(res, setlocale(locstr)) |
| 68 |
if (nestr(res, "C")) { |
| 69 |
return(1) |
| 70 |
} |
| 71 |
call reportfail(concat("Locale missing: ", locstr, " (", locname, ")")) |
| 72 |
return (0) |
| 73 |
} |