Changeset 51 in libcf for trunk/test/test.c
- Timestamp:
- 04/02/13 10:23:52 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/test.c
r49 r51 22 22 #define PORT 1234 23 23 24 CF_Debug_Ctx gDebugCtx;25 CF_Debug_CallStack gDebugCallstack;26 24 CF_Mutex globalMutex; 27 25 … … 63 61 CF_Thread tid[10]; 64 62 65 CF_DEBUG_ CALLSTACK_PUSH (gDebugCtx);63 CF_DEBUG_BEGIN_FUNCTION; 66 64 67 65 /* initialize */ … … 125 123 /* finalize */ 126 124 CF_Log_Finalize (); 125 126 CF_DEBUG_END_FUNCTION; 127 127 } 128 128 … … 132 132 char buffer[128] = {0x00,}; 133 133 134 CF_DEBUG_ CALLSTACK_PUSH (gDebugCtx);134 CF_DEBUG_BEGIN_FUNCTION; 135 135 136 136 fd = CF_File_Open (file, CF_FILE_RO); 137 137 if (fd < 0) 138 CF_DEBUG_ TRACE (gDebugCtx, "what the ... file open ?\n");138 CF_DEBUG_PRINT (stderr, "what the ... file open ?\n"); 139 139 140 140 if (CF_File_Read (fd, buffer, sizeof (buffer)) < 0) 141 CF_DEBUG_ TRACE (gDebugCtx, "what the ... file read ?\n");141 CF_DEBUG_PRINT (stderr, "what the ... file read ?\n"); 142 142 else 143 CF_DEBUG_ TRACE_BIN (gDebugCtx, (unsigned char *)buffer,144 145 146 147 143 CF_DEBUG_PRINT_BIN (stdout, (unsigned char *)buffer, 144 sizeof (buffer), 145 "-- %d bytes of %d bytes\n", 146 sizeof (buffer), 147 CF_File_GetSize (fd)); 148 148 149 149 CF_File_Close (fd); 150 150 151 CF_DEBUG_ CALLSTACK_POP (gDebugCtx, NULL);151 CF_DEBUG_END_FUNCTION; 152 152 } 153 153 154 154 void test_callstack3 (void) 155 155 { 156 CF_DEBUG_CALLSTACK_PUSH (gDebugCtx); 157 while (CF_DEBUG_CALLSTACK_POP (gDebugCtx, &gDebugCallstack) == CF_OK) 158 { 159 CF_DEBUG_TRACE (gDebugCtx, "print callstack [file:%s line:%d func:%s]\n", 160 gDebugCallstack.file, 161 gDebugCallstack.line, 162 gDebugCallstack.function); 163 } 164 CF_DEBUG_CALLSTACK_POP (gDebugCtx, NULL); 156 CF_DEBUG_BEGIN_FUNCTION; 157 CF_Debug_PrintCallStack (stdout); 158 CF_DEBUG_END_FUNCTION; 165 159 } 166 160 void test_callstack2 (void) 167 161 { 168 CF_DEBUG_ CALLSTACK_PUSH (gDebugCtx);162 CF_DEBUG_BEGIN_FUNCTION; 169 163 test_callstack3 (); 170 CF_DEBUG_ CALLSTACK_POP (gDebugCtx, NULL);164 CF_DEBUG_END_FUNCTION; 171 165 } 172 166 void test_callstack1 (void) 173 167 { 174 CF_DEBUG_ CALLSTACK_PUSH (gDebugCtx);168 CF_DEBUG_BEGIN_FUNCTION; 175 169 test_callstack2 (); 176 CF_DEBUG_ CALLSTACK_POP (gDebugCtx, NULL);170 CF_DEBUG_END_FUNCTION; 177 171 } 178 172 … … 333 327 int main (int argc, char ** argv) 334 328 { 335 gDebugCtx = CF_Debug_CreateCtx (); 336 337 CF_DEBUG_CALLSTACK_PUSH (gDebugCtx); 329 CF_DEBUG_BEGIN_FUNCTION; 338 330 339 331 // 1 … … 353 345 test_socket (); 354 346 355 CF_DEBUG_CALLSTACK_POP (gDebugCtx, &gDebugCallstack);356 357 347 CF_DEBUG_PRINT (stderr, " == END OF TEST ==\n"); 358 CF_DEBUG_TRACE (gDebugCtx, "here is the end of function [file:%s line:%d func:%s]\n", 359 gDebugCallstack.file, 360 gDebugCallstack.line, 361 gDebugCallstack.function); 362 363 CF_Debug_DestroyCtx (gDebugCtx); 348 349 CF_DEBUG_END_FUNCTION; 364 350 365 351 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.