diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-05-11 15:24:53 -0400 |
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-05-11 15:34:45 -0400 |
| commit | b7a60c5bed989a52a53b8b697203f55367f55a89 (patch) | |
| tree | 993173328bdf96eb469c2412241f202cdbc5cf53 /tests | |
| parent | 58d3ca17dcd3f8b3aeb50b8e4f24afc76d33ff26 (diff) | |
| download | stasis-b7a60c5bed989a52a53b8b697203f55367f55a89.tar.gz | |
Replace msg, perror, and fprintf with SYS message macrosuse-sys-macros
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_conda.c | 8 | ||||
| -rw-r--r-- | tests/test_system.c | 2 | ||||
| -rw-r--r-- | tests/test_utils.c | 4 | ||||
| -rw-r--r-- | tests/test_wheel.c | 38 |
4 files changed, 26 insertions, 26 deletions
diff --git a/tests/test_conda.c b/tests/test_conda.c index e32c9f2..f6ee2f8 100644 --- a/tests/test_conda.c +++ b/tests/test_conda.c @@ -146,11 +146,11 @@ void test_pip_index_provides() { int result = pkg_index_provides(PKG_USE_PIP, test->pindex, test->name, "."); STASIS_ASSERT(result == test->expected, "Unexpected result"); if (PKG_INDEX_PROVIDES_FAILED(result)) { - fprintf(stderr, "error: %s\n", pkg_index_provides_strerror(result)); + SYSERROR("%s", pkg_index_provides_strerror(result)); } else if (result == PKG_NOT_FOUND) { - fprintf(stderr, "package not found: '%s'\n", test->name); + SYSERROR("package not found: '%s'", test->name); } else { - printf("package found: '%s'\n", test->name); + SYSDEBUG("package found: '%s'", test->name); } } } @@ -208,7 +208,7 @@ int main(int argc, char *argv[]) { char ws[] = "workspace_XXXXXX"; if (!mkdtemp(ws)) { - perror("mkdtemp"); + SYSERROR("unable to mkdtemp: %s", strerror(errno)); exit(1); } getcwd(cwd_start, sizeof(cwd_start) - 1); diff --git a/tests/test_system.c b/tests/test_system.c index 9e4a862..cdef618 100644 --- a/tests/test_system.c +++ b/tests/test_system.c @@ -4,7 +4,7 @@ static int ascii_file_contains(const char *filename, const char *value) { int result = -1; char *contents = stasis_testing_read_ascii(filename); if (!contents) { - perror(filename); + SYSERROR("unable to read %s: %s", filename, strerror(errno)); return result; } result = strcmp(contents, value) == 0; diff --git a/tests/test_utils.c b/tests/test_utils.c index 119dea3..696e7ff 100644 --- a/tests/test_utils.c +++ b/tests/test_utils.c @@ -276,7 +276,7 @@ void test_file_readlines() { const char *data = "I am\na file\nwith multiple lines\nsee?\n"; FILE *fp = fopen(filename, "w"); if (!fp) { - perror(filename); + SYSERROR("unable to open file: %s, %s", filename, strerror(errno)); return; } if (fwrite(data, sizeof(*data), strlen(data), fp) != strlen(data)) { @@ -375,7 +375,7 @@ void test_rmtree() { snprintf(path, sizeof(path), "%s/%s", root, tree[i]); snprintf(mockfile, sizeof(mockfile), "%s/%zu.txt", path, i); if (mkdir(path, 0755)) { - perror(path); + SYSERROR("mkdir failed: %s, %s", path, strerror(errno)); STASIS_ASSERT(false, NULL); } touch(mockfile); diff --git a/tests/test_wheel.c b/tests/test_wheel.c index 525251d..e486b05 100644 --- a/tests/test_wheel.c +++ b/tests/test_wheel.c @@ -80,27 +80,27 @@ static void mock_python_package() { mkdir("testpkg/src", 0755); mkdir("testpkg/src/testpkg", 0755); if (touch("testpkg/src/testpkg/__init__.py")) { - fprintf(stderr, "unable to write __init__.py"); + SYSERROR("unable to write __init__.py"); exit(1); } if (touch("testpkg/README.md")) { - fprintf(stderr, "unable to write README.md"); + SYSERROR("unable to write README.md"); exit(1); } if (stasis_testing_write_ascii("testpkg/pyproject.toml", pyproject_toml_data)) { - perror("unable to write pyproject.toml"); + SYSERROR("unable to write pyproject.toml"); exit(1); } if (stasis_testing_write_ascii("testpkg/README.md", readme)) { - perror("unable to write readme"); + SYSERROR("unable to write readme"); exit(1); } if (pip_exec("install build")) { - fprintf(stderr, "unable to install build tool using pip\n"); + SYSERROR("unable to install build tool using pip"); exit(1); } if (python_exec("-m build -w ./testpkg")) { - fprintf(stderr, "unable build test package"); + SYSERROR("unable build test package"); exit(1); } } @@ -113,7 +113,7 @@ int main(int argc, char *argv[]) { char ws[] = "workspace_XXXXXX"; if (!mkdtemp(ws)) { - perror("mkdtemp"); + SYSERROR("mkdtemp failed: %s, %s", ws, strerror(errno)); exit(1); } getcwd(cwd_start, sizeof(cwd_start) - 1); @@ -145,29 +145,29 @@ int main(int argc, char *argv[]) { ctx.storage.root = strdup(cwd_workspace); char *cfgfile = join((char *[]) {globals.sysconfdir, "stasis.ini", NULL}, "/"); if (!cfgfile) { - perror("unable to create path to global config"); + SYSERROR("unable to create path to global config"); exit(1); } ctx._stasis_ini_fp.cfg = ini_open(cfgfile); if (!ctx._stasis_ini_fp.cfg) { - fprintf(stderr, "unable to open config file, %s\n", cfgfile); + SYSERROR("unable to open config file, %s", cfgfile); exit(1); } ctx._stasis_ini_fp.cfg_path = realpath(cfgfile, NULL); if (!ctx._stasis_ini_fp.cfg_path) { - fprintf(stderr, "unable to determine absolute path of config, %s\n", cfgfile); + SYSERROR("unable to determine absolute path of config, %s", cfgfile); exit(1); } guard_free(cfgfile); setenv("LANG", "C", 1); if (bootstrap_build_info(&ctx)) { - fprintf(stderr, "bootstrap_build_info failed\n"); + SYSERROR("bootstrap_build_info failed"); exit(1); } if (delivery_init(&ctx, INI_READ_RENDER)) { - fprintf(stderr, "delivery_init failed\n"); + SYSERROR("delivery_init failed"); exit(1); } @@ -178,23 +178,23 @@ int main(int argc, char *argv[]) { guard_free(install_url); if (conda_activate(ctx.storage.conda_install_prefix, "base")) { - fprintf(stderr, "conda_activate failed\n"); + SYSERROR("conda_activate failed"); exit(1); } if (conda_exec("install -y boa conda-build")) { - fprintf(stderr, "conda_exec failed\n"); + SYSERROR("conda_exec failed"); exit(1); } if (conda_setup_headless()) { - fprintf(stderr, "conda_setup_headless failed\n"); + SYSERROR("conda_setup_headless failed"); exit(1); } if (conda_env_create("testpkg", ctx.meta.python, NULL)) { - fprintf(stderr, "conda_env_create failed\n"); + SYSERROR("conda_env_create failed"); exit(1); } if (conda_activate(ctx.storage.conda_install_prefix, "testpkg")) { - fprintf(stderr, "conda_activate failed\n"); + SYSERROR("conda_activate failed"); exit(1); } @@ -203,11 +203,11 @@ int main(int argc, char *argv[]) { STASIS_TEST_RUN(tests); if (chdir(cwd_start) < 0) { - fprintf(stderr, "chdir failed\n"); + SYSERROR("chdir failed: %s, %s", cwd_start, strerror(errno)); exit(1); } if (rmtree(cwd_workspace)) { - perror(cwd_workspace); + SYSERROR("rmtree failed: %s, %s", cwd_workspace, strerror(errno)); } delivery_free(&ctx); globals_free(); |
