Oneliner: add checking dds_get_x_status
Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
e06959abb6
commit
d11066bf84
2 changed files with 123 additions and 57 deletions
|
@ -213,7 +213,7 @@ static dds_return_t check_status_change_fields_are_0 (int ll, dds_entity_t ent)
|
||||||
const char *d = lldesc[ll].desc;
|
const char *d = lldesc[ll].desc;
|
||||||
void *status = malloc (lldesc[ll].size);
|
void *status = malloc (lldesc[ll].size);
|
||||||
dds_return_t ret;
|
dds_return_t ret;
|
||||||
if ((ret = get_status (ll, ent, status)) <= 0)
|
if ((ret = get_status (ll, ent, status)) < 0)
|
||||||
{
|
{
|
||||||
free (status);
|
free (status);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1362,64 +1362,82 @@ static int checkstatus (struct oneliner_ctx *ctx, int ll, int ent, struct onelin
|
||||||
{
|
{
|
||||||
const void *p = advance (status, &off, *d);
|
const void *p = advance (status, &off, *d);
|
||||||
int i;
|
int i;
|
||||||
switch (*d)
|
if (peektok (argl, NULL) == '*')
|
||||||
{
|
{
|
||||||
case 'n':
|
(void) nexttok (argl, NULL);
|
||||||
if (!nexttok_int (argl, &i) || i < 0)
|
switch (*d)
|
||||||
return setresult (ctx, -1, "checkstatus: field %d expecting non-negative integer", field);
|
{
|
||||||
printf ("%s%"PRIu32" %d", sep, *(uint32_t *)p, i); fflush (stdout);
|
case 'n': printf ("%s%"PRIu32, sep, *(uint32_t *)p); break;
|
||||||
if (*(uint32_t *)p != (uint32_t)i)
|
case 'c': printf ("%s%"PRId32, sep, *(int32_t *)p); break;
|
||||||
return setresult (ctx, 0, "checkstatus: field %d has actual %"PRIu32" expected %d", field, *(uint32_t *)p, i);
|
case 'P': printf ("%s%"PRIu32, sep, *(uint32_t *)p); break;
|
||||||
break;
|
case 'R': printf ("%s%d", sep, (int) *(dds_sample_rejected_status_kind *)p); break;
|
||||||
case 'c':
|
case 'I': break; // instance handle is too complicated
|
||||||
if (!nexttok_int (argl, &i))
|
case 'E': printf ("%s%"PRIx64, sep, *(dds_instance_handle_t *)p); break;
|
||||||
return setresult (ctx, -1, "checkstatus: field %d expecting integer", field);
|
default: return DDS_RETCODE_BAD_PARAMETER;
|
||||||
printf ("%s%"PRId32" %d", sep, *(int32_t *)p, i); fflush (stdout);
|
}
|
||||||
if (*(int32_t *)p != i)
|
printf (" *"); fflush (stdout);
|
||||||
return setresult (ctx, 0, "checkstatus: field %d has actual %"PRId32" expected %d", field, *(int32_t *)p, i);
|
}
|
||||||
break;
|
else
|
||||||
case 'P':
|
{
|
||||||
if (nexttok (argl, NULL) != TOK_NAME)
|
switch (*d)
|
||||||
return setresult (ctx, -1, "checkstatus: field %d expecting policy name", field);
|
{
|
||||||
size_t polidx;
|
case 'n':
|
||||||
for (polidx = 0; polidx < sizeof (qostab) / sizeof (qostab[0]); polidx++)
|
if (!nexttok_int (argl, &i) || i < 0)
|
||||||
if (strcmp (argl->v.n, qostab[polidx].abbrev) == 0)
|
return setresult (ctx, -1, "checkstatus: field %d expecting non-negative integer", field);
|
||||||
break;
|
printf ("%s%"PRIu32" %d", sep, *(uint32_t *)p, i); fflush (stdout);
|
||||||
if (polidx == sizeof (qostab) / sizeof (qostab[0]))
|
if (*(uint32_t *)p != (uint32_t)i)
|
||||||
return setresult (ctx, -1, "checkstatus: field %d expecting policy name", field);
|
return setresult (ctx, 0, "checkstatus: field %d has actual %"PRIu32" expected %d", field, *(uint32_t *)p, i);
|
||||||
printf ("%s%"PRIu32" %"PRIu32, sep, *(uint32_t *)p, (uint32_t) qostab[polidx].id); fflush (stdout);
|
break;
|
||||||
if (*(uint32_t *)p != (uint32_t) qostab[polidx].id)
|
case 'c':
|
||||||
return setresult (ctx, 0, "checkstatus: field %d has actual %"PRIu32" expected %d", field, *(uint32_t *)p, (int) qostab[polidx].id);
|
if (!nexttok_int (argl, &i))
|
||||||
break;
|
return setresult (ctx, -1, "checkstatus: field %d expecting integer", field);
|
||||||
case 'R':
|
printf ("%s%"PRId32" %d", sep, *(int32_t *)p, i); fflush (stdout);
|
||||||
if (nexttok (argl, NULL) != TOK_NAME)
|
if (*(int32_t *)p != i)
|
||||||
return setresult (ctx, -1, "checkstatus: field %d expecting reason", field);
|
return setresult (ctx, 0, "checkstatus: field %d has actual %"PRId32" expected %d", field, *(int32_t *)p, i);
|
||||||
if (strcmp (argl->v.n, "i") == 0) i = (int) DDS_REJECTED_BY_INSTANCES_LIMIT;
|
break;
|
||||||
else if (strcmp (argl->v.n, "s") == 0) i = (int) DDS_REJECTED_BY_SAMPLES_LIMIT;
|
case 'P':
|
||||||
else if (strcmp (argl->v.n, "spi") == 0) i = (int) DDS_REJECTED_BY_SAMPLES_PER_INSTANCE_LIMIT;
|
if (nexttok (argl, NULL) != TOK_NAME)
|
||||||
else return setresult (ctx, -1, "checkstatus: field %d expecting reason", field);
|
return setresult (ctx, -1, "checkstatus: field %d expecting policy name", field);
|
||||||
printf ("%s%d %d", sep, (int) *(dds_sample_rejected_status_kind *)p, i); fflush (stdout);
|
size_t polidx;
|
||||||
if (*(dds_sample_rejected_status_kind *)p != (dds_sample_rejected_status_kind) i)
|
for (polidx = 0; polidx < sizeof (qostab) / sizeof (qostab[0]); polidx++)
|
||||||
return setresult (ctx, 0, "checkstatus: field %d has actual %d expected %d", field, (int) (*(dds_sample_rejected_status_kind *)p), i);
|
if (strcmp (argl->v.n, qostab[polidx].abbrev) == 0)
|
||||||
break;
|
break;
|
||||||
case 'I': // instance handle is too complicated
|
if (polidx == sizeof (qostab) / sizeof (qostab[0]))
|
||||||
break;
|
return setresult (ctx, -1, "checkstatus: field %d expecting policy name", field);
|
||||||
case 'E': {
|
printf ("%s%"PRIu32" %"PRIu32, sep, *(uint32_t *)p, (uint32_t) qostab[polidx].id); fflush (stdout);
|
||||||
int ent1 = -1;
|
if (*(uint32_t *)p != (uint32_t) qostab[polidx].id)
|
||||||
dds_instance_handle_t esi1 = 0;
|
return setresult (ctx, 0, "checkstatus: field %d has actual %"PRIu32" expected %d", field, *(uint32_t *)p, (int) qostab[polidx].id);
|
||||||
if (nexttok_if (argl, '*'))
|
break;
|
||||||
ent1 = -1;
|
case 'R':
|
||||||
else if ((ent1 = parse_entity1 (argl, NULL)) < 0)
|
if (nexttok (argl, NULL) != TOK_NAME)
|
||||||
return setresult (ctx, -1, "checkstatus: field %d expecting * or entity name", field);
|
return setresult (ctx, -1, "checkstatus: field %d expecting reason", field);
|
||||||
else if ((esi1 = lookup_insthandle (ctx, ent, ent1)) == 0)
|
if (strcmp (argl->v.n, "i") == 0) i = (int) DDS_REJECTED_BY_INSTANCES_LIMIT;
|
||||||
return setresult (ctx, -1, "checkstatus: field %d instance handle lookup failed", field);
|
else if (strcmp (argl->v.n, "s") == 0) i = (int) DDS_REJECTED_BY_SAMPLES_LIMIT;
|
||||||
printf ("%s%"PRIx64" %"PRIx64, sep, *(dds_instance_handle_t *)p, esi1); fflush (stdout);
|
else if (strcmp (argl->v.n, "spi") == 0) i = (int) DDS_REJECTED_BY_SAMPLES_PER_INSTANCE_LIMIT;
|
||||||
if (ent1 >= 0 && *(dds_instance_handle_t *)p != esi1)
|
else return setresult (ctx, -1, "checkstatus: field %d expecting reason", field);
|
||||||
return setresult (ctx, 0, "checkstatus: field %d has actual %"PRIx64" expected %"PRIx64, field, *(dds_instance_handle_t *)p, esi1);
|
printf ("%s%d %d", sep, (int) *(dds_sample_rejected_status_kind *)p, i); fflush (stdout);
|
||||||
break;
|
if (*(dds_sample_rejected_status_kind *)p != (dds_sample_rejected_status_kind) i)
|
||||||
|
return setresult (ctx, 0, "checkstatus: field %d has actual %d expected %d", field, (int) (*(dds_sample_rejected_status_kind *)p), i);
|
||||||
|
break;
|
||||||
|
case 'I': // instance handle is too complicated
|
||||||
|
break;
|
||||||
|
case 'E': {
|
||||||
|
int ent1 = -1;
|
||||||
|
dds_instance_handle_t esi1 = 0;
|
||||||
|
if (nexttok_if (argl, '*'))
|
||||||
|
ent1 = -1;
|
||||||
|
else if ((ent1 = parse_entity1 (argl, NULL)) < 0)
|
||||||
|
return setresult (ctx, -1, "checkstatus: field %d expecting * or entity name", field);
|
||||||
|
else if ((esi1 = lookup_insthandle (ctx, ent, ent1)) == 0)
|
||||||
|
return setresult (ctx, -1, "checkstatus: field %d instance handle lookup failed", field);
|
||||||
|
printf ("%s%"PRIx64" %"PRIx64, sep, *(dds_instance_handle_t *)p, esi1); fflush (stdout);
|
||||||
|
if (ent1 >= 0 && *(dds_instance_handle_t *)p != esi1)
|
||||||
|
return setresult (ctx, 0, "checkstatus: field %d has actual %"PRIx64" expected %"PRIx64, field, *(dds_instance_handle_t *)p, esi1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return DDS_RETCODE_BAD_PARAMETER;
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
return DDS_RETCODE_BAD_PARAMETER;
|
|
||||||
}
|
}
|
||||||
sep = ", ";
|
sep = ", ";
|
||||||
if (*d != 'I')
|
if (*d != 'I')
|
||||||
|
@ -1729,6 +1747,43 @@ static void dosetflags (struct oneliner_ctx *ctx)
|
||||||
dds_entity_unpin (xwr);
|
dds_entity_unpin (xwr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void docheckstatus (struct oneliner_ctx *ctx)
|
||||||
|
{
|
||||||
|
const int ll = parse_listener (ctx);
|
||||||
|
if (ll < 0)
|
||||||
|
error (ctx, "checkstatus: requires listener name");
|
||||||
|
if (lldesc[ll].cb_status_off == 0)
|
||||||
|
error (ctx, "checkstatus: listener %s has no status", lldesc[ll].name);
|
||||||
|
struct oneliner_lex l1 = ctx->l;
|
||||||
|
if (*ctx->l.inp != '(')
|
||||||
|
error (ctx, "checkstatus: missing arguments");
|
||||||
|
int tok;
|
||||||
|
while ((tok = nexttok (&ctx->l, NULL)) != EOF && tok != ')')
|
||||||
|
;
|
||||||
|
const int ent = parse_entity (ctx);
|
||||||
|
if (ent < 0)
|
||||||
|
error (ctx, "check listener: requires an entity");
|
||||||
|
if (ctx->es[ent] == 0)
|
||||||
|
make_entity (ctx, ent, NULL);
|
||||||
|
entname_t name;
|
||||||
|
printf ("status(%s %s): ", lldesc[ll].name, getentname (&name, ent));
|
||||||
|
|
||||||
|
void *status = malloc (lldesc[ll].size);
|
||||||
|
dds_return_t ret;
|
||||||
|
if ((ret = get_status (ll, ctx->es[ent], status)) < 0)
|
||||||
|
{
|
||||||
|
free (status);
|
||||||
|
error_dds (ctx, ret, "get_status failed");
|
||||||
|
}
|
||||||
|
if (checkstatus (ctx, ll, ent, &l1, status) <= 0)
|
||||||
|
{
|
||||||
|
free (status);
|
||||||
|
longjmp (ctx->jb, 1);
|
||||||
|
}
|
||||||
|
free (status);
|
||||||
|
printf ("\n");
|
||||||
|
}
|
||||||
|
|
||||||
static void dispatchcmd (struct oneliner_ctx *ctx)
|
static void dispatchcmd (struct oneliner_ctx *ctx)
|
||||||
{
|
{
|
||||||
static const struct {
|
static const struct {
|
||||||
|
@ -1737,6 +1792,7 @@ static void dispatchcmd (struct oneliner_ctx *ctx)
|
||||||
} cs[] = {
|
} cs[] = {
|
||||||
{ "-", dodelete },
|
{ "-", dodelete },
|
||||||
{ "?", dowait },
|
{ "?", dowait },
|
||||||
|
{ "status", docheckstatus },
|
||||||
{ "wr", dowr },
|
{ "wr", dowr },
|
||||||
{ "wrdisp", dowrdisp },
|
{ "wrdisp", dowrdisp },
|
||||||
{ "disp", dodisp },
|
{ "disp", dodisp },
|
||||||
|
|
|
@ -144,6 +144,10 @@
|
||||||
* "i" for instances, "spi" for samples per instance)
|
* "i" for instances, "spi" for samples per instance)
|
||||||
* sm see pm
|
* sm see pm
|
||||||
*
|
*
|
||||||
|
* A * can be substituted for any argument to indicate the value
|
||||||
|
* doesn't matter. (The value does get printed, so it can be a
|
||||||
|
* handy way to get quickly check the actual value in some cases).
|
||||||
|
*
|
||||||
* | ?!LISTENER
|
* | ?!LISTENER
|
||||||
*
|
*
|
||||||
* (Not listener) tests that LISTENER has not been invoked since
|
* (Not listener) tests that LISTENER has not been invoked since
|
||||||
|
@ -171,6 +175,12 @@
|
||||||
* h suppress periodic heartbeats
|
* h suppress periodic heartbeats
|
||||||
* d drop outgoing data
|
* d drop outgoing data
|
||||||
*
|
*
|
||||||
|
* | status LISTENER(ARGS) ENTITY-NAME
|
||||||
|
*
|
||||||
|
* Compare the result of dds_get_L_status against ARGS for the
|
||||||
|
* specified entity, where L is corresponds to the event named by
|
||||||
|
* LISTENER. "da" and "dor" events are not allowed.
|
||||||
|
*
|
||||||
* WRITE-LIKE ::= wr write
|
* WRITE-LIKE ::= wr write
|
||||||
* | wrdisp write-dispose
|
* | wrdisp write-dispose
|
||||||
* | disp dispose
|
* | disp dispose
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue