/**
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2015 ForgeRock AS.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <setjmp.h>
#include "platform.h"
#include "am.h"
#include "log.h"
#include "cmocka.h"
void am_worker_pool_init_reset();
void am_net_init_ssl_reset();
/**
* This is the simplest of tests to check we can log things without crashing.
*
* In fact, because of the way logging works (differently) in test mode than it does in "agent mode"
* all we're really doing here is to test that logging in test mode isn't broken. This may or may not
* bear any relation to whether logging works for the rest of the time.
*/
AM_LOG_INFO(0, "instance id is zero and no args");
/* we're testing this will not crash */
/* this will not appear, since the instance is greater than zero, but it should not crash either */
AM_LOG_ALWAYS(0, "Now %s the %s of our %s, %s summ%s of York",
"is",
"winter",
"discontent",
"Made glorious",
"er by this son");
/* attempt to overflow the buffer, although this will be ultimately unsuccessful because the
* logging works differently in unit test mode than it does in "real life" mode.
*/
AM_LOG_ALWAYS(0, "\n"
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n"
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n"
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n"
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n"
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n"
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n"
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n"
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n"
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n"
"1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n"
"ABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJ");
}
/*************************************************************************************/
/**
* Set up everything (shared memory, etc.) so we can log, just as we would if we were
* really running (as opposed to running in test harness mode).
*/
// destroy the cache, if it exists
// Note that we need a valid audit file name, even though we never audit
}
/**
* Tear down everything after doing some logging.
*/
void logging_teardown() {
}
/**
* Validate that the specified file contains the specified string. Very limited. The
* string searched for must occur entirely on a line and not span lines (if it does, it
* won't be matched).
*
* @param log_file_name The log file name
* @param text The text string to search for
* @return 1 if present, 0 if not present
*/
int result = 0;
}
} else {
}
return result;
}
/*************************************************************************************/
/**
* Ensure that an impractically high log level we DO actually log text via AM_LOG_DEBUG.
*/
int result;
sleep(5);
}
/**
* Ensure that at warning log level we do NOT log something via AM_LOG_DEBUG.
*/
int result;
sleep(5);
assert_int_equal(result, 0);
}
/**
* Ensure that at warning log level we DO log something via AM_LOG_WARNING.
*/
int result;
sleep(5);
}