xref: /openbmc/qemu/tests/tcg/cris/libc/check_mapbrk.c (revision ca693d1c)
1 #include <stdio.h>
2 #include <stdlib.h>
3 
4 /* Basic sanity check that syscalls to implement malloc (brk, mmap2,
5    munmap) are trivially functional.  */
6 
7 int main ()
8 {
9   void *p1, *p2, *p3, *p4, *p5, *p6;
10 
11   if ((p1 = malloc (8100)) == NULL
12       || (p2 = malloc (16300)) == NULL
13       || (p3 = malloc (4000)) == NULL
14       || (p4 = malloc (500)) == NULL
15       || (p5 = malloc (1023*1024)) == NULL
16       || (p6 = malloc (8191*1024)) == NULL)
17   {
18     printf ("fail\n");
19     exit (1);
20   }
21 
22   free (p1);
23   free (p2);
24   free (p3);
25   free (p4);
26   free (p5);
27   free (p6);
28 
29   p1 = malloc (64000);
30   if (p1 == NULL)
31   {
32     printf ("fail\n");
33     exit (1);
34   }
35   free (p1);
36 
37   printf ("pass\n");
38   exit (0);
39 }
40