projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Unify architecture io_uring syscall numbers
[fio.git]
/
t
/
stest.c
diff --git
a/t/stest.c
b/t/stest.c
index 0e0d8b0b4785998546f437fb336a2038ec34ce41..c6bf2d1efa8e86899c3a4e4f54b442d801d53533 100644
(file)
--- a/
t/stest.c
+++ b/
t/stest.c
@@
-11,35
+11,42
@@
#define MAGIC2 0xf0a1e9b3
#define LOOPS 32
#define MAGIC2 0xf0a1e9b3
#define LOOPS 32
+#define MAXSMALLOC 120*1024*1024UL
+#define LARGESMALLOC 128*1024U
struct elem {
unsigned int magic1;
struct flist_head list;
unsigned int magic2;
struct elem {
unsigned int magic1;
struct flist_head list;
unsigned int magic2;
+ unsigned int size;
};
};
-FLIST_HEAD(list);
+
static
FLIST_HEAD(list);
static int do_rand_allocs(void)
{
static int do_rand_allocs(void)
{
- unsigned int size, nr, rounds = 0;
+ unsigned int size, nr, rounds = 0
, ret = 0
;
unsigned long total;
struct elem *e;
unsigned long total;
struct elem *e;
+ bool error;
while (rounds++ < LOOPS) {
#ifdef STEST_SEED
srand(MAGIC1);
#endif
while (rounds++ < LOOPS) {
#ifdef STEST_SEED
srand(MAGIC1);
#endif
+ error = false;
nr = total = 0;
nr = total = 0;
- while (total <
120*1024*1024UL
) {
+ while (total <
MAXSMALLOC
) {
size = 8 * sizeof(struct elem) + (int) (999.0 * (rand() / (RAND_MAX + 1.0)));
e = smalloc(size);
if (!e) {
printf("fail at %lu, size %u\n", total, size);
size = 8 * sizeof(struct elem) + (int) (999.0 * (rand() / (RAND_MAX + 1.0)));
e = smalloc(size);
if (!e) {
printf("fail at %lu, size %u\n", total, size);
+ ret++;
break;
}
e->magic1 = MAGIC1;
e->magic2 = MAGIC2;
break;
}
e->magic1 = MAGIC1;
e->magic2 = MAGIC2;
+ e->size = size;
total += size;
flist_add_tail(&e->list, &list);
nr++;
total += size;
flist_add_tail(&e->list, &list);
nr++;
@@
-51,34
+58,39
@@
static int do_rand_allocs(void)
e = flist_entry(list.next, struct elem, list);
assert(e->magic1 == MAGIC1);
assert(e->magic2 == MAGIC2);
e = flist_entry(list.next, struct elem, list);
assert(e->magic1 == MAGIC1);
assert(e->magic2 == MAGIC2);
+ total -= e->size;
flist_del(&e->list);
sfree(e);
flist_del(&e->list);
sfree(e);
+
+ if (!error) {
+ e = smalloc(LARGESMALLOC);
+ if (!e) {
+ error = true;
+ ret++;
+ printf("failure allocating %u bytes at %lu allocated during sfree phase\n",
+ LARGESMALLOC, total);
+ }
+ else
+ sfree(e);
+ }
}
}
}
}
- return 0;
-}
-
-static int do_specific_alloc(unsigned long size)
-{
- void *ptr;
-
- ptr = smalloc(size);
- sfree(ptr);
- return 0;
+ return ret;
}
int main(int argc, char *argv[])
{
}
int main(int argc, char *argv[])
{
+ int ret;
+
arch_init(argv);
sinit();
debug_init();
arch_init(argv);
sinit();
debug_init();
- do_rand_allocs();
-
- /* smalloc bug, commit 271067a6 */
- do_specific_alloc(671386584);
+ ret = do_rand_allocs();
+ smalloc_debug(0); /* TODO: check that free and total blocks
+ ** match */
scleanup();
scleanup();
- return
0
;
+ return
ret
;
}
}