aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile10
-rw-r--r--tests/files.c36
-rw-r--r--tests/mem.c36
-rw-r--r--tests/stack.c28
-rw-r--r--tests/write.c50
5 files changed, 114 insertions, 46 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 963e097..c2e0e72 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,8 +1,4 @@
.PHONY: all clean
-
-CC = clang
-
-all : files mem stack write
-
-clean :
- rm -f files mem stack write
+all: files mem stack write
+clean:
+ rm -f -- $(ALL)
diff --git a/tests/files.c b/tests/files.c
index 1b2dafa..d11d530 100644
--- a/tests/files.c
+++ b/tests/files.c
@@ -1,16 +1,34 @@
+/**
+ * Copyright (C) 2016, 2018, 2021 Tom Ryder <tom@sanctum.geek.nz>
+ *
+ * This file is part of doomsh.
+ *
+ * doomsh is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * doomsh is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * doomsh. If not, see <https://www.gnu.org/licenses/>.
+ */
+
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
/* files.c -- Open as many files as we can */
int main(void) {
- FILE *fp = NULL;
- int i = 0;
- for (;;i++) {
- if ((fp = tmpfile()) == NULL) {
- fprintf(stderr, "Created %u files\n", i);
- perror("tmpfile");
- raise(SIGABRT);
- }
- }
+ FILE *fp = NULL;
+ int i = 0;
+ for (;;i++) {
+ if ((fp = tmpfile()) == NULL) {
+ fprintf(stderr, "Created %u files\n", i);
+ perror("tmpfile");
+ raise(SIGABRT);
+ }
+ }
}
diff --git a/tests/mem.c b/tests/mem.c
index b39e538..025446d 100644
--- a/tests/mem.c
+++ b/tests/mem.c
@@ -1,3 +1,21 @@
+/**
+ * Copyright (C) 2016, 2018, 2021 Tom Ryder <tom@sanctum.geek.nz>
+ *
+ * This file is part of doomsh.
+ *
+ * doomsh is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * doomsh is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * doomsh. If not, see <https://www.gnu.org/licenses/>.
+ */
+
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@@ -11,13 +29,13 @@
* you really want to actually use the memory. Do you trust your OOM though?
*/
int main(void){
- void *ptr = NULL;
- unsigned long mb = 5;
- for (;;mb += 5) {
- fprintf(stderr, "%lu MB\n", mb);
- if ((ptr = realloc(ptr, mb * 1000000)) == NULL) {
- raise(SIGABRT);
- }
- /* memset(ptr, 0, mb * 1000000); */
- }
+ void *ptr = NULL;
+ unsigned long mb = 5;
+ for (;;mb += 5) {
+ fprintf(stderr, "%lu MB\n", mb);
+ if ((ptr = realloc(ptr, mb * 1000000)) == NULL) {
+ raise(SIGABRT);
+ }
+ /* memset(ptr, 0, mb * 1000000); */
+ }
}
diff --git a/tests/stack.c b/tests/stack.c
index 3f89d8b..86bf042 100644
--- a/tests/stack.c
+++ b/tests/stack.c
@@ -1,3 +1,21 @@
+/**
+ * Copyright (C) 2016, 2018, 2021 Tom Ryder <tom@sanctum.geek.nz>
+ *
+ * This file is part of doomsh.
+ *
+ * doomsh is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * doomsh is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * doomsh. If not, see <https://www.gnu.org/licenses/>.
+ */
+
#include <stdio.h>
#include <stdlib.h>
@@ -5,11 +23,11 @@ void rec(int *ip);
/* stack.c -- Cause a stack overflow */
int main(void) {
- int i = 0;
- rec(&i);
+ int i = 0;
+ rec(&i);
}
void rec(int *ip) {
- char i[256];
- printf("%u\n", (*ip)++);
- rec(ip);
+ char i[256];
+ printf("%u\n", (*ip)++);
+ rec(ip);
}
diff --git a/tests/write.c b/tests/write.c
index df5bf88..e503951 100644
--- a/tests/write.c
+++ b/tests/write.c
@@ -1,21 +1,39 @@
+/**
+ * Copyright (C) 2016, 2018, 2021 Tom Ryder <tom@sanctum.geek.nz>
+ *
+ * This file is part of doomsh.
+ *
+ * doomsh is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * doomsh is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * doomsh. If not, see <https://www.gnu.org/licenses/>.
+ */
+
#include <signal.h>
#include <stdio.h>
int main(void) {
- FILE *fp = NULL;
- int b = 1;
- char c = '\0';
- if ((fp = tmpfile()) == NULL) {
- perror("tmpfile");
- raise(SIGABRT);
- }
- for (;;b++) {
- if (fwrite(&c, 1, 1, fp) == 0) {
- perror("fwrite");
- raise(SIGABRT);
- }
- if (b % 1000 == 0) {
- fprintf(stderr, "Wrote %u octets\n", b);
- }
- }
+ FILE *fp = NULL;
+ int b = 1;
+ char c = '\0';
+ if ((fp = tmpfile()) == NULL) {
+ perror("tmpfile");
+ raise(SIGABRT);
+ }
+ for (;;b++) {
+ if (fwrite(&c, 1, 1, fp) == 0) {
+ perror("fwrite");
+ raise(SIGABRT);
+ }
+ if (b % 1000 == 0) {
+ fprintf(stderr, "Wrote %u octets\n", b);
+ }
+ }
}