13.04 - Asserts


'result.shell' is 'success'

What: Asserts that the result of the command execution is success.
ASSERT {result<Res:result.shell>} IS success

VERIFY {result<Res:result.shell>} IS success
Note: For differences between ASSERT and VERIFY assertion mode see this page this page

Input: 
  • result<Res:result.shell>: The name of the resource which references a resource that contains the result of a shell execution command. (Resource of category result.shell)

Example:

LOAD shell/shell_command.txt AS command.file
CONVERT command.file TO query.shell USING $(timeout:15000) AS commandLine

EXECUTE execute WITH commandLine ON ssh_server AS result

ASSERT result IS success


'result.shell' is 'failure' with {expected return code}

What: Asserts that the return code of a command execution who failed is the expected code.
ASSERT {result<Res:result.shell>} IS failure WITH $(<expectedCode>)

VERIFY {result<Res:result.shell>} IS failure WITH $(<expectedCode>)
Note: For differences between ASSERT and VERIFY assertion mode see this page this page

Input: 
  • result<Res:result.shell>: The name of the resource which references a resource that contains the result of a shell execution command. (Resource of category result.shell)
  • <expectedCode>: The expected return code of the command execution.

Example:

ASSERT result IS failure WITH $(1)


'result.shell' does 'contain' {regex}

What: Asserts that a stream (standard exit stream or error stream) resulting of an execution command contains a character string.

ASSERT {result<Res:result.shell>} DOES contain WITH $(<searchPattern>) USING $(<streamType>)

VERIFY {result<Res:result.shell>} DOES contain WITH $(<searchPattern>) USING $(<streamType>)
Note: For differences between ASSERT and VERIFY assertion mode see this page this page

Input: 
  • result<Res:result.shell>: The resource that contains the result of an execution command. (Resource of category 'result.shell')
  • <searchPattern>: The regular expression searched in the stream.
  • <streamType>: The kind of stream in which we are searching the character string. 2 values are possible: 
    • out: To search inside a standard output stream.
    • err: To search inside the error stream.
Note: If you want to check for special characters used in the regular expression formalism, you will have to escape them with a backslash ("\").

Example:

EXECUTE execute WITH commandLine ON ssh-server AS result

ASSERT
result DOES contain WITH $(hello world) USING $(err)

'result.shell' does 'not.contain' {regex}

What: Asserts that a stream (standard exit stream or error stream) resulting of an execution command does not contain a specific character string.

ASSERT {result<Res:result.shell>} DOES not.contain WITH $(<searchPattern>) USING $(<streamType>)

VERIFY {result<Res:result.shell>} DOES not.contain WITH $(<searchPattern>) USING $(<streamType>)
Note: For differences between ASSERT and VERIFY assertion mode see this page this page

Input: 
  • result<Res:result.shell>: The resource that contains the result of an execution command. (Resource of category result.shell)
  • <searchPattern>: The regular expression searched in the stream.
  • <streamType>: The kind of stream in which we are searching the character string. 2 values are possible: 
    • out: To search inside a standard output stream.
    • err: To search inside the error stream.
Note: If you want to check for special characters used in the regular expression formalism, you will have to escape them with a backslash ("\").

Example:

EXECUTE execute WITH commandLine ON ssh-server AS result

ASSERT
result DOES not.contain WITH $(hello world) USING $(err)