Exemple #1
0
static void test_null_buffer(void)
{
    int status = ft_format(NONE, NULL, 1);
    CU_ASSERT_EQUAL(status, -1);
    status = ft_format(NONE, NULL, 0);
    CU_ASSERT_TRUE(status > 0);
}
Exemple #2
0
static void test_feedtype(
        const feedtypet   ft,
        const char* const expect)
{
    char   buf[128];
    size_t len = strlen(expect);
    int    status = ft_format(ft, NULL, 0);
    CU_ASSERT_EQUAL(status, len);

    status = ft_format(ft, buf, 0);
    CU_ASSERT_EQUAL(status, len);

    status = ft_format(ft, buf, 1);
    CU_ASSERT_EQUAL(status, len);
    CU_ASSERT_EQUAL(buf[0], 0);

    status = ft_format(ft, buf, 2);
    CU_ASSERT_EQUAL(status, len);
    CU_ASSERT_EQUAL(buf[0], expect[0]);
    CU_ASSERT_EQUAL(buf[1], 0);

    status = ft_format(ft, buf, sizeof(buf));
    CU_ASSERT_EQUAL(status, len);
    CU_ASSERT_STRING_EQUAL(buf, expect);
}
Exemple #3
0
static void pti_usage(void)
{
    char        feedbuf[256];
    const char* pqPath = getDefaultQueuePath();

    (void)ft_format(feedtype, feedbuf, sizeof(feedbuf));
    log_error_q(
"Usage: %s [options] [file]\n"
"Options:\n"
"    -f feedtype   Use <feedtype> as data-product feed-type. Default is %s.\n"
"    -g sleep      Sleep <sleep> nanoseconds between inserting products.\n"
"                  Ignored if <file> given. Default is %lu\n"
"    -l dest       Log to `dest`. One of: \"\" (system logging daemon), \"-\"\n"
"                  (standard error), or file `dest`. Default is \"%s\"\n"
"    -m max_size   Maximum product size in bytes. Ignored if <file> given.\n"
"                  Default is %lu.\n"
"    -n num_prods  Number of products. Ignored if <file> given. Default is\n"
"                  %lu.\n"
"    -q queue      Use <queue> as product-queue. Default is \"%s\".\n"
"    -s seqno      Set initial product sequence number to <seqno>. Default is\n"
"                  %d.\n"
"    -v            Verbose logging level: log each product.\n"
"    -x            Debug logging level.\n"
"Operands:\n"
"    file          Pathname of file containing size and timestamp entries.\n"
"                  If given, then '-g', '-m', and '-n' options are ignored",
            progname, feedbuf, inter_prod_gap, log_get_default_destination(),
            max_prod_size, num_prods, pqPath, seq_start);
}