bool critical;
bool secure;
bool print_stats;
+ int delay_s;
+ int delay_freq;
};
void parse_options(int argc, const char **argv, struct parsed_params *params)
assert(!params->msg);
for (;;) {
- int opt = getopt(argc, (char **) argv, "b:p:t:hc:skz");
+ int opt = getopt(argc, (char **) argv, "b:p:t:hc:skzd:f:");
if (opt < 0)
break;
case 'z':
params->secure = true;
break;
+ case 'd':
+ params->delay_s = atoi(optarg);
+ break;
+ case 'f':
+ params->delay_freq = atoi(optarg);
+ break;
default:
break;
}
r = EXIT_FAILURE;
fprintf(stderr, "Log #%d: error %d\n", i, ret);
}
+ if (params->delay_s > 0 && params->delay_freq > 0 && (i + 1) % params->delay_freq == 0)
+ sleep(params->delay_s);
}
if (params->print_stats) {
{
assert(progname);
- printf("Usage: %s [-p priority] [-b buffer] [-t tag] [-c number] [-s] [message]\n"
+ printf("Usage: %s [-p priority] [-b buffer] [-t tag] [-c number] [-s] [-d time] [-f freq] [message]\n"
"\t-p priority \tone of {Debug, Info, Warning, Error, Verbose, Fatal}\n"
"\t \tfirst letter is enough; defaults to Info\n"
"\t-b buffer \tone of {main, system, radio, apps, kmsg, syslog}\n"
"\t-k \tmake this a 'critical' log\n"
"\t-z \tmake this a 'secure' log\n"
"\t-h \tshow this help\n"
+ "\t-d time \twait a given number of seconds after sending a log\n"
+ "\t-f freq \tonly wait after every given amount of logs\n"
"\tmessage \tmessage for logging; if not specified, each line from standard input\n"
"\t \tis logged separately until EOF\n",
progname);
.count = 1,
.critical = false,
.secure = false,
- .print_stats = false
+ .print_stats = false,
+ .delay_s = 0,
+ .delay_freq = 1,
};
parse_options(argc, argv, ¶ms);
if (params.critical && params.secure) {
line=`$cmd_prefix $format`
[[ "$line" == "rawformatTEST" ]] && ok || fail
+LOG_DETAILS="testing if dlogsend -d works"
+dlogutil -c
+dlogsend -b main -c 9999 -d 4 -f 7 -t DLOG_TESTSUITE "hi" &
+DLOGSEND_PID=$!
+sleep 10
+kill $DLOGSEND_PID
+# In 10 seconds, 3 cycles 7 logs each should have happened.
+[[ "$(dlogutil -d DLOG_TESTSUITE | wc -l)" -eq 21 ]] && ok || fail
+
if [ $type == "pipe" ]; then
for format in raw brief long; do
for i in {1..8} 10 15 20 25 {513..520}; do