int main()
{
  /* Must initialise Pantheios, when using from C (and there are no C++
   * compilation units in the link-unit).
   *
   * If this is not done, undefined behaviour will ensue ...
   */
  if(pantheios_init() < 0)
  {
    return EXIT_FAILURE;
  }
  else
  {
    int   i = 123;
    float f = 99.99f;

    /* Log the int and the float: Output: "int=123, float=99.99"
     */
    pantheios_logprintf(PANTHEIOS_SEV_INFORMATIONAL
                      , PANTHEIOS_LITERAL_STRING("int=%d, float=%g")
                      , i, f);

    /* Must uninitialise Pantheios.
     *
     * pantheios_uninit() must be called once for each successful (>=0)
     * invocation of pantheios_init().
     */
    pantheios_uninit();

    return EXIT_SUCCESS;
  }
}
static void test_1_1()
{
    PAN_CHAR_T const pi[] = "test_1_1";

    int r;

    s_PI_N = pi;

    r = pantheios_init();

    XTESTS_TEST_INTEGER_EQUAL(2, s_numGPI);

    if(r < 0)
    {
        XTESTS_FAIL("could not initialise libraries");
    }
    else
    {
        XTESTS_TEST_INTEGER_EQUAL(1, s_numInits);
        XTESTS_TEST_INTEGER_EQUAL(0, s_numUninits);
        XTESTS_TEST_INTEGER_EQUAL(2, s_numGPI);

        XTESTS_TEST_MULTIBYTE_STRING_EQUAL("test_1_1", pantheios_getProcessIdentity());
        XTESTS_TEST_POINTER_EQUAL(pi, pantheios_getProcessIdentity());

        pantheios_uninit();

        XTESTS_TEST_INTEGER_EQUAL(1, s_numInits);
        XTESTS_TEST_INTEGER_EQUAL(1, s_numUninits);
        XTESTS_TEST_INTEGER_EQUAL(4, s_numGPI);
    }
}
int main(int argc, char** argv)
{
    int retCode = EXIT_SUCCESS;
    int verbosity = 2;

    XTESTS_COMMANDLINE_PARSEVERBOSITY(argc, argv, &verbosity);

    if(XTESTS_START_RUNNER("test.component.core.initialisation_sequence", verbosity))
    {
        if(XTESTS_CASE_BEGIN("Pantheios initialisation sequence", ""))
        {
            int r;

            XTESTS_TEST_INTEGER_EQUAL(0, s_feInitValue);
            XTESTS_TEST_INTEGER_EQUAL(0, s_beInitValue);

            r = pantheios_init();

            if(r < 0)
            {
                XTESTS_FAIL_WITH_QUALIFIER("failed to initialise Pantheios", pantheios_getInitCodeString(r));
            }
            else
            {
                XTESTS_TEST_INTEGER_EQUAL(1, s_feInitValue);
                XTESTS_TEST_INTEGER_EQUAL(1, s_beInitValue);

                pantheios_uninit();

                XTESTS_TEST_INTEGER_EQUAL(2, s_feInitValue);
                XTESTS_TEST_INTEGER_EQUAL(2, s_beInitValue);
            }

            XTESTS_CASE_END("Pantheios initialisation sequence");
        }

        XTESTS_PRINT_RESULTS();

        XTESTS_END_RUNNER_UPDATE_EXITCODE(&retCode);
    }

    return retCode;
}
Ejemplo n.º 4
0
int main()
{
  int i = pantheios_init();

  if(i >= 0)
  {
    PANTHEIOS_ASSERT(1);

    PANTHEIOS_ASSERT(0);


    PANTHEIOS_MESSAGE_ASSERT(1, "it was true");

    PANTHEIOS_MESSAGE_ASSERT(0, "it was false");

    pantheios_uninit();
  }

  return EXIT_SUCCESS;
}
Ejemplo n.º 5
0
int main(int argc, char *argv[])
{
    int res;

#if 0
    { for(size_t i = 0;0 != ++i;) {} }
#endif /* 0 */

    if(pantheios_init() < 0)
    {
        res = EXIT_FAILURE;
    }
    else
    {
        res = main_(argc, argv);

        pantheios_uninit();
    }

    return res;
}
Ejemplo n.º 6
0
int main()
{
  int i = pantheios_init();

  if(i >= 0)
  {
    /* 1. Using the Pantheios API macro PANTHEIOS_MAKE_EXTENDED_SEVERITY() */
    pantheios_logprintf(PANTHEIOS_MAKE_EXTENDED_SEVERITY(PANTHEIOS_SEV_NOTICE, 10), PANTHEIOS_LITERAL_STRING("hello"));


    /* 2 (a). In your code, you'd define your own, most succinct, symbol, e.g. ACME_XSEV(sev, xi28) */
#define ACME_XSEV(sev, xi28)    PANTHEIOS_MAKE_EXTENDED_SEVERITY(PANTHEIOS_SEV_ ## sev, xi28)

    /* 2 (b). and use it as follows */
    pantheios_logprintf(ACME_XSEV(NOTICE, 10), PANTHEIOS_LITERAL_STRING("hello"));


    pantheios_uninit();
  }

  return EXIT_SUCCESS;
}
Ejemplo n.º 7
0
int main()
{
  /* Must initialise Pantheios, when using from C (and there are no C++
   * compilation units in the link-unit).
   *
   * If this is not done, undefined behaviour will ensue ...
   */
  if(pantheios_init() < 0)
  {
    return EXIT_FAILURE;
  }
  else
  {
    pantheios_logputs(PANTHEIOS_SEV_DEBUG, PANTHEIOS_LITERAL_STRING("debug"));
    pantheios_logputs(PANTHEIOS_SEV_INFORMATIONAL, PANTHEIOS_LITERAL_STRING("info"));
    pantheios_logputs(PANTHEIOS_SEV_NOTICE, PANTHEIOS_LITERAL_STRING("notice"));
    pantheios_logputs(PANTHEIOS_SEV_WARNING, PANTHEIOS_LITERAL_STRING("warn"));

    pantheios_be_file_setFilePath(PANTHEIOS_LITERAL_STRING("file-1.log"), PANTHEIOS_BE_FILE_F_TRUNCATE, PANTHEIOS_BE_FILE_F_TRUNCATE, 1);

    pantheios_logputs(PANTHEIOS_SEV_ERROR, PANTHEIOS_LITERAL_STRING("error"));
    pantheios_logputs(PANTHEIOS_SEV_CRITICAL, PANTHEIOS_LITERAL_STRING("critical"));
    pantheios_logputs(PANTHEIOS_SEV_ALERT, PANTHEIOS_LITERAL_STRING("alert"));
    pantheios_logputs(PANTHEIOS_SEV_EMERGENCY, PANTHEIOS_LITERAL_STRING("emergency"));

    pantheios_be_file_setFilePath(PANTHEIOS_LITERAL_STRING("file-5.log"), 0, 0, 5);

    /* Must uninitialise Pantheios.
     *
     * pantheios_uninit() must be called once for each successful (>=0)
     * invocation of pantheios_init().
     */
    pantheios_uninit();

    return EXIT_SUCCESS;
  }
}
Ejemplo n.º 8
0
int main(int argc, char *argv[])
{
    int bVerbose    =   1;

    if(pantheios_init() < 0)
    {
        return EXIT_FAILURE;
    }
    else
    {
        pantheios_init();

        pantheios_init();
        pantheios_uninit();

        pantheios_init();
        pantheios_uninit();


        pantheios_getNextBackEndId();

        { int i; for(i = 1; i < argc; ++i)
        {
            char const  *const  arg =   argv[i];

            if(arg[0] == '-')
            {
                if(arg[1] == '-')
                {
                    /* -- arguments */
                    usage(1, "Invalid argument(s) specified", i, argc, argv);
                }
                else
                {
                    /* - arguments */
                    switch(arg[1])
                    {
                        case    '?':
                            usage(1, NULL, -1, argc, argv);
                            break;
                        case    's':
                            bVerbose    =   0;
                            break;
                        case    'v':
                            bVerbose    =   1;
                            break;
                        default:
                            usage(1, "Invalid argument(s) specified", i, argc, argv);
                            break;
                    }
                }
            }
            else
            {
                /* other arguments */
                usage(1, "Invalid argument(s) specified", i, argc, argv);
            }
        }}

        pantheios_uninit();

        pantheios_uninit();

        return EXIT_SUCCESS;
    }
}