diff options
| author | JP Appel <jeanpierre.appel01@gmail.com> | 2024-07-26 22:23:17 -0400 |
|---|---|---|
| committer | JP Appel <jeanpierre.appel01@gmail.com> | 2024-07-26 22:23:17 -0400 |
| commit | 47f09225b07c33c7657ded5bbe4c7e4f98eb9e30 (patch) | |
| tree | 3bedbf21474f480af8e4c47b3e0de6e79ab6fb81 /examples/basics.c | |
| parent | 6f864672834e646aedbdf8c279b58226e8a2a2f3 (diff) | |
FEAT: test can now time out
Tests now have an extra field `max_time_ms` which is the max duration
before it's process gets killed. A time of 0 ms is used to disable
eztester managed timeouts, however a test can still return a timeout
status which will be handled similarily.
Diffstat (limited to 'examples/basics.c')
| -rw-r--r-- | examples/basics.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/examples/basics.c b/examples/basics.c new file mode 100644 index 0000000..6aab9d2 --- /dev/null +++ b/examples/basics.c @@ -0,0 +1,51 @@ +#include "../eztester.h" +#include <stdio.h> +#include <unistd.h> + +#define EZTESTER_IMPLEMENTATION +#include "../build/header/eztester.h" +#undef EZTESTER_IMPLEMENTATION + +eztester_status shell_exists() { + int status = eztester_shell(NULL); + if (status) { + return TEST_FAIL; + } else { + return TEST_PASS; + } +} + +eztester_status python3_exists() { + int status = eztester_shell("/usr/bin/env python3 --version"); + if (status) { + return TEST_FAIL; + } else { + return TEST_PASS; + } +} + +eztester_status sleepy() { + eztester_log("Im feeling sleepy"); + sleep(2); + eztester_log("zzzzzzz"); + sleep(1); + eztester_log("ZZZZZZZZ"); + sleep(2); + eztester_log("oh, hello there."); + return TEST_PASS; +} + +int main(int argc, char *argv[]) { + eztester_list *list = eztester_create_list(5); + + eztester_register( + list, (eztester_test){eztester_always_pass_test, "Always pass", 0}); + eztester_register( + list, (eztester_test){eztester_always_warn_test, "Always warn", 0}); + eztester_register(list, (eztester_test){sleepy, "Timeout test", 4e3}); + eztester_register(list, (eztester_test){python3_exists, "Python3 Exists", 0}); + + eztester_run(list, EXIT_ON_FAIL); + + return 0; +} |
