diff options
Diffstat (limited to 'src/regress/lib/libc/malloc')
13 files changed, 0 insertions, 511 deletions
diff --git a/src/regress/lib/libc/malloc/Makefile b/src/regress/lib/libc/malloc/Makefile deleted file mode 100644 index 7eb84f6a6c..0000000000 --- a/src/regress/lib/libc/malloc/Makefile +++ /dev/null | |||
| @@ -1,8 +0,0 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.7 2018/01/28 13:42:17 otto Exp $ | ||
| 2 | |||
| 3 | SUBDIR+= malloc_general malloc0test malloc_errno malloc_ulimit1 malloc_ulimit2 | ||
| 4 | SUBDIR+= malloc_threaderr | ||
| 5 | |||
| 6 | install: | ||
| 7 | |||
| 8 | .include <bsd.subdir.mk> | ||
diff --git a/src/regress/lib/libc/malloc/malloc0test/Makefile b/src/regress/lib/libc/malloc/malloc0test/Makefile deleted file mode 100644 index fc2295c091..0000000000 --- a/src/regress/lib/libc/malloc/malloc0test/Makefile +++ /dev/null | |||
| @@ -1,11 +0,0 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.2 2017/07/08 00:08:26 bluhm Exp $ | ||
| 2 | |||
| 3 | PROG= malloc0test | ||
| 4 | |||
| 5 | .for m in C D F G J j R S U X << >>> | ||
| 6 | REGRESS_TARGETS += run-regress-${PROG}-${m:S/</-/g:S/>/+/g} | ||
| 7 | run-regress-${PROG}-${m:S/</-/g:S/>/+/g}: ${PROG} | ||
| 8 | MALLOC_OPTIONS='${m}' ./${PROG} | ||
| 9 | .endfor | ||
| 10 | |||
| 11 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libc/malloc/malloc0test/malloc0test.c b/src/regress/lib/libc/malloc/malloc0test/malloc0test.c deleted file mode 100644 index 06ff0996ee..0000000000 --- a/src/regress/lib/libc/malloc/malloc0test/malloc0test.c +++ /dev/null | |||
| @@ -1,120 +0,0 @@ | |||
| 1 | /* $OpenBSD: malloc0test.c,v 1.5 2008/04/13 00:22:17 djm Exp $ */ | ||
| 2 | /* | ||
| 3 | * Public domain. 2001, Theo de Raadt | ||
| 4 | */ | ||
| 5 | #include <sys/types.h> | ||
| 6 | #include <sys/signal.h> | ||
| 7 | #include <stdio.h> | ||
| 8 | #include <unistd.h> | ||
| 9 | #include <stdlib.h> | ||
| 10 | #include <setjmp.h> | ||
| 11 | #include <limits.h> | ||
| 12 | #include <errno.h> | ||
| 13 | |||
| 14 | volatile sig_atomic_t got; | ||
| 15 | jmp_buf jmp; | ||
| 16 | |||
| 17 | static void | ||
| 18 | catch(int signo) | ||
| 19 | { | ||
| 20 | got++; | ||
| 21 | longjmp(jmp, 1); | ||
| 22 | } | ||
| 23 | |||
| 24 | static int | ||
| 25 | test(char *p, int size) | ||
| 26 | { | ||
| 27 | signal(SIGSEGV, catch); | ||
| 28 | got = 0; | ||
| 29 | if (setjmp(jmp) == 0) | ||
| 30 | *p = 0; | ||
| 31 | if (setjmp(jmp) == 0) | ||
| 32 | *(p+size-1) = 0; | ||
| 33 | return (got); | ||
| 34 | } | ||
| 35 | |||
| 36 | char *prot_table[] = { | ||
| 37 | "unprotected", | ||
| 38 | "fuckup", | ||
| 39 | "protected" | ||
| 40 | }; | ||
| 41 | |||
| 42 | #define SIZE 10 | ||
| 43 | |||
| 44 | /* | ||
| 45 | * Do random memory allocations. | ||
| 46 | * | ||
| 47 | * For each one, ensure that it is at least 16 bytes in size (that | ||
| 48 | * being what our current malloc returns for the minsize of an | ||
| 49 | * object, alignment wise); | ||
| 50 | * | ||
| 51 | * For zero-byte allocations, check that they are still aligned. | ||
| 52 | * | ||
| 53 | * For each object, ensure that they are correctly protected or not | ||
| 54 | * protected. | ||
| 55 | * | ||
| 56 | * Does not regress test malloc + free combinations ... it should. | ||
| 57 | */ | ||
| 58 | int | ||
| 59 | main(int argc, char *argv[]) | ||
| 60 | { | ||
| 61 | caddr_t blob; | ||
| 62 | int size, tsize; | ||
| 63 | int prot; | ||
| 64 | int rval = 0, fuckup = 0; | ||
| 65 | long limit = 200000, count; | ||
| 66 | int ch, silent = 0; | ||
| 67 | char *ep; | ||
| 68 | extern char *__progname; | ||
| 69 | |||
| 70 | while ((ch = getopt(argc, argv, "sn:")) != -1) { | ||
| 71 | switch (ch) { | ||
| 72 | case 's': | ||
| 73 | silent = 1; | ||
| 74 | break; | ||
| 75 | case 'n': | ||
| 76 | errno = 0; | ||
| 77 | limit = strtol(optarg, &ep, 10); | ||
| 78 | if (optarg[0] == '\0' || *ep != '\0' || | ||
| 79 | (errno == ERANGE && | ||
| 80 | (limit == LONG_MAX || limit == LONG_MIN))) | ||
| 81 | goto usage; | ||
| 82 | break; | ||
| 83 | default: | ||
| 84 | usage: | ||
| 85 | fprintf(stderr, "Usage: %s [-s][-n <count>]\n", | ||
| 86 | __progname); | ||
| 87 | exit(1); | ||
| 88 | } | ||
| 89 | } | ||
| 90 | |||
| 91 | if (limit == 0) | ||
| 92 | limit = LONG_MAX; | ||
| 93 | |||
| 94 | for (count = 0; count < limit; count++) { | ||
| 95 | size = arc4random_uniform(SIZE); | ||
| 96 | blob = malloc(size); | ||
| 97 | if (blob == NULL) { | ||
| 98 | fprintf(stderr, "success: out of memory\n"); | ||
| 99 | exit(rval); | ||
| 100 | } | ||
| 101 | |||
| 102 | tsize = size == 0 ? 16 : size; | ||
| 103 | fuckup = 0; | ||
| 104 | prot = test(blob, tsize); | ||
| 105 | |||
| 106 | if (size == 0 && prot < 2) | ||
| 107 | fuckup = 1; | ||
| 108 | |||
| 109 | if (fuckup) { | ||
| 110 | printf("%8p %6d %20s %10s\n", blob, size, | ||
| 111 | prot_table[prot], fuckup ? "fuckup" : ""); | ||
| 112 | rval = 1; | ||
| 113 | } | ||
| 114 | |||
| 115 | if (!silent && count % 100000 == 0 && count != 0) | ||
| 116 | fprintf(stderr, "count = %ld\n", count); | ||
| 117 | } | ||
| 118 | |||
| 119 | return rval; | ||
| 120 | } | ||
diff --git a/src/regress/lib/libc/malloc/malloc_errno/Makefile b/src/regress/lib/libc/malloc/malloc_errno/Makefile deleted file mode 100644 index 73ebe37491..0000000000 --- a/src/regress/lib/libc/malloc/malloc_errno/Makefile +++ /dev/null | |||
| @@ -1,5 +0,0 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.1 2003/07/15 10:06:31 otto Exp $ | ||
| 2 | |||
| 3 | PROG= malloc_errno | ||
| 4 | |||
| 5 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libc/malloc/malloc_errno/malloc_errno.c b/src/regress/lib/libc/malloc/malloc_errno/malloc_errno.c deleted file mode 100644 index 896ea3c900..0000000000 --- a/src/regress/lib/libc/malloc/malloc_errno/malloc_errno.c +++ /dev/null | |||
| @@ -1,46 +0,0 @@ | |||
| 1 | /* $OpenBSD: malloc_errno.c,v 1.4 2003/12/25 18:49:57 miod Exp $ */ | ||
| 2 | /* | ||
| 3 | * Public domain. 2003, Otto Moerbeek | ||
| 4 | */ | ||
| 5 | #include <err.h> | ||
| 6 | #include <errno.h> | ||
| 7 | #include <stdio.h> | ||
| 8 | #include <stdlib.h> | ||
| 9 | |||
| 10 | static void | ||
| 11 | testerrno(size_t sz) | ||
| 12 | { | ||
| 13 | void *p; | ||
| 14 | |||
| 15 | errno = -1; | ||
| 16 | p = malloc(sz); | ||
| 17 | |||
| 18 | if (p == NULL && errno != ENOMEM) | ||
| 19 | errx(1, "fail: %lx %p %d", (unsigned long)sz, p, errno); | ||
| 20 | |||
| 21 | /* if alloc succeeded, test if errno did not change */ | ||
| 22 | if (p != NULL && errno != -1) | ||
| 23 | errx(1, "fail: %lx %p %d", (unsigned long)sz, p, errno); | ||
| 24 | |||
| 25 | free(p); | ||
| 26 | } | ||
| 27 | |||
| 28 | /* | ||
| 29 | * Provide some (silly) arguments to malloc(), and check if ERRNO is set | ||
| 30 | * correctly. | ||
| 31 | */ | ||
| 32 | int | ||
| 33 | main(int argc, char *argv[]) | ||
| 34 | { | ||
| 35 | size_t i; | ||
| 36 | |||
| 37 | testerrno(1); | ||
| 38 | testerrno(100000); | ||
| 39 | testerrno(-1); | ||
| 40 | testerrno(-1000); | ||
| 41 | testerrno(-10000); | ||
| 42 | testerrno(-10000000); | ||
| 43 | for (i = 0; i < 0x10; i++) | ||
| 44 | testerrno(i * 0x10000000); | ||
| 45 | return 0; | ||
| 46 | } | ||
diff --git a/src/regress/lib/libc/malloc/malloc_general/Makefile b/src/regress/lib/libc/malloc/malloc_general/Makefile deleted file mode 100644 index a0ee823bbe..0000000000 --- a/src/regress/lib/libc/malloc/malloc_general/Makefile +++ /dev/null | |||
| @@ -1,27 +0,0 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.3 2017/01/24 16:03:28 otto Exp $ | ||
| 2 | |||
| 3 | REGRESS_TARGETS= t1 t2 t3 t4 t5 t6 t7 | ||
| 4 | PROG= malloc_general | ||
| 5 | |||
| 6 | .include <bsd.regress.mk> | ||
| 7 | |||
| 8 | t1: malloc_general | ||
| 9 | ${.OBJDIR}/malloc_general "" | ||
| 10 | |||
| 11 | t2: malloc_general | ||
| 12 | ${.OBJDIR}//malloc_general C | ||
| 13 | |||
| 14 | t3: malloc_general | ||
| 15 | ${.OBJDIR}//malloc_general J | ||
| 16 | |||
| 17 | t4: malloc_general | ||
| 18 | ${.OBJDIR}//malloc_general F | ||
| 19 | |||
| 20 | t5: malloc_general | ||
| 21 | ${.OBJDIR}//malloc_general G | ||
| 22 | |||
| 23 | t6: malloc_general | ||
| 24 | ${.OBJDIR}//malloc_general S | ||
| 25 | |||
| 26 | t7: malloc_general | ||
| 27 | ${.OBJDIR}//malloc_general FGJ | ||
diff --git a/src/regress/lib/libc/malloc/malloc_general/malloc_general.c b/src/regress/lib/libc/malloc/malloc_general/malloc_general.c deleted file mode 100644 index 51bfb03a34..0000000000 --- a/src/regress/lib/libc/malloc/malloc_general/malloc_general.c +++ /dev/null | |||
| @@ -1,125 +0,0 @@ | |||
| 1 | /* $OpenBSD */ | ||
| 2 | /* | ||
| 3 | * Copyright (c) 2017 Otto Moerbeek <otto@drijf.net> | ||
| 4 | * | ||
| 5 | * Permission to use, copy, modify, and distribute this software for any | ||
| 6 | * purpose with or without fee is hereby granted, provided that the above | ||
| 7 | * copyright notice and this permission notice appear in all copies. | ||
| 8 | * | ||
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include <err.h> | ||
| 19 | #include <stdio.h> | ||
| 20 | #include <stdlib.h> | ||
| 21 | #include <string.h> | ||
| 22 | |||
| 23 | /* $define VERBOSE */ | ||
| 24 | |||
| 25 | #define N 1000 | ||
| 26 | |||
| 27 | size_t | ||
| 28 | size(void) | ||
| 29 | { | ||
| 30 | int p = arc4random_uniform(13) + 3; | ||
| 31 | return arc4random_uniform(1 << p); | ||
| 32 | } | ||
| 33 | |||
| 34 | struct { void *p; size_t sz; } a[N]; | ||
| 35 | |||
| 36 | extern char *malloc_options; | ||
| 37 | |||
| 38 | void | ||
| 39 | fill(u_char *p, size_t sz) | ||
| 40 | { | ||
| 41 | size_t i; | ||
| 42 | |||
| 43 | for (i = 0; i < sz; i++) | ||
| 44 | p[i] = i % 256; | ||
| 45 | } | ||
| 46 | |||
| 47 | void | ||
| 48 | check(u_char *p, size_t sz) | ||
| 49 | { | ||
| 50 | size_t i; | ||
| 51 | |||
| 52 | for (i = 0; i < sz; i++) | ||
| 53 | if (p[i] != i % 256) | ||
| 54 | errx(1, "check"); | ||
| 55 | } | ||
| 56 | |||
| 57 | int | ||
| 58 | main(int argc, char *argv[]) | ||
| 59 | { | ||
| 60 | int count, p, i; | ||
| 61 | void * q; | ||
| 62 | size_t sz; | ||
| 63 | |||
| 64 | if (argc == 1) | ||
| 65 | errx(1, "usage: malloc_options"); | ||
| 66 | |||
| 67 | malloc_options = argv[1]; | ||
| 68 | |||
| 69 | for (count = 0; count < 800000; count++) { | ||
| 70 | if (count % 10000 == 0) { | ||
| 71 | printf("."); | ||
| 72 | fflush(stdout); | ||
| 73 | } | ||
| 74 | p = arc4random_uniform(2); | ||
| 75 | i = arc4random_uniform(N); | ||
| 76 | switch (p) { | ||
| 77 | case 0: | ||
| 78 | if (a[i].p) { | ||
| 79 | #ifdef VERBOSE | ||
| 80 | printf("F %p\n", a[i].p); | ||
| 81 | #endif | ||
| 82 | if (a[i].p) | ||
| 83 | check(a[i].p, a[i].sz); | ||
| 84 | free(a[i].p); | ||
| 85 | a[i].p = NULL; | ||
| 86 | } | ||
| 87 | sz = size(); | ||
| 88 | #ifdef VERBOSE | ||
| 89 | printf("M %zu=", sz); | ||
| 90 | #endif | ||
| 91 | a[i].p = malloc(sz); | ||
| 92 | a[i].sz = sz; | ||
| 93 | #ifdef VERBOSE | ||
| 94 | printf("%p\n", a[i].p); | ||
| 95 | #endif | ||
| 96 | if (a[i].p) | ||
| 97 | fill(a[i].p, sz); | ||
| 98 | break; | ||
| 99 | case 1: | ||
| 100 | sz = size(); | ||
| 101 | #ifdef VERBOSE | ||
| 102 | printf("R %p %zu=", a[i].p, sz); | ||
| 103 | #endif | ||
| 104 | q = realloc(a[i].p, sz); | ||
| 105 | #ifdef VERBOSE | ||
| 106 | printf("%p\n", q); | ||
| 107 | #endif | ||
| 108 | if (a[i].p && q) | ||
| 109 | check(q, a[i].sz < sz ? a[i].sz : sz); | ||
| 110 | if (q) { | ||
| 111 | a[i].p = q; | ||
| 112 | a[i].sz = sz; | ||
| 113 | fill(a[i].p, sz); | ||
| 114 | } | ||
| 115 | break; | ||
| 116 | } | ||
| 117 | } | ||
| 118 | for (i = 0; i < N; i++) { | ||
| 119 | if (a[i].p) | ||
| 120 | check(a[i].p, a[i].sz); | ||
| 121 | free(a[i].p); | ||
| 122 | } | ||
| 123 | printf("\n"); | ||
| 124 | return 0; | ||
| 125 | } | ||
diff --git a/src/regress/lib/libc/malloc/malloc_threaderr/Makefile b/src/regress/lib/libc/malloc/malloc_threaderr/Makefile deleted file mode 100644 index 2d715af58b..0000000000 --- a/src/regress/lib/libc/malloc/malloc_threaderr/Makefile +++ /dev/null | |||
| @@ -1,13 +0,0 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.2 2018/01/28 14:55:24 otto Exp $ | ||
| 2 | |||
| 3 | # This test is supposed to print a malloc error and create a core dump | ||
| 4 | |||
| 5 | REGRESS_TARGETS= t1 | ||
| 6 | PROG= malloc_threaderr | ||
| 7 | LDADD+= -pthread | ||
| 8 | DPADD+= ${LIBPTHREAD} | ||
| 9 | |||
| 10 | .include <bsd.regress.mk> | ||
| 11 | |||
| 12 | t1: malloc_threaderr | ||
| 13 | ${.OBJDIR}/malloc_threaderr 2>&1 | fgrep 'in free(): bogus pointer (double free?)' | ||
diff --git a/src/regress/lib/libc/malloc/malloc_threaderr/malloc_threaderr.c b/src/regress/lib/libc/malloc/malloc_threaderr/malloc_threaderr.c deleted file mode 100644 index f34f37fc93..0000000000 --- a/src/regress/lib/libc/malloc/malloc_threaderr/malloc_threaderr.c +++ /dev/null | |||
| @@ -1,58 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2018 Otto Moerbeek <otto@drijf.net> | ||
| 3 | * | ||
| 4 | * Permission to use, copy, modify, and distribute this software for any | ||
| 5 | * purpose with or without fee is hereby granted, provided that the above | ||
| 6 | * copyright notice and this permission notice appear in all copies. | ||
| 7 | * | ||
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include <err.h> | ||
| 18 | #include <stdio.h> | ||
| 19 | #include <stdlib.h> | ||
| 20 | #include <pthread.h> | ||
| 21 | |||
| 22 | pthread_cond_t cond; | ||
| 23 | pthread_mutex_t mutex; | ||
| 24 | |||
| 25 | void *p; | ||
| 26 | |||
| 27 | void *m(void *arg) | ||
| 28 | { | ||
| 29 | p = malloc(100000); | ||
| 30 | if (p == NULL) | ||
| 31 | err(1, NULL); | ||
| 32 | return NULL; | ||
| 33 | } | ||
| 34 | |||
| 35 | void *f(void *arg) | ||
| 36 | { | ||
| 37 | free(p); | ||
| 38 | free(p); | ||
| 39 | return NULL; | ||
| 40 | } | ||
| 41 | |||
| 42 | int | ||
| 43 | main(void) | ||
| 44 | { | ||
| 45 | pthread_t t1, t2; | ||
| 46 | |||
| 47 | printf("This test is supposed to print a malloc error and create a core dump\n"); | ||
| 48 | |||
| 49 | if (pthread_create(&t1, NULL, m, NULL)) | ||
| 50 | err(1, "pthread_create"); | ||
| 51 | pthread_join(t1, NULL); | ||
| 52 | |||
| 53 | if (pthread_create(&t2, NULL, f, NULL)) | ||
| 54 | err(1, "pthread_create"); | ||
| 55 | pthread_join(t2, NULL); | ||
| 56 | |||
| 57 | return 0; | ||
| 58 | } | ||
diff --git a/src/regress/lib/libc/malloc/malloc_ulimit1/Makefile b/src/regress/lib/libc/malloc/malloc_ulimit1/Makefile deleted file mode 100644 index 46ced27a98..0000000000 --- a/src/regress/lib/libc/malloc/malloc_ulimit1/Makefile +++ /dev/null | |||
| @@ -1,5 +0,0 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.1 2006/04/18 19:03:30 otto Exp $ | ||
| 2 | |||
| 3 | PROG= malloc_ulimit1 | ||
| 4 | |||
| 5 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libc/malloc/malloc_ulimit1/malloc_ulimit1.c b/src/regress/lib/libc/malloc/malloc_ulimit1/malloc_ulimit1.c deleted file mode 100644 index 94f7eb16b5..0000000000 --- a/src/regress/lib/libc/malloc/malloc_ulimit1/malloc_ulimit1.c +++ /dev/null | |||
| @@ -1,45 +0,0 @@ | |||
| 1 | /* $OpenBSD: malloc_ulimit1.c,v 1.3 2017/07/27 15:08:37 bluhm Exp $ */ | ||
| 2 | |||
| 3 | /* Public Domain, 2006, Otto Moerbeek <otto@drijf.net> */ | ||
| 4 | |||
| 5 | #include <sys/types.h> | ||
| 6 | #include <sys/time.h> | ||
| 7 | #include <sys/resource.h> | ||
| 8 | #include <err.h> | ||
| 9 | #include <stdlib.h> | ||
| 10 | #include <stdio.h> | ||
| 11 | |||
| 12 | /* | ||
| 13 | * This code tries to trigger the case present in -current as of April | ||
| 14 | * 2006) where the allocation of the region itself succeeds, but the | ||
| 15 | * page dir entry pages fails. | ||
| 16 | * This in turn trips a "hole in directories" error. | ||
| 17 | * Having a large (512M) ulimit -m helps a lot in triggering the | ||
| 18 | * problem. Note that you may need to run this test multiple times to | ||
| 19 | * see the error. | ||
| 20 | */ | ||
| 21 | |||
| 22 | #define STARTI 1300 | ||
| 23 | #define FACTOR 1024 | ||
| 24 | |||
| 25 | int | ||
| 26 | main() | ||
| 27 | { | ||
| 28 | struct rlimit lim; | ||
| 29 | size_t sz; | ||
| 30 | int i; | ||
| 31 | void *p; | ||
| 32 | |||
| 33 | if (getrlimit(RLIMIT_DATA, &lim) == -1) | ||
| 34 | err(1, "getrlimit"); | ||
| 35 | |||
| 36 | sz = lim.rlim_cur / FACTOR; | ||
| 37 | |||
| 38 | for (i = STARTI; i >= 0; i--) { | ||
| 39 | size_t len = (sz-i) * FACTOR; | ||
| 40 | p = malloc(len); | ||
| 41 | free(p); | ||
| 42 | free(malloc(4096)); | ||
| 43 | } | ||
| 44 | return (0); | ||
| 45 | } | ||
diff --git a/src/regress/lib/libc/malloc/malloc_ulimit2/Makefile b/src/regress/lib/libc/malloc/malloc_ulimit2/Makefile deleted file mode 100644 index bc83666415..0000000000 --- a/src/regress/lib/libc/malloc/malloc_ulimit2/Makefile +++ /dev/null | |||
| @@ -1,5 +0,0 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.1 2006/04/18 19:04:03 otto Exp $ | ||
| 2 | |||
| 3 | PROG= malloc_ulimit2 | ||
| 4 | |||
| 5 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libc/malloc/malloc_ulimit2/malloc_ulimit2.c b/src/regress/lib/libc/malloc/malloc_ulimit2/malloc_ulimit2.c deleted file mode 100644 index 9510649090..0000000000 --- a/src/regress/lib/libc/malloc/malloc_ulimit2/malloc_ulimit2.c +++ /dev/null | |||
| @@ -1,43 +0,0 @@ | |||
| 1 | /* $OpenBSD: malloc_ulimit2.c,v 1.3 2017/07/27 15:08:37 bluhm Exp $ */ | ||
| 2 | |||
| 3 | /* Public Domain, 2006, Otto Moerbeek <otto@drijf.net> */ | ||
| 4 | |||
| 5 | #include <sys/types.h> | ||
| 6 | #include <sys/time.h> | ||
| 7 | #include <sys/resource.h> | ||
| 8 | #include <err.h> | ||
| 9 | #include <stdlib.h> | ||
| 10 | #include <stdio.h> | ||
| 11 | |||
| 12 | #define FACTOR 1024 | ||
| 13 | |||
| 14 | int | ||
| 15 | main() | ||
| 16 | { | ||
| 17 | struct rlimit lim; | ||
| 18 | size_t sz; | ||
| 19 | int i; | ||
| 20 | void *p; | ||
| 21 | |||
| 22 | if (getrlimit(RLIMIT_DATA, &lim) == -1) | ||
| 23 | err(1, "getrlimit"); | ||
| 24 | |||
| 25 | sz = lim.rlim_cur / FACTOR; | ||
| 26 | |||
| 27 | for (i = 0; ; i++) { | ||
| 28 | size_t len = (sz-i) * FACTOR; | ||
| 29 | p = malloc(len); | ||
| 30 | if (p != NULL) { | ||
| 31 | free(p); | ||
| 32 | break; | ||
| 33 | } | ||
| 34 | } | ||
| 35 | i += 10; | ||
| 36 | for (; i >= 0; i--) { | ||
| 37 | size_t len = (sz-i) * FACTOR; | ||
| 38 | p = malloc(len); | ||
| 39 | free(p); | ||
| 40 | free(malloc(4096)); | ||
| 41 | } | ||
| 42 | return (0); | ||
| 43 | } | ||
