summaryrefslogtreecommitdiff
path: root/libmailutils/tests/logstr.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmailutils/tests/logstr.c')
-rw-r--r--libmailutils/tests/logstr.c48
1 files changed, 46 insertions, 2 deletions
diff --git a/libmailutils/tests/logstr.c b/libmailutils/tests/logstr.c
index 7b6f96770..9628b7522 100644
--- a/libmailutils/tests/logstr.c
+++ b/libmailutils/tests/logstr.c
@@ -1,5 +1,5 @@
/* This file is part of GNU Mailutils test suite
- Copyright (C) 2017-2019 Free Software Foundation, Inc.
+ Copyright (C) 2017-2024 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -624,6 +624,49 @@ fmt_locus6 (mu_stream_t str)
mu_stream_printf (str, "default\n");
}
+/* Check the log prefix
+ Expected output:
+ LOG1: one
+ LOG2: two
+ prefix off
+ LOG2: prefix on
+ three
+ */
+static void
+check_prefix (mu_stream_t str)
+{
+ char *prefix[2] = { "LOG1", "LOG2" };
+ char *s;
+ int mode = MU_LOGMODE_PREFIX;
+
+ mu_stream_ioctl (str, MU_IOCTL_LOGSTREAM,
+ MU_IOCTL_LOGSTREAM_SET_PREFIX, prefix[0]);
+ mu_stream_ioctl (str, MU_IOCTL_LOGSTREAM,
+ MU_IOCTL_LOGSTREAM_SET_MODE, &mode);
+ mu_stream_printf (str, "one\n");
+
+ mu_stream_ioctl (str, MU_IOCTL_LOGSTREAM,
+ MU_IOCTL_LOGSTREAM_GET_PREFIX, &s);
+ if (!s || strcmp (s, prefix[0]))
+ {
+ mu_error ("%s:%d: wrong prefix returned", __FILE__, __LINE__);
+ }
+ free (s);
+
+ mu_stream_ioctl (str, MU_IOCTL_LOGSTREAM,
+ MU_IOCTL_LOGSTREAM_SET_PREFIX, prefix[1]);
+ mu_stream_printf (str, "two\n");
+
+ mu_stream_printf (str, "\033X<%d>prefix off\n",
+ MU_LOGMODE_PREFIX);
+ mu_stream_printf (str, "prefix on\n");
+
+ mu_stream_ioctl (str, MU_IOCTL_LOGSTREAM,
+ MU_IOCTL_LOGSTREAM_SET_PREFIX, NULL);
+ mu_stream_printf (str, "three\n");
+
+}
+
struct testcase
{
@@ -654,6 +697,7 @@ struct testcase testcases[] = {
{ "fmt: locus; restore defaults", fmt_locus4 },
{ "fmt: locus; restore defaults, display locus", fmt_locus5 },
{ "fmt: set locus", fmt_locus6 },
+ { "prefix", check_prefix },
{ NULL }
};
@@ -722,7 +766,7 @@ main (int argc, char **argv)
log_reset (log);
}
}
-
+ mu_stream_destroy (&log);
return 0;
}

Return to:

Send suggestions and report system problems to the System administrator.