LCOV - differential code coverage report
Current view: top level - src/interfaces/ecpg/test/thread - alloc.pgc (source / functions) Coverage Total Hit CBC
Current: Differential Code Coverage HEAD vs 15 Lines: 100.0 % 19 19 19
Current Date: 2023-04-08 17:13:01 Functions: 100.0 % 2 2 2
Baseline: 15 Line coverage date bins:
Baseline Date: 2023-04-08 15:09:40 (240..) days: 100.0 % 19 19 19
Legend: Lines: hit not hit Function coverage date bins:
(240..) days: 100.0 % 2 2 2

 Age         Owner                  TLA  Line data    Source code
                                  1                 : #include <stdint.h>
                                  2                 : #include <stdlib.h>
                                  3                 : #include "ecpg_config.h"
                                  4                 : 
                                  5                 : #ifndef ENABLE_THREAD_SAFETY
                                  6                 : int
                                  7                 : main(void)
                                  8                 : {
                                  9                 :     printf("No threading enabled.\n");
                                 10                 :     return 0;
                                 11                 : }
                                 12                 : #else
                                 13                 : #ifdef WIN32
                                 14                 : #define WIN32_LEAN_AND_MEAN
                                 15                 : #include <windows.h>
                                 16                 : #include <process.h>
                                 17                 : #include <locale.h>
                                 18                 : #else
                                 19                 : #include <pthread.h>
                                 20                 : #endif
                                 21                 : #include <stdio.h>
                                 22                 : 
                                 23                 : #define THREADS     16
                                 24                 : #define REPEATS     50
                                 25                 : 
                                 26                 : exec sql include sqlca;
                                 27                 : exec sql include ../regression;
                                 28                 : 
                                 29                 : exec sql whenever sqlerror sqlprint;
                                 30                 : exec sql whenever not found sqlprint;
                                 31                 : 
                                 32                 : #ifdef WIN32
                                 33                 : static unsigned __stdcall fn(void* arg)
                                 34                 : #else
 5670 tgl                        35 CBC          16 : static void* fn(void* arg)
                                 36                 : #endif
                                 37                 : {
                                 38                 :     int i;
                                 39                 : 
                                 40                 :     EXEC SQL BEGIN DECLARE SECTION;
                                 41                 :     int  value;
                                 42                 :     char name[100];
                                 43              16 :     char **r = NULL;
                                 44                 :     EXEC SQL END DECLARE SECTION;
                                 45                 : 
 1143 peter                      46              16 :     value = (intptr_t) arg;
 5670 tgl                        47              16 :     sprintf(name, "Connection: %d", value);
                                 48                 : 
                                 49              16 :     EXEC SQL CONNECT TO REGRESSDB1 AS :name;
                                 50              16 :     EXEC SQL SET AUTOCOMMIT TO ON;
                                 51             816 :     for (i = 1; i <= REPEATS; ++i)
                                 52                 :     {
                                 53             800 :         EXEC SQL SELECT relname INTO :r FROM pg_class WHERE relname = 'pg_class';
                                 54             800 :         free(r);
                                 55             800 :         r = NULL;
                                 56                 :     }
                                 57              16 :     EXEC SQL DISCONNECT :name;
                                 58              16 : 
                                 59              16 :     return 0;
                                 60                 : }
                                 61                 : 
 5072 meskes                     62               1 : int main ()
                                 63                 : {
                                 64                 :     intptr_t i;
                                 65                 : #ifdef WIN32
                                 66                 :     HANDLE threads[THREADS];
                                 67                 : #else
                                 68                 :     pthread_t threads[THREADS];
                                 69                 : #endif
                                 70                 : 
                                 71                 : #ifdef WIN32
                                 72                 :     for (i = 0; i < THREADS; ++i)
                                 73                 :     {
                                 74                 :         unsigned id;
                                 75                 :         threads[i] = (HANDLE)_beginthreadex(NULL, 0, fn, (void*)i, 0, &id);
                                 76                 :     }
                                 77                 : 
                                 78                 :     WaitForMultipleObjects(THREADS, threads, TRUE, INFINITE);
                                 79                 :     for (i = 0; i < THREADS; ++i)
                                 80                 :         CloseHandle(threads[i]);
                                 81                 : #else
 5670 tgl                        82              17 :     for (i = 0; i < THREADS; ++i)
 1143 peter                      83              16 :         pthread_create(&threads[i], NULL, fn, (void *) i);
 5670 tgl                        84              17 :     for (i = 0; i < THREADS; ++i)
                                 85              16 :         pthread_join(threads[i], NULL);
                                 86                 : #endif
                                 87                 : 
                                 88               1 :     return 0;
                                 89                 : }
                                 90                 : #endif
        

Generated by: LCOV version v1.16-55-g56c0a2a