aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/data/compression/bz2bin0 -> 42 bytes
-rw-r--r--tests/data/compression/gzbin0 -> 26 bytes
-rw-r--r--tests/data/compression/none1
-rw-r--r--tests/data/compression/xzbin0 -> 72 bytes
-rw-r--r--tests/data/compression/zipbin0 -> 202 bytes
-rw-r--r--tests/data/compression/zstdbin0 -> 19 bytes
-rw-r--r--tests/data/gbo_ng.ini66
-rw-r--r--tests/include/testing.h3
-rw-r--r--tests/rt_generic_ng_based_on.sh30
-rw-r--r--tests/test_conda.c52
-rw-r--r--tests/test_recipe.c12
-rw-r--r--tests/test_str.c57
-rw-r--r--tests/test_utils.c47
-rw-r--r--tests/test_wheel.c6
14 files changed, 225 insertions, 49 deletions
diff --git a/tests/data/compression/bz2 b/tests/data/compression/bz2
new file mode 100644
index 0000000..20d3517
--- /dev/null
+++ b/tests/data/compression/bz2
Binary files differ
diff --git a/tests/data/compression/gz b/tests/data/compression/gz
new file mode 100644
index 0000000..2762cd9
--- /dev/null
+++ b/tests/data/compression/gz
Binary files differ
diff --git a/tests/data/compression/none b/tests/data/compression/none
new file mode 100644
index 0000000..ce01362
--- /dev/null
+++ b/tests/data/compression/none
@@ -0,0 +1 @@
+hello
diff --git a/tests/data/compression/xz b/tests/data/compression/xz
new file mode 100644
index 0000000..f54e3fc
--- /dev/null
+++ b/tests/data/compression/xz
Binary files differ
diff --git a/tests/data/compression/zip b/tests/data/compression/zip
new file mode 100644
index 0000000..1f77925
--- /dev/null
+++ b/tests/data/compression/zip
Binary files differ
diff --git a/tests/data/compression/zstd b/tests/data/compression/zstd
new file mode 100644
index 0000000..a827868
--- /dev/null
+++ b/tests/data/compression/zstd
Binary files differ
diff --git a/tests/data/gbo_ng.ini b/tests/data/gbo_ng.ini
new file mode 100644
index 0000000..355e5ee
--- /dev/null
+++ b/tests/data/gbo_ng.ini
@@ -0,0 +1,66 @@
+[meta]
+mission = generic
+name = GBO
+version = 2.4.6
+rc = 1
+final = false
+based_on = {{ env:TEST_DATA }}/gbo.yml
+python = 3.11
+
+
+[conda]
+installer_name = Miniforge3
+installer_version = 26.3.2-2
+installer_platform = {{env:STASIS_CONDA_PLATFORM}}
+installer_arch = {{env:STASIS_CONDA_ARCH}}
+installer_baseurl = https://github.com/conda-forge/miniforge/releases/download/{{conda.installer_version}}
+;conda_packages =
+pip_packages =
+ firewatch==0.0.4
+ gwcs==0.22.1
+ tweakwcs==0.9.0
+
+
+[runtime]
+CPPFLAGS = ${CPPFLAGS} -fpermissive
+PYTHONUNBUFFERED = 1
+
+
+[test:firewatch]
+repository = https://github.com/astroconda/firewatch
+script_setup =
+ pip install -e '.'
+script =
+ firewatch -c conda-forge -p ${STASIS_CONDA_PLATFORM_SUBDIR} | grep -E ' python-[0-9]'
+
+
+[test:tweakwcs]
+repository = https://github.com/spacetelescope/tweakwcs
+script_setup =
+ pip install -e '.[test]'
+script =
+ pytest \
+ -r fEsx \
+ --basetemp="{{ func:basetemp_dir() }}" \
+ --junitxml="{{ func:junitxml_file() }}"
+
+
+[deploy:artifactory:delivery]
+files =
+ {{ storage.output_dir }}/**
+dest = {{ meta.mission }}/{{ info.build_name }}/
+
+
+[deploy:docker]
+registry = bytesalad.stsci.edu
+image_compression = zstd -v -9 -c
+build_args =
+ SNAPSHOT_INPUT={{ info.release_name }}.yml
+ SNAPSHOT_PKGDIR=packages
+tags =
+ {{ meta.name }}:{{ info.build_number }}-py{{ meta.python_compact }}
+ {{ deploy.docker.registry }}/{{ meta.name }}:{{ info.build_number }}-py{{ meta.python_compact }}
+test_script =
+ source /etc/profile
+ python -m pip freeze
+ mamba info
diff --git a/tests/include/testing.h b/tests/include/testing.h
index d11398c..a669b5d 100644
--- a/tests/include/testing.h
+++ b/tests/include/testing.h
@@ -11,7 +11,7 @@
#ifdef STASIS_TEST_VERBOSE
#define STASIS_TEST_MSG(MSG, ...) do { \
-fprintf(stderr, "%s:%d:%s(): ", path_basename(__FILE__), __LINE__, __FUNCTION__); \
+fprintf(stderr, "%s:%d:%s(): ", path_basename(__FILE__), __LINE__, __func__); \
fprintf(stderr, MSG LINE_SEP, __VA_ARGS__); \
} while (0)
#else
@@ -76,6 +76,7 @@ inline void stasis_testing_record_result_summary() {
do_message = 1;
#endif
strcpy(status_msg, "PASS");
+ do_reason = 0;
passed++;
}
if (do_message) {
diff --git a/tests/rt_generic_ng_based_on.sh b/tests/rt_generic_ng_based_on.sh
new file mode 100644
index 0000000..de5af24
--- /dev/null
+++ b/tests/rt_generic_ng_based_on.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+here="$(dirname ${BASH_SOURCE[0]})"
+source $here/setup.sh
+
+TEST_NAME=gbo_ng
+PYTHON_VERSIONS=(
+ 3.11
+)
+setup_workspace "$TEST_NAME"
+run_command install_stasis
+
+ln -s "$TEST_DATA"/"$TEST_NAME".yml
+for py_version in "${PYTHON_VERSIONS[@]}"; do
+ run_command run_stasis --python "$py_version" \
+ --no-docker \
+ --no-artifactory \
+ "$TEST_DATA"/"$TEST_NAME".ini
+done
+
+check_output_add "(null)"
+run_command check_output_stasis_dir stasis/*/output
+check_output_reset
+
+# NOTE: indexer default output directory is "output"
+check_output_add "(null)"
+run_command run_stasis_indexer stasis
+run_command check_output_indexed_dir output
+check_output_reset
+
+teardown_workspace "$TEST_NAME"
diff --git a/tests/test_conda.c b/tests/test_conda.c
index 4d0b4d8..7de1275 100644
--- a/tests/test_conda.c
+++ b/tests/test_conda.c
@@ -2,15 +2,14 @@
#include "conda.h"
#include "delivery.h"
-char cwd_start[PATH_MAX];
-char cwd_workspace[PATH_MAX];
int conda_is_installed = 0;
void test_micromamba() {
+ const char *cwd_workspace = TEST_WORKSPACE_DIR;
char mm_prefix[PATH_MAX] = {0};
char c_prefix[PATH_MAX] = {0};
- snprintf(mm_prefix, strlen(cwd_workspace) + strlen("micromamba") + 2, "%s/%s", cwd_workspace, "micromamba");
- snprintf(c_prefix, strlen(mm_prefix) + strlen("conda") + 2, "%s/%s", mm_prefix, "conda");
+ snprintf(mm_prefix, sizeof(mm_prefix), "%s/%s/%s", cwd_workspace, "tools", "micromamba");
+ snprintf(c_prefix, sizeof(c_prefix), "%s/%s", mm_prefix, "conda");
struct testcase {
struct MicromambaInfo mminfo;
@@ -18,10 +17,10 @@ void test_micromamba() {
int result;
};
struct testcase tc[] = {
- {.mminfo = {.download_dir = cwd_workspace, .micromamba_prefix = mm_prefix, .conda_prefix = c_prefix}, .cmd = "info", .result = 0},
- {.mminfo = {.download_dir = cwd_workspace, .micromamba_prefix = mm_prefix, .conda_prefix = c_prefix}, .cmd = "env list", .result = 0},
- {.mminfo = {.download_dir = cwd_workspace, .micromamba_prefix = mm_prefix, .conda_prefix = c_prefix}, .cmd = "run python3 -V", .result = 0},
- {.mminfo = {.download_dir = cwd_workspace, .micromamba_prefix = mm_prefix, .conda_prefix = c_prefix}, .cmd = "no_such_option", .result = 109},
+ {.mminfo = {.download_dir = (char *) cwd_workspace, .micromamba_prefix = mm_prefix, .conda_prefix = c_prefix}, .cmd = "info", .result = 0},
+ {.mminfo = {.download_dir = (char *) cwd_workspace, .micromamba_prefix = mm_prefix, .conda_prefix = c_prefix}, .cmd = "env list", .result = 0},
+ {.mminfo = {.download_dir = (char *) cwd_workspace, .micromamba_prefix = mm_prefix, .conda_prefix = c_prefix}, .cmd = "run python3 -V", .result = 0},
+ {.mminfo = {.download_dir = (char *) cwd_workspace, .micromamba_prefix = mm_prefix, .conda_prefix = c_prefix}, .cmd = "no_such_option", .result = 109},
};
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
@@ -67,7 +66,7 @@ void test_conda_activate() {
STASIS_SKIP_IF(!conda_is_installed, "cannot run without conda");
STASIS_ASSERT_FATAL(conda_activate(ctx.storage.conda_install_prefix, "base") == 0, "unable to activate base environment");
-
+ runtime_replace(&ctx.runtime.environ, __environ);
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
struct testcase *item = &tc[i];
char *value = getenv(item->key);
@@ -102,11 +101,13 @@ void test_python_exec() {
void test_conda_setup_headless() {
globals.conda_packages = strlist_init();
globals.pip_packages = strlist_init();
- strlist_append(&globals.conda_packages, "boa");
strlist_append(&globals.conda_packages, "conda-build");
- strlist_append(&globals.conda_packages, "conda-verify");
strlist_append(&globals.pip_packages, "pytest");
- STASIS_ASSERT(conda_setup_headless() == 0, "headless configuration failed");
+ struct CondaCapabilities cc;
+ int capable = conda_capable(&cc, ctx.storage.conda_install_prefix);
+ STASIS_ASSERT_FATAL(capable == EXIT_SUCCESS, "conda capability check function should not fail");
+ STASIS_ASSERT(conda_setup_headless(&cc) == 0, "headless configuration failed");
+ conda_capable_free(&cc);
}
void test_conda_env_create_from_uri() {
@@ -207,18 +208,10 @@ int main(int argc, char *argv[]) {
test_delivery_gather_tool_versions,
};
- char ws[] = "workspace_XXXXXX";
- if (!mkdtemp(ws)) {
- SYSERROR("unable to mkdtemp: %s", strerror(errno));
- exit(1);
- }
- getcwd(cwd_start, sizeof(cwd_start) - 1);
- mkdir(ws, 0755);
- chdir(ws);
- getcwd(cwd_workspace, sizeof(cwd_workspace) - 1);
- snprintf(conda_prefix, strlen(cwd_workspace) + strlen("conda") + 2, "%s/conda", cwd_workspace);
+ snprintf(conda_prefix, strlen(TEST_WORKSPACE_DIR) + strlen("conda") + 2, "%s/conda", TEST_WORKSPACE_DIR);
+ const char *installer_version = "26.3.2-2";
const char *mockinidata = "[meta]\n"
"name = mock\n"
"version = 1.0.0\n"
@@ -227,18 +220,21 @@ int main(int argc, char *argv[]) {
"python = 3.11\n"
"[conda]\n"
"installer_name = Miniforge3\n"
- "installer_version = 24.3.0-0\n"
+ "installer_version = %s\n"
"installer_platform = {{env:STASIS_CONDA_PLATFORM}}\n"
"installer_arch = {{env:STASIS_CONDA_ARCH}}\n"
- "installer_baseurl = https://github.com/conda-forge/miniforge/releases/download/24.3.0-0\n";
- stasis_testing_write_ascii("mock.ini", mockinidata);
+ "installer_baseurl = https://github.com/conda-forge/miniforge/releases/download/%s\n";
+ char mockinidata_final[STASIS_BUFSIZ] = {0};
+ snprintf(mockinidata_final, sizeof(mockinidata_final), mockinidata, installer_version, installer_version);
+
+ stasis_testing_write_ascii("mock.ini", mockinidata_final);
struct INIFILE *ini = ini_open("mock.ini");
ctx._stasis_ini_fp.delivery = ini;
ctx._stasis_ini_fp.delivery_path = realpath("mock.ini", NULL);
const char *sysconfdir = getenv("STASIS_SYSCONFDIR");
globals.sysconfdir = strdup(sysconfdir ? sysconfdir : STASIS_SYSCONFDIR);
- ctx.storage.root = strdup(cwd_workspace);
+ ctx.storage.root = strdup(TEST_WORKSPACE_DIR);
setenv("LANG", "C", 1);
bootstrap_build_info(&ctx);
@@ -246,10 +242,6 @@ int main(int argc, char *argv[]) {
STASIS_TEST_RUN(tests);
- chdir(cwd_start);
- if (rmtree(cwd_workspace)) {
- perror(cwd_workspace);
- }
delivery_free(&ctx);
globals_free();
STASIS_TEST_END_MAIN();
diff --git a/tests/test_recipe.c b/tests/test_recipe.c
index 3ea21ce..939ac7d 100644
--- a/tests/test_recipe.c
+++ b/tests/test_recipe.c
@@ -33,27 +33,27 @@ void test_recipe_clone() {
{.recipe_dir = "recipe_condaforge",
.url = "https://github.com/conda-forge/fitsverify-feedstock",
.gitref = "HEAD",
- .expect_type = RECIPE_TYPE_CONDA_FORGE,
+ .expect_type = RECIPE_STYLE_CONDA_FORGE,
.expect_return = 0},
{.recipe_dir = "recipe_astroconda",
.url = "https://github.com/astroconda/astroconda-contrib",
.gitref = "HEAD",
- .expect_type = RECIPE_TYPE_ASTROCONDA,
+ .expect_type = RECIPE_STYLE_ASTROCONDA,
.expect_return = 0},
{.recipe_dir = "recipe_generic",
.url = "local_repo",
.gitref = "HEAD",
- .expect_type = RECIPE_TYPE_GENERIC,
+ .expect_type = RECIPE_STYLE_GENERIC,
.expect_return = 0},
{.recipe_dir = "recipe_unknown",
.url = "https://github.com/astroconda/firewatch",
.gitref = "HEAD",
- .expect_type = RECIPE_TYPE_UNKNOWN,
+ .expect_type = RECIPE_STYLE_UNKNOWN,
.expect_return = 0},
{.recipe_dir = "recipe_broken",
.url = "123_BAD_BAD_BAD_456",
.gitref = "HEAD",
- .expect_type = RECIPE_TYPE_UNKNOWN,
+ .expect_type = RECIPE_STYLE_UNKNOWN,
.expect_return = 128},
};
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
@@ -76,7 +76,7 @@ void test_recipe_clone() {
// Ensure a path to the repository was returned in the result argument
STASIS_ASSERT(result_path != NULL, "result path should not be NULL");
// Verify the repository was detected as the correct recipe type
- STASIS_ASSERT(recipe_get_type(result_path) == test->expect_type, "repository detected as the wrong type");
+ STASIS_ASSERT(recipe_get_style(result_path) == test->expect_type, "repository detected as the wrong type");
if (test->expect_return == 0) {
// Verify the result path exists
diff --git a/tests/test_str.c b/tests/test_str.c
index 09d8809..26dcf4c 100644
--- a/tests/test_str.c
+++ b/tests/test_str.c
@@ -16,7 +16,7 @@ void test_to_short_version() {
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
char *result = to_short_version(tc[i].data);
STASIS_ASSERT_FATAL(result != NULL, "should not be NULL");
- //printf("%s[%zu], result: %s, expected: %s\n", __FUNCTION__, i, result, tc[i].expected);
+ printf("%s[%zu], result: %s, expected: %s\n", __func__, i, result, tc[i].expected);
STASIS_ASSERT(strcmp(result, tc[i].expected) == 0, "unexpected result");
guard_free(result);
}
@@ -110,12 +110,17 @@ void test_strchrdel() {
const struct testcase tc[] = {
{.data ="aaaabbbbcccc", .input = "ac", .expected = "bbbb"},
{.data = "1I 2have 3a 4pencil 5box.", .input = "1245", .expected = "I have 3a pencil box."},
+ {.data = "1I 2have 3a 4pencil 5box.", .input = "12345", .expected = "I have a pencil box."},
{.data = "\v\v\vI\t\f ha\tve a\t pen\tcil b\tox.", .input = " \f\t\v", "Ihaveapencilbox."},
};
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
char *data = strdup(tc[i].data);
+ printf("data before: %s\n", data);
+ debug_hexdump(data, strlen(data) + 1);
strchrdel(data, tc[i].input);
+ printf("data after: %s\n", data);
+ debug_hexdump(data, strlen(data) + 1);
STASIS_ASSERT(strcmp(data, tc[i].expected) == 0, "wrong status for condition");
guard_free(data);
}
@@ -184,7 +189,10 @@ void test_num_chars() {
{.data = "abc\t\ndef\nabc\ndef\n", .input = '\t', .expected = 1},
};
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
- STASIS_ASSERT(num_chars(tc[i].data, tc[i].input) == tc[i].expected, "incorrect number of characters detected");
+ const int count = num_chars(tc[i].data, tc[i].input);
+ SYSDEBUG("input[%zu] = '%s'", i, tc[i].data);
+ SYSDEBUG("result[%zu:'%c'] = %d", i, tc[i].input, count);
+ STASIS_ASSERT(count == tc[i].expected, "incorrect number of characters detected");
}
}
@@ -207,6 +215,13 @@ void test_split() {
};
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
char **result = split((char *) tc[i].data, tc[i].delim, tc[i].max_split);
+ if (tc[i].data) {
+ SYSDEBUG("input[%zu] = %s", i, tc[i].data);
+ for (size_t j = 0; result[j] != NULL; j++) {
+ SYSDEBUG("result[%zu][%zu] = %s", i, j, result[j]);
+ debug_hexdump(result[j], strlen(result[j]) + 1);
+ }
+ }
STASIS_ASSERT(strcmp_array((const char **) result, tc[i].expected) == 0, "Split failed");
guard_array_free(result);
}
@@ -225,8 +240,9 @@ void test_join() {
{.data = NULL, .delim = NULL, .expected = ""},
};
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
- char *result;
- result = join((char **) tc[i].data, tc[i].delim);
+ char *result = join((char **) tc[i].data, tc[i].delim);
+ SYSDEBUG("result[%zu] = '%s'", i, result ? result : "NULL");
+ debug_hexdump(result, strlen(result ? result : ""));
STASIS_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "failed to join array");
guard_free(result);
}
@@ -245,6 +261,8 @@ void test_join_ex() {
};
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
char *result = join_ex((char *) tc[i].delim, "a", "b", "c", "d", "e", NULL);
+ SYSDEBUG("result[%zu] = '%s'\n", i, result);
+ debug_hexdump(result, (int) strlen(result) + 1);
STASIS_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "failed to join array");
guard_free(result);
}
@@ -271,6 +289,9 @@ void test_substring_between() {
};
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
char *result = substring_between((char *) tc[i].data, tc[i].delim);
+ SYSDEBUG("input[%zu] = '%s'", i, tc[i].data ? tc[i].data : "NULL");
+ SYSDEBUG("result[%zu] = '%s'", i, result ? result : "NULL");
+ debug_hexdump(result, result ? strlen(result) + 1 : 0);
STASIS_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "unable to extract substring");
guard_free(result);
}
@@ -290,6 +311,16 @@ void test_strdeldup() {
};
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
char **result = strdeldup(tc[i].data);
+ if (tc[i].data && result) {
+ char *input_str = join((char **) tc[i].data, " ");
+ SYSDEBUG("input[%zu] = '%s'", i, input_str);
+ guard_free(input_str);
+
+ char *result_str = join(result, " ");
+ SYSDEBUG("result[%zu] = '%s'", i, result_str);
+ debug_hexdump(result_str, strlen(result_str));
+ guard_free(result_str);
+ }
STASIS_ASSERT(strcmp_array((const char **) result, tc[i].expected) == 0, "incorrect number of duplicates removed");
guard_array_free(result);
}
@@ -316,11 +347,14 @@ void test_lstrip() {
};
STASIS_ASSERT(lstrip(NULL) == NULL, "incorrect return type");
+ const size_t maxlen = 64;
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
- char *buf = calloc(255, sizeof(*buf));
- strncpy(buf, tc[i].data, 254);
- buf[254] = '\0';
+ char *buf = calloc(maxlen + 1, sizeof(*buf));
+ strncpy(buf, tc[i].data, maxlen);
char *result = lstrip(buf);
+ SYSDEBUG("input[%zu] = '%s'", i, buf);
+ SYSDEBUG("result[%zu] = '%s'", i, result ? result : "NULL");
+ debug_hexdump(result, maxlen);
STASIS_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "incorrect strip-from-left");
guard_free(buf);
}
@@ -341,11 +375,14 @@ void test_strip() {
};
STASIS_ASSERT(strip(NULL) == NULL, "incorrect return type");
+ const ssize_t maxlen = 64;
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
- char *buf = calloc(255, sizeof(*buf));
- strncpy(buf, tc[i].data, 254);
- buf[254] = '\0';
+ char *buf = calloc(maxlen + 1, sizeof(*buf));
+ strncpy(buf, tc[i].data, maxlen);
char *result = strip(buf);
+ SYSDEBUG("input[%zu] = '%s'", i, buf);
+ SYSDEBUG("result[%zu] = '%s'", i, result ? result : "NULL");
+ debug_hexdump(result, maxlen);
STASIS_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "incorrect strip-from-right");
guard_free(buf);
}
diff --git a/tests/test_utils.c b/tests/test_utils.c
index fc53f53..e1689dd 100644
--- a/tests/test_utils.c
+++ b/tests/test_utils.c
@@ -456,6 +456,52 @@ void test_pushd_popd_suggested_workflow() {
}
}
+void test_is_file_compressed() {
+ const char *filenames[] = {
+ "zstd", "bz2", "gz", "xz", "zip",
+ };
+ char datadir[PATH_MAX] = {0};
+ snprintf(datadir, sizeof(datadir), "%s/compression", TEST_DATA_DIR);
+
+ char inputfile[PATH_MAX] = {0};
+ for (size_t i = 0; i < sizeof(filenames) / sizeof(*filenames); i++) {
+ snprintf(inputfile, sizeof(inputfile), "%s/%s", datadir, filenames[i]);
+ const int compressed = is_file_compressed(inputfile);
+ SYSDEBUG("[%zu] is %s compressed? => %s", i, inputfile, compressed ? "Yes" : "No");
+ STASIS_ASSERT(compressed == true, "compression should have been detected");
+ }
+
+ snprintf(inputfile, sizeof(inputfile), "%s/none", datadir);
+ STASIS_ASSERT(is_file_compressed(inputfile) == false, "'none' file should not be detected as compressed data");
+
+ for (size_t i = 0; i < sizeof(filenames) / sizeof(*filenames); i++) {
+ char bytes[128];
+ if (get_random_bytes(bytes, sizeof(bytes))) {
+ SYSERROR("get_random_bytes failed: %s, %s", bytes, strerror(errno));
+ STASIS_ASSERT_FATAL(false, "get_random_bytes failed");
+ return;
+ }
+
+ FILE *fp = fopen(filenames[i], "wb");
+ if (!fp) {
+ SYSERROR("fopen failed: %s, %s", filenames[i], strerror(errno));
+ STASIS_ASSERT_FATAL(false, "fopen failed");
+ return;
+ }
+
+ bytes[0] = 'J';
+ const size_t bytes_written = fwrite(bytes, 1, sizeof(bytes), fp);
+ if (bytes_written != sizeof(bytes)) {
+ SYSERROR("fwrite failed: %s, %s", bytes, strerror(errno));
+ STASIS_ASSERT_FATAL(false, "fwrite failed");
+ return;
+ }
+ fclose(fp);
+
+ STASIS_ASSERT(is_file_compressed(filenames[i]) == false, "random data should not be detected as compressed");
+ }
+}
+
int main(int argc, char *argv[]) {
STASIS_TEST_BEGIN_MAIN();
@@ -479,6 +525,7 @@ int main(int argc, char *argv[]) {
test_dirstack,
test_pushd_popd,
test_pushd_popd_suggested_workflow,
+ test_is_file_compressed,
};
const char *ws = "workspace";
getcwd(cwd_start, sizeof(cwd_start) - 1);
diff --git a/tests/test_wheel.c b/tests/test_wheel.c
index e486b05..c9aff6a 100644
--- a/tests/test_wheel.c
+++ b/tests/test_wheel.c
@@ -175,17 +175,19 @@ int main(int argc, char *argv[]) {
delivery_get_conda_installer_url(&ctx, install_url, PATH_MAX);
delivery_get_conda_installer(&ctx, install_url);
delivery_install_conda(ctx.conda.installer_path, ctx.storage.conda_install_prefix);
+ delivery_conda_enable(&ctx);
guard_free(install_url);
if (conda_activate(ctx.storage.conda_install_prefix, "base")) {
SYSERROR("conda_activate failed");
exit(1);
}
- if (conda_exec("install -y boa conda-build")) {
+ if (conda_exec("install -y conda-build")) {
SYSERROR("conda_exec failed");
exit(1);
}
- if (conda_setup_headless()) {
+
+ if (conda_setup_headless(&ctx.conda.capabilities)) {
SYSERROR("conda_setup_headless failed");
exit(1);
}