PSLIST_FOREACH(info, sl) { cq_info_t *cqi = sl->data; cq_info_check(cqi); if (THREAD_INVALID_ID == cqi->stid) str_printf(s, "%-2s ", "-"); else str_printf(s, "%-2d ", cqi->stid); str_catf(s, "%-6zu ", cqi->event_count); str_catf(s, "%-4zu ", cqi->periodic_count); str_catf(s, "%-4zu ", cqi->idle_count); str_catf(s, "%-5s ", 0 == cqi->last_idle ? "-" : compact_time(delta_time(tm_time(), cqi->last_idle))); str_catf(s, "%'6d ", cqi->period); str_catf(s, "%10zu ", cqi->heartbeat_count); str_catf(s, "%10zu ", cqi->triggered_count); str_catf(s, "\"%s\"%*s", cqi->name, (int) (maxlen - vstrlen(cqi->name)), ""); if (cqi->parent != NULL) str_catf(s, " (%s)", cqi->parent); str_putc(s, '\n'); shell_write(sh, str_2c(s)); }
int strpool_test(void) { StrPool pool = {0}; char *p; int i; printf("testing strpool..."); TEST(!strpool_find(&pool,"abc")); p=strpool_add(&pool,"abc"); TEST(p); TEST(0==strcmp("abc",strpool_add(&pool,"abc"))); TEST(p == strpool_add(&pool,"abc")); for(i = 0; i < 100; ++i) { int j; char tmp[128]; sprintf(tmp,"%i",i); strpool_add(&pool,tmp); for(j = 0; j <= i; ++j) { sprintf(tmp,"%i",j); TEST(strpool_find(&pool,tmp)); } } strpool_cleanup(&pool); #define TEST_S(A,B) TEST(0==strcmp(A,B)) p = NULL; str_cat(&p,"a"); TEST_S(p,"a"); str_cat(&p,"b"); TEST_S(p,"ab"); str_catf(&p,"%i%s%i",1,"foo",2); TEST_S(p,"ab1foo2"); free(p); printf("done.\n"); return 0; }