The CMake build originally had a single minimal installation test (ast_test.c).
The ast_tester/ directory contains 10 C test programs and 32 Fortran test
programs that were only runnable via a Starlink-specific tcsh script. Many AST
classes had no C test coverage — their only tests were Fortran programs
depending on Starlink libraries (EMS, CHR, PSX). The goal is to:
- Add the existing C tests to the CMake build
- Convert Fortran tests to C to eliminate the Fortran/Starlink dependency
| Phase | Status |
|---|---|
| Phase 1: Add existing C tests to CMake | Complete |
| Phase 2 Batch 1: Simple Fortran conversions | Complete (8 tests) |
| Phase 2 Batch 2: Medium Fortran conversions | Complete (6 tests) |
| Phase 2 Batch 3: Larger Fortran conversions | Complete (5 tests) |
| Phase 2 Batch 4: Checkdump-pattern tests | Complete (4 tests) |
| Phase 2 Batch 5: Channel-callback tests | Complete |
| Phase 2 Batch 6: Huge/manual stress tests | Complete (1 test) |
| Phase 2 Batch 7: Final large tests | Complete (2 tests) |
| Phase 2 Batch 8: WCS-conversion regression harness | Complete (14 tests from wcsconverter.f) |
| Phase 2 Batch 9: Simplify regression harness | Complete (3 tests from simplify.f) |
| Phase 2 Batch 10: Plotter smoke tests | Complete (20 tests, conditional on PLplot) |
| Phase 2 Batch 11: .head native round-trip tests | Complete (20 wcsconv tests from .head files) |
| Phase 2 Batch 12: Grid smoke tests (no PLplot) | Complete (21 tests via logging GRF plugin) |
| Phase 2 Batch 13: Resample / QuadApprox coverage | Complete (1 test) |
| Phase 2 Batch 14: astMask sky-curvature coverage | Complete (1 test) |
| Phase 2 Batch 15: Plot3D logging tests (no PLplot) | Complete (32 tests via the logging grf and grf3d plugins) |
| Phase 3: CI integration | Complete (tests run via ctest) |
Original test (1):
- ast_test — minimal installation check
Existing C tests added to CMake (10):
- testerror, testobject, testconvert, testresimp, testaxis, testframe, testunitnorm, testsplinemap_c, testyamlchan (conditional), testthreads (conditional)
Fortran tests converted to C (59 default + 20 conditional + 1 optional):
- Batch 1: testzoommap, testnormmap, testmapping, testskyframe, testcmpframe, testlutmap, testratemap, testchannel
- Batch 2: testrate, testspecframe, testflux, testspecflux, testcmpmap, testpolymap
- Batch 3: testchebymap, testunitnormmap, testtrangrid, testmoc, testfitstable
- Batch 4: testframeset, testswitchmap, testtime, testkeymap
- Batch 5: testmocchan, testxmlchan, testtable, teststcschan, testfitschan
- Batch 6: testregions, testrebinseq, testplotter (conditional on PLplot)
- Batch 7: testrebin, teststc
- Batch 8: 14 × wcsconv_* regression-diff tests driven by ported wcsconverter.c
- Batch 9: 3 × simplify_* + 3 × simplify_*_astequal regression-diff tests driven by ported simplify.c
- Batch 10: 20 × plotter_* smoke tests (conditional on PLplot) — run testplotter on each .head file with .attr/.fattr/.box companions to verify astGrid doesn't crash
- Batch 11: 20 × wcsconv_*_native_astequal tests — round-trip .head files through wcsconverter in native encoding and verify semantic equivalence via ast_astequal
Grid smoke tests using logging GRF (21 default):
- Batch 12: testgrid + 20 × grid_* smoke tests — run testgrid on each .head file using the logging GRF plugin (grf_log.c) which provides a virtual viewport with no PLplot dependency. Same .head/.attr/.fattr/.box fixtures as Batch 10.
Coverage gap tests (2 default):
- Batch 13: testresample — exercises astResampleD/F/I across 10 interpolation schemes (NEAREST, LINEAR, SINC, SINCSINC, SINCCOS, SINCGAUSS, GAUSS, SOMB, SOMBCOS, BLOCKAVE), plus bad-pixel handling, variance propagation, AST__NOBAD flag, and astQuadApprox.
- Batch 14: testregionmasking — verifies how astMask treats the great-circle edges of a Polygon defined in a SkyFrame. Establishes a projection-independent ground truth by classifying each pixel centre directly (map pixel to sky, ask the Polygon via astTran2), then compares against astMask. Confirms that for a CAR projection the default (SimpVertices=1) mask linearises the curved edges (wrong at 467/38036 interior pixels in the test geometry) while SimpVertices=0 reproduces the curved boundary exactly; for TAN both agree because gnomonic maps great circles to straight lines. The CAR and TAN GRID<->SKY FrameSets are embedded as native serialised strings (read back with astFromString) so the test does not depend on the FitsChan class.
Plot3D coverage (32 default):
- Batch 15: testgrf3dlog + testplot3dlog + 28 × plot3dlog_* cases — a logging
grf3d plugin (grf3d_log.c) with no PLplot dependency logs every 3D graphics
call and can draw an SVG through a camera. testgrf3dlog pins the module's
log formats, attribute handling, text-plane metrics and SVG projection
directly. testplot3dlog builds a Plot3D from a fixture, checks its
serialisation round trip, and performs grid/border/text/mark/outline and
frame-editing actions; each row of fixtures/plot3d/cases.txt compares the
resulting log byte for byte and the dump through compare_dumps with
committed references, covering every RootCorner value, Norm, per-plane and
axis-3 attributes, ignored attributes, Gap/MinTick, a FITS spectral cube,
SetCurrent and RemoveFrame, a non-unit graphics box, the refused Plot
methods, a Plot3D over a Region and fixed-camera SVG pictures. The logs are
the oracle for the Rust port's Plot3D. The cases exposed and now guard four
fixes: two plot.c reads past supplied tick arrays, the Plot3D tick hand-off
for corners whose sky-plane Plot fell back to interior labelling, and the
missing CmpFrame Equal that made a Plot3D over a Region unequal to its own
round trip (asserted directly in testcmpframe). Before committing a new
.dumpreference, run its test in a build configured with-DCMAKE_C_FLAGS="-march=haswell -ffp-contract=fast"(thebuild-fmarecipe): compare_dumps allows 4 ULP, and a WinMap shift computed from a non-exact scale moves by more than that between fused and unfused builds. Choose box values with exact coefficients instead. - Batch 15 (continued): testplot3dattr + testgrflog + the svg_erase case — the Rust port's review of the oracle found two Plot3D defects it recorded as correct: the _XZ and _YZ attribute suffixes reached each other's Plot, and a set Norm was dumped with its set flag clear so it never read back (and Equal did not compare Norm). Both are fixed; testplot3dattr reads the Plot3D's own dump to see which Plot a suffixed attribute reached and round-trips Norm, and the planes, norm and svg_behind references are regenerated. The logging modules' SVG gained what the port's SvgGrf draws: escaped text, 2D text turned the right way in whole degrees (the twenty plot/expected SVGs regenerated), and a black polygon under each text by default, as the PGPLOT backend erases (astGrfLogSetSvgErase( 0 ) and astGrf3DLogSetSvgErase( 0 ) turn it off; --no-erase in testgrid and testplot3dlog; a ninth cases.txt field, "0" for svg_noerase). testgrflog is the 2D module's SVG unit test. Plan: docs/superpowers/plans/2026-11-29-plot3d-oracle-fixes.md.
New C-only regression tests (no Fortran original):
- testplotattr — a newly created Plot reports no attribute as set: ForceExterior was never initialised as unset in astInitPlot, so astTest said it was set to zero and every Plot dump carried FrcExt = 0, which also stopped Plot3D from telling whether the user had chosen a value. Uses the logging GRF module.
- testslamap — SlaMap transform with an undefined (AST__BAD) conversion argument must return AST__BAD outputs rather than NaN; FK45Z and FK54Z agree with ERFA's eraFk45z and eraFk54z, including FK54Z away from B1950.
- testspecmap — astSpecAdd reads only the arguments the caller supplies: TPF2HL's six documented arguments in a six-element array, which AddressSanitizer checks.
- testimmutable — every Mapping class with a publicly settable attribute must allow the change while its reference count is one and report AST__IMMUT once it has been cloned, as SUN/210 requires, for both setting and clearing. Also checks that Invert stays settable on a shared Mapping. PermMap's PermSplit and WcsMap's FITSProj and LonCheck are excluded because they are protected and no astSet call reaches them.
- testxphmap — the XphMap loader: every projection name in its table, the Order
and Type components surviving a dump/load/re-dump round trip, an unknown Type
being rejected, and the forward transformation being invertible over a scan of
the projection's grid. XphMap has no public constructor, so every XphMap in it
comes from a dump, which is also the only route into the loader. The loader's
fixed leak of the Type string is not asserted by any test: LeakSanitizer is
unavailable on Darwin, and every test here suppresses leak reports because
AST's memory system caches freed blocks. Running this test under
ASAN_OPTIONS=detect_leaks=1on Linux is the manual check. For every projection type, at orders 0 to 3 and in both directions, it also checks that the number of pixel centres in the grid that are transformed is the number of HEALPix pixels on the sky, and that each makes the return trip. The inverse transformation must also accept the unused second copy of each pixel of the facet that an HPX grid splits between its two ends, and return it as the used copy. Positions too far from the grid for the index of a grid cell to fit in an integer, and positions that are not finite, must give AST__BAD. So must every position outside the grid being transformed, for every type and direction, which a scan of the grid and its surroundings at orders 0 to 3 checks, along with positions just beyond the grid at order 27. A position on the boundary of a used cell must be transformed to the position that continues the transformation of that cell or of another used cell that it bounds, and a position that bounds no used cell must give AST__BAD, which a scan of every cell corner and edge centre at orders 0 to 2 checks. Every position of a pole (the centre or the corners of an XPH grid, and the outer corner of each polar facet of an HPX grid) must be transformed to a position of the same pole, at orders 0, 1, 3 and 27. A position displaced off the edge of the sky by less than the margin the HPX projection allows for rounding must be transformed as the position on the edge is, and one displaced by much more must give AST__BAD. An Order outside the range 0 to 27 must be rejected by the loader with AST__LDERR, and pixels at both ends of the grid must be transformed at order 27. The conversion of the index of a far grid cell to an integer was undefined, which the test can mostly only detect under UndefinedBehaviorSanitizer. - testwcsmap — WcsMap projections at the points where AST's wcslib fork has differed from upstream wcslib 8.10: QSC near a face centre, HPX poles, facet edges and non-default H and K, the ZPN far side for a degree-2 polynomial, PCO near the equator, COP at the poles, MER near the pole (the D2R macro's parentheses), and native coordinates a little past a limit, which wcslib's per-projection tolerance accepts. Wanted values are upstream's output for the same projection and parameters.
- testcorruptinput — corrupt or malicious input must be rejected without a crash, memory corruption, or a run time or memory use out of proportion to its size.
Each case is a small dump or FITS header of the kind a fuzzer produces by changing one value of a valid input, and each made the library do one of those things.
It covers integers too large for an int, and the AST__MXAXES limit on the inputs, outputs and axes of a Mapping or Frame, in constructors and loaders.
It covers component objects that are missing from a dump or belong to the wrong class, Regions whose defining points are missing or the wrong number or whose components have the wrong number of axes, a Polygon vertex with no value, and a PointSet that claims more values than a dump can hold.
For a FrameSet it covers more Frames or nodes claimed than are present, node links that form a loop, and Mappings and Frames that disagree about the number of axes.
It covers Frames with the wrong number of axes for their class, a SkyFrame whose axes are not described, loaders that carry on after an error, a PermMap that refers to a constant it does not have, a full MatrixMap with more elements than can be counted or named, a SplineMap given a position that is not a number, a KeyMap that asks for a huge hash table, a projection whose parameters are unusable (which must report an error every time it is used), and sky positions and Epochs too large to format or to bring into range one turn at a time.
For FITS headers it covers a WCSAXES value that is not a usable number of axes, CTYPE values of fewer than three characters, an IRAF WAT card with no string value, a header whose transformation fails part of the way through a compound Mapping, a pixel size so small that its reciprocal is infinite, an axis with a blank label beside a spectral axis, an epoch of observation that has no calendar date (for which no DATE-OBS keyword is written), an axis whose CDELT keyword is missing or is not a number (which has the default pixel size of 1.0) or is zero (which is replaced by a millionth of CRVAL), and a celestial axis that has no partner (which is rejected with the same error whatever projection its CTYPE names, or ignored if the header holds nothing but its CTYPE).
It covers text of any length (values, Labels, Domains and Units far longer than the fixed buffers that error messages, warnings, titles, default Labels and Symbols, dump comments and formatted values are written into), a Unit for which the search for a Mapping from the default Unit fails, a Table column name longer than astAddColumn allows, and a Format string that asks
sprintffor values that are not there. It covers a TimeFrame date Format that asks for more decimal places than a seconds field can have, a time that has no calendar date, and the default Label of a local time. It covers a string attribute value of thousands of characters given to astSetC or astSet, and attribute names of hundreds of characters given to a CmpFrame, Prism, FrameSet or Plot3D. It covers a floating point FITS keyword value and an STC-S position written with hundreds of digits, an STC XML document with long text where a unit, a time scale or a time is expected, and a YAML mapping that repeats a long key. It covers astMapSplit on a compound Mapping in which a MatrixMap or WcsMap couples two of twelve axes, and FITS headers with twenty WCS axes and two pixel axes, both of which used to take a time that grew faster than the factorial of the number of axes. It covers a MathMap dump that states billions of functions and holds one, and a RateMap that a SwitchMap uses as a route in the direction the RateMap does not define. Run it with the sanitizers enabled, which is how most of the faults are detected. Some of the buffer overflows are inside a larger structure when AST is built thread-safe, where the sanitizers cannot see them; an optimized build with_FORTIFY_SOURCEtraps on those. - testmapmerge — simplifying a Mapping must not change what it does. Each case is a small compound Mapping for which the code that merges one class with its neighbours, or swaps it with them, used to give a Mapping that was not equivalent, report an error, or read or write memory it should not have. Every Mapping is simplified, and must keep its numbers of inputs and outputs and give the same results from its forward and inverse transformations. It covers a PermMap created without one of its permutation arrays, an inverted PermMap with more inputs than outputs, and a PermMap that supplies constants to two Mappings in parallel. It covers WcsMaps that differ only in the number of projection parameters, an inverted PermMap beside a WcsMap, a PolyMap beside its own inverse, and a TimeMap conversion followed by its inverse. It covers a full MatrixMap that is really diagonal and is used inverted, a MatrixMap with no inverse that is used inverted, and diagonal MatrixMaps with different numbers of inputs and outputs beside a WinMap. It covers a WinMap beside a unit MatrixMap, beside two Mappings in parallel, with a scale of zero, and followed by a MatrixMap that discards an axis the WinMap shifts. It covers astEqual for MathMaps whose functions differ only in their last operation or are a single constant, since astEqual decides whether a Mapping cancels with the inverse of its neighbour, and a SwitchMap followed by the inverse of a SwitchMap with a different route. Run it with the sanitizers enabled, which is how the memory faults are detected.
- testfitswrite — an unusual FrameSet must be written to a FITS header without harm. A FrameSet that a foreign encoding cannot describe must simply not be written: astWrite returns zero, reports no error and leaves the FitsChan as it found it. Each case is a small FrameSet for which the library used to read or write memory it should not have, call itself without end, report an internal error, or write a header that did not describe the FrameSet. It covers a compound Mapping with an Ident, axes that could only be written as look-up tables where a world axis depends on two pixel axes or the Mapping has no inverse, and polynomial distortion beside axes that share a pixel axis. It covers more Frames than there are version letters, an offset sky coordinate system beside a Frame that claims a letter through its Ident, and FITS-PC secondary axis descriptions that need a reference frame, projection parameters or a number of axes that the primary description does not have. It covers a FITS-CLASS cube with a fourth axis, a sky axis Symbol too long for a keyword comment, a Domain that differs from an axis Symbol only in its last character, and a write that fails after it has replaced cards that were already in the FitsChan (which must be put back). Run it with the sanitizers enabled, which is how the memory faults are detected.
- testcast — a Frame must be comparable with a Frame of an ancestral class before any Frame of an intermediate class has been used, and must be cast only into a class that it is an instance of. astConvert casts a template that does not match into the class of the target, and the CmpFrame, Region and FrameSet classes did so using a virtual function table that was only set up when an object of exactly that class was created. It covers two SpecFluxFrames with different Domains before any plain CmpFrame exists (so that case must stay first in the program), and a CmpFrame that holds a Region. The same three classes copied a Frame as if it were of any class derived from their own, so it also calls the protected astCast to require no result for a Frame that is not an instance of the class asked for (an StcSearchLocation into an StcObsDataLocation, a FrameSet into a Plot, a plain CmpFrame into a SpecFluxFrame), and a Frame of the right class for the casts that are possible.
- testloaderhardening — class loaders must enforce the invariants that their constructors guarantee. For PolyMap, LutMap, MathMap, WcsMap, SplineMap, Plot, Plot3D and Moc it loads a valid hand-crafted dump, then variants that each break one invariant, and requires every variant to be rejected with a specific error code. For a MathMap the variants have fewer forward functions than outputs or inverse functions than inputs, a negative number of functions, and a function that is missing from the dump. For each class of Mapping that can only have particular numbers of inputs and outputs, it changes Nin and Nout in the dump of a valid Mapping and requires the result to be rejected, and it checks that a Mapping, Frame or Region encapsulated by another Mapping cannot be left out of a dump or replaced by an object of another class. The DssMap check is made by testdssmap, since a DssMap has no public constructor. It also checks that objects built by the constructors survive a dump and load (including a WcsMap of type AST__WCSBAD, whose axis indices are not checked), that a LutMap loaded with fewer than two good table values has no inverse, that a SplineMap whose end knots are not coincident gives AST__BAD outside the interval over which its spline is defined, and that astMalloc, astCalloc, astRealloc and astGrow report an error for a size that overflows.
- testregionhardening — a Region made through the public interface must not make the library overrun an array, call a function without end, or loop for ever, whatever its shape or Frames. Each case used to do one of those things, and most do not change a result, so the test is only decisive under the sanitizers. It covers the grid of points inside a Box that has no width on an axis (in a Frame, a CmpFrame and a SkyFrame) or is far longer than it is wide, a string attribute value that holds a "%" character, a comma and an equals sign, or quotes (a Region must store what a Frame stores, and no other attribute may change), masking with a Region that has no upper limit and with a PointList on a grid with the wrong number of dimensions, and the overlap of a PointList, of two Intervals of which one excludes the range that the other includes, of a Region with more current Frame axes than base Frame axes, and of a Prism that has no boundary mesh (which must be reported as an overlap that cannot be determined). It covers the bounds of a PointList and a NullRegion, and the mesh of a Prism, after each has been mapped into a Frame with a different number of axes, an Ellipse used as the uncertainty of a Box (which must be moved without changing size), an Ellipse made from three points in a line (which must report the error on every use), and a Circle mapped so that no Ellipse can be fitted to its boundary. It covers a Polygon whose vertices all coincide, and Polygons with huge and infinite vertex values, which only have to be created without hanging. It maps a Box, a Circle and a PointList into a Frame with fewer axes, and masks with each through the same Mapping, requiring the Mapping to be unchanged afterwards and the Box and PointList masks to be those of the Region projected on to the remaining axis.
- testregionlogic — results that depend on how Regions keep and combine their state, each of which was wrong without any error being reported. An Interval given as the uncertainty of a Box must report the bounds of the position it was moved to. The overlap of a Prism with a Box that holds it, with the negation of that Box, with an equal Prism and with its own negation must be 2, 1, 5 and 6 (and 3, 1, 5 and 6 with the Regions in the other order). The intersection of two half-planes, one inside the other, must not be reported as bounded, and asking for its bounds must not be an error.
- testfields — astFields, astAbbrev and astCentre, which the Plot class uses on every numerical axis label, must stay within the text they are given and must not use a value that has not been set. They are protected functions, so the test defines astCLASS and uses the protected interface, as testaxis does. It covers a sky axis value with fewer fields than its Format, astAbbrev given a sky axis value that has no fields and nothing to compare it with, a value with leading spaces on a simple axis, and a sky axis value that has a leading plus sign and one field or is blank. For dates it requires astUnformat to refuse a month of zero or thirteen (and the Epoch attribute to reject one), while still reading a day of zero as the day before the first of the month. It requires TimeFrame astCentre to return the same values as before for a gap that changes the day or the time, the value it was given for a gap too small to change the formatted date, and a value within the gap for a gap that crosses the end of a month or year. The text of each case is held in memory of exactly its own size, so that the sanitizers see a read beyond it.
- testplotclip — a Plot must report an error raised while transforming positions into its clipping Frame without annulling the PointSet that its caller supplied. The clipping Frame is reached through an IntraMap that fails on request. The double annul is a use of freed memory, so the test is only decisive under AddressSanitizer.
- testplotcopy — a copy of a Plot must own its graphics context KeyMap: it starts with the original's contents, changes independently, and is released separately. It also copies a Plot3D and annuls the original and the copy in either order. Releasing the KeyMap twice is a use of freed memory, so that part of the test is only decisive under AddressSanitizer.
- testgridgap — a grid line that crosses a gap in the sky must not be drawn across it. It draws the grids of issue 114 (Galactic and FK5 over a whole-sky HPX image, FK5 over the rotated CHIPASS HPX image and FK5 over a whole-sky Aitoff image, which are the headers of the hpxsky, chipass and aitsky plot fixtures) through a Line function registered with astGrfSet. Every straight line drawn must have its middle, or a point just round it, on the sky, and the sky distance between its ends by way of its middle must be close to the direct distance. The second check is what catches a line across the seam at the edge of the Aitoff ellipse: that line lies inside the ellipse, so every point on it is on the sky, but its ends are close together on the sky while its middle is far from both. Lines shorter than the length below which the library draws a segment straight whatever lies under it (the square root of half of Tol, as a fraction of the longer side of the graphics box) are not checked, since a gap that narrow may be crossed by design. It also draws Galactic and FK5 grids over the oblique whole-sky HPX image of the projection sweep (plot/proj/hpx-oblique.head, reference point at Galactic (120, 45)), which moves the facet gaps so that a hop across one is about as long as the segments either side, which only a check of the segment against the curve itself rejects.
- testgridgeom — the geometry of every grid line astGrid draws is checked against the Mapping, with no stored reference, so the check holds on every platform however the curves are segmented. One ctest per row of fixtures/plot/geometry.txt: the plots of plot/cases.txt and a sweep of every projection WcsMap supports at an equatorial and an oblique reference point, each with a Galactic and an FK5 grid. Check A maps both ends of each drawn segment into the current Frame, samples the grid line between them, and requires the segment's midpoint to lie within 0.75 Tol of the sampled curve (Crv's own bound is Tol/sqrt(2); legitimate output reaches 0.46 Tol; a straight line across a gap in the sky scores from 0.8 Tol). Check B samples every line found across the plotting area and requires a segment of the same line within 2 Tol of each visible sample, and requires every multiple of the gap between the outermost lines to be a line. The row's level (gate, residual, report) says which checks may fail it; GRIDGEOM_DROP removes the longest polyline first as a self-test of check B.
- gen_proj_heads — writes the headers of the projection sweep under fixtures/plot/proj and prints the matching rows of geometry.txt; the headers are committed and this program exists so that they can be regenerated.
- testpolymapinv — a PolyMap must only offer an iterative inverse when it has a forward transformation to iterate. It checks the IterInverse default and TranInverse for PolyMaps with no coefficients, with inverse coefficients only and with forward coefficients only, that asking for an iterative inverse without a forward transformation is an error (through the attribute, the constructor options and a dump), and that the iterative inverse of a forward-only PolyMap still inverts it.
- testsplinemapedge — SplineMap values on the edges of the area covered by its knots. A bilinear and a constant SplineMap with a single knot interval on each axis, and SplineMaps with one interval on one axis and two on the other, must give the exact spline value on every edge and corner, and AST__BAD just outside. A SplineMap whose knots are all equal on one axis covers no area and must give AST__BAD rather than NaN.
- testdssmap — the DssMap class, which AST no longer creates and which can only be reached by loading a dump written by an older version. Using the dump in fixtures/serialisation/c_dssmap.ast, it checks the sky positions of pixels on the plate and the return trip, that sky positions on the far side of the sky from the plate centre and positions too large for the plate solution give AST__BAD, and that a dump is rejected if a required value is missing, if it does not have two inputs and two outputs, or if its plate centre or pixel offsets are too large for the DSS FITS keywords. It also checks that a DssMap absorbs a neighbouring WinMap on simplification only when the new pixel offsets are whole numbers of pixels that an integer can hold. The conversion of an oversized pixel offset to an integer was undefined, which the test can only detect under UndefinedBehaviorSanitizer.
- testmoccds — the Moc class against the CDS HEALPix library. The expected values were computed with cdshealpix 0.10.1 as used by cds-moc 0.19.3, the library that MOCPy is built on, and are held in tables in the test. The cells of each Circle and Polygon were found from the cell centres, because the cdshealpix 0.10.1 functions that cover a cone or a polygon returned wrong cells in some cases (cds-healpix-rust issue 33, fixed in cdshealpix 0.10.2, whose coverage functions agree with every table). It checks the cell that holds each of 20 sky positions at six orders from 0 to 27, many of them on a cell boundary, on a meridian where the HEALPix projections used by the Moc class are cut, or at a pole. It checks the cells of the Mocs of 65 Circles, including Circles centred on such positions, Circles that cover more than half the sky and Mocs with a MaxOrder of zero, and of the Mocs of 12 Polygons. It checks that string and JSON MOCs written by cds-moc are read correctly, and that AST writes a string MOC with spaces between its cells.
Optional manual stress test:
- testhuge_c
Created stub headers for Starlink dependencies:
cmake/sae_par.h— definesSAI__OKandSAI__ERRORcmake/star/mers.h— inline no-op stubs forerrMark,errRlse,errStat,errAnnul,errRep
Created ast_tester/CMakeLists.txt with:
WHOLE_ARCHIVElinking for satellite libraries (ast_err, ast_grf_*) to resolve symbols referenced by libast at runtime- Conditional tests for YAML and pthreads support
- Data file copying for testsplinemap_c and testcmpmap
Fixed testobject.c to use baseName() for portable __FILE__ comparison
and __LINE__ captures instead of hardcoded line numbers.
Fixed testsplinemap_c.c to check fscanf return values.
Fixed testthreads.c to return NULL from worker() thread function. Later
reworked so each worker watches its own thread-local status and reports the
outcome back through the shared struct, replacing the Starlink EMS calls
(errStat/errAnnul) that are no-ops in the standalone build and so could
never detect the expected lock error.
ctest decides pass/fail purely from each program's exit code (no pass/fail
regex), so a test that always returns 0 reports success even when its own
checks fail. Eight programs ran off the end of main() with no return
statement (an implicit return 0 in C99) and so had been silently passing:
testerror, testobject, testaxis, testframe, testunitnorm,
testsplinemap_c, testthreads, testyamlchan (and testregions, which
returned a hardcoded 0). All now return astOK ? 0 : 1. Making the status
real exposed two genuine failures that had been masked:
- testyamlchan: its input data files (
imaging_wcs.asdf,tanSipWcs.txt,lsst_wcs.txt) existed in the source tree but were never copied into the build directory; added the missingconfigure_filecalls. Running the test under AddressSanitizer then exposed two pre-existing buffer overflows inyamlchan.c/memory.c(stack overrun inReadPoly'sdimd/dimw, and astr - 1underread inastChrSplit_), fixed by cherry-picking the upstream fixes from PR #39.
Each converted test:
- Uses the public C API (
ast.h) only - Uses standard C strings and
astMalloc/astFree(no CHR/PSX) - Uses
astWatch(&status)+astOKfor error checking (no EMS) - Fortran
err_mark/err_rlsesimply omitted - Fortran channel source/sink callbacks replaced by
astToString/astFromStringor ChannelSinkFile/SourceFileattributes - Fortran
psx_calloc/psx_freereplaced byastMalloc/astFree - Fortran 1-based indices adjusted to C 0-based where needed (e.g.
astGetCell)
Each converted test file has a header comment documenting any differences. Key issues:
-
testfitstable.c: String column sizes differ because C
astMapPut1Cstores actual string content without padding, while Fortran CHARACTER variables are stored at their declared length. This affectsColumnSize,ColumnLenC,NAXIS1,TFORM, andTDIMheader values. The test skips hardcoded size checks and verifies round-trips instead. TODO: Decide whether the C API should pad strings for FITS BINTABLE conventions. -
testunitnormmap.c: The
differ()comparison function has an absolute tolerance floor of1e-14not present in the Fortran original, needed because near-zero values can differ between simplified and unsimplified Mappings. -
testhuge.c: This is a faithful C port of the original huge 64-bit stress test. It is built only when
AST_ENABLE_HUGE_TEST=ONand should be treated as a manual test rather than a routine CI test. It allocates two60001 x 60001float arrays and can take a very long time to run, especially under sanitizers. -
testzoommap.c: Simplified immutability error recovery (checks
!astOKrather than specificAST__IMMUTcode). -
testfitschan.c: FITS card padding ignored during assertions to match Fortran string comparison rules. Fixed a
heap-use-after-freebug inastStore_(memory.c) exposed by AddressSanitizer duringastConvert. Also carries C-only write cases with no Fortran counterpart. The last of these usefixtures/wcsconv/inputs/lsst2.ast, whose pixel-to-sky Mapping contains a SplineMap, to pin two fitschan.c defects:MakeIntWorldapplied the SIP CD values topartmatrows that the failed linearity test had left NULL, segfaulting whenever NAXIS1/NAXIS2 gave a box of about 1000 pixels or more and FitsTol was tight enough that the fit over it failed; andSIPIntWorldaccepted a SIP description whose CRPIX values came back AST__BAD, soastWritereported success while emitting SIP coefficients and no primary axis description. A further case, built in the test rather than read from a fixture, pins a third defect:SIPIntWorldtested the Mapping following the SIP polynomial over a box centred on the reference point and with a tolerance in pixels, so a SIP description could be accepted, and its CRPIX and CD values fitted, over a region the image does not occupy. -
testregions.c: Translated automatically and then fixed up to cast
astTranNinput arrays to(const double *). Several automatic-translation defects were later corrected againsttestregions.f: the per-section "X tests failed" messages were printed unconditionally (the Fortranif status != OKguard had been dropped);checkBox/checkCircle/checkEllipseeach used the wrong FITS header (a single unrelated block had been copied into all three);checkdumpcompared dump strings withstrcmpinstead of falling back toastOverlap()==5as the Fortran does; and fourfrm1 = astFrame(...)statements had been absorbed into//comments. TheastGetRegionDisccheck incheckCmpRegionuses tolerances relaxed to1e-7(from the Fortran's1e-9/1e-8) because that disc is fitted to a subsampled boundary mesh and so varies at the~1e-8level with build/optimisation settings; the Fortran test built against the autoconf AST passes the tight tolerance on the same machine. -
testrebinseq.c: Translated to use
astRebinSeq[I|F|D]depending on the types of the in/out pointers. -
testrebin.c: Collapses 27 Fortran subroutines (9 test groups × 3 type variants each) into 9 parameterized C functions using a DataType enum. Tests astRebinD/F/I across 6 spread functions.
-
teststc.c: Tests STC classes using 10 external XML data files. Uses safeGetC() wrapper and strcmpTrim() for Fortran trailing-space semantics. astTranN arrays use in[ncoord][npoint] layout (Fortran column-major order).
-
wcsconverter.c: C port of the Fortran regression-diff harness. Not a self-validating test — it is a CLI (
wcsconverter <in> <encoding> <out> [<attrs>]) driven byast_tester/CMakeLists.txt'sadd_wcsconv_test()helper, which registers one ctest per fixture that invokes the binary and diffs its output against a committed reference file. Replaces the 16-row regression loop in the oldast_testertcsh script (the two duplicate rows there collapse to 14 unique fixtures). Thetimj.nativereference was regenerated during the port to absorb a 1-ulp noise-level drift in a single MatrixMap inverse cell between the 2018-era reference and current libast output. -
simplify.c: C port of the Fortran simplify harness. Like wcsconverter, it is a CLI (
simplify <in> <out>) driven byast_tester/CMakeLists.txt'sadd_simplify_test()helper. Each fixture reads a.mapinput, runsastSimplify, and diffs the output against a committed.simpreference. Both byte-level string diff and astEqual semantic comparison tests are registered, matching the wcsconverter pattern. Three fixtures: brad, lsst1, rigby. -
ast_astequal.c: Generic semantic equivalence comparator (renamed from wcs_astequal.c). Reads two AST object files and exits 0 if astEqual reports them equivalent. Handles both AST dumps (via astChannel) and FITS encodings (via astFitsChan). Used by both wcsconverter and simplify test harnesses.
- testplot3d.f (1357 lines) — Plot3D (requires PGPLOT; interactive/graphical test that cannot be fully converted without a graphics backend). A C port (testplot3d.c) exists and runs when PLplot is found.
- regression.f (1515 lines) — stdout-diff regression harness. Deferred; most functionality is already covered by individual class tests.
- joye_car_headers/: Contains additional FITS WCS headers (CAR projection variants from W. Joye) that could be added to plotter and wcsconv tests. Note: 3 files (CAR_model, CHIPASS_Equ, cmap_3years_GP_D2) have non-FITS preamble lines ("FITS headers in ...") that would need stripping first.
- Dead file cleanup: The following files are no longer used and could be
removed in a future pass:
- Old build scripts:
doplot,makeplot,maketest,moctohtml - Duplicate
2dspline.dat(identical to2dspline_c.dat) asdftest.py(standalone Python test, not integrated)regression.current,regression.out(old diff targets)draw3d-test2.txt,draw3d-test3.txt(unreferenced)
- Old build scripts:
- Moc memory for an explicit MinOrder: astAddRegion and astAddPixelMask record every cell of the initial grid that is inside the Region individually, at 16 bytes each, until IncorporateCells merges them into ranges. When MinOrder has not been set the initial grid is capped at 262144 cells, but a MinOrder that has been set is used as given, so the memory is then proportional to the area of the Region in cells at MinOrder. An 80 degree Circle at MaxOrder 18 with MinOrder 13 takes over 4 GB and more than ten minutes. Bounding this would mean merging the cells of the initial grid into ranges as they are found, which is a change to the CellList design.
The GitHub Actions workflow runs ctest which automatically picks up all
test targets. No workflow changes were needed. Tests conditional on YAML
and pthreads are handled by CMake options.
The original testhuge.f now has a C port in ast_tester/testhuge.c.
Because it is intentionally enormous, it is not built by default.
Enable it with:
cmake -B build-huge -DCMAKE_BUILD_TYPE=Debug -DAST_ENABLE_HUGE_TEST=ON
cmake --build build-huge --target testhuge_c
Run it manually:
./build-huge/ast_tester/testhuge_c
This test is a manual stress test, not a routine regression test. It can consume tens of gigabytes of RAM and may take a very long time to complete. It should not normally be combined with sanitizers.
A tolerance-based, architecture-independent regression oracle records the
current numerical output of AST transforms over three corpora so that future
work (SIMD kernels, refactors) can be checked for unintended changes. See
docs/superpowers/specs/2026-06-27-transform-oracle-design.md.
gen_transform_oracle(built, not a test) scans the fixture tree and writes three committed reference files:simplify_fixtures.oracle(thesimplify/*.mapand*.simpnative dumps),headers.oracle(the*.headFITS headers) andframesets.oracle(the*.astFrameSet dumps).check_transform_oracle(the ctest gate) reads an oracle file as its sole manifest, reloads each named fixture, re-transforms the recorded inputs and compares within tolerance. Four ctests:transform_oracle_selftest(parser),transform_oracle_simplify,transform_oracle_headers,transform_oracle_framesets.test_oracle_utilunit-tests the helpers.- Checks: golden forward and golden inverse (every fixture; the inverse
section's inputs are the forward outputs);
.map/.simpequivalence gated on stored agreement; and, for the GRID-domain corpora, round-trip accuracy (inverse(forward(P)) ~= P) to an absolute pixel tolerance. oracle/transform_oracle_overrides.txtrecords per-fixture round-trip exceptions (currentlytsc.headandtnx-cheb.head, whose inverses do not recover the pixel and are flagged for investigation), and per-row golden exceptions for values that sit on a mathematical singularity (currently rows 2 and 3 ofneg_unitnormmap_inv_fwd_diffcentre.map's inverse section, which depend on whether the compiler contracts a multiply-add).- The recorded values are build-configuration dependent in the last bit or two.
Regenerating
framesets.oracleunder a Debug sanitizer build reproduces the committed file except for about 60 latitude values differing by one ULP from the Release build it was captured with. That is what the 1e-7 tolerance is for, and both files pass the gate, so do not commit a regeneration that only moves last digits -- it is churn, not a change. Regenerate only when a transform has intentionally changed, and check the diff names the fixtures you expect.
Regenerate after an intentional transform change and commit the diff:
cmake --build build --target gen_transform_oracle
./build/ast_tester/gen_transform_oracle ast_tester/fixtures \
ast_tester/fixtures/oracle/simplify_fixtures.oracle \
ast_tester/fixtures/oracle/headers.oracle \
ast_tester/fixtures/oracle/framesets.oracle
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
ctest --test-dir build --output-on-failure
Shows 106 default tests (+ 20 conditional PLplot plotter smoke tests), all passing (minus pre-existing testresimp segfault).