1 /***************************************************************************
2 * Copyright 1995, Technion, Israel Institute of Technology
3 * Electrical Eng, Software Lab.
4 * Author: Michael Veksler.
5 ***************************************************************************
6 * File: dde_atom_test.c
7 * Purpose : tests for dde_atom object
8 ***************************************************************************
14 #include "shm_main_blk.h"
15 #include "debugtools.h"
17 DECLARE_DEBUG_CHANNEL(atom
)
18 DECLARE_DEBUG_CHANNEL(sem
)
19 DECLARE_DEBUG_CHANNEL(shm
)
20 #define TOGETHER (DDE_ATOMS/5)
23 /* run random sequences */
26 ATOM atom_list
[TOGETHER
];
27 char str
[TOGETHER
][80];
29 int atom_len
[TOGETHER
];
35 for (i
=0 ; i
<=10000/TOGETHER
; i
++) {
36 for (atom_n
=0 ; atom_n
<TOGETHER
; atom_n
++) {
37 atom_len
[atom_n
]=rand()%64+1;
38 for (j
=atom_len
[atom_n
]-1; j
>=0; j
--)
40 str
[atom_n
][j
]=(char)(rand()%255+1);
41 } while (j
==0 && str
[atom_n
][j
]=='#');
43 str
[atom_n
][ atom_len
[atom_n
] ]='\0';
45 atom_list
[atom_n
]=GlobalAddAtom(str
[atom_n
]);
47 if (atom_list
[atom_n
]==0) {
48 fprintf(stderr
,"failed i=%d, atom_n=%d\n",i
,atom_n
);
51 if (atom_list
[atom_n
]!=GlobalAddAtom(str
[atom_n
])) {
53 "wrong second GlobalAddAtom(\"%s\")\n", str
[atom_n
]);
57 for (atom_n
=0 ; atom_n
<TOGETHER
; atom_n
++) {
61 len
=GlobalGetAtomName( atom_list
[atom_n
], buf
, 79);
62 if (atom_len
[atom_n
] != len
) {
63 fprintf(stderr
, "i=%d, atom_n=%d; ", i
, atom_n
);
65 "wrong length of GlobalGetAtomName(\"%s\")\n",
72 for (atom_n
=0 ; atom_n
<TOGETHER
; atom_n
++) {
73 GlobalDeleteAtom(atom_list
[atom_n
]);
74 if (atom_list
[atom_n
]!=GlobalAddAtom(str
[atom_n
])) {
75 fprintf(stderr
, "i=%d, atom_n=%d; ", i
, atom_n
);
77 "wrong third GlobalAddAtom(\"%s\")\n", str
[atom_n
]);
80 GlobalDeleteAtom(atom_list
[atom_n
]);
81 GlobalDeleteAtom(atom_list
[atom_n
]);
83 atom_list
[atom_n
]=GlobalAddAtom(str
[atom_n
]);
84 if (atom_list
[atom_n
]!=GlobalAddAtom(str
[atom_n
])) {
86 "i=%d, atom_n=%d wrong fifth GlobalAddAtom(\"%s\")\n",
91 GlobalDeleteAtom(atom_list
[atom_n
]);
92 if (atom_list
[atom_n
]!=GlobalFindAtom(str
[atom_n
])) {
94 "i=%d, atom_n=%d wrong GlobalFindAtom(\"%s\")\n",
99 GlobalDeleteAtom(atom_list
[atom_n
]);