diff options
author | Mitya Selivanov <automainint@guattari.tech> | 2024-07-31 23:32:36 +0200 |
---|---|---|
committer | Mitya Selivanov <automainint@guattari.tech> | 2024-07-31 23:32:36 +0200 |
commit | 15f6e03347418caf2fdd178480c84295d417bae0 (patch) | |
tree | 1a3a81273f013be91960b64703638fa692a18315 /bxgen.c | |
parent | 823b3f75baae3120218f45acaf2eb8cb2f844cb8 (diff) | |
download | bxgen-15f6e03347418caf2fdd178480c84295d417bae0.zip |
Test suite
Diffstat (limited to 'bxgen.c')
-rwxr-xr-x | bxgen.c | 55 |
1 files changed, 42 insertions, 13 deletions
@@ -3861,18 +3861,15 @@ c8 *l_find(c8 *name) { // ================================================================ // -// EXAMPLE +// TEST SUITE // // ================================================================ -#if HELPERS && TESTING +#if TESTING -int main(int argc, char **argv) { - (void) argc; - (void) argv; - - LOG(INFO, "bxgen " VERSION); +#if HELPERS +b8 link_with_libc(void) { // ============================================================ // // Create the program semantic tree @@ -3936,16 +3933,48 @@ int main(int argc, char **argv) { } else if (HO != LE) { LOG(INFO, "Skip running the executable. Host data ordering is not compatible."); } else { - // Run the created executable file. + LOG(VERBOSE, "Running the executable"); + i32 ret = system("./test_foo"); - CHECK(WEXITSTATUS(ret) == 42, "Failure", -1); + if (WEXITSTATUS(ret) != 42) + return 0; } - LOG(INFO, "Bye!"); - return 0; + return 1; } -#endif +#endif // HELPERS -#endif +i32 main(i32 argc, c8 **argv) { + LOG(INFO, "bxgen " VERSION); + + i32 status = 0; + + i32 num_tests = 0; + i32 num_passed = 0; + + #define RUN_TEST_(t) \ + do { \ + ++num_tests; \ + if (t()) { \ + ++num_passed; \ + LOG(INFO, #t " - OK"); \ + } else \ + LOG(ERROR, #t " - FAIL"); \ + } while (0) + + #if HELPERS + RUN_TEST_(link_with_libc); + #endif + + #undef RUN_TEST_ + + LOG(INFO, "%d of %d tests passed.", num_passed, num_tests); + + return num_passed == num_tests ? 0 : -1; +} + +#endif // TESTING + +#endif // IMPLEMENTATION |