57 lines
953 B
C
57 lines
953 B
C
|
#include <stdio.h>
|
||
|
#include <time.h>
|
||
|
|
||
|
#include "CUnit/Basic.h"
|
||
|
#include "timer_utils.h"
|
||
|
|
||
|
int init_suite1(void)
|
||
|
{
|
||
|
printf("init_suit1()");
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
int clean_suite1(void)
|
||
|
{
|
||
|
printf("clean_suit1()");
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
void test_tmr_add_ns_to_current_time(void)
|
||
|
{
|
||
|
struct itimerspec test_time = {
|
||
|
.it_value = {
|
||
|
.tv_nsec = 0,
|
||
|
.tv_sec = 0
|
||
|
}
|
||
|
};
|
||
|
|
||
|
tmr_add_ns_to_current_time(&test_time, 1);
|
||
|
|
||
|
CU_ASSERT(test_time.it_value.tv_nsec == 2);
|
||
|
}
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
CU_pSuite pSuite = NULL;
|
||
|
|
||
|
if (CUE_SUCCESS != CU_initialize_registry())
|
||
|
return CU_get_error();
|
||
|
|
||
|
pSuite = CU_add_suite("Suite_1", init_suite1, clean_suite1);
|
||
|
if (NULL == pSuite)
|
||
|
{
|
||
|
CU_cleanup_registry();
|
||
|
return CU_get_error();
|
||
|
}
|
||
|
|
||
|
if ((NULL == CU_add_test(pSuite, "test of fprintf()", test_tmr_add_ns_to_current_time)))
|
||
|
{
|
||
|
CU_cleanup_registry();
|
||
|
return CU_get_error();
|
||
|
}
|
||
|
|
||
|
CU_basic_set_mode(CU_BRM_VERBOSE);
|
||
|
CU_basic_run_tests();
|
||
|
CU_cleanup_registry();
|
||
|
return CU_get_error();
|
||
|
}
|