My Project
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
omtTestError.c File Reference
#include "omtTest.h"
#include "omalloc.h"

Go to the source code of this file.

Data Structures

struct  LongSpec
 

Macros

#define OM_CHECK   1
 

Functions

omMemCell omFindCell (struct LongSpec spec)
 
int omtTestErrors ()
 

Data Structure Documentation

◆ LongSpec

struct LongSpec

Definition at line 6 of file omtTestError.c.

Data Fields
int MaxSize
int MinSize
int MinTrack
int NotIsBin
int NoTrack
int NotZero

Macro Definition Documentation

◆ OM_CHECK

#define OM_CHECK   1

Definition at line 2 of file omtTestError.c.

Function Documentation

◆ omFindCell()

omMemCell omFindCell ( struct LongSpec  spec)

Definition at line 16 of file omtTestError.c.

17{
18 int i;
19 for (i=0; i<MAX_CELLS; i++)
20 {
21 if ((cells[i].addr != NULL) &&
22 (spec.MinTrack == 0 || (DO_CHECK(cells[i].spec) &&
23 DO_TRACK(cells[i].spec) &&
24 GET_TRACK(cells[i].spec) >= spec.MinTrack)) &&
25 (spec.MinSize == 0 || GET_SIZE(cells[i].spec) >= spec.MinSize) &&
26 (spec.MaxSize == 0 || GET_SIZE(cells[i].spec) <= spec.MaxSize) &&
27 (spec.NotIsBin == 0 || cells[i].bin == NULL) &&
28 (spec.NotZero == 0 || !IS_ZERO(cells[i].spec)) &&
29 (spec.NoTrack == 0 || !DO_CHECK(cells[i].spec) || !DO_TRACK(cells[i].spec)))
30 {
31 return &cells[i];
32 }
33 }
34 return NULL;
35}
int i
Definition: cfEzgcd.cc:132
#define NULL
Definition: omList.c:12
int MinTrack
Definition: omtTestError.c:10
omMemCell_t cells[MAX_CELLS]
Definition: omtTest.c:11
#define GET_TRACK(spec)
Definition: omtTest.h:71
#define IS_ZERO(spec)
Definition: omtTest.h:54
#define DO_CHECK(spec)
Definition: omtTest.h:63
#define GET_SIZE(spec)
Definition: omtTest.h:51
#define DO_TRACK(spec)
Definition: omtTest.h:70
#define MAX_CELLS
Definition: omtTest.h:17

◆ omtTestErrors()

int omtTestErrors ( )

Definition at line 37 of file omtTestError.c.

38{
39#ifndef OM_NDEBUG
40 int level = om_Opts.MinCheck;
42 struct LongSpec spec;
43 int missed = 0, alloc;
44 omMemCell cell = NULL;
45
46 printf("omtTestErrors: Start\n");
47 om_Opts.MinCheck = 2;
49 {
52 printf("!!!expect %s\n", omError2Serror(error));
53 memset(&spec, 0, sizeof(struct LongSpec));
54 cell = NULL;
55 alloc = 0;
56 switch (error)
57 {
59 {
60 spec.MaxSize = OM_MAX_BLOCK_SIZE;
61 cell = omFindCell(spec);
62 if (cell != NULL)
63 {
64 omBin bin = omGetTopBinOfAddr(cell->addr);
65 omBinPage last_page = bin->last_page;
66 omAssume(last_page != NULL);
67 bin->last_page = NULL;
68 omDebugBin(cell->bin);
69 bin->last_page = last_page;
70 }
71 else printf("cell not found\n");
72 break;
73 }
74
76 {
78 break;
79 }
80
82 {
83 omDebugAddr((void*) om_MaxAddr);
84 break;
85 }
86
88 {
89 spec.MinSize = 8;
90 spec.MaxSize = OM_MAX_BLOCK_SIZE;
91 spec.NoTrack = 1;
92 cell = omFindCell(spec);
93 if (cell != NULL)
94 {
95 omDebugAddr(cell->addr + SIZEOF_VOIDP);
96 }
97 else printf("cell not found\n");
98 break;
99 }
100
102 {
103 spec.MinSize = 8;
104 spec.MinTrack = 3;
105 cell = omFindCell(spec);
106 if (cell != NULL)
107 {
108 omDebugAddr(cell->addr + SIZEOF_VOIDP);
109 }
110 else printf("cell not found\n");
111 break;
112 }
113
115 {
116 spec.MaxSize = OM_MAX_BLOCK_SIZE;
117 cell = omFindCell(spec);
118 if (cell != NULL)
119 {
120 omDebugAddrSize(cell->addr, OM_MAX_BLOCK_SIZE + 1);
122 {
124 spec.MaxSize = 0;
125 spec.MinTrack = 3;
126 spec.NotIsBin = 1;
127 spec.MinSize = 2;
128 cell = omFindCell(spec);
129 if (cell != NULL)
130 {
131 omDebugAddrSize(cell->addr, GET_SIZE(cell->spec) + SIZEOF_OM_ALIGNMENT);
133 {
135 spec.MaxSize = OM_MAX_BLOCK_SIZE;
136 spec.MinTrack = 0;
137 spec.NotIsBin = 0;
138 cell = omFindCell(spec);
139 if (cell != NULL)
140 omDebugBinAddrSize(cell->addr, GET_SIZE(cell->spec) - 1);
141 else printf("cell not found");
142 }
143 }
144 else printf("cell not found\n");
145 }
146 }
147 else printf("cell not found\n");
148 break;
149 }
150
152 {
153#if KEEP_LEVEL > 0
154 void* addr = om_AlwaysKeptAddrs;
155 while (addr != NULL && omIsTrackAddr(addr))
156 {
157 addr = *((void**) addr);
158 }
159 if (addr != NULL)
160 {
161 omFree(addr);
163 {
165 addr = om_AlwaysKeptAddrs;
166 while (addr != NULL && ! omIsTrackAddr(addr))
167 {
168 addr = *((void**) addr);
169 }
170 if (addr != NULL)
171 {
172 addr = omAddr_2_OutAddr(addr);
173 omFree(addr);
174 }
175 }
176 }
177 if (addr == NULL)
178 {
179 printf("addr not found\n");
180 break;
181 }
183 break;
184#endif
185 spec.MinTrack = 5;
186 spec.NotIsBin = 1;
187 cell = omFindCell(spec);
188 if (cell != NULL)
189 {
190 omFree(cell->addr);
191 omFree(cell->addr);
192 alloc = 1;
193 cell->addr=NULL;
194 }
195 else printf("cell not found\n");
196 break;
197 }
198
200 {
201 spec.MaxSize = OM_MAX_BLOCK_SIZE;
202 spec.NoTrack = 1;
203 cell = omFindCell(spec);
204 if (cell != NULL)
205 {
206 omBinPage page = omGetBinPageOfAddr(cell->addr);
207 omBinPageRegion region = page->region;
208 page->region = NULL;
209 om_Opts.MinCheck = 1;
210 omDebugAddr(cell->addr);
211 om_Opts.MinCheck = 2;
212 page->region = region;
213 }
214 else printf("cell not found\n");
215 break;
216 }
217
218 case omError_WrongBin:
219 {
220 spec.MaxSize = 32;
221 spec.NoTrack = 1;
222 cell = omFindCell(spec);
223 if (cell != NULL)
224 {
225 omDebugAddrBin(cell->addr, &om_StaticBin[OM_MAX_BIN_INDEX]);
226 }
227 else printf("cell not found\n");
228 break;
229 }
230
232 {
233 spec.MaxSize = OM_MAX_BLOCK_SIZE;
234 cell = omFindCell(spec);
235 if (cell != NULL)
236 {
237 omDebugAddrBin(cell->addr, (void*) omGetTopBinOfAddr(cell->addr) + SIZEOF_VOIDP);
238 }
239 else printf("cell not found\n");
240 break;
241 }
242
244 {
245 spec.NotIsBin = 1;
246 spec.MinSize = OM_MAX_BLOCK_SIZE + 1;
247 cell = omFindCell(spec);
248 if (cell != NULL)
249 {
250 omDebugBinAddr(cell->addr);
251 }
252 else printf("cell not found");
253 break;
254 }
255
257 {
258 cell = omFindCell(spec);
259 if (cell != NULL)
260 {
261 omDebugAddr(cell->addr + 1);
262 }
263 else printf("cell not found\n");
264 break;
265 }
266
268 {
269 void* addr = omAlloc(0);
270 addr = omRealloc(addr, 0);
271 omFree(addr);
272 break;
273 }
274
276 {
277 void* last = omListLast(om_SpecBin);
278 if (last != NULL)
279 {
280 *((void**)last) = om_SpecBin;
282 *((void**)last) = NULL;
283 } else printf("last == NULL\n");
284 break;
285 }
286
288 {
289 if (om_SpecBin != NULL && om_SpecBin->next != NULL)
290 {
291 int max_blocks = om_SpecBin->max_blocks;
292 om_SpecBin->max_blocks = om_SpecBin->next->max_blocks + 1;
293 omCheckSortedList(om_SpecBin, max_blocks, 5, omError_NoError, OM_FLR);
294 om_SpecBin->max_blocks = max_blocks;
295 } else printf("om_SpecBin->next == NULL\n");
296 break;
297 }
298
300 {
301 if (om_KeptAddr != NULL)
302 {
303 void* last = omListLast(om_KeptAddr);
304 *((void**)last) = om_KeptAddr;
305 om_Opts.MinCheck = 5;
307 om_Opts.MinCheck = 2;
308 *((void**)last) = NULL;
309 }
310 else printf("om_KeptAddr == NULL\n");
311 break;
312 }
313
315 {
316 if (om_Opts.Keep > 0)
317 {
318 spec.MinTrack=3;
319 spec.NotIsBin = 1;
320 cell = omFindCell(spec);
321 if (cell != NULL)
322 {
323 void* value;
324 omFree(cell->addr);
325 value = *((void**) cell->addr);
326 *((void**) cell->addr) = value -1;
328 *((void**) cell->addr) = value;
329 alloc = 1;
330 cell->addr = NULL;
331 }
332 else printf("cell not found\n");
333 }
334 else printf("om_Opts.Keep == 0");
335 break;
336 }
337
339 {
340 spec.MinTrack = 3;
341 spec.NotIsBin = 1;
342 cell = omFindCell(spec);
343 if (cell != NULL)
344 {
345 void* addr = cell->addr + omSizeOfAddr(cell->addr);
346 void* value = *((void**) addr);
347 *((void**) addr) = value -1;
348 omDebugAddr(cell->addr);
349 *((void**) addr) = value;
350 }
351 else printf("cell not found\n");
352 break;
353 }
354
356 {
357 spec.MinTrack=3;
358 cell = omFindCell(spec);
359 if (cell != NULL)
360 {
361 void* addr = cell->addr - SIZEOF_VOIDP;
362 void* value = *((void**) addr);
363 *((void**) addr) = value -1;
364 omDebugAddr(cell->addr);
365 *((void**) addr) = value;
366 }
367 else printf("cell not found\n");
368 break;
369 }
370
372 {
373/* can only test for NULL string */
374#if 0
375 spec.MaxSize = OM_MAX_BLOCK_SIZE;
376 cell = omFindCell(spec);
377 if (cell != NULL)
378 {
379 char* addr = (char*) cell->addr;
380 char* s;
381 memset(cell->addr, 1, omSizeOfAddr(cell->addr));
382 omDebugAddr(cell->addr);
383 s = omStrDup(addr);
384 omFree(s);
386 }
387 else printf("cell not found\n");
388 break;
389#endif
390 omStrDup(NULL);
391 break;
392 }
393
395 {
397 break;
398 }
399
400 default:
401 printf("No Error test implemented\n");
402 }
403
404 if (om_ErrorStatus != error)
405 {
406 printf("---missed %s\n", omError2Serror(error));
407 missed++;
408 }
409 else
410 {
411 printf("+++ok %s\n", omError2Serror(error));
412 }
413
415 if (cell != NULL)
416 {
417 if (alloc) TestAlloc(cell, cell->spec);
418 omtTestDebug(cell);
419 }
420 else
421 {
423 }
425 {
426 printf("omtTest panik: memory corrupted\n\n");
427 return -1;
428 }
429 printf("\n");
430 }
431 printf("omtTestErrors: Summary: missed = %d\n\n", missed);
432 om_Opts.MinCheck = level;
433 return missed;
434#else
435 return 0;
436#endif
437}
int level(const CanonicalForm &f)
const CanonicalForm int s
Definition: facAbsFact.cc:51
STATIC_VAR poly last
Definition: hdegree.cc:1173
#define error(a)
Definition: mpr_numeric.cc:966
#define omStrDup(s)
Definition: omAllocDecl.h:263
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omDebugMemory()
Definition: omAllocDecl.h:318
#define omDebugBinAddrSize(addr, size)
Definition: omAllocDecl.h:312
#define omDebugAddr(addr)
Definition: omAllocDecl.h:314
#define omDebugBinAddr(addr)
Definition: omAllocDecl.h:310
#define omRealloc(addr, size)
Definition: omAllocDecl.h:225
#define omDebugAddrSize(addr, size)
Definition: omAllocDecl.h:313
#define omFree(addr)
Definition: omAllocDecl.h:261
#define omDebugBin(bin)
Definition: omAllocDecl.h:317
#define omDebugAddrBin(addr, bin)
Definition: omAllocDecl.h:311
#define omGetTopBinOfAddr(addr)
omBin_t om_StaticBin[]
size_t omSizeOfAddr(const void *addr)
#define omGetBinPageOfAddr(addr)
Definition: omBinPage.h:22
void * om_AlwaysKeptAddrs
Definition: omDebug.c:31
void * om_KeptAddr
Definition: omDebug.c:28
unsigned long om_MaxAddr
Definition: omDebugCheck.c:19
void * omAddr_2_OutAddr(void *addr)
#define omIsTrackAddr(addr)
Definition: omDebug.h:12
omError_t om_ErrorStatus
Definition: omError.c:13
const char * omError2Serror(omError_t error)
Definition: omError.c:65
omError_t om_InternalErrorStatus
Definition: omError.c:14
#define omAssume(x)
Definition: omError.h:85
@ omError_WrongSize
Definition: omError.h:26
@ omError_ListCycleError
Definition: omError.h:34
@ omError_BackPattern
Definition: omError.h:38
@ omError_NullAddr
Definition: omError.h:22
@ omError_NullSizeAlloc
Definition: omError.h:33
@ omError_MaxError
Definition: omError.h:42
@ omError_FrontPattern
Definition: omError.h:39
@ omError_UnalignedAddr
Definition: omError.h:32
@ omError_MemoryCorrupted
Definition: omError.h:21
@ omError_FreedAddr
Definition: omError.h:27
@ omError_UnknownBin
Definition: omError.h:30
@ omError_FreedAddrOrMemoryCorrupted
Definition: omError.h:28
@ omError_NotString
Definition: omError.h:40
@ omError_SortedListError
Definition: omError.h:35
@ omError_KeptAddrListCorrupted
Definition: omError.h:36
@ omError_NotBinAddr
Definition: omError.h:31
@ omError_InvalidRangeAddr
Definition: omError.h:23
@ omError_FalseAddr
Definition: omError.h:24
@ omError_WrongBin
Definition: omError.h:29
@ omError_NoError
Definition: omError.h:18
@ omError_StickyBin
Definition: omError.h:41
@ omError_FreePattern
Definition: omError.h:37
@ omError_FalseAddrOrMemoryCorrupted
Definition: omError.h:25
enum omError_e omError_t
Definition: omError.h:44
#define omCheckSortedList(ptr, what, level, report, OM_FLR_VAL)
Definition: omList.h:85
#define omListLast(ptr)
Definition: omList.h:64
#define omCheckList(ptr, level, report, OM_FLR_VAL)
Definition: omList.h:83
omOpts_t om_Opts
Definition: omOpts.c:13
omBinPage_t * omBinPage
Definition: omStructs.h:16
omBin_t * omBin
Definition: omStructs.h:12
omBinPageRegion_t * omBinPageRegion
Definition: omStructs.h:20
#define OM_MAX_BLOCK_SIZE
Definition: omTables.c:31
omSpecBin om_SpecBin
Definition: om_Alloc.c:20
omMemCell omFindCell(struct LongSpec spec)
Definition: omtTestError.c:16
void TestAlloc(omMemCell cell, unsigned long spec)
Definition: omtTest.c:182
void omtTestDebug(omMemCell cell)
Definition: omtTest.c:36
void InitCellAddrContent(omMemCell cell)
Definition: omtTest.c:130
omMemCell_t * omMemCell
Definition: omtTest.h:33
#define omMergeStickyBinIntoBin(A, B)
Definition: xalloc.h:275