From 99d158b4864990009c2fbb22345bf8de44a47510 Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 22 Mar 2021 10:23:47 -0400 Subject: [PATCH] Modified CodeGeneratorTest to use all command line options. --- .../test/code_generator_test/.gitignore | 3 ++- .../test/code_generator_test/makefile | 4 ++-- .../test/code_generator_test/test_data.h | 12 ++++++++++++ .../test/code_generator_test/test_driver.c | 17 +++++++---------- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/makina-compiler/test/code_generator_test/.gitignore b/makina-compiler/test/code_generator_test/.gitignore index c585e19..0f1f446 100644 --- a/makina-compiler/test/code_generator_test/.gitignore +++ b/makina-compiler/test/code_generator_test/.gitignore @@ -1 +1,2 @@ -out \ No newline at end of file +out +.vscode \ No newline at end of file diff --git a/makina-compiler/test/code_generator_test/makefile b/makina-compiler/test/code_generator_test/makefile index f4c098c..27b1e71 100644 --- a/makina-compiler/test/code_generator_test/makefile +++ b/makina-compiler/test/code_generator_test/makefile @@ -3,10 +3,10 @@ test: out/test ./out/test out/test: test_driver.c out/test.c out/test.h out - gcc test_driver.c out/test.c -std=c99 -Wall -Wextra -o out/test + gcc test_driver.c out/test.c -I "." -std=c99 -Wall -Wextra -o out/test out/test.c: - java -jar ../../out/artifacts/makina_compiler_jar/makina-compiler.jar test_source.mkna -o out + java -jar ../../out/artifacts/makina_compiler_jar/makina-compiler.jar test_source.mkna -m "struct machine_data" -e "struct event_data" -i "test_data.h" -o out out: mkdir out diff --git a/makina-compiler/test/code_generator_test/test_data.h b/makina-compiler/test/code_generator_test/test_data.h index e69de29..7753c42 100644 --- a/makina-compiler/test/code_generator_test/test_data.h +++ b/makina-compiler/test/code_generator_test/test_data.h @@ -0,0 +1,12 @@ +#ifndef TEST_DATA_H +#define TEST_DATA_H + +struct machine_data { + char _; +}; + +struct event_data { + int guard; +}; + +#endif /*TEST_DATA_H*/ diff --git a/makina-compiler/test/code_generator_test/test_driver.c b/makina-compiler/test/code_generator_test/test_driver.c index 6d09def..e8df37e 100644 --- a/makina-compiler/test/code_generator_test/test_driver.c +++ b/makina-compiler/test/code_generator_test/test_driver.c @@ -9,11 +9,9 @@ int s1_s2_entry(struct test *self, struct test_event *event) { return 0; } -int s1_s2_e1_guard_value = 0; - int s1_s2_e1_guard(struct test *self, struct test_event *event) { fprintf(output, "s1_s2_e1_guard\n"); - return s1_s2_e1_guard_value; + return event->ctx.guard; } int s1_s2_e1_action(struct test *self, struct test_event *event) { @@ -75,13 +73,12 @@ int main (void) { output = fopen("out/test_output.txt", "w+"); struct test instance; test_init(&instance); //s1_entry, s1_s2_entry - test_process_event(&instance, &(struct test_event) {.id = test_event_e1}); //s1_s2_e1_guard, s1_s2_exit, s1_exit, s2_entry, s2_s1_entry - test_process_event(&instance, &(struct test_event) {.id = test_event_e2}); //... - test_process_event(&instance, &(struct test_event) {.id = test_event_e1}); //s2_s1_exit, s2_exit, s2_s1_e1_action, s1_entry, s1_s2_entry - s1_s2_e1_guard_value = 1; - test_process_event(&instance, &(struct test_event) {.id = test_event_e1}); //s1_s2_e1_guard, s1_s2_e1_action - test_process_event(&instance, &(struct test_event) {.id = test_event_e2}); //s1_s2_exit, s1_exit, s2_entry, s2_s3_entry - test_process_event(&instance, &(struct test_event) {.id = test_event_e2}); //s2_s3_exit, s2_exit, s1_entry, s1_s2_entry + test_process_event(&instance, &(struct test_event) {.id = test_event_e1, .ctx = (struct event_data){0}}); //s1_s2_e1_guard, s1_s2_exit, s1_exit, s2_entry, s2_s1_entry + test_process_event(&instance, &(struct test_event) {.id = test_event_e2, .ctx = (struct event_data){0}}); //... + test_process_event(&instance, &(struct test_event) {.id = test_event_e1, .ctx = (struct event_data){0}}); //s2_s1_exit, s2_exit, s2_s1_e1_action, s1_entry, s1_s2_entry + test_process_event(&instance, &(struct test_event) {.id = test_event_e1, .ctx = (struct event_data){1}}); //s1_s2_e1_guard, s1_s2_e1_action + test_process_event(&instance, &(struct test_event) {.id = test_event_e2, .ctx = (struct event_data){0}}); //s1_s2_exit, s1_exit, s2_entry, s2_s3_entry + test_process_event(&instance, &(struct test_event) {.id = test_event_e2, .ctx = (struct event_data){0}}); //s2_s3_exit, s2_exit, s1_entry, s1_s2_entry fclose(output); return 0; } \ No newline at end of file