1) Moved tprintf and related functions to their own file in common/libc/printf/tprintf.c.

This file is included by both libc and hostcompat.

2) Changed printf -> tprintf in all testbin programs
This commit is contained in:
Scott Haseley
2016-01-15 13:33:11 -05:00
parent 98ff530afb
commit 0ab862abfa
49 changed files with 501 additions and 478 deletions

View File

@@ -79,7 +79,7 @@ subproc_read(void)
int fd;
int i, res;
printf("File Reader starting ...\n\n");
tprintf("File Reader starting ...\n\n");
fd = open(FNAME, O_RDONLY);
if (fd < 0) {
@@ -102,5 +102,5 @@ subproc_read(void)
close(fd);
printf("File Read exited successfully!\n");
tprintf("File Read exited successfully!\n");
}

View File

@@ -124,8 +124,8 @@ big_file(int size)
{
int i, j, fileid;
printf("[BIGFILE] test starting :\n");
printf("\tCreating a file of size: %d\n", size);
tprintf("[BIGFILE] test starting :\n");
tprintf("\tCreating a file of size: %d\n", size);
fileid = open(BIGFILE_NAME, O_WRONLY|O_CREAT|O_TRUNC, 0664);
if (fileid < 0) {
@@ -136,16 +136,16 @@ big_file(int size)
fbuffer[i] = LETTER(i);
}
printf("\tWriting to file.\n");
tprintf("\tWriting to file.\n");
for (i = 0; i < size; i += BUFFER_SIZE) {
write(fileid, fbuffer, BUFFER_SIZE);
if (!(i % (10 * BUFFER_SIZE))) {
printf("\rBW : %d", i);
tprintf("\rBW : %d", i);
}
}
printf("\n\tReading from file.\n");
tprintf("\n\tReading from file.\n");
close(fileid);
fileid = open(BIGFILE_NAME, O_RDONLY);
@@ -164,7 +164,7 @@ big_file(int size)
}
if (!(i % (10 * BUFFER_SIZE))) {
printf("\rBR : %d", i);
tprintf("\rBR : %d", i);
}
/* Check to see that the data is consistent : */
@@ -181,7 +181,7 @@ big_file(int size)
err(1, "[BIGFILE]: %s: remove", BIGFILE_NAME);
}
printf("\n[BIGFILE] : Success!\n");
tprintf("\n[BIGFILE] : Success!\n");
}
/* ===================================================
@@ -195,7 +195,7 @@ concur(void)
int i, fd;
int r1, r2, w1;
printf("Spawning 2 readers, 1 writer.\n");
tprintf("Spawning 2 readers, 1 writer.\n");
fd = open(FNAME, O_WRONLY|O_CREAT|O_TRUNC, 0664);
@@ -203,7 +203,7 @@ concur(void)
err(1, "[CONCUR]: %s: open", FNAME);
}
printf("Initializing test file: ");
tprintf("Initializing test file: ");
for (i = 0; i < SECTOR_SIZE + 1; i++) {
cbuffer[i] = READCHAR;
@@ -216,13 +216,13 @@ concur(void)
close(fd);
printf("Done initializing. Starting processes...\n");
tprintf("Done initializing. Starting processes...\n");
r1 = forkoff(subproc_read);
w1 = forkoff(subproc_write);
r2 = forkoff(subproc_read);
printf("Waiting for processes.\n");
tprintf("Waiting for processes.\n");
dowait(r1);
dowait(r2);
@@ -232,7 +232,7 @@ concur(void)
err(1, "[CONCUR]: %s: remove", FNAME);
}
printf("[CONCUR] Done!\n");
tprintf("[CONCUR] Done!\n");
}
/* ===================================================
@@ -253,14 +253,14 @@ dir_test(int depth)
for (i = 0; i < depth; i++) {
strcat(dirname, tmp);
printf("\tCreating dir : %s\n", dirname);
tprintf("\tCreating dir : %s\n", dirname);
if (mkdir(dirname, 0775) < 0) {
err(1, "[DIRTEST]: %s: mkdir", dirname);
}
strcat(dirname, fmp);
printf("\tCreating file: %s\n", dirname);
tprintf("\tCreating file: %s\n", dirname);
fd = open(dirname, O_WRONLY|O_CREAT|O_TRUNC, 0664);
if (fd<0) {
@@ -270,19 +270,19 @@ dir_test(int depth)
dirname[strlen(dirname) - strlen(fmp)] = '\0';
}
printf("[DIRTEST] : Passed directory creation test.\n");
tprintf("[DIRTEST] : Passed directory creation test.\n");
for (i = 0; i < depth; i++) {
strcat(dirname, fmp);
printf("\tDeleting file: %s\n", dirname);
tprintf("\tDeleting file: %s\n", dirname);
if (remove(dirname)) {
err(1, "[DIRTEST]: %s: remove", dirname);
}
dirname[strlen(dirname) - strlen(fmp)] = '\0';
printf("\tRemoving dir : %s\n", dirname);
tprintf("\tRemoving dir : %s\n", dirname);
if (rmdir(dirname)) {
err(1, "[DIRTEST]: %s: rmdir", dirname);
@@ -291,8 +291,8 @@ dir_test(int depth)
dirname[strlen(dirname) - strlen(tmp)] = '\0';
}
printf("[DIRTEST] : Passed directory removal test.\n");
printf("[DIRTEST] : Success!\n");
tprintf("[DIRTEST] : Passed directory removal test.\n");
tprintf("[DIRTEST] : Success!\n");
}
/* ===================================================
@@ -325,21 +325,21 @@ main(int argc, char * argv[])
}
if (tv & RUNBIGFILE) {
printf("[BIGFILE] : Run #1\n");
tprintf("[BIGFILE] : Run #1\n");
big_file(BIGFILE_SIZE);
printf("[BIGFILE] : Run #2\n");
tprintf("[BIGFILE] : Run #2\n");
big_file(BIGFILE_SIZE);
}
if (tv & RUNDIRTEST) {
printf("[DIRTEST] : Run #1\n");
tprintf("[DIRTEST] : Run #1\n");
dir_test(DIR_DEPTH);
printf("[DIRTEST] : Run #2\n");
tprintf("[DIRTEST] : Run #2\n");
dir_test(DIR_DEPTH);
}
if (tv & RUNCONCUR) {
printf("[CONCUR]\n");
tprintf("[CONCUR]\n");
concur();
}
return 0;

View File

@@ -67,7 +67,7 @@ subproc_write(void)
buffer[i] = WRITECHAR;
}
printf("File Writer starting ...\n");
tprintf("File Writer starting ...\n");
fd = open(FNAME, O_WRONLY);
if (fd < 0) {
@@ -81,5 +81,5 @@ subproc_write(void)
close(fd);
printf("File Write exited successfully!\n");
tprintf("File Write exited successfully!\n");
}