diff options
author | Joseph Hunkeler <jhunkeler@users.noreply.github.com> | 2024-07-15 10:07:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-15 10:07:25 -0400 |
commit | 07dc44efdc5c2fbc2b34c969e623d3b0bc0df15a (patch) | |
tree | 1f41c27e50baeee149b59b8c3d37a9c72cbd0ded /src/delivery.c | |
parent | 70cd78cdef69237ba3c511b9e091715ec6d093e5 (diff) | |
download | stasis-07dc44efdc5c2fbc2b34c969e623d3b0bc0df15a.tar.gz |
Unit tests (#12)
* Change return value of conda_setup_headless() from void to int
* Replace exit() with return;
* Return early if unpacking the micromamba binary fails
* Exit program when pointer to INIFILE is NULL.
* Validation function cannot otherwise proceed
* The way the logic is set up I've decided to duplicate the installation code for now until I find time to revise it
* The only meaningful difference between a "fresh start" and reusing the conda installation is a rmtree().
* Exposes STASIS_DOWNLOAD_TIMEOUT environment variable
* Sets the connection timeout for libcurl to 30, instead of 300.
* Export ini_section_create() function
* Add download() tests
* Add conda_*() tests
* Add boilerplate source file for test framework
* Fixes segfault reported by @GeorgeJCleary (#10)
* The key is now an array index. When key is -1, the env variable is not defined.
* Free resources only when continue on error is disabled (#11)
* Fix segfault due to premature shutdown/cleanup
* If conda_setup_headless cannot succeed, die
* Set STASIS_SYSCONFDIR for tests
Diffstat (limited to 'src/delivery.c')
-rw-r--r-- | src/delivery.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/delivery.c b/src/delivery.c index 0c20550..b27ab08 100644 --- a/src/delivery.c +++ b/src/delivery.c @@ -420,6 +420,10 @@ static int populate_mission_ini(struct Delivery **ctx) { } void validate_delivery_ini(struct INIFILE *ini) { + if (!ini) { + SYSERROR("%s", "INIFILE is NULL!"); + exit(1); + } if (ini_section_search(&ini, INI_SEARCH_EXACT, "meta")) { ini_has_key_required(ini, "meta", "name"); ini_has_key_required(ini, "meta", "version"); @@ -1428,6 +1432,18 @@ void delivery_install_conda(char *install_script, char *conda_install_dir) { fprintf(stderr, "conda installation failed\n"); exit(1); } + } else { + // Proceed with the installation + // -b = batch mode (non-interactive) + char cmd[PATH_MAX] = {0}; + snprintf(cmd, sizeof(cmd) - 1, "%s %s -b -p %s", + find_program("bash"), + install_script, + conda_install_dir); + if (shell_safe(&proc, cmd)) { + fprintf(stderr, "conda installation failed\n"); + exit(1); + } } } else { msg(STASIS_MSG_L3, "Conda removal disabled by configuration\n"); @@ -1451,7 +1467,10 @@ void delivery_conda_enable(struct Delivery *ctx, char *conda_install_dir) { exit(1); } - conda_setup_headless(); + if (conda_setup_headless()) { + // no COE check. this call must succeed. + exit(1); + } } void delivery_defer_packages(struct Delivery *ctx, int type) { |