check_loop.c   check_loop.c 
skipping to change at line 30 skipping to change at line 30
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with libqb. If not, see <http://www.gnu.org/licenses/>. * along with libqb. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "os_base.h" #include "os_base.h"
#include <check.h> #include <check.h>
#include <qb/qbdefs.h> #include <qb/qbdefs.h>
#include <qb/qbutil.h> #include <qb/qbutil.h>
#include <qb/qbloop.h> #include <qb/qbloop.h>
#include <qb/qblog.h>
static int32_t job_1_run_count = 0; static int32_t job_1_run_count = 0;
static int32_t job_2_run_count = 0; static int32_t job_2_run_count = 0;
static int32_t job_3_run_count = 0; static int32_t job_3_run_count = 0;
static void job_1(void *data) static void job_1(void *data)
{ {
job_1_run_count++; job_1_run_count++;
} }
skipping to change at line 334 skipping to change at line 335
static int expire_leak_runs = 0; static int expire_leak_runs = 0;
static void empty_func_tmo(void*data) static void empty_func_tmo(void*data)
{ {
expire_leak_counter++; expire_leak_counter++;
} }
static void stop_func_tmo(void*data) static void stop_func_tmo(void*data)
{ {
qb_loop_t *l = (qb_loop_t *)data; qb_loop_t *l = (qb_loop_t *)data;
printf("%s(%d)\n", __func__, expire_leak_counter); qb_log(LOG_DEBUG, "expire_leak_counter:%d", expire_leak_counter);
qb_loop_stop(l); qb_loop_stop(l);
} }
static void next_func_tmo(void*data) static void next_func_tmo(void*data)
{ {
qb_loop_t *l = (qb_loop_t *)data; qb_loop_t *l = (qb_loop_t *)data;
int32_t i; int32_t i;
uint64_t tmo; uint64_t tmo;
uint64_t max_tmo = 0; uint64_t max_tmo = 0;
qb_loop_timer_handle th; qb_loop_timer_handle th;
printf("%s(%d)\n", __func__, expire_leak_counter); qb_log(LOG_DEBUG, "expire_leak_counter:%d", expire_leak_counter);
for (i = 0; i < 300; i++) { for (i = 0; i < 300; i++) {
tmo = ((1 + i) * QB_TIME_NS_IN_MSEC) + 500000; tmo = ((1 + i) * QB_TIME_NS_IN_MSEC) + 500000;
qb_loop_timer_add(l, QB_LOOP_LOW, tmo, NULL, empty_func_tmo, &th); qb_loop_timer_add(l, QB_LOOP_LOW, tmo, NULL, empty_func_tmo, &th);
qb_loop_timer_add(l, QB_LOOP_MED, tmo, NULL, empty_func_tmo, &th); qb_loop_timer_add(l, QB_LOOP_MED, tmo, NULL, empty_func_tmo, &th);
qb_loop_timer_add(l, QB_LOOP_HIGH, tmo, NULL, empty_func_tmo , &th); qb_loop_timer_add(l, QB_LOOP_HIGH, tmo, NULL, empty_func_tmo , &th);
max_tmo = QB_MAX(max_tmo, tmo); max_tmo = QB_MAX(max_tmo, tmo);
} }
expire_leak_runs++; expire_leak_runs++;
if (expire_leak_runs == EXPIRE_NUM_RUNS) { if (expire_leak_runs == EXPIRE_NUM_RUNS) {
qb_loop_timer_add(l, QB_LOOP_LOW, max_tmo, l, stop_func_tmo, &th); qb_loop_timer_add(l, QB_LOOP_LOW, max_tmo, l, stop_func_tmo, &th);
skipping to change at line 420 skipping to change at line 421
suite_add_tcase(s, tc); suite_add_tcase(s, tc);
tc = tcase_create("expire_leak"); tc = tcase_create("expire_leak");
tcase_add_test(tc, test_loop_timer_expire_leak); tcase_add_test(tc, test_loop_timer_expire_leak);
tcase_set_timeout(tc, 30); tcase_set_timeout(tc, 30);
suite_add_tcase(s, tc); suite_add_tcase(s, tc);
return s; return s;
} }
static void libqb_log_fn(const char *file_name,
int32_t file_line, int32_t severity, const char *ms
g)
{
printf("libqb: %s:%d %s\n", file_name, file_line, msg);
}
int32_t main(void) int32_t main(void)
{ {
int32_t number_failed; int32_t number_failed;
SRunner *sr = srunner_create(loop_job_suite()); SRunner *sr = srunner_create(loop_job_suite());
srunner_add_suite (sr, loop_timer_suite()); srunner_add_suite (sr, loop_timer_suite());
qb_util_set_log_function(libqb_log_fn); qb_log_init("check", LOG_USER, LOG_EMERG);
qb_log_ctl(QB_LOG_SYSLOG, QB_LOG_CONF_ENABLED, QB_FALSE);
qb_log_filter_ctl(QB_LOG_STDERR, QB_LOG_FILTER_ADD,
QB_LOG_FILTER_FILE, "*", LOG_INFO);
qb_log_ctl(QB_LOG_STDERR, QB_LOG_CONF_ENABLED, QB_TRUE);
srunner_run_all(sr, CK_VERBOSE); srunner_run_all(sr, CK_VERBOSE);
number_failed = srunner_ntests_failed(sr); number_failed = srunner_ntests_failed(sr);
srunner_free(sr); srunner_free(sr);
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
} }
 End of changes. 5 change blocks. 
10 lines changed or deleted 8 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/