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:
@@ -2148,7 +2148,7 @@ doindent(unsigned depth)
|
||||
unsigned i;
|
||||
|
||||
for (i=0; i<depth; i++) {
|
||||
printf(" ");
|
||||
tprintf(" ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2174,17 +2174,17 @@ printdiffs(unsigned indent, struct fsobject *obja, struct fsobject *objb)
|
||||
entb = entb->next) {
|
||||
if (enta->name == entb->name) {
|
||||
doindent(indent);
|
||||
printf("%s", name_get(enta->name));
|
||||
tprintf("%s", name_get(enta->name));
|
||||
if (enta->obj->isdir &&
|
||||
!entb->obj->isdir) {
|
||||
printf(": expected dir, found file;");
|
||||
printf(" %u names missing.\n",
|
||||
tprintf(": expected dir, found file;");
|
||||
tprintf(" %u names missing.\n",
|
||||
count_subtree(enta->obj) - 1);
|
||||
}
|
||||
else if (!enta->obj->isdir &&
|
||||
entb->obj->isdir) {
|
||||
printf(": expected file, found dir;");
|
||||
printf(" %u extra names.\n",
|
||||
tprintf(": expected file, found dir;");
|
||||
tprintf(" %u extra names.\n",
|
||||
count_subtree(entb->obj) - 1);
|
||||
}
|
||||
else if (!enta->obj->isdir &&
|
||||
@@ -2194,18 +2194,18 @@ printdiffs(unsigned indent, struct fsobject *obja, struct fsobject *objb)
|
||||
alen = enta->obj->obj_file.len;
|
||||
blen = entb->obj->obj_file.len;
|
||||
if (alen == blen) {
|
||||
printf("\t\t%lld bytes (ok)\n",
|
||||
tprintf("\t\t%lld bytes (ok)\n",
|
||||
alen);
|
||||
}
|
||||
else {
|
||||
printf(": found %lld bytes, "
|
||||
tprintf(": found %lld bytes, "
|
||||
"expected %lld "
|
||||
"bytes.\n",
|
||||
blen, alen);
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("/\n");
|
||||
tprintf("/\n");
|
||||
printdiffs(indent + 1,
|
||||
enta->obj, entb->obj);
|
||||
}
|
||||
@@ -2215,13 +2215,13 @@ printdiffs(unsigned indent, struct fsobject *obja, struct fsobject *objb)
|
||||
}
|
||||
if (!found) {
|
||||
doindent(indent);
|
||||
printf("%s: missing ", name_get(enta->name));
|
||||
tprintf("%s: missing ", name_get(enta->name));
|
||||
if (enta->obj->isdir) {
|
||||
printf("subtree with %u names.\n",
|
||||
tprintf("subtree with %u names.\n",
|
||||
count_subtree(enta->obj) - 1);
|
||||
}
|
||||
else {
|
||||
printf("file\n");
|
||||
tprintf("file\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2238,13 +2238,13 @@ printdiffs(unsigned indent, struct fsobject *obja, struct fsobject *objb)
|
||||
}
|
||||
if (!found) {
|
||||
doindent(indent);
|
||||
printf("%s: extra ", name_get(entb->name));
|
||||
tprintf("%s: extra ", name_get(entb->name));
|
||||
if (entb->obj->isdir) {
|
||||
printf("subtree with %u names.\n",
|
||||
tprintf("subtree with %u names.\n",
|
||||
count_subtree(entb->obj) - 1);
|
||||
}
|
||||
else {
|
||||
printf("file\n");
|
||||
tprintf("file\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2326,7 +2326,7 @@ checkfilezeros(int fd, const char *namestr, off_t start, off_t end)
|
||||
unsigned poison = 0, trash = 0;
|
||||
off_t origstart = start;
|
||||
|
||||
printf(" %lld - %lld (expecting zeros)\n", start, end);
|
||||
tprintf(" %lld - %lld (expecting zeros)\n", start, end);
|
||||
|
||||
if (lseek(fd, start, SEEK_SET) == -1) {
|
||||
err(1, "%s: lseek to %lld", namestr, start);
|
||||
@@ -2356,19 +2356,19 @@ checkfilezeros(int fd, const char *namestr, off_t start, off_t end)
|
||||
start += ret;
|
||||
}
|
||||
if (poison > 0 || trash > 0) {
|
||||
printf("ERROR: File %s: expected zeros from %lld to %lld; "
|
||||
tprintf("ERROR: File %s: expected zeros from %lld to %lld; "
|
||||
"found",
|
||||
namestr, origstart, end);
|
||||
if (poison > 0) {
|
||||
printf(" %u poison bytes", poison);
|
||||
tprintf(" %u poison bytes", poison);
|
||||
if (trash > 0) {
|
||||
printf(" and");
|
||||
tprintf(" and");
|
||||
}
|
||||
}
|
||||
if (trash > 0) {
|
||||
printf(" %u trash bytes", trash);
|
||||
tprintf(" %u trash bytes", trash);
|
||||
}
|
||||
printf("\n");
|
||||
tprintf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2440,7 +2440,7 @@ checkfiledata(int fd, const char *namestr, unsigned code, unsigned seq,
|
||||
checkend = regionend;
|
||||
}
|
||||
|
||||
printf(" %lld - %lld\n", checkstart, checkend);
|
||||
tprintf(" %lld - %lld\n", checkstart, checkend);
|
||||
|
||||
readfiledata(fd, namestr,
|
||||
regionstart, checkstart, checkend, regionend);
|
||||
@@ -2695,7 +2695,7 @@ checkonefilecontents(const char *namestr, struct fsobject *file,
|
||||
return;
|
||||
}
|
||||
assert(change->type == FC_WRITE);
|
||||
printf("ERROR: File %s is zero length but was expected to "
|
||||
tprintf("ERROR: File %s is zero length but was expected to "
|
||||
"contain at least %lld bytes at offset %lld!\n",
|
||||
namestr, change->fc_write.pos, change->fc_write.len);
|
||||
close(fd);
|
||||
@@ -2704,7 +2704,7 @@ checkonefilecontents(const char *namestr, struct fsobject *file,
|
||||
|
||||
/* XXX: this check is wrong too. */
|
||||
if (change->type == FC_CREAT) {
|
||||
printf("ERROR: File %s was never written to but has "
|
||||
tprintf("ERROR: File %s was never written to but has "
|
||||
"length %lld\n",
|
||||
namestr, file->obj_file.len);
|
||||
close(fd);
|
||||
@@ -2741,12 +2741,12 @@ checkonefilecontents(const char *namestr, struct fsobject *file,
|
||||
*/
|
||||
while (!change_is_present(fd, namestr, file->obj_file.len, change)) {
|
||||
if (change->version < okversion) {
|
||||
printf("File %s: change for version %u is missing\n",
|
||||
tprintf("File %s: change for version %u is missing\n",
|
||||
namestr, change->version);
|
||||
}
|
||||
change = backup_for_file(change->prev,file->obj_file.identity);
|
||||
if (change == NULL) {
|
||||
printf("File %s: no matching version found\n",
|
||||
tprintf("File %s: no matching version found\n",
|
||||
namestr);
|
||||
close(fd);
|
||||
return;
|
||||
@@ -2781,18 +2781,18 @@ checkallfilecontents(struct fsobject *dir, struct fschange *change)
|
||||
for (de = dir->obj_dir.entries; de != NULL; de = de->next) {
|
||||
namestr = name_get(de->name);
|
||||
if (de->obj->isdir) {
|
||||
printf(" >>> Entering %s\n", namestr);
|
||||
tprintf(" >>> Entering %s\n", namestr);
|
||||
if (chdir(namestr)) {
|
||||
err(1, "%s: chdir", namestr);
|
||||
}
|
||||
checkallfilecontents(de->obj, change);
|
||||
printf(" <<< Leaving %s\n", namestr);
|
||||
tprintf(" <<< Leaving %s\n", namestr);
|
||||
if (chdir("..")) {
|
||||
err(1, "..: chdir");
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("%s...\n", namestr);
|
||||
tprintf("%s...\n", namestr);
|
||||
checkonefilecontents(namestr, de->obj, change);
|
||||
}
|
||||
}
|
||||
@@ -2813,7 +2813,7 @@ checkfs(void)
|
||||
/*
|
||||
* We just built the model; talk about it.
|
||||
*/
|
||||
printf("Established %u versions across %u directories and %u files\n",
|
||||
tprintf("Established %u versions across %u directories and %u files\n",
|
||||
changes->version + 1, nextdirnum, nextfilenum);
|
||||
|
||||
/*
|
||||
@@ -2821,7 +2821,7 @@ checkfs(void)
|
||||
* FOUND holding the found volume state.
|
||||
*/
|
||||
inspectfs();
|
||||
printf("Found %u subdirs and %u files on the volume\n",
|
||||
tprintf("Found %u subdirs and %u files on the volume\n",
|
||||
found_subdirs, found_files);
|
||||
|
||||
/*
|
||||
@@ -2856,7 +2856,7 @@ checkfs(void)
|
||||
best = change;
|
||||
bestscore = score;
|
||||
}
|
||||
//printf("version %u score %u\n", change->version, score);
|
||||
//tprintf("version %u score %u\n", change->version, score);
|
||||
change = change->next;
|
||||
}
|
||||
assert(best != NULL);
|
||||
@@ -2874,9 +2874,9 @@ checkfs(void)
|
||||
* differences. XXX: this results in not checking file
|
||||
* data...
|
||||
*/
|
||||
printf("FAILURE: Directory tree does not match on any "
|
||||
tprintf("FAILURE: Directory tree does not match on any "
|
||||
"version.\n");
|
||||
printf("Best version is %u; describing differences:\n",
|
||||
tprintf("Best version is %u; describing differences:\n",
|
||||
best->version);
|
||||
printdiffs(1, state, found);
|
||||
return;
|
||||
@@ -2886,9 +2886,9 @@ checkfs(void)
|
||||
* Ok, we did get an exact match. Print it.
|
||||
*/
|
||||
|
||||
printf("Directory tree matched in version %u.\n", best->version);
|
||||
tprintf("Directory tree matched in version %u.\n", best->version);
|
||||
if (best->partial) {
|
||||
printf("WARNING: this is a version from a partially committed "
|
||||
tprintf("WARNING: this is a version from a partially committed "
|
||||
"operation.\n");
|
||||
}
|
||||
|
||||
@@ -2905,7 +2905,7 @@ checkfs(void)
|
||||
|
||||
/* now check the file contents */
|
||||
|
||||
printf("Checking file contents...\n");
|
||||
tprintf("Checking file contents...\n");
|
||||
checkallfilecontents(state, best);
|
||||
printf("Done.\n");
|
||||
tprintf("Done.\n");
|
||||
}
|
||||
|
@@ -165,7 +165,7 @@ data_matches(const char *namestr, off_t regionoffset,
|
||||
}
|
||||
else if (zero_at(where, howmuch)) {
|
||||
if (where >= zerostart) {
|
||||
printf("WARNING: file %s range %lld-%lld is "
|
||||
tprintf("WARNING: file %s range %lld-%lld is "
|
||||
"zeroed\n",
|
||||
namestr, regionoffset + where,
|
||||
regionoffset + where + howmuch);
|
||||
@@ -176,7 +176,7 @@ data_matches(const char *namestr, off_t regionoffset,
|
||||
}
|
||||
else if (poison_at(where, howmuch)) {
|
||||
if (where >= zerostart) {
|
||||
printf("ERROR: file %s range %lld-%lld is "
|
||||
tprintf("ERROR: file %s range %lld-%lld is "
|
||||
"poisoned\n",
|
||||
namestr, regionoffset + where,
|
||||
regionoffset + where + howmuch);
|
||||
@@ -205,7 +205,7 @@ data_check(const char *namestr, off_t regionoffset,
|
||||
|
||||
if (!data_matches(namestr, regionoffset,
|
||||
code, seq, zerostart, len, checkstart, checklen)) {
|
||||
printf("ERROR: file %s range %lld-%lld contains garbage\n",
|
||||
tprintf("ERROR: file %s range %lld-%lld contains garbage\n",
|
||||
namestr, regionoffset + checkstart,
|
||||
regionoffset + checkstart + checklen);
|
||||
}
|
||||
|
@@ -72,7 +72,7 @@ do_createfile(unsigned name)
|
||||
if (fd < 0) {
|
||||
err(1, "%s: create", namestr);
|
||||
}
|
||||
printf("create %s\n", namestr);
|
||||
tprintf("create %s\n", namestr);
|
||||
return fd;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ do_write(int fd, unsigned name, unsigned code, unsigned seq,
|
||||
done += ret;
|
||||
}
|
||||
|
||||
printf("write %s: %lld at %lld\n", namestr, len, pos);
|
||||
tprintf("write %s: %lld at %lld\n", namestr, len, pos);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -134,7 +134,7 @@ do_truncate(int fd, unsigned name, off_t len)
|
||||
if (ftruncate(fd, len) == -1) {
|
||||
err(1, "%s: truncate to %lld", namestr, len);
|
||||
}
|
||||
printf("truncate %s: to %lld\n", namestr, len);
|
||||
tprintf("truncate %s: to %lld\n", namestr, len);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -146,7 +146,7 @@ do_mkdir(unsigned name)
|
||||
if (mkdir(namestr, 0775) == -1) {
|
||||
err(1, "%s: mkdir", namestr);
|
||||
}
|
||||
printf("mkdir %s\n", namestr);
|
||||
tprintf("mkdir %s\n", namestr);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -158,7 +158,7 @@ do_rmdir(unsigned name)
|
||||
if (rmdir(namestr) == -1) {
|
||||
err(1, "%s: rmdir", namestr);
|
||||
}
|
||||
printf("rmdir %s\n", namestr);
|
||||
tprintf("rmdir %s\n", namestr);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -170,7 +170,7 @@ do_unlink(unsigned name)
|
||||
if (remove(namestr) == -1) {
|
||||
err(1, "%s: remove", namestr);
|
||||
}
|
||||
printf("remove %s\n", namestr);
|
||||
tprintf("remove %s\n", namestr);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -183,7 +183,7 @@ do_link(unsigned from, unsigned to)
|
||||
if (link(fromstr, tostr) == -1) {
|
||||
err(1, "link %s to %s", fromstr, tostr);
|
||||
}
|
||||
printf("link %s %s\n", fromstr, tostr);
|
||||
tprintf("link %s %s\n", fromstr, tostr);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -196,7 +196,7 @@ do_rename(unsigned from, unsigned to)
|
||||
if (rename(fromstr, tostr) == -1) {
|
||||
err(1, "rename %s to %s", fromstr, tostr);
|
||||
}
|
||||
printf("rename %s %s\n", fromstr, tostr);
|
||||
tprintf("rename %s %s\n", fromstr, tostr);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -216,7 +216,7 @@ do_renamexd(unsigned fromdir, unsigned from, unsigned todir, unsigned to)
|
||||
if (rename(frombuf, tobuf) == -1) {
|
||||
err(1, "rename %s to %s", frombuf, tobuf);
|
||||
}
|
||||
printf("rename %s %s\n", frombuf, tobuf);
|
||||
tprintf("rename %s %s\n", frombuf, tobuf);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -228,7 +228,7 @@ do_chdir(unsigned name)
|
||||
if (chdir(namestr) == -1) {
|
||||
err(1, "chdir: %s", namestr);
|
||||
}
|
||||
printf("chdir %s\n", namestr);
|
||||
tprintf("chdir %s\n", namestr);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -237,7 +237,7 @@ do_chdirup(void)
|
||||
if (chdir("..") == -1) {
|
||||
err(1, "chdir: ..");
|
||||
}
|
||||
printf("chdir ..\n");
|
||||
tprintf("chdir ..\n");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -246,6 +246,6 @@ do_sync(void)
|
||||
if (sync()) {
|
||||
warn("sync");
|
||||
}
|
||||
printf("sync\n");
|
||||
printf("----------------------------------------\n");
|
||||
tprintf("sync\n");
|
||||
tprintf("----------------------------------------\n");
|
||||
}
|
||||
|
@@ -132,13 +132,13 @@ printworkloads(void)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
printf("Supported workloads:\n");
|
||||
tprintf("Supported workloads:\n");
|
||||
for (i=0; i<numworkloads; i++) {
|
||||
printf(" %s", workloads[i].name);
|
||||
tprintf(" %s", workloads[i].name);
|
||||
if (workloads[i].argname) {
|
||||
printf(" %s", workloads[i].argname);
|
||||
tprintf(" %s", workloads[i].argname);
|
||||
}
|
||||
printf("\n");
|
||||
tprintf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user