diff --git a/newlib/examples/hello.c b/newlib/examples/hello.c index 866da42a..8ef0d79d 100644 --- a/newlib/examples/hello.c +++ b/newlib/examples/hello.c @@ -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; } diff --git a/newlib/examples/jacobi.c b/newlib/examples/jacobi.c index 968360e4..e9ab0a84 100644 --- a/newlib/examples/jacobi.c +++ b/newlib/examples/jacobi.c @@ -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);