Automation testing tools.

This commit is contained in:
Geoffrey Challen
2016-01-11 16:08:40 -05:00
parent 5f05f192de
commit b66416e24f
14 changed files with 872 additions and 3 deletions

View File

@@ -59,6 +59,7 @@ int vsnprintf(char *buf, size_t len, const char *fmt, __va_list ap);
/* Automated testing extensions. */
int tprintf(const char *fmt, ...);
int nprintf(const char *fmt, ...);
int printsf(const char *fmt, ...);
/* Print the argument string and then a newline. Returns 0 or -1 on error. */

View File

@@ -97,6 +97,24 @@ tprintf(const char *fmt, ...)
return chars;
}
/* printf variant that is loud during automated testing */
int
nprintf(const char *fmt, ...)
{
int chars;
va_list ap;
if (strcmp(KERNEL_SECRET, "") == 0) {
return 0;
}
va_start(ap, fmt);
chars = vprintf(fmt, ap);
va_end(ap);
return chars;
}
/* printf variant that prepends the kernel secret */
int
printsf(const char *fmt, ...)

View File

@@ -10,8 +10,8 @@ SUBDIRS=add argtest badcall bigexec bigfile bigfork bigseek bloat conman \
filetest forkbomb forktest frack guzzle hash hog huge kitchen \
malloctest matmult multiexec palin parallelvm poisondisk psort \
quinthuge quintmat quintsort randcall redirect rmdirtest rmtest \
sbrktest schedpong sink sort sparsefile sty tail tictac triplehuge \
triplemat triplesort usemtest zero
sbrktest schedpong sink sort sparsefile spinner sty tail tictac \
triplehuge triplemat triplesort usemtest waiter zero
# But not:
# userthreads (no support in kernel API in base system)

View File

@@ -0,0 +1,11 @@
# Makefile for spinner
TOP=../../..
.include "$(TOP)/mk/os161.config.mk"
PROG=spinner
SRCS=spinner.c
BINDIR=/testbin
.include "$(TOP)/mk/os161.prog.mk"

View File

@@ -0,0 +1,47 @@
/*
* spinner.c
*
* Spins as hard as it can, forking multiple processes as needed. Intended to
* test our ability to detect stuck processes in userspace.
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <err.h>
static
void
spin(void)
{
volatile int i;
for (i=0; i <= 1000; i++) {
if (i == 1000) {
i = 0;
}
}
}
int
main(int argc, char **argv)
{
int i, count, pid;
if (argc != 2) {
errx(1, "Usage: spinner <count>");
}
count = atoi(argv[1]);
for (i = 1; i < count; i++) {
pid = fork();
if (pid != 0) {
spin();
}
}
spin();
errx(2, "spinner: spin returned");
// 09 Jan 2015 : GWA : Shouldn't get here.
return 0;
}

View File

@@ -0,0 +1,11 @@
# Makefile for waiter
TOP=../../..
.include "$(TOP)/mk/os161.config.mk"
PROG=waiter
SRCS=waiter.c
BINDIR=/testbin
.include "$(TOP)/mk/os161.prog.mk"

View File

@@ -0,0 +1,29 @@
/*
* waiter.c
*
* Just sits there without doing anything. We use the read system call just to
* provide a way to wait. Intended to test our ability to detect stuck
* processes in userspace.
*/
#include <unistd.h>
#include <err.h>
int
main(void)
{
char ch=0;
int len;
while (ch!='q') {
len = read(STDIN_FILENO, &ch, 1);
if (len < 0) {
err(1, "stdin: read");
}
if (len==0) {
/* EOF */
break;
}
}
return 0;
}