From 931ee28eb9c5b5e3c2b0d3008f5f65d810dc9b0c Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 20 Jun 2024 15:10:56 -0400 Subject: Unit tests (#6) * Initial commit of unit tests [WIP] * Address shortcomings and bugs flushed out by unit tests * Enable unit testing in CI workflow * Enable verbose ctests * Handle lack of __FILE_NAME__ define * Only podman support `run --arch` argument * Skip docker build testing if CI system cannot pull an image * Remove errant call to puts() * Identify local repo user * Fix missing xmllint * NULL terminate arrays * Fix filename assignment in is_url mode * Break loop when expected lines are exhausted * strcmp_array expects NULL terminated array. Iterating by size in this case passes NULL to strcmp leading to an invalid read * Remove debug printf statements * Disable a few warnings for tests * Workaround for ctest junit xml truncation * Update checkout@v4 * Prevent false-positive result * Return zero on error * Fix strlist_remove function * Value argument can be constant * Fix test to match changes to startswith and endswith * Add test_ini.c * Fix redaction code to accept NULL pointers in array * And let the caller specify the length of the array of strings to redact. * Redactions now occur directly on authentication strings rather than their command line arguments * Fix BUILD_TESTING_DEBUG * Adds missing -D argument --- src/docker.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/docker.c') diff --git a/src/docker.c b/src/docker.c index f8c9c11..308fbc7 100644 --- a/src/docker.c +++ b/src/docker.c @@ -28,7 +28,7 @@ int docker_script(const char *image, char *data, unsigned flags) { char buffer[OMC_BUFSIZ]; memset(cmd, 0, sizeof(cmd)); - snprintf(cmd, sizeof(cmd) - 1, "docker run --rm -i %s /bin/bash -", image); + snprintf(cmd, sizeof(cmd) - 1, "docker run --rm -i %s /bin/sh -", image); outfile = popen(cmd, "w"); if (!outfile) { @@ -103,7 +103,7 @@ static int docker_exists() { return false; } -char *docker_ident() { +static char *docker_ident() { FILE *fp = NULL; char *tempfile = NULL; char line[PATH_MAX]; -- cgit