summaryrefslogtreecommitdiff
path: root/tools/hi-test.c
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-23 19:42:23 (GMT)
committerJohn Denker <jsd@av8n.com>2012-07-23 19:42:23 (GMT)
commitfdaeef07dffa8894672da5e51f63d467d452c7c9 (patch)
treef0f2e77d7ff0520dc9d34ee0fecb67ea2c311bc7 /tools/hi-test.c
parent8eeff9d54790fdc8b3d9e069d191487417102476 (diff)
much more logical about keeping track of pipes and how they are used
Diffstat (limited to 'tools/hi-test.c')
-rw-r--r--tools/hi-test.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/tools/hi-test.c b/tools/hi-test.c
index e2626cc..0661ada 100644
--- a/tools/hi-test.c
+++ b/tools/hi-test.c
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <string>
#include <signal.h>
+#include <sstream>
#include <stdio.h> /* perror() */
@@ -13,6 +14,8 @@ const int sa_good(0);
const int sa_spam(1);
const int sa_usage(64);
+int verbosity(0);
+
////////////////
// little utility to help with argument parsing:
//
@@ -42,10 +45,12 @@ void exeunt(const int sts){
using namespace std;
string progname;
+string progid;
+int mypid;
void dump(const string var){
char* str = getenv(var.c_str());
- cerr << progname << ": " << var;
+ cerr << progid << " " << var;
if (str) cerr << " is set to '" << str << "'" << endl;
else cerr << " is not set." << endl;
}
@@ -55,10 +60,19 @@ void countsome(const int unit){
int total(0);
for (;;) {
int rslt = read(unit, buf, sizeof(buf));
+ if (verbosity) cerr << "hi-test: count: unit " << unit
+ << " read returns " << rslt << endl;
if (rslt <= 0) break;
total += rslt;
}
- cerr << "read " << total << " bytes from unit " << unit << endl;
+ cerr << progid
+ << " read " << total << " bytes from unit " << unit << endl;
+}
+
+string basename(const string path){
+ size_t where = path.rfind("/");
+ if (where != string::npos) return path.substr(1+where);
+ return path;
}
int main(int _argc, const char** _argv){
@@ -68,7 +82,16 @@ int main(int _argc, const char** _argv){
int countmode(0);
int argc(_argc);
const char **argv(_argv);
- progname = *argv; argv++; argc--;
+
+ {
+ progname = *argv;
+ mypid = getpid();
+ stringstream binder;
+ binder << "+++++ " << basename(progname) << "[" << mypid << "]";
+ progid = binder.str();
+ }
+
+ argv++; argc--;
while (argc) {
string arg(*argv); argv++; argc--;
@@ -113,8 +136,8 @@ int main(int _argc, const char** _argv){
exit(sa_usage);
}
}
-
- cerr << "++++ hi-test pid: " << getpid() << " group: " << getpgid(0);
+
+ cerr << progid << " group: " << getpgid(0);
char* foo = getenv("HI_Q_GROUP");
if (foo) cerr << " HI_Q_GROUP: " << foo;
cerr << endl;