static int test_klog(void) { kprintf("Testing klog.\n"); int mask_old = klog.mask; klog.mask = KL_MASK(KL_LOG); /* Deleting logs if there are some old left. */ klog_clear(); klog_dump(); /* Testing logging with different number of messages. */ assert(test_log_messages(1) == 0); assert(test_log_messages(KL_SIZE - 1) == 0); assert(test_log_messages(KL_SIZE) == 0); assert(test_log_messages(KL_SIZE + 1) == 0); assert(test_log_messages(3 * KL_SIZE + 1) == 0); /* Testing logging messages with multiple threads. */ assert(multithreads_test(1) == 0); assert(multithreads_test(5) == 0); assert(multithreads_test(8) == 0); assert(logging_with_custom_mask() == 0); assert(testing_different_number_of_parametars() == 0); assert(stress_test() == 0); /* Testing logging while klog don't accept any logs. */ klog.mask = 0; assert(logging_klog_zero_mask() == 0); klog.mask = mask_old; return KTEST_SUCCESS; }
/* * test_all_log_messages -- test log messages on all levels, with and without * a prefix. */ static void test_all_log_messages(void) { rpmemd_prefix(NULL); test_log_messages(RPD_LOG_ERR); test_log_messages(RPD_LOG_WARN); test_log_messages(RPD_LOG_NOTICE); test_log_messages(RPD_LOG_INFO); test_log_messages(_RPD_LOG_DBG); rpmemd_prefix("[%s]", PREFIX); test_log_messages(RPD_LOG_ERR); test_log_messages(RPD_LOG_WARN); test_log_messages(RPD_LOG_NOTICE); test_log_messages(RPD_LOG_INFO); test_log_messages(_RPD_LOG_DBG); }