diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-08-15 14:21:53 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-08-15 14:24:42 -0400 |
commit | e12887af230bd4a4789379ac03f3f819e8644cf9 (patch) | |
tree | 7936556329cc38a2f5944f4642d492d55de17c3f | |
parent | 5943ac7ac8bdf989956be98a7b131a5eec02b6b0 (diff) | |
download | stasis-e12887af230bd4a4789379ac03f3f819e8644cf9.tar.gz |
Add two template convenience functions
* get_junitxml_result_auto()
* get_basetemp_result_auto()
-rw-r--r-- | include/template_func_proto.h | 2 | ||||
-rw-r--r-- | src/stasis_main.c | 2 | ||||
-rw-r--r-- | src/template_func_proto.c | 44 |
3 files changed, 48 insertions, 0 deletions
diff --git a/include/template_func_proto.h b/include/template_func_proto.h index 212759c..6c5ace4 100644 --- a/include/template_func_proto.h +++ b/include/template_func_proto.h @@ -5,5 +5,7 @@ int get_github_release_notes_tplfunc_entrypoint(void *frame, void *data_out); int get_github_release_notes_auto_tplfunc_entrypoint(void *frame, void *data_out); +int get_junitxml_result_auto_entrypoint(void *frame, void *data_out); +int get_basetemp_result_auto_entrypoint(void *frame, void *data_out); #endif //TEMPLATE_FUNC_PROTO_H
\ No newline at end of file diff --git a/src/stasis_main.c b/src/stasis_main.c index 4c47672..3ca628d 100644 --- a/src/stasis_main.c +++ b/src/stasis_main.c @@ -328,6 +328,8 @@ int main(int argc, char *argv[]) { // Prototypes can be found in template_func_proto.h tpl_register_func("get_github_release_notes", &get_github_release_notes_tplfunc_entrypoint, 3, NULL); tpl_register_func("get_github_release_notes_auto", &get_github_release_notes_auto_tplfunc_entrypoint, 1, &ctx); + tpl_register_func("get_junitxml_result_auto", &get_junitxml_result_auto_entrypoint, 1, &ctx); + tpl_register_func("get_basetemp_result_auto", &get_basetemp_result_auto_entrypoint, 1, &ctx); // Set up PREFIX/etc directory information // The user may manipulate the base directory path with STASIS_SYSCONFDIR diff --git a/src/template_func_proto.c b/src/template_func_proto.c index 92ae355..e9d1835 100644 --- a/src/template_func_proto.c +++ b/src/template_func_proto.c @@ -66,3 +66,47 @@ int get_github_release_notes_auto_tplfunc_entrypoint(void *frame, void *data_out return result; } + +int get_junitxml_result_auto_entrypoint(void *frame, void *data_out) { + int result = 0; + char **output = (char **) data_out; + struct tplfunc_frame *f = (struct tplfunc_frame *) frame; + const struct Delivery *ctx = (const struct Delivery *) f->data_in; + + char cwd[PATH_MAX] = {0}; + getcwd(cwd, PATH_MAX - 1); + char nametmp[PATH_MAX] = {0}; + strcpy(nametmp, cwd); + char *name = path_basename(nametmp); + + *output = calloc(PATH_MAX, sizeof(**output)); + if (!*output) { + SYSERROR("failed to allocate output string: %s", strerror(errno)); + return -1; + } + sprintf(*output, "%s/results-%s-%s.xml", ctx->storage.results_dir, name, ctx->info.release_name); + + return result; +} + +int get_basetemp_result_auto_entrypoint(void *frame, void *data_out) { + int result = 0; + char **output = (char **) data_out; + struct tplfunc_frame *f = (struct tplfunc_frame *) frame; + const struct Delivery *ctx = (const struct Delivery *) f->data_in; + + char cwd[PATH_MAX] = {0}; + getcwd(cwd, PATH_MAX - 1); + char nametmp[PATH_MAX] = {0}; + strcpy(nametmp, cwd); + char *name = path_basename(nametmp); + + *output = calloc(PATH_MAX, sizeof(**output)); + if (!*output) { + SYSERROR("failed to allocate output string: %s", strerror(errno)); + return -1; + } + sprintf(*output, "%s/truth-%s-%s", ctx->storage.tmpdir, name, ctx->info.release_name); + + return result; +}
\ No newline at end of file |