
Users can add test() methods to their packages to run smoke tests on installations with the new `spack test` command (the old `spack test` is now `spack unit-test`). spack test is environment-aware, so you can `spack install` an environment and then run `spack test run` to run smoke tests on all of its packages. Historical test logs can be perused with `spack test results`. Generic smoke tests for MPI implementations, C, C++, and Fortran compilers as well as specific smoke tests for 18 packages. Inside the test method, individual tests can be run separately (and continue to run best-effort after a test failure) using the `run_test` method. The `run_test` method encapsulates finding test executables, running and checking return codes, checking output, and error handling. This handles the following trickier aspects of testing with direct support in Spack's package API: - [x] Caching source or intermediate build files at build time for use at test time. - [x] Test dependencies, - [x] packages that require a compiler for testing (such as library only packages). See the packaging guide for more details on using Spack testing support. Included is support for package.py files for virtual packages. This does not change the Spack interface, but is a major change in internals. Co-authored-by: Tamara Dahlgren <dahlgren1@llnl.gov> Co-authored-by: wspear <wjspear@gmail.com> Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>
71 lines
1.7 KiB
C
71 lines
1.7 KiB
C
/* Simple "Hello World" test set up to handle a single page fault
|
|
*
|
|
* Inspired by libsigsegv's test cases with argument names for handlers
|
|
* taken from the header files.
|
|
*/
|
|
|
|
#include "sigsegv.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h> /* for exit */
|
|
# include <stddef.h> /* for NULL on SunOS4 (per libsigsegv examples) */
|
|
#include <setjmp.h> /* for controlling handler-related flow */
|
|
|
|
|
|
/* Calling environment */
|
|
jmp_buf calling_env;
|
|
|
|
char *message = "Hello, World!";
|
|
|
|
/* Track the number of times the handler is called */
|
|
volatile int times_called = 0;
|
|
|
|
|
|
/* Continuation function, which relies on the latest libsigsegv API */
|
|
static void
|
|
resume(void *cont_arg1, void *cont_arg2, void *cont_arg3)
|
|
{
|
|
/* Go to calling environment and restore state. */
|
|
longjmp(calling_env, times_called);
|
|
}
|
|
|
|
/* sigsegv handler */
|
|
int
|
|
handle_sigsegv(void *fault_address, int serious)
|
|
{
|
|
times_called++;
|
|
|
|
/* Generate handler output for the test. */
|
|
printf("Caught sigsegv #%d\n", times_called);
|
|
|
|
return sigsegv_leave_handler(resume, NULL, NULL, NULL);
|
|
}
|
|
|
|
/* "Buggy" function used to demonstrate non-local goto */
|
|
void printit(char *m)
|
|
{
|
|
if (times_called < 1) {
|
|
/* Force SIGSEGV only on the first call. */
|
|
volatile int *fail_ptr = 0;
|
|
int failure = *fail_ptr;
|
|
printf("%s\n", m);
|
|
} else {
|
|
/* Print it correctly. */
|
|
printf("%s\n", m);
|
|
}
|
|
}
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
/* Install the global SIGSEGV handler */
|
|
sigsegv_install_handler(&handle_sigsegv);
|
|
|
|
char *msg = "Hello World!";
|
|
int calls = setjmp(calling_env); /* Resume here after detecting sigsegv */
|
|
|
|
/* Call the function that will trigger the page fault. */
|
|
printit(msg);
|
|
|
|
return 0;
|
|
}
|