Added changes to the user space apps hello.c and jacobi.c to make them

return something not equal 0 if there was some kind of error.
This commit is contained in:
Jacek Galowicz 2012-09-16 16:43:40 +02:00
parent 4ba3077534
commit fb15bae2e7
2 changed files with 21 additions and 11 deletions

View file

@ -29,6 +29,8 @@
#define NR_OPEN 10
#define FS_INIT { [0 ... NR_OPEN-1] = {NULL, 0, 0} }
#define TESTSTR "hello in new file '/bin/test.txt'"
int main(int argc, char** argv)
{
int i, testfile;
@ -43,25 +45,31 @@ int main(int argc, char** argv)
teststr = malloc(sizeof(char)*100);
if (!teststr)
return EFAULT;
exit(1);
testfile = open("/bin/test.txt", O_CREAT | O_EXCL, "wr");
if (testfile < 1)
printf("error");
write(testfile, "hello in new file '/bin/test.txt'", 34);
if (testfile < 1) {
printf("error: Was not able to open /bin/test.txt\n");
exit(1);
}
write(testfile, TESTSTR, 34);
lseek(testfile, 0, SEEK_SET);
read(testfile, teststr, 100);
close(testfile);
printf("read from new file: %s\n", teststr);
if (strcmp(teststr, TESTSTR))
exit(1);
testdir = opendir("/bin/");
if (testdir < 1)
printf("error");
if (testdir < 1) {
printf("error: Was not able to open /bin directory");
exit(1);
}
testdirent = readdir(testdir);
printf("1. Dirent: %s", testdirent->d_name);
closedir(testdir);
printf("read from new file: %s\n", teststr);
return errno;
}

View file

@ -178,8 +178,10 @@ int main(int argc, char **argv)
if (max < error)
max = error;
if (error > 0.01f)
printf("Result is on position %d wrong (%f != 1.0)\n", i, X[i]);
if (error > 0.01f) {
printf("Result is on position %d wrong (%f != 1.0)\n", i, X[i]);
exit(1);
}
}
printf("maximal error is %f\n", max);