Userland changes for test161/assignment 3.
This commit is contained in:
parent
194f76ef70
commit
fedf80f599
@ -44,6 +44,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <test/test.h>
|
||||||
|
#include <test161/test161.h>
|
||||||
|
|
||||||
#define BRANCHES 6
|
#define BRANCHES 6
|
||||||
|
|
||||||
@ -76,7 +78,9 @@ init(void)
|
|||||||
for (j=0; j<DIM; j++) {
|
for (j=0; j<DIM; j++) {
|
||||||
m1[i*DIM+j] = random() % 11 - 5;
|
m1[i*DIM+j] = random() % 11 - 5;
|
||||||
}
|
}
|
||||||
|
TEST161_TPROGRESS(0);
|
||||||
}
|
}
|
||||||
|
nprintf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
@ -177,11 +181,15 @@ dowait(pid_t pid)
|
|||||||
exit(failures);
|
exit(failures);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// If the child crashes or waitpid returns -1, we don't know how many errors
|
||||||
|
// resulted (if any), but it's an error if we can't tell.
|
||||||
if (waitpid(pid, &status, 0) < 0) {
|
if (waitpid(pid, &status, 0) < 0) {
|
||||||
warn("waitpid(%d)", pid);
|
warn("waitpid(%d)", pid);
|
||||||
|
failures += 1;
|
||||||
}
|
}
|
||||||
else if (WIFSIGNALED(status)) {
|
else if (WIFSIGNALED(status)) {
|
||||||
warnx("pid %d: signal %d", pid, WTERMSIG(status));
|
warnx("pid %d: signal %d", pid, WTERMSIG(status));
|
||||||
|
failures += 1;
|
||||||
}
|
}
|
||||||
else if (WEXITSTATUS(status) > 0) {
|
else if (WEXITSTATUS(status) > 0) {
|
||||||
failures += WEXITSTATUS(status);
|
failures += WEXITSTATUS(status);
|
||||||
@ -196,7 +204,6 @@ dotest(void)
|
|||||||
unsigned i, me;
|
unsigned i, me;
|
||||||
pid_t pids[BRANCHES];
|
pid_t pids[BRANCHES];
|
||||||
int t;
|
int t;
|
||||||
char msg[128];
|
|
||||||
|
|
||||||
me = 0;
|
me = 0;
|
||||||
for (i=0; i<BRANCHES; i++) {
|
for (i=0; i<BRANCHES; i++) {
|
||||||
@ -207,26 +214,28 @@ dotest(void)
|
|||||||
grind();
|
grind();
|
||||||
t = trace();
|
t = trace();
|
||||||
if (t == right[i]) {
|
if (t == right[i]) {
|
||||||
snprintf(msg, sizeof(msg),
|
tsay("Stage %u #%u done: %d\n", i, me, trace());
|
||||||
"Stage %u #%u done: %d\n", i, me, trace());
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
snprintf(msg, sizeof(msg),
|
tsay("Stage %u #%u FAILED: got %d, expected %d\n",
|
||||||
"Stage %u #%u FAILED: got %d, expected %d\n",
|
|
||||||
i, me, t, right[i]);
|
i, me, t, right[i]);
|
||||||
|
success(TEST161_FAIL, SECRET, "/testbin/bigfork");
|
||||||
failures++;
|
failures++;
|
||||||
}
|
}
|
||||||
(void)write(STDOUT_FILENO, msg, strlen(msg));
|
TEST161_TPROGRESS(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=BRANCHES; i-- > 0; ) {
|
for (i=BRANCHES; i-- > 0; ) {
|
||||||
dowait(pids[i]);
|
dowait(pids[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (failures > 0) {
|
if (failures > 0) {
|
||||||
tprintf("%u failures.\n", failures);
|
tprintf("%u failures.\n", failures);
|
||||||
|
success(TEST161_FAIL, SECRET, "/testbin/bigfork");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tprintf("Done.\n");
|
tprintf("Done.\n");
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/bigfork");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <test161/test161.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SIZE is the amount of memory used.
|
* SIZE is the amount of memory used.
|
||||||
@ -90,12 +91,11 @@ main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
e = &array[0];
|
e = &array[0];
|
||||||
for (i=0; i<SIZE; i++) {
|
for (i=0; i<SIZE; i++) {
|
||||||
if (i % stride == 0) {
|
TEST161_LPROGRESS(i, stride);
|
||||||
putchar('.');
|
|
||||||
}
|
|
||||||
e = e->e;
|
e = e->e;
|
||||||
}
|
}
|
||||||
|
|
||||||
tprintf("\nDone!\n");
|
// Success is not crashing
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/ctest");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <test161/test161.h>
|
||||||
|
|
||||||
#define PageSize 4096
|
#define PageSize 4096
|
||||||
#define NumPages 512
|
#define NumPages 512
|
||||||
@ -54,30 +55,37 @@ main(void)
|
|||||||
|
|
||||||
/* move number in so that sparse[i][0]=i */
|
/* move number in so that sparse[i][0]=i */
|
||||||
for (i=0; i<NumPages; i++) {
|
for (i=0; i<NumPages; i++) {
|
||||||
|
TEST161_TPROGRESS(i);
|
||||||
sparse[i][0]=i;
|
sparse[i][0]=i;
|
||||||
}
|
}
|
||||||
|
|
||||||
tprintf("stage [1] done\n");
|
tprintf("stage [1] done\n");
|
||||||
|
nprintf("\n");
|
||||||
|
|
||||||
/* increment each location 5 times */
|
/* increment each location 5 times */
|
||||||
for (j=0; j<5; j++) {
|
for (j=0; j<5; j++) {
|
||||||
for (i=0; i<NumPages; i++) {
|
for (i=0; i<NumPages; i++) {
|
||||||
|
TEST161_TPROGRESS(i);
|
||||||
sparse[i][0]++;
|
sparse[i][0]++;
|
||||||
}
|
}
|
||||||
tprintf("stage [2.%d] done\n", j);
|
tprintf("stage [2.%d] done\n", j);
|
||||||
|
nprintf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
tprintf("stage [2] done\n");
|
tprintf("stage [2] done\n");
|
||||||
|
|
||||||
/* check if the numbers are sane */
|
/* check if the numbers are sane */
|
||||||
for (i=NumPages-1; i>=0; i--) {
|
for (i=NumPages-1; i>=0; i--) {
|
||||||
|
TEST161_TPROGRESS(i);
|
||||||
if (sparse[i][0]!=i+5) {
|
if (sparse[i][0]!=i+5) {
|
||||||
tprintf("BAD NEWS!!! - your VM mechanism has a bug!\n");
|
tprintf("BAD NEWS!!! - your VM mechanism has a bug!\n");
|
||||||
|
success(TEST161_FAIL, SECRET, "/testbin/huge");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tprintf("You passed!\n");
|
nprintf("\n");
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/huge");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <test161/test161.h>
|
||||||
|
|
||||||
#define Dim 72 /* sum total of the arrays doesn't fit in
|
#define Dim 72 /* sum total of the arrays doesn't fit in
|
||||||
* physical memory
|
* physical memory
|
||||||
@ -58,22 +59,35 @@ main(void)
|
|||||||
{
|
{
|
||||||
int i, j, k, r;
|
int i, j, k, r;
|
||||||
|
|
||||||
for (i = 0; i < Dim; i++) /* first initialize the matrices */
|
for (i = 0; i < Dim; i++) { /* first initialize the matrices */
|
||||||
for (j = 0; j < Dim; j++) {
|
for (j = 0; j < Dim; j++) {
|
||||||
A[i][j] = i;
|
TEST161_TPROGRESS_N(i*Dim + j, 1000);
|
||||||
B[i][j] = j;
|
A[i][j] = i;
|
||||||
C[i][j] = 0;
|
B[i][j] = j;
|
||||||
|
C[i][j] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
nprintf("\n");
|
||||||
|
|
||||||
for (i = 0; i < Dim; i++) /* then multiply them together */
|
for (i = 0; i < Dim; i++) { /* then multiply them together */
|
||||||
for (j = 0; j < Dim; j++)
|
for (j = 0; j < Dim; j++) {
|
||||||
for (k = 0; k < Dim; k++)
|
for (k = 0; k < Dim; k++) {
|
||||||
T[i][j][k] = A[i][k] * B[k][j];
|
TEST161_TPROGRESS_N(i*j*Dim*Dim + k, 50000);
|
||||||
|
T[i][j][k] = A[i][k] * B[k][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nprintf("\n");
|
||||||
|
|
||||||
for (i = 0; i < Dim; i++)
|
for (i = 0; i < Dim; i++) {
|
||||||
for (j = 0; j < Dim; j++)
|
for (j = 0; j < Dim; j++) {
|
||||||
for (k = 0; k < Dim; k++)
|
for (k = 0; k < Dim; k++) {
|
||||||
C[i][j] += T[i][j][k];
|
TEST161_TPROGRESS_N(i*j*Dim*Dim + k, 50000);
|
||||||
|
C[i][j] += T[i][j][k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nprintf("\n");
|
||||||
|
|
||||||
r = 0;
|
r = 0;
|
||||||
for (i = 0; i < Dim; i++)
|
for (i = 0; i < Dim; i++)
|
||||||
@ -83,8 +97,11 @@ main(void)
|
|||||||
tprintf("answer is: %d (should be %d)\n", r, RIGHT);
|
tprintf("answer is: %d (should be %d)\n", r, RIGHT);
|
||||||
if (r != RIGHT) {
|
if (r != RIGHT) {
|
||||||
tprintf("FAILED\n");
|
tprintf("FAILED\n");
|
||||||
|
success(TEST161_FAIL, SECRET, "/testbin/matmult");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tprintf("Passed.\n");
|
tprintf("Passed.\n");
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/matmult");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,7 @@ a canal - Panama!
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <test161/test161.h>
|
||||||
|
|
||||||
char palindrome[8000] =
|
char palindrome[8000] =
|
||||||
"amanaplanacaretabanamyriadasumalacaliarahoopapintacatalpaagasanoil"
|
"amanaplanacaretabanamyriadasumalacaliarahoopapintacatalpaagasanoil"
|
||||||
@ -186,13 +187,13 @@ main(void)
|
|||||||
end--;
|
end--;
|
||||||
|
|
||||||
for (start = palindrome; start <= end; start++, end--) {
|
for (start = palindrome; start <= end; start++, end--) {
|
||||||
putchar('.');
|
|
||||||
if (*start != *end) {
|
if (*start != *end) {
|
||||||
|
success(TEST161_FAIL, SECRET, "/testbin/palin");
|
||||||
tprintf("NOT a palindrome\n");
|
tprintf("NOT a palindrome\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tprintf("IS a palindrome\n");
|
tprintf("IS a palindrome\n");
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/palin");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <test/test.h>
|
||||||
|
#include <test161/test161.h>
|
||||||
|
|
||||||
#define NJOBS 24
|
#define NJOBS 24
|
||||||
|
|
||||||
@ -87,24 +89,6 @@ struct matrix {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/*
|
|
||||||
* Use this instead of just calling tprintf so we know each printout
|
|
||||||
* is atomic; this prevents the lines from getting intermingled.
|
|
||||||
*/
|
|
||||||
static
|
|
||||||
void
|
|
||||||
say(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
char buf[256];
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
write(STDOUT_FILENO, buf, strlen(buf));
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
multiply(struct matrix *res, const struct matrix *m1, const struct matrix *m2)
|
multiply(struct matrix *res, const struct matrix *m1, const struct matrix *m2)
|
||||||
@ -120,6 +104,7 @@ multiply(struct matrix *res, const struct matrix *m1, const struct matrix *m2)
|
|||||||
res->m_data[i][j] = val;
|
res->m_data[i][j] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
TEST161_TPROGRESS(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
@ -201,18 +186,20 @@ go(int mynum)
|
|||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
say("Process %d (pid %d) starting computation...\n", mynum,
|
tsay("Process %d (pid %d) starting computation...\n", mynum,
|
||||||
(int) getpid());
|
(int) getpid());
|
||||||
|
|
||||||
computeall(mynum);
|
computeall(mynum);
|
||||||
r = answer();
|
r = answer();
|
||||||
|
|
||||||
if (r != right_answers[mynum]) {
|
if (r != right_answers[mynum]) {
|
||||||
say("Process %d answer %d: FAILED, should be %d\n",
|
tsay("Process %d answer %d: FAILED, should be %d\n",
|
||||||
mynum, r, right_answers[mynum]);
|
mynum, r, right_answers[mynum]);
|
||||||
|
success(TEST161_FAIL, SECRET, "/testbin/parallelvm");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
say("Process %d answer %d: passed\n", mynum, r);
|
|
||||||
|
tsay("Process %d answer %d: passed\n", mynum, r);
|
||||||
|
nsay("\nProc %d OK\n", mynum);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,7 +328,7 @@ makeprocs(bool dowait)
|
|||||||
if (pids[i]==0) {
|
if (pids[i]==0) {
|
||||||
/* child */
|
/* child */
|
||||||
if (dowait) {
|
if (dowait) {
|
||||||
say("Process %d forked\n", i);
|
tsay("Process %d forked\n", i);
|
||||||
semopen(&s1);
|
semopen(&s1);
|
||||||
semopen(&s2);
|
semopen(&s2);
|
||||||
semV(&s1, 1);
|
semV(&s1, 1);
|
||||||
@ -356,9 +343,9 @@ makeprocs(bool dowait)
|
|||||||
if (dowait) {
|
if (dowait) {
|
||||||
semopen(&s1);
|
semopen(&s1);
|
||||||
semopen(&s2);
|
semopen(&s2);
|
||||||
say("Waiting for fork...\n");
|
tsay("Waiting for fork...\n");
|
||||||
semP(&s1, NJOBS);
|
semP(&s1, NJOBS);
|
||||||
say("Starting computation.\n");
|
tsay("Starting computation.\n");
|
||||||
semV(&s2, NJOBS);
|
semV(&s2, NJOBS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,10 +365,12 @@ makeprocs(bool dowait)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (failcount>0) {
|
if (failcount>0) {
|
||||||
tprintf("%d subprocesses failed\n", failcount);
|
printf("%d subprocesses failed\n", failcount);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
nprintf("\n");
|
||||||
tprintf("Test complete\n");
|
tprintf("Test complete\n");
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/parallelvm");
|
||||||
|
|
||||||
semclose(&s1);
|
semclose(&s1);
|
||||||
semclose(&s2);
|
semclose(&s2);
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <test161/test161.h>
|
||||||
|
|
||||||
#define _PATH_RANDOM "random:"
|
#define _PATH_RANDOM "random:"
|
||||||
|
|
||||||
@ -271,6 +272,37 @@ dosbrk(ssize_t size)
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
// fork a child that segfaults
|
||||||
|
|
||||||
|
typedef void (*segfault_fn)(void);
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
expect_segfault(segfault_fn func)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
int result;
|
||||||
|
pid_t pid = dofork();
|
||||||
|
|
||||||
|
if (pid == 0) {
|
||||||
|
func(); // This exits
|
||||||
|
} else {
|
||||||
|
result = waitpid(pid, &status, 0);
|
||||||
|
if (result == -1) {
|
||||||
|
err(1, "waitpid");
|
||||||
|
}
|
||||||
|
else if (WIFSIGNALED(status)) {
|
||||||
|
if (WTERMSIG(status) != 11) {
|
||||||
|
errx(1, "child: Signal %d", WTERMSIG(status));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
errx(1, "child exited, expected segfault");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// align the heap
|
// align the heap
|
||||||
|
|
||||||
@ -323,8 +355,7 @@ test1(void)
|
|||||||
if (checkpage(p, 0, false)) {
|
if (checkpage(p, 0, false)) {
|
||||||
errx(1, "FAILED: data corrupt");
|
errx(1, "FAILED: data corrupt");
|
||||||
}
|
}
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/sbrktest");
|
||||||
tprintf("Passed sbrk test 1.\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -362,8 +393,7 @@ test2(void)
|
|||||||
errx(1, "FAILED: sbrk shrink didn't restore the heap "
|
errx(1, "FAILED: sbrk shrink didn't restore the heap "
|
||||||
"(got %p, expected %p", q, op);
|
"(got %p, expected %p", q, op);
|
||||||
}
|
}
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/sbrktest");
|
||||||
tprintf("Passed sbrk test 2.\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -414,8 +444,7 @@ test3(void)
|
|||||||
errx(1, "FAILED: sbrk shrink didn't restore the heap "
|
errx(1, "FAILED: sbrk shrink didn't restore the heap "
|
||||||
"(got %p, expected %p", q, op);
|
"(got %p, expected %p", q, op);
|
||||||
}
|
}
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/sbrktest");
|
||||||
tprintf("Passed sbrk test 3.\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -474,8 +503,7 @@ test4(void)
|
|||||||
errx(1, "FAILED: sbrk shrink didn't restore the heap "
|
errx(1, "FAILED: sbrk shrink didn't restore the heap "
|
||||||
"(got %p, expected %p", q, op);
|
"(got %p, expected %p", q, op);
|
||||||
}
|
}
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/sbrktest");
|
||||||
tprintf("Passed sbrk test 4.\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -487,7 +515,7 @@ test4(void)
|
|||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
test5(void)
|
test5_helper(void)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
@ -497,13 +525,21 @@ test5(void)
|
|||||||
errx(1, "FAILED: I didn't crash");
|
errx(1, "FAILED: I didn't crash");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test5(void)
|
||||||
|
{
|
||||||
|
expect_segfault(test5_helper);
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/sbrktest");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocates a page and checks that the next page past it is not
|
* Allocates a page and checks that the next page past it is not
|
||||||
* valid. (Crashes when successful.)
|
* valid. (Crashes when successful.)
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
test6(void)
|
test6_helper(void)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
@ -514,13 +550,21 @@ test6(void)
|
|||||||
errx(1, "FAILED: I didn't crash");
|
errx(1, "FAILED: I didn't crash");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test6(void)
|
||||||
|
{
|
||||||
|
expect_segfault(test6_helper);
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/sbrktest");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocates and frees a page and checks that the page freed is no
|
* Allocates and frees a page and checks that the page freed is no
|
||||||
* longer valid. (Crashes when successful.)
|
* longer valid. (Crashes when successful.)
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
test7(void)
|
test7_helper(void)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
@ -532,6 +576,14 @@ test7(void)
|
|||||||
errx(1, "FAILED: I didn't crash");
|
errx(1, "FAILED: I didn't crash");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test7(void)
|
||||||
|
{
|
||||||
|
expect_segfault(test7_helper);
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/sbrktest");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocates some pages, frees half of them, and checks that the page
|
* Allocates some pages, frees half of them, and checks that the page
|
||||||
* past the new end of the heap is no longer valid. (Crashes when
|
* past the new end of the heap is no longer valid. (Crashes when
|
||||||
@ -539,7 +591,7 @@ test7(void)
|
|||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
test8(void)
|
test8_helper(void)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
@ -551,6 +603,14 @@ test8(void)
|
|||||||
errx(1, "FAILED: I didn't crash");
|
errx(1, "FAILED: I didn't crash");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
void
|
||||||
|
test8(void)
|
||||||
|
{
|
||||||
|
expect_segfault(test8_helper);
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/sbrktest");
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// heap size
|
// heap size
|
||||||
|
|
||||||
@ -600,12 +660,12 @@ test9(void)
|
|||||||
dot = pages / 64;
|
dot = pages / 64;
|
||||||
for (i=0; i<pages; i++) {
|
for (i=0; i<pages; i++) {
|
||||||
markpagelight(p, i);
|
markpagelight(p, i);
|
||||||
if (dot > 0 && i % dot == 0) {
|
if (dot > 0) {
|
||||||
tprintf(".");
|
TEST161_LPROGRESS_N(i, dot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dot > 0) {
|
if (dot > 0) {
|
||||||
tprintf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
tprintf("Testing each page.\n");
|
tprintf("Testing each page.\n");
|
||||||
@ -618,12 +678,12 @@ test9(void)
|
|||||||
warnx("FAILED: data corrupt");
|
warnx("FAILED: data corrupt");
|
||||||
bad = true;
|
bad = true;
|
||||||
}
|
}
|
||||||
if (dot > 0 && i % dot == 0) {
|
if (dot > 0) {
|
||||||
tprintf(".");
|
TEST161_LPROGRESS_N(i, dot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dot > 0) {
|
if (dot > 0) {
|
||||||
tprintf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
if (bad) {
|
if (bad) {
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -641,6 +701,7 @@ test9(void)
|
|||||||
tprintf("And really freeing it.\n");
|
tprintf("And really freeing it.\n");
|
||||||
(void)dosbrk(-size);
|
(void)dosbrk(-size);
|
||||||
tprintf("Passed sbrk test 9 (all)\n");
|
tprintf("Passed sbrk test 9 (all)\n");
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/sbrktest");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -692,6 +753,7 @@ test10(void)
|
|||||||
(void)dosbrk(-PAGE_SIZE);
|
(void)dosbrk(-PAGE_SIZE);
|
||||||
|
|
||||||
tprintf("Passed sbrk test 10.\n");
|
tprintf("Passed sbrk test 10.\n");
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/sbrktest");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -714,9 +776,7 @@ test11(void)
|
|||||||
tprintf("Touching the pages.\n");
|
tprintf("Touching the pages.\n");
|
||||||
for (i=0; i<num; i++) {
|
for (i=0; i<num; i++) {
|
||||||
markpagelight(p, i);
|
markpagelight(p, i);
|
||||||
if (i % 4 == 0) {
|
TEST161_LPROGRESS_N(i, 4);
|
||||||
tprintf(".");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
tprintf("\n");
|
tprintf("\n");
|
||||||
|
|
||||||
@ -727,17 +787,16 @@ test11(void)
|
|||||||
warnx("FAILED: data corrupt");
|
warnx("FAILED: data corrupt");
|
||||||
bad = true;
|
bad = true;
|
||||||
}
|
}
|
||||||
if (i % 4 == 0) {
|
TEST161_LPROGRESS_N(i, 4);
|
||||||
tprintf(".");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
tprintf("\n");
|
printf("\n");
|
||||||
if (bad) {
|
if (bad) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
tprintf("Now NOT freeing the pages. They should get freed on exit.\n");
|
tprintf("Now NOT freeing the pages. They should get freed on exit.\n");
|
||||||
tprintf("If not, you'll notice pretty quickly.\n");
|
tprintf("If not, you'll notice pretty quickly.\n");
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/sbrktest");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -779,6 +838,7 @@ test12(void)
|
|||||||
say("Parent done.\n");
|
say("Parent done.\n");
|
||||||
dowait(pid);
|
dowait(pid);
|
||||||
tprintf("Passed sbrk test 12.\n");
|
tprintf("Passed sbrk test 12.\n");
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/sbrktest");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -812,6 +872,7 @@ test13(void)
|
|||||||
}
|
}
|
||||||
dowait(pid);
|
dowait(pid);
|
||||||
tprintf("Passed sbrk test 13.\n");
|
tprintf("Passed sbrk test 13.\n");
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/sbrktest");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -847,6 +908,7 @@ test14(void)
|
|||||||
errx(1, "FAILED: data corrupt in parent after child ran");
|
errx(1, "FAILED: data corrupt in parent after child ran");
|
||||||
}
|
}
|
||||||
tprintf("Passed sbrk test 14.\n");
|
tprintf("Passed sbrk test 14.\n");
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/sbrktest");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -948,6 +1010,8 @@ test15(void)
|
|||||||
|
|
||||||
(void)dosbrk(-PAGE_SIZE * num);
|
(void)dosbrk(-PAGE_SIZE * num);
|
||||||
tprintf("Passed sbrk test 15.\n");
|
tprintf("Passed sbrk test 15.\n");
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/sbrktest");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -1004,11 +1068,9 @@ stresstest(unsigned long seed, bool large)
|
|||||||
bad = true;
|
bad = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i % dot == 0) {
|
TEST161_LPROGRESS_N(i, dot);
|
||||||
tprintf(".");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
tprintf("\n");
|
printf("\n");
|
||||||
if (bad) {
|
if (bad) {
|
||||||
warnx("FAILED");
|
warnx("FAILED");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -1016,6 +1078,7 @@ stresstest(unsigned long seed, bool large)
|
|||||||
|
|
||||||
dosbrk(-(num * PAGE_SIZE));
|
dosbrk(-(num * PAGE_SIZE));
|
||||||
tprintf("Passed sbrk %s stress test.\n", large ? "large" : "small");
|
tprintf("Passed sbrk %s stress test.\n", large ? "large" : "small");
|
||||||
|
success(TEST161_SUCCESS, SECRET, "/testbin/sbrktest");
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <test161/test161.h>
|
||||||
|
|
||||||
/* Larger than physical memory */
|
/* Larger than physical memory */
|
||||||
#define SIZE (144*1024)
|
#define SIZE (144*1024)
|
||||||
@ -54,6 +55,8 @@
|
|||||||
* Also, quicksort has somewhat more interesting memory usage patterns.
|
* Also, quicksort has somewhat more interesting memory usage patterns.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static int iters;
|
||||||
|
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
sort(int *arr, int size)
|
sort(int *arr, int size)
|
||||||
@ -64,6 +67,8 @@ sort(int *arr, int size)
|
|||||||
if (size<2) {
|
if (size<2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
TEST161_LPROGRESS_N(iters, 4000);
|
||||||
|
++iters;
|
||||||
|
|
||||||
pivot = size/2;
|
pivot = size/2;
|
||||||
sort(arr, pivot);
|
sort(arr, pivot);
|
||||||
@ -122,7 +127,7 @@ check(void)
|
|||||||
i, A[i], i+1, A[i+1]);
|
i, A[i], i+1, A[i+1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
warnx("Passed.");
|
success(TEST161_SUCCESS, SECRET, "/testbin/sort");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <test161/test161.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some initialized data. This is here to increase the chance that
|
* Some initialized data. This is here to increase the chance that
|
||||||
@ -78,6 +79,7 @@ check_data(void)
|
|||||||
if (k != SUM_OF_DATA_STUFF) {
|
if (k != SUM_OF_DATA_STUFF) {
|
||||||
warnx("My initialized data sums to the wrong value!");
|
warnx("My initialized data sums to the wrong value!");
|
||||||
warnx("Got: %u Expected: %u", k, SUM_OF_DATA_STUFF);
|
warnx("Got: %u Expected: %u", k, SUM_OF_DATA_STUFF);
|
||||||
|
success(TEST161_FAIL, SECRET, "/testbin/zero");
|
||||||
errx(1, "FAILED");
|
errx(1, "FAILED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,6 +96,7 @@ check_bss(void)
|
|||||||
warnx("BSS entry at index %u (address %p) not zero!",
|
warnx("BSS entry at index %u (address %p) not zero!",
|
||||||
i, &bss_stuff[i]);
|
i, &bss_stuff[i]);
|
||||||
warnx("Found: 0x%x", bss_stuff[i]);
|
warnx("Found: 0x%x", bss_stuff[i]);
|
||||||
|
success(TEST161_FAIL, SECRET, "/testbin/zero");
|
||||||
errx(1, "FAILED");
|
errx(1, "FAILED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,6 +118,7 @@ check_sbrk(void)
|
|||||||
tprintf("I guess you haven't implemented sbrk yet.\n");
|
tprintf("I guess you haven't implemented sbrk yet.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
success(TEST161_FAIL, SECRET, "/testbin/zero");
|
||||||
err(1, "sbrk");
|
err(1, "sbrk");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,6 +128,7 @@ check_sbrk(void)
|
|||||||
i, &base[i]);
|
i, &base[i]);
|
||||||
warnx("Got: 0x%x", (unsigned char)base[i]);
|
warnx("Got: 0x%x", (unsigned char)base[i]);
|
||||||
warnx("Base of sbrk region: %p", base);
|
warnx("Base of sbrk region: %p", base);
|
||||||
|
success(TEST161_FAIL, SECRET, "/testbin/zero");
|
||||||
errx(1, "FAILED");
|
errx(1, "FAILED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,6 +145,6 @@ main(void)
|
|||||||
tprintf("zero: phase 2: checking sbrk()\n");
|
tprintf("zero: phase 2: checking sbrk()\n");
|
||||||
check_sbrk();
|
check_sbrk();
|
||||||
|
|
||||||
tprintf("zero: passed\n");
|
success(TEST161_SUCCESS, SECRET, "/testbin/zero");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user