135c4bbdfSmrg/**
235c4bbdfSmrg * Copyright © 2012 Canonical, Ltd.
335c4bbdfSmrg *
435c4bbdfSmrg *  Permission is hereby granted, free of charge, to any person obtaining a
535c4bbdfSmrg *  copy of this software and associated documentation files (the "Software"),
635c4bbdfSmrg *  to deal in the Software without restriction, including without limitation
735c4bbdfSmrg *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
835c4bbdfSmrg *  and/or sell copies of the Software, and to permit persons to whom the
935c4bbdfSmrg *  Software is furnished to do so, subject to the following conditions:
1035c4bbdfSmrg *
1135c4bbdfSmrg *  The above copyright notice and this permission notice (including the next
1235c4bbdfSmrg *  paragraph) shall be included in all copies or substantial portions of the
1335c4bbdfSmrg *  Software.
1435c4bbdfSmrg *
1535c4bbdfSmrg *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1635c4bbdfSmrg *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1735c4bbdfSmrg *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1835c4bbdfSmrg *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1935c4bbdfSmrg *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2035c4bbdfSmrg *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2135c4bbdfSmrg *  DEALINGS IN THE SOFTWARE.
2235c4bbdfSmrg */
2335c4bbdfSmrg
24ed6184dfSmrg/* Test relies on assert() */
25ed6184dfSmrg#undef NDEBUG
26ed6184dfSmrg
2735c4bbdfSmrg#ifdef HAVE_DIX_CONFIG_H
2835c4bbdfSmrg#include <dix-config.h>
2935c4bbdfSmrg#endif
3035c4bbdfSmrg
3135c4bbdfSmrg#include <stdint.h>
3235c4bbdfSmrg#include <unistd.h>
3335c4bbdfSmrg#include "assert.h"
3435c4bbdfSmrg#include "misc.h"
3535c4bbdfSmrg
361b5d61b8Smrg#include "tests-common.h"
371b5d61b8Smrg
3835c4bbdfSmrgstruct number_format_test {
3935c4bbdfSmrg    uint64_t number;
4035c4bbdfSmrg    char string[21];
4135c4bbdfSmrg    char hex_string[17];
4235c4bbdfSmrg};
4335c4bbdfSmrg
4435c4bbdfSmrgstruct signed_number_format_test {
4535c4bbdfSmrg    int64_t number;
4635c4bbdfSmrg    char string[21];
4735c4bbdfSmrg};
4835c4bbdfSmrg
4935c4bbdfSmrgstruct float_number_format_test {
5035c4bbdfSmrg    double number;
5135c4bbdfSmrg    char string[21];
5235c4bbdfSmrg};
5335c4bbdfSmrg
5435c4bbdfSmrgstatic Bool
5535c4bbdfSmrgcheck_signed_number_format_test(long int number)
5635c4bbdfSmrg{
5735c4bbdfSmrg    char string[21];
5835c4bbdfSmrg    char expected[21];
5935c4bbdfSmrg
6035c4bbdfSmrg    sprintf(expected, "%ld", number);
6135c4bbdfSmrg    FormatInt64(number, string);
6235c4bbdfSmrg    if(strncmp(string, expected, 21) != 0) {
6335c4bbdfSmrg        fprintf(stderr, "Failed to convert %jd to decimal string (expected %s but got %s)\n",
6435c4bbdfSmrg                (intmax_t) number, expected, string);
6535c4bbdfSmrg        return FALSE;
6635c4bbdfSmrg    }
6735c4bbdfSmrg
6835c4bbdfSmrg    return TRUE;
6935c4bbdfSmrg}
7035c4bbdfSmrg
7135c4bbdfSmrgstatic Bool
7235c4bbdfSmrgcheck_float_format_test(double number)
7335c4bbdfSmrg{
7435c4bbdfSmrg    char string[21];
7535c4bbdfSmrg    char expected[21];
7635c4bbdfSmrg
7735c4bbdfSmrg    /* we currently always print float as .2f */
7835c4bbdfSmrg    sprintf(expected, "%.2f", number);
7935c4bbdfSmrg
8035c4bbdfSmrg    FormatDouble(number, string);
8135c4bbdfSmrg    if(strncmp(string, expected, 21) != 0) {
8235c4bbdfSmrg        fprintf(stderr, "Failed to convert %f to string (%s vs %s)\n",
8335c4bbdfSmrg                number, expected, string);
8435c4bbdfSmrg        return FALSE;
8535c4bbdfSmrg    }
8635c4bbdfSmrg
8735c4bbdfSmrg    return TRUE;
8835c4bbdfSmrg}
8935c4bbdfSmrg
9035c4bbdfSmrgstatic Bool
9135c4bbdfSmrgcheck_number_format_test(long unsigned int number)
9235c4bbdfSmrg{
9335c4bbdfSmrg    char string[21];
9435c4bbdfSmrg    char expected[21];
9535c4bbdfSmrg
9635c4bbdfSmrg    sprintf(expected, "%lu", number);
9735c4bbdfSmrg
9835c4bbdfSmrg    FormatUInt64(number, string);
9935c4bbdfSmrg    if(strncmp(string, expected, 21) != 0) {
10035c4bbdfSmrg        fprintf(stderr, "Failed to convert %ju to decimal string (%s vs %s)\n",
10135c4bbdfSmrg                (intmax_t) number, expected, string);
10235c4bbdfSmrg        return FALSE;
10335c4bbdfSmrg    }
10435c4bbdfSmrg
10535c4bbdfSmrg    sprintf(expected, "%lx", number);
10635c4bbdfSmrg    FormatUInt64Hex(number, string);
10735c4bbdfSmrg    if(strncmp(string, expected, 17) != 0) {
10835c4bbdfSmrg        fprintf(stderr, "Failed to convert %ju to hexadecimal string (%s vs %s)\n",
10935c4bbdfSmrg                (intmax_t) number, expected, string);
11035c4bbdfSmrg        return FALSE;
11135c4bbdfSmrg    }
11235c4bbdfSmrg
11335c4bbdfSmrg    return TRUE;
11435c4bbdfSmrg}
11535c4bbdfSmrg
11635c4bbdfSmrg/* FIXME: max range stuff */
11735c4bbdfSmrgdouble float_tests[] = { 0, 5, 0.1, 0.01, 5.2342, 10.2301,
11835c4bbdfSmrg                         -1, -2.00, -0.6023, -1203.30
11935c4bbdfSmrg                        };
12035c4bbdfSmrg
12135c4bbdfSmrg#pragma GCC diagnostic push
12235c4bbdfSmrg#pragma GCC diagnostic ignored "-Woverflow"
12335c4bbdfSmrg
12435c4bbdfSmrgstatic void
12535c4bbdfSmrgnumber_formatting(void)
12635c4bbdfSmrg{
12735c4bbdfSmrg    int i;
12835c4bbdfSmrg    long unsigned int unsigned_tests[] = { 0,/* Zero */
12935c4bbdfSmrg                                           5, /* Single digit number */
13035c4bbdfSmrg                                           12, /* Two digit decimal number */
13135c4bbdfSmrg                                           37, /* Two digit hex number */
13235c4bbdfSmrg                                           0xC90B2, /* Large < 32 bit number */
13335c4bbdfSmrg                                           0x15D027BF211B37A, /* Large > 32 bit number */
13435c4bbdfSmrg                                           0xFFFFFFFFFFFFFFFF, /* Maximum 64-bit number */
13535c4bbdfSmrg    };
13635c4bbdfSmrg
13735c4bbdfSmrg    long int signed_tests[] = { 0,/* Zero */
13835c4bbdfSmrg                                5, /* Single digit number */
13935c4bbdfSmrg                                12, /* Two digit decimal number */
14035c4bbdfSmrg                                37, /* Two digit hex number */
14135c4bbdfSmrg                                0xC90B2, /* Large < 32 bit number */
14235c4bbdfSmrg                                0x15D027BF211B37A, /* Large > 32 bit number */
14335c4bbdfSmrg                                0x7FFFFFFFFFFFFFFF, /* Maximum 64-bit signed number */
14435c4bbdfSmrg                                -1, /* Single digit number */
14535c4bbdfSmrg                                -12, /* Two digit decimal number */
14635c4bbdfSmrg                                -0xC90B2, /* Large < 32 bit number */
14735c4bbdfSmrg                                -0x15D027BF211B37A, /* Large > 32 bit number */
14835c4bbdfSmrg                                -0x7FFFFFFFFFFFFFFF, /* Maximum 64-bit signed number */
14935c4bbdfSmrg    } ;
15035c4bbdfSmrg
1511b5d61b8Smrg    for (i = 0; i < ARRAY_SIZE(unsigned_tests); i++)
15235c4bbdfSmrg        assert(check_number_format_test(unsigned_tests[i]));
15335c4bbdfSmrg
1541b5d61b8Smrg    for (i = 0; i < ARRAY_SIZE(signed_tests); i++)
15535c4bbdfSmrg        assert(check_signed_number_format_test(signed_tests[i]));
15635c4bbdfSmrg
1571b5d61b8Smrg    for (i = 0; i < ARRAY_SIZE(float_tests); i++)
15835c4bbdfSmrg        assert(check_float_format_test(float_tests[i]));
15935c4bbdfSmrg}
16035c4bbdfSmrg#pragma GCC diagnostic pop
16135c4bbdfSmrg
16235c4bbdfSmrg#pragma GCC diagnostic push
16335c4bbdfSmrg#pragma GCC diagnostic ignored "-Wformat-security"
16435c4bbdfSmrg#pragma GCC diagnostic ignored "-Wformat"
16535c4bbdfSmrg#pragma GCC diagnostic ignored "-Wformat-extra-args"
16635c4bbdfSmrgstatic void logging_format(void)
16735c4bbdfSmrg{
16835c4bbdfSmrg    const char *log_file_path = "/tmp/Xorg-logging-test.log";
16935c4bbdfSmrg    const char *str = "%s %d %u %% %p %i";
17035c4bbdfSmrg    char buf[1024];
17135c4bbdfSmrg    int i;
17235c4bbdfSmrg    unsigned int ui;
17335c4bbdfSmrg    long li;
17435c4bbdfSmrg    unsigned long lui;
17535c4bbdfSmrg    FILE *f;
17635c4bbdfSmrg    char read_buf[2048];
17735c4bbdfSmrg    char *logmsg;
17835c4bbdfSmrg    uintptr_t ptr;
17935c4bbdfSmrg
18035c4bbdfSmrg    /* set up buf to contain ".....end" */
18135c4bbdfSmrg    memset(buf, '.', sizeof(buf));
18235c4bbdfSmrg    strcpy(&buf[sizeof(buf) - 4], "end");
18335c4bbdfSmrg
18435c4bbdfSmrg    LogInit(log_file_path, NULL);
1851b5d61b8Smrg    assert((f = fopen(log_file_path, "r")));
18635c4bbdfSmrg
18735c4bbdfSmrg#define read_log_msg(msg) do {                                  \
18835c4bbdfSmrg        msg = fgets(read_buf, sizeof(read_buf), f);             \
18935c4bbdfSmrg        assert(msg != NULL);                                   \
19035c4bbdfSmrg        msg = strchr(read_buf, ']');                            \
19135c4bbdfSmrg        assert(msg != NULL);                                    \
19235c4bbdfSmrg        assert(strlen(msg) > 2);                                \
19335c4bbdfSmrg        msg = msg + 2; /* advance past [time.stamp] */          \
19435c4bbdfSmrg    } while (0)
19535c4bbdfSmrg
19635c4bbdfSmrg    /* boring test message */
19735c4bbdfSmrg    LogMessageVerbSigSafe(X_ERROR, -1, "test message\n");
19835c4bbdfSmrg    read_log_msg(logmsg);
19935c4bbdfSmrg    assert(strcmp(logmsg, "(EE) test message\n") == 0);
20035c4bbdfSmrg
20135c4bbdfSmrg    /* long buf is truncated to "....en\n" */
20235c4bbdfSmrg    LogMessageVerbSigSafe(X_ERROR, -1, buf);
20335c4bbdfSmrg    read_log_msg(logmsg);
20435c4bbdfSmrg    assert(strcmp(&logmsg[strlen(logmsg) - 3], "en\n") == 0);
20535c4bbdfSmrg
20635c4bbdfSmrg    /* same thing, this time as string substitution */
20735c4bbdfSmrg    LogMessageVerbSigSafe(X_ERROR, -1, "%s", buf);
20835c4bbdfSmrg    read_log_msg(logmsg);
20935c4bbdfSmrg    assert(strcmp(&logmsg[strlen(logmsg) - 3], "en\n") == 0);
21035c4bbdfSmrg
21135c4bbdfSmrg    /* strings containing placeholders should just work */
21235c4bbdfSmrg    LogMessageVerbSigSafe(X_ERROR, -1, "%s\n", str);
21335c4bbdfSmrg    read_log_msg(logmsg);
21435c4bbdfSmrg    assert(strcmp(logmsg, "(EE) %s %d %u %% %p %i\n") == 0);
21535c4bbdfSmrg
21635c4bbdfSmrg    /* literal % */
21735c4bbdfSmrg    LogMessageVerbSigSafe(X_ERROR, -1, "test %%\n");
21835c4bbdfSmrg    read_log_msg(logmsg);
21935c4bbdfSmrg    assert(strcmp(logmsg, "(EE) test %\n") == 0);
22035c4bbdfSmrg
22135c4bbdfSmrg    /* character */
22235c4bbdfSmrg    LogMessageVerbSigSafe(X_ERROR, -1, "test %c\n", 'a');
22335c4bbdfSmrg    read_log_msg(logmsg);
22435c4bbdfSmrg    assert(strcmp(logmsg, "(EE) test a\n") == 0);
22535c4bbdfSmrg
22635c4bbdfSmrg    /* something unsupported % */
22735c4bbdfSmrg    LogMessageVerbSigSafe(X_ERROR, -1, "test %Q\n");
22835c4bbdfSmrg    read_log_msg(logmsg);
22935c4bbdfSmrg    assert(strstr(logmsg, "BUG") != NULL);
23035c4bbdfSmrg    LogMessageVerbSigSafe(X_ERROR, -1, "\n");
23135c4bbdfSmrg    fseek(f, 0, SEEK_END);
23235c4bbdfSmrg
23335c4bbdfSmrg    /* string substitution */
23435c4bbdfSmrg    LogMessageVerbSigSafe(X_ERROR, -1, "%s\n", "substituted string");
23535c4bbdfSmrg    read_log_msg(logmsg);
23635c4bbdfSmrg    assert(strcmp(logmsg, "(EE) substituted string\n") == 0);
23735c4bbdfSmrg
23835c4bbdfSmrg    /* Invalid format */
23935c4bbdfSmrg    LogMessageVerbSigSafe(X_ERROR, -1, "%4", 4);
24035c4bbdfSmrg    read_log_msg(logmsg);
24135c4bbdfSmrg    assert(strcmp(logmsg, "(EE) ") == 0);
24235c4bbdfSmrg    LogMessageVerbSigSafe(X_ERROR, -1, "\n");
24335c4bbdfSmrg    fseek(f, 0, SEEK_END);
24435c4bbdfSmrg
24535c4bbdfSmrg    /* %hld is bogus */
24635c4bbdfSmrg    LogMessageVerbSigSafe(X_ERROR, -1, "%hld\n", 4);
24735c4bbdfSmrg    read_log_msg(logmsg);
24835c4bbdfSmrg    assert(strstr(logmsg, "BUG") != NULL);
24935c4bbdfSmrg    LogMessageVerbSigSafe(X_ERROR, -1, "\n");
25035c4bbdfSmrg    fseek(f, 0, SEEK_END);
25135c4bbdfSmrg
25235c4bbdfSmrg    /* number substitution */
25335c4bbdfSmrg    ui = 0;
25435c4bbdfSmrg    do {
25535c4bbdfSmrg        char expected[30];
25635c4bbdfSmrg        sprintf(expected, "(EE) %u\n", ui);
25735c4bbdfSmrg        LogMessageVerbSigSafe(X_ERROR, -1, "%u\n", ui);
25835c4bbdfSmrg        read_log_msg(logmsg);
25935c4bbdfSmrg        assert(strcmp(logmsg, expected) == 0);
26035c4bbdfSmrg
26135c4bbdfSmrg        sprintf(expected, "(EE) %x\n", ui);
26235c4bbdfSmrg        LogMessageVerbSigSafe(X_ERROR, -1, "%x\n", ui);
26335c4bbdfSmrg        read_log_msg(logmsg);
26435c4bbdfSmrg        assert(strcmp(logmsg, expected) == 0);
26535c4bbdfSmrg
26635c4bbdfSmrg        if (ui == 0)
26735c4bbdfSmrg            ui = 1;
26835c4bbdfSmrg        else
26935c4bbdfSmrg            ui <<= 1;
27035c4bbdfSmrg    } while(ui);
27135c4bbdfSmrg
27235c4bbdfSmrg    lui = 0;
27335c4bbdfSmrg    do {
27435c4bbdfSmrg        char expected[30];
27535c4bbdfSmrg        sprintf(expected, "(EE) %lu\n", lui);
27635c4bbdfSmrg        LogMessageVerbSigSafe(X_ERROR, -1, "%lu\n", lui);
27735c4bbdfSmrg        read_log_msg(logmsg);
27835c4bbdfSmrg
27935c4bbdfSmrg        sprintf(expected, "(EE) %lld\n", (unsigned long long)ui);
28035c4bbdfSmrg        LogMessageVerbSigSafe(X_ERROR, -1, "%lld\n", (unsigned long long)ui);
28135c4bbdfSmrg        read_log_msg(logmsg);
28235c4bbdfSmrg        assert(strcmp(logmsg, expected) == 0);
28335c4bbdfSmrg
28435c4bbdfSmrg        sprintf(expected, "(EE) %lx\n", lui);
28535c4bbdfSmrg        printf("%s\n", expected);
28635c4bbdfSmrg        LogMessageVerbSigSafe(X_ERROR, -1, "%lx\n", lui);
28735c4bbdfSmrg        read_log_msg(logmsg);
28835c4bbdfSmrg        assert(strcmp(logmsg, expected) == 0);
28935c4bbdfSmrg
29035c4bbdfSmrg        sprintf(expected, "(EE) %llx\n", (unsigned long long)ui);
29135c4bbdfSmrg        LogMessageVerbSigSafe(X_ERROR, -1, "%llx\n", (unsigned long long)ui);
29235c4bbdfSmrg        read_log_msg(logmsg);
29335c4bbdfSmrg        assert(strcmp(logmsg, expected) == 0);
29435c4bbdfSmrg
29535c4bbdfSmrg        if (lui == 0)
29635c4bbdfSmrg            lui = 1;
29735c4bbdfSmrg        else
29835c4bbdfSmrg            lui <<= 1;
29935c4bbdfSmrg    } while(lui);
30035c4bbdfSmrg
30135c4bbdfSmrg    /* signed number substitution */
30235c4bbdfSmrg    i = 0;
30335c4bbdfSmrg    do {
30435c4bbdfSmrg        char expected[30];
30535c4bbdfSmrg        sprintf(expected, "(EE) %d\n", i);
30635c4bbdfSmrg        LogMessageVerbSigSafe(X_ERROR, -1, "%d\n", i);
30735c4bbdfSmrg        read_log_msg(logmsg);
30835c4bbdfSmrg        assert(strcmp(logmsg, expected) == 0);
30935c4bbdfSmrg
31035c4bbdfSmrg        sprintf(expected, "(EE) %d\n", i | INT_MIN);
31135c4bbdfSmrg        LogMessageVerbSigSafe(X_ERROR, -1, "%d\n", i | INT_MIN);
31235c4bbdfSmrg        read_log_msg(logmsg);
31335c4bbdfSmrg        assert(strcmp(logmsg, expected) == 0);
31435c4bbdfSmrg
31535c4bbdfSmrg        if (i == 0)
31635c4bbdfSmrg            i = 1;
31735c4bbdfSmrg        else
31835c4bbdfSmrg            i <<= 1;
31935c4bbdfSmrg    } while(i > INT_MIN);
32035c4bbdfSmrg
32135c4bbdfSmrg    li = 0;
32235c4bbdfSmrg    do {
32335c4bbdfSmrg        char expected[30];
32435c4bbdfSmrg        sprintf(expected, "(EE) %ld\n", li);
32535c4bbdfSmrg        LogMessageVerbSigSafe(X_ERROR, -1, "%ld\n", li);
32635c4bbdfSmrg        read_log_msg(logmsg);
32735c4bbdfSmrg        assert(strcmp(logmsg, expected) == 0);
32835c4bbdfSmrg
32935c4bbdfSmrg        sprintf(expected, "(EE) %ld\n", li | LONG_MIN);
33035c4bbdfSmrg        LogMessageVerbSigSafe(X_ERROR, -1, "%ld\n", li | LONG_MIN);
33135c4bbdfSmrg        read_log_msg(logmsg);
33235c4bbdfSmrg        assert(strcmp(logmsg, expected) == 0);
33335c4bbdfSmrg
33435c4bbdfSmrg        sprintf(expected, "(EE) %lld\n", (long long)li);
33535c4bbdfSmrg        LogMessageVerbSigSafe(X_ERROR, -1, "%lld\n", (long long)li);
33635c4bbdfSmrg        read_log_msg(logmsg);
33735c4bbdfSmrg        assert(strcmp(logmsg, expected) == 0);
33835c4bbdfSmrg
33935c4bbdfSmrg        sprintf(expected, "(EE) %lld\n", (long long)(li | LONG_MIN));
34035c4bbdfSmrg        LogMessageVerbSigSafe(X_ERROR, -1, "%lld\n", (long long)(li | LONG_MIN));
34135c4bbdfSmrg        read_log_msg(logmsg);
34235c4bbdfSmrg        assert(strcmp(logmsg, expected) == 0);
34335c4bbdfSmrg
34435c4bbdfSmrg        if (li == 0)
34535c4bbdfSmrg            li = 1;
34635c4bbdfSmrg        else
34735c4bbdfSmrg            li <<= 1;
34835c4bbdfSmrg    } while(li > LONG_MIN);
34935c4bbdfSmrg
35035c4bbdfSmrg
35135c4bbdfSmrg    /* pointer substitution */
35235c4bbdfSmrg    /* we print a null-pointer differently to printf */
35335c4bbdfSmrg    LogMessageVerbSigSafe(X_ERROR, -1, "%p\n", NULL);
35435c4bbdfSmrg    read_log_msg(logmsg);
35535c4bbdfSmrg    assert(strcmp(logmsg, "(EE) 0x0\n") == 0);
35635c4bbdfSmrg
35735c4bbdfSmrg    ptr = 1;
35835c4bbdfSmrg    do {
35935c4bbdfSmrg        char expected[30];
36035c4bbdfSmrg#ifdef __sun /* Solaris doesn't autoadd "0x" to %p format */
36135c4bbdfSmrg        sprintf(expected, "(EE) 0x%p\n", (void*)ptr);
36235c4bbdfSmrg#else
36335c4bbdfSmrg        sprintf(expected, "(EE) %p\n", (void*)ptr);
36435c4bbdfSmrg#endif
36535c4bbdfSmrg        LogMessageVerbSigSafe(X_ERROR, -1, "%p\n", (void*)ptr);
36635c4bbdfSmrg        read_log_msg(logmsg);
36735c4bbdfSmrg        assert(strcmp(logmsg, expected) == 0);
36835c4bbdfSmrg        ptr <<= 1;
36935c4bbdfSmrg    } while(ptr);
37035c4bbdfSmrg
37135c4bbdfSmrg
3721b5d61b8Smrg    for (i = 0; i < ARRAY_SIZE(float_tests); i++) {
37335c4bbdfSmrg        double d = float_tests[i];
37435c4bbdfSmrg        char expected[30];
37535c4bbdfSmrg        sprintf(expected, "(EE) %.2f\n", d);
37635c4bbdfSmrg        LogMessageVerbSigSafe(X_ERROR, -1, "%f\n", d);
37735c4bbdfSmrg        read_log_msg(logmsg);
37835c4bbdfSmrg        assert(strcmp(logmsg, expected) == 0);
37935c4bbdfSmrg
38035c4bbdfSmrg        /* test for length modifiers, we just ignore them atm */
38135c4bbdfSmrg        LogMessageVerbSigSafe(X_ERROR, -1, "%.3f\n", d);
38235c4bbdfSmrg        read_log_msg(logmsg);
38335c4bbdfSmrg        assert(strcmp(logmsg, expected) == 0);
38435c4bbdfSmrg
38535c4bbdfSmrg        LogMessageVerbSigSafe(X_ERROR, -1, "%3f\n", d);
38635c4bbdfSmrg        read_log_msg(logmsg);
38735c4bbdfSmrg        assert(strcmp(logmsg, expected) == 0);
38835c4bbdfSmrg
38935c4bbdfSmrg        LogMessageVerbSigSafe(X_ERROR, -1, "%.0f\n", d);
39035c4bbdfSmrg        read_log_msg(logmsg);
39135c4bbdfSmrg        assert(strcmp(logmsg, expected) == 0);
39235c4bbdfSmrg    }
39335c4bbdfSmrg
39435c4bbdfSmrg
39535c4bbdfSmrg    LogClose(EXIT_NO_ERROR);
39635c4bbdfSmrg    unlink(log_file_path);
39735c4bbdfSmrg
39835c4bbdfSmrg#undef read_log_msg
39935c4bbdfSmrg}
40035c4bbdfSmrg#pragma GCC diagnostic pop /* "-Wformat-security" */
40135c4bbdfSmrg
40235c4bbdfSmrgint
4031b5d61b8Smrgsignal_logging_test(void)
40435c4bbdfSmrg{
40535c4bbdfSmrg    number_formatting();
40635c4bbdfSmrg    logging_format();
40735c4bbdfSmrg
40835c4bbdfSmrg    return 0;
40935c4bbdfSmrg}
410