summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Fu <vincent.fu@wdc.com>2019-10-16 15:03:32 -0400
committerVincent Fu <vincent.fu@wdc.com>2019-11-06 11:18:59 -0500
commit94a30f0abcdd162c1f8c32ef46b4328c7b6e5224 (patch)
treeace18cc72e6cdb406038114d23135302b3c6ebf4
parent82d4d748901108702922833107e55559cffe0f6c (diff)
downloadfio-94a30f0abcdd162c1f8c32ef46b4328c7b6e5224.tar.gz
fio-94a30f0abcdd162c1f8c32ef46b4328c7b6e5224.tar.bz2
t/stest: non-zero exit value on failure
To facilitate automated testing, return a non-zero exit value when a smalloc failure occurs.
-rw-r--r--t/stest.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/t/stest.c b/t/stest.c
index 515ae5a5..c6bf2d1e 100644
--- a/t/stest.c
+++ b/t/stest.c
@@ -25,7 +25,7 @@ static FLIST_HEAD(list);
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;
bool error;
@@ -41,6 +41,7 @@ static int do_rand_allocs(void)
e = smalloc(size);
if (!e) {
printf("fail at %lu, size %u\n", total, size);
+ ret++;
break;
}
e->magic1 = MAGIC1;
@@ -65,6 +66,7 @@ static int do_rand_allocs(void)
e = smalloc(LARGESMALLOC);
if (!e) {
error = true;
+ ret++;
printf("failure allocating %u bytes at %lu allocated during sfree phase\n",
LARGESMALLOC, total);
}
@@ -74,18 +76,21 @@ static int do_rand_allocs(void)
}
}
- return 0;
+ return ret;
}
int main(int argc, char *argv[])
{
+ int ret;
+
arch_init(argv);
sinit();
debug_init();
- do_rand_allocs();
- smalloc_debug(0); /* free and total blocks should match */
+ ret = do_rand_allocs();
+ smalloc_debug(0); /* TODO: check that free and total blocks
+ ** match */
scleanup();
- return 0;
+ return ret;
}