aboutgitcodelistschat:MatrixIRC
path: root/tests/unit/util.c
diff options
context:
space:
mode:
authorAlice Frosi <afrosi@redhat.com>2023-05-10 15:19:49 +0200
committerAlice Frosi <afrosi@redhat.com>2023-05-11 10:52:53 +0200
commit94df2efe2d2221bf0c4d77510142c95283d76f2b (patch)
tree68a137ca71de1f8d5f552d78de3ea3111230067b /tests/unit/util.c
parentb29288b8b000730bbd416b0e1f4f4c694e346e20 (diff)
downloadseitan-94df2efe2d2221bf0c4d77510142c95283d76f2b.tar
seitan-94df2efe2d2221bf0c4d77510142c95283d76f2b.tar.gz
seitan-94df2efe2d2221bf0c4d77510142c95283d76f2b.tar.bz2
seitan-94df2efe2d2221bf0c4d77510142c95283d76f2b.tar.lz
seitan-94df2efe2d2221bf0c4d77510142c95283d76f2b.tar.xz
seitan-94df2efe2d2221bf0c4d77510142c95283d76f2b.tar.zst
seitan-94df2efe2d2221bf0c4d77510142c95283d76f2b.zip
Clean-up error message and test
Refactoring error messages: - standardize error messages and functions - return on error instead of exit - test error when target doesn't exist - include ability to capture stderr and stdout in the tests
Diffstat (limited to 'tests/unit/util.c')
-rw-r--r--tests/unit/util.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/unit/util.c b/tests/unit/util.c
index 45171f2..5c36c54 100644
--- a/tests/unit/util.c
+++ b/tests/unit/util.c
@@ -30,6 +30,8 @@ int pipefd[2];
pid_t pid;
char path[PATH_MAX] = "/tmp/test-seitan";
struct gluten gluten;
+char stderr_buff[BUFSIZ];
+char stdout_buff[BUFSIZ];
int install_notification_filter(struct args_target *at)
{
@@ -231,3 +233,19 @@ void teardown()
munmap(at, sizeof(struct args_target));
unlink(path);
}
+
+void ck_stderr()
+{
+ setbuf(stderr, stderr_buff);
+}
+
+void ck_stdout()
+{
+ setbuf(stdout, stdout_buff);
+}
+
+void ck_error_msg(char *s)
+{
+ ck_assert_msg(strstr(stderr_buff, s) != NULL, "err=\"%s\" doesn't contain \"%s\" ",
+ stderr_buff, s);
+}