diff options
author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2024-10-30 12:21:20 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-30 12:21:20 -0400 |
commit | f25f05d8ac309b343f8e34e882d92cb8bc78eca3 (patch) | |
tree | 740bbf4fa413357d1e839bd308ab545d1271de96 /tests/README.md | |
parent | ec55ea8fc503ad3fb53635d7e9e6d58a63c6684a (diff) | |
parent | 3da6e513cc64990aa865613bd0bb9ba5d6624570 (diff) | |
download | stasis-f25f05d8ac309b343f8e34e882d92cb8bc78eca3.tar.gz |
Merge pull request #65 from jhunkeler/more-rt
More RT
Diffstat (limited to 'tests/README.md')
-rw-r--r-- | tests/README.md | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..bb1f896 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,48 @@ +# Testing STASIS + +## Unit tests + +Rules: + +* Use the boilerplate `_test_boilerplate.c` + * ```shell + cp _test_boilerplate.c test_mynewtest.c + ``` +* Test file names start with `test_` (`test_file.c`) +* Test functions start with `test_` (`void test_function()`) +* Test suites can be skipped by returning `127` from `main()` +* PASS, FAIL, and SKIP conditions are set by the assertion macros `STASIS_{ASSERT,ASSERT_FATAL,SKIP_IF}` +* Parametrized tests should implement an array of `struct testcase` + * The `testcase` structure should be local to each `test_` function + * The `testcase` variables are freeform + * Example: + ```c + void test_function() { + struct testcase { + int your; + int variables; + int here; + }; + struct testcase tc[] = { + {.your = 0, .variables = 1, .here = 2}, + {.your = 3, .variables = 4, .here = 5}, + // ... + }; + for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) { + // STASIS_ASSERT()s here + } + } + ``` + +## Regression test (RT) + +Rules: + +* Regression tests are shell scripts (BASH) +* Use the boilerplate `_rt_boilerplate.sh` + * ```shell + cp _rt_boilerplate.sh rt_mynewtest.sh + ``` +* Test file names start with `rt_` (`rt_file.sh`) +* Test function names are freeform, however they must be executed using `run_command()` (`run_command test_function`) +* Test suites can be skipped by returning `127` from the shell script
\ No newline at end of file |