| 102 | } |
| 103 | |
| 104 | void mexFunction |
| 105 | ( |
| 106 | int nargout, |
| 107 | mxArray *pargout [ ], |
| 108 | int nargin, |
| 109 | const mxArray *pargin [ ] |
| 110 | ) |
| 111 | { |
| 112 | |
| 113 | FILE *f = fopen ("errlog.txt", "w") ; |
| 114 | FILE *ff = fopen ("fprint.txt", "w") ; |
| 115 | |
| 116 | GrB_Info info, expected ; |
| 117 | |
| 118 | GB_Global_GrB_init_called_set (false) ; |
| 119 | OK (GrB_init (GrB_NONBLOCKING)) ; |
| 120 | OK (GrB_finalize ( )) ; |
| 121 | |
| 122 | GB_Global_GrB_init_called_set (false) ; |
| 123 | OK (GxB_init (GrB_NONBLOCKING, mxMalloc, NULL, NULL, mxFree)) ; |
| 124 | |
| 125 | // mxMalloc, mxCalloc, mxRealloc, and mxFree are not thread safe |
| 126 | GB_Global_malloc_is_thread_safe_set (false) ; |
| 127 | |
| 128 | GB_Global_abort_function_set (GB_mx_abort) ; |
| 129 | GB_Global_malloc_tracking_set (true) ; |
| 130 | |
| 131 | fprintf (f,"\n========================================================\n") ; |
| 132 | fprintf (f,"=== GB_mex_errors : testing error handling =============\n") ; |
| 133 | fprintf (f,"========================================================\n") ; |
| 134 | fprintf (f,"many errors are expected\n") ; |
| 135 | |
| 136 | OK (GxB_Type_fprint_(GrB_BOOL, G3, ff)) ; |
| 137 | expected = GrB_INVALID_VALUE ; |
| 138 | ERR (GxB_Type_fprint_(GrB_BOOL, G3, stdin)) ; |
| 139 | |
| 140 | int64_t nmalloc ; |
| 141 | nmalloc = GB_Global_nmalloc_get ( ) ; |
| 142 | |
| 143 | printf ("nmalloc %d at start\n", nmalloc) ; |
| 144 | bool malloc_debug = GB_mx_get_global (true) ; |
| 145 | nmalloc = GB_Global_nmalloc_get ( ) ; |
| 146 | printf ("nmalloc %d after complex init\n", nmalloc) ; |
| 147 | |
| 148 | GrB_Matrix A = NULL, B = NULL, C = NULL, Z = NULL, Acrud = NULL, |
| 149 | Aempty = NULL, E = NULL, F = NULL, A0 = NULL, H = NULL, |
| 150 | Empty1 = NULL, A4 = NULL, C4 = NULL ; |
| 151 | GrB_Vector v = NULL, vcrud = NULL, vempty = NULL, w = NULL, u = NULL, |
| 152 | v0 = NULL, v2 = NULL, z = NULL, h = NULL, vb = NULL ; |
| 153 | GrB_Type T = NULL, Tcrud ; |
| 154 | GrB_UnaryOp op1 = NULL, op1crud = NULL, o1 = NULL, op1b = NULL ; |
| 155 | GrB_BinaryOp op2 = NULL, op2crud = NULL, o2 = NULL, op0 = NULL, op3 = NULL, |
| 156 | op2b = NULL ; |
| 157 | GrB_Monoid monoid = NULL, monoid_crud = NULL, m2 = NULL, m0 = NULL, |
| 158 | monoidb = NULL ; |
| 159 | GrB_Semiring semiring = NULL, semicrud = NULL, s2 = NULL, s0 = NULL, |
| 160 | semiring2 = NULL ; |
| 161 | GrB_Descriptor desc = NULL, dcrud = NULL, d0 = NULL, |
nothing calls this directly
no test coverage detected