question

MarkV avatar image
MarkV asked MarkV posted

Response map with tokens on second line

I have a case where I want to take the output of a command that shows what debug trace types are enabled and programmatically disable them. The output of the command is as follows (partial output shown):

 

Registered Trace Type(s) | Trace id(s) currently enabled
--------------------------------------------------------
TRACE_PTAP          
                           No trace(s) enabled!
RING_TRACE          
                           All trace(s) enabled!
RING_EVENTS         
                           No trace(s) enabled!
TRACE_DSPCFG        
                           No trace(s) enabled!
TRACE_DSP           
                           All trace(s) enabled!
TRACE_CMD_HANDLER   
                           No trace(s) enabled!
CPU_MON             
                           No trace(s) enabled!
--------------------------------------------------------

 

Notice that the token 'No/All trace(s) enabled!' is on a separate line from the trace type. Spaces are used to line up the tokens into a column.

 

I want to get all the trace types that have 'All trace(s) enabled!' from the response, put them in a list then use a while loop to disable them.

 

I think the best  way to map the output is to use a block response map, but I am not sure how to deal with the repetitive tokens and how to extract the trace types into a list.

 

Thanks in advance.

iTestresponse map
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

MarkV avatar image
MarkV answered MarkV posted

Ok, I could not get the custom query provided in the response map to work, but I came up with a custom query that worked for me.

 

This one works (returns tracesTypes that are enabled):

//block2[message='{0}']/traceType

e.g.,

//block2[message='All trace(s) enabled!']/traceType

 

did not work:

//block2/traceType[message = '{0}']

//block2/traceType[message = 'All trace(s) enabled!'] (no matches found)

 

To use the response, the results from the showTypes command is saved in a variable that I then use in a foreach action to disable the traces:

[query -alwayslist showTypes_results "GetTraceTypes(\"All trace(s) enabled!\")"]

 

Pretty neat once you figure out whats going on!

Thanks,

Mark

 

10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

PaulD avatar image
PaulD answered PaulD posted

Yes.  A block map can work for this.  You will need to create a container that represents the repeating structure (trace type, trace ids) and you'll have to mark this block so that it can appear multiple times.  Within the container, you'll have a line for the type, and then a container that can appear multiple times for the IDs.

 

You can also use pattern mapping to get this done.  Consider each of the type/id portions as a pattern (which spans multiple lines).  You'll just have to customize the patterns generated -- which will require that you know some regex stuff.

 

If you'd like us to help, please send a few more examples -- with some where selective IDs are enabled, so that we're sure it will work for all cases.

3 comments
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

MarkV avatar image MarkV commented ·

For my purposes, any Trace ID is enabled when it has "All trace(s) enabled!" on the second line. There is more grainularity for some of the IDs but its typically "All" or "No" for debugging. Attachment has the command with output at step 8.

 

Thanks,

Mark

 

 

0 Likes 0 ·
KumarS avatar image KumarS MarkV commented ·

Here is a response map with a query called "getTraceTypes" which takes the message as the argument.

 

You will see that I created three blocks, one for header, one for footer and one for the middle block which repeats. If you look at the structure view, it becomes very easy to write XPATH queries based on the XML shown in the structure view to extract any data you want.

 

 

0 Likes 0 ·
block.ffrm (5.5 KiB)
MarkV avatar image MarkV KumarS commented ·

Thanks KumarS. I studied your response map but being a iTest newbie, especially using xPath queries, I need some help taking the response map you provided to the next step. Basically, a query that builds a list variable of trace types that are enabled, where msg = "All trace(s) are enabled!".

 

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.