Skip to content

Commit

Permalink
fix: fix test get function error on linux
Browse files Browse the repository at this point in the history
CLK_TCK => clock_gettime
  • Loading branch information
molingyu committed Sep 7, 2024
1 parent b948c32 commit 0b55648
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/unit_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,6 @@ int _utest_test_closure_failed = 0;
int _utest_test_closure_passed = 0;

char* _utest_current_test_unit_name = "";
clock_t _utest_test_start, _utest_test_end;
struct timespec _utest_test_start, _utest_test_end;

int _utest_test_unit_return = 0;
9 changes: 5 additions & 4 deletions test/unit_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ extern int _utest_test_closure_failed;
extern int _utest_test_closure_passed;

extern char* _utest_current_test_unit_name;
extern clock_t _utest_test_start, _utest_test_end;
extern struct timespec _utest_test_start, _utest_test_end;

extern int _utest_test_unit_return;

Expand All @@ -191,15 +191,16 @@ extern int _utest_test_unit_return;
{ \
printf( "Tarting %s unit tests\n", T ); \
printf( "\n" ); \
_utest_test_start = clock(); \
clock_gettime( CLOCK_MONOTONIC, &_utest_test_start ); \
BLOCK; \
_utest_test_end = clock(); \
clock_gettime( CLOCK_MONOTONIC, &_utest_test_end ); \
printf( "\n" ); \
printf( "Test Suites: \033[31m%d failed\033[0m, \033[32m%d passed\033[0m, %d total\n", _utest_test_suite_failed, \
_utest_test_suite_passed, _utest_test_suite_total ); \
printf( "Test: \033[31m%d failed\033[0m, \033[32m%d passed\033[0m, %d total\n", _utest_test_units_failed, \
_utest_test_units_passed, _utest_test_units_total ); \
printf( "Time: %.4f s\n", (double)( _utest_test_end - _utest_test_start ) / CLK_TCK ); \
printf( "Time: %.4f s\n", (double)( ( _utest_test_end.tv_sec - _utest_test_start.tv_sec ) + \
( _utest_test_end.tv_nsec - _utest_test_start.tv_nsec ) / 1e9 ) ); \
printf( "\nRan all test suites.\n" ); \
if ( _utest_test_units_failed == 0 ) \
{ \
Expand Down

0 comments on commit 0b55648

Please sign in to comment.