####################################################################
# Copyright (c) 2014 Ericsson
#
# All rights reserved. This program and the accompanying materials are
# made available under the terms of the Eclipse Public License 2.0 which
# accompanies this distribution, and is available at
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
#    Jonathan Rajotte - Initial API and implementation
####################################################################
####################################################################
# Scenario: Initialize
####################################################################
<SCENARIO>
Initialize
<COMMAND_INPUT>
lttng --mi xml version
</COMMAND_INPUT>
<COMMAND_RESULT>
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
<?xml version="1.0" encoding="UTF-8"?>
<command>
  <name>version</name>
  <output>
    <version>
      <string>2.6.0</string>
      <major>2</major>
      <minor>6</minor>
      <commit></commit>
      <patchLevel>0</patchLevel>
      <name>TestMI</name>
      <description>Lorem ipsum</description>
      <url>http://lttng.org</url>
      <license>lttng is free software and under the GPL license and part LGPL</license>
    </version>
  </output>
</command>
</COMMAND_OUTPUT>

<COMMAND_INPUT>
lttng --mi xml list
</COMMAND_INPUT>
<COMMAND_RESULT>
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
<?xml version="1.0" encoding="UTF-8"?>
<command>
  <name>list</name>
  <output>
    <sessions/>
  </output>
</command>
</COMMAND_OUTPUT>

<COMMAND_INPUT>
lttng --mi xml list -k
</COMMAND_INPUT>
<COMMAND_RESULT>
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
<?xml version="1.0" encoding="UTF-8"?>
<command>
  <name>list</name>
  <output>
    <domains>
      <domain>
        <type>KERNEL</type>
        <buffer_type>PER_PID</buffer_type>
        <events>
          <event>
            <name>sched_kthread_stop</name>
            <type>TRACEPOINT</type>
            <enabled>true</enabled>
            <filter>false</filter>
            <loglevel>TRACE_EMERG</loglevel>
            <loglevel_type>ALL</loglevel_type>
            <exclusion>false</exclusion>
          </event>
          <event>
            <name>sched_kthread_stop_ret</name>
            <type>TRACEPOINT</type>
            <enabled>true</enabled>
            <filter>false</filter>
            <loglevel>TRACE_EMERG</loglevel>
            <loglevel_type>ALL</loglevel_type>
            <exclusion>false</exclusion>
          </event>
          <event>
            <name>sched_wakeup_new</name>
            <type>TRACEPOINT</type>
            <enabled>true</enabled>
            <filter>false</filter>
            <loglevel>TRACE_EMERG</loglevel>
            <loglevel_type>ALL</loglevel_type>
            <exclusion>false</exclusion>
          </event>
        </events>
      </domain>
    </domains>
  </output>
</command>
</COMMAND_OUTPUT>

<COMMAND_INPUT>
lttng --mi xml list -k --syscall
</COMMAND_INPUT>
<COMMAND_RESULT>
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
<?xml version="1.0" encoding="UTF-8"?>
<command>
    <name>list</name>
    <output>
        <events>
            <event>
                <name>read</name>
                <type>SYSCALL</type>
                <enabled>true</enabled>
                <filter>false</filter>
            </event>
            <event>
                <name>write</name>
                <type>SYSCALL</type>
                <enabled>true</enabled>
                <filter>false</filter>
            </event>
            <event>
                <name>open</name>
                <type>SYSCALL</type>
                <enabled>true</enabled>
                <filter>false</filter>
            </event>
        </events>
    </output>
</command>
</COMMAND_OUTPUT>

<COMMAND_INPUT>
lttng --mi xml list -u -f
</COMMAND_INPUT>
<COMMAND_RESULT>
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
<?xml version="1.0" encoding="UTF-8"?>
<command>
  <name>list</name>
  <output>
    <domains>
      <domain>
        <type>UST</type>
        <buffer_type>PER_PID</buffer_type>
        <pids>
          <pid>
            <id>9379</id>
            <name>/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello</name>
            <events>
              <event>
                <name>ust_tests_hello:tptest_sighandler</name>
                <type>TRACEPOINT</type>
                <enabled>true</enabled>
                <filter>false</filter>
                <loglevel>TRACE_DEBUG_MODULE</loglevel>
                <loglevel_type>ALL</loglevel_type>
                <exclusion>false</exclusion>
                <event_fields/>
              </event>
              <event>
                <name>ust_tests_hello:tptest</name>
                <type>TRACEPOINT</type>
                <enabled>true</enabled>
                <filter>false</filter>
                <loglevel>TRACE_INFO</loglevel>
                <loglevel_type>ALL</loglevel_type>
                <exclusion>false</exclusion>
                <event_fields>
                  <event_field>
                    <name>doublefield</name>
                    <type>FLOAT</type>
                    <nowrite>0</nowrite>
                  </event_field>
                  <event_field>
                    <name>floatfield</name>
                    <type>FLOAT</type>
                    <nowrite>0</nowrite>
                  </event_field>
                  <event_field>
                    <name>stringfield</name>
                    <type>STRING</type>
                    <nowrite>0</nowrite>
                  </event_field>
                </event_fields>
              </event>
            </events>
          </pid>
          <pid>
            <id>4852</id>
            <name>/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello</name>
            <events>
              <event>
                <name>ust_tests_hello:tptest_sighandler</name>
                <type>TRACEPOINT</type>
                <enabled>true</enabled>
                <filter>false</filter>
                <loglevel>TRACE_WARNING</loglevel>
                <loglevel_type>ALL</loglevel_type>
                <exclusion>false</exclusion>
                <event_fields/>
              </event>
              <event>
                <name>ust_tests_hello:tptest</name>
                <type>TRACEPOINT</type>
                <enabled>true</enabled>
                <filter>false</filter>
                <loglevel>TRACE_DEBUG_FUNCTION</loglevel>
                <loglevel_type>ALL</loglevel_type>
                <exclusion>false</exclusion>
                <event_fields>
                  <event_field>
                    <name>doublefield</name>
                    <type>FLOAT</type>
                    <nowrite>0</nowrite>
                  </event_field>
                  <event_field>
                    <name>floatfield</name>
                    <type>FLOAT</type>
                    <nowrite>0</nowrite>
                  </event_field>
                  <event_field>
                    <name>stringfield</name>
                    <type>STRING</type>
                    <nowrite>0</nowrite>
                  </event_field>
                </event_fields>
              </event>
            </events>
          </pid>
        </pids>
      </domain>
    </domains>
  </output>
</command>
</COMMAND_OUTPUT>
<COMMAND_INPUT>
lttng --mi xml list -j
</COMMAND_INPUT>
<COMMAND_RESULT>
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
<?xml version="1.0" encoding="UTF-8"?>
<command>
    <name>list</name>
    <output>
        <domains>
            <domain>
                <type>JUL</type>
                <buffer_type>PER_PID</buffer_type>
                <pids/>
            </domain>
        </domains>
    </output>
</command>
</COMMAND_OUTPUT>
<COMMAND_INPUT>
lttng --mi xml list -l
</COMMAND_INPUT>
<COMMAND_RESULT>
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
<?xml version="1.0" encoding="UTF-8"?>
<command>
    <name>list</name>
    <output>
        <domains>
            <domain>
                <type>LOG4J</type>
                <buffer_type>PER_PID</buffer_type>
                <pids>
                    <pid>
                        <id>18332</id>
                        <name>java</name>
                        <events>
                            <event>
                                <name>Test</name>
                                <type>TRACEPOINT</type>
                                <enabled>true</enabled>
                                <filter>false</filter>
                                <loglevel>UNKNOWN</loglevel>
                                <loglevel_type>ALL</loglevel_type>
                                <exclusion>false</exclusion>
                            </event>
                        </events>
                    </pid>
                </pids>
            </domain>
        </domains>
    </output>
</command>
</COMMAND_OUTPUT>
<COMMAND_INPUT>
lttng --mi xml list -p
</COMMAND_INPUT>
<COMMAND_RESULT>
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
<?xml version="1.0" encoding="UTF-8"?>
<command>
  <name>list</name>
  <output>
    <domains>
      <domain>
        <type>PYTHON</type>
        <buffer_type>PER_PID</buffer_type>
        <pids>
          <pid>
            <id>4940</id>
            <name>python3</name>
            <events>
              <event>
                <name>my-logger</name>
                <type>TRACEPOINT</type>
                <enabled>true</enabled>
                <filter>false</filter>
                <loglevel>PYTHON_NOTSET</loglevel>
                <loglevel_type>ALL</loglevel_type>
                <exclusion>false</exclusion>
              </event>
            </events>
          </pid>
        </pids>
      </domain>
    </domains>
  </output>
</command>
</COMMAND_OUTPUT>
</SCENARIO>

####################################################################
# Scenario: Test "lttng create <session> with LTTng 2.1 options
####################################################################
##################################################################
<SCENARIO>
CreateSessionFileProto
<COMMAND_INPUT>
lttng --mi xml create mysession -U file:///tmp
</COMMAND_INPUT>
<COMMAND_RESULT>
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
<?xml version="1.0" encoding="UTF-8"?>
<command>
  <name>create</name>
  <output>
    <session>
      <name>mysession</name>
      <path>/tmp</path>
      <enabled>false</enabled>
      <snapshot_mode>0</snapshot_mode>
      <live_timer_interval>0</live_timer_interval>
    </session>
  </output>
  <success>true</success>
</command>
</COMMAND_OUTPUT>

<COMMAND_INPUT>
lttng --mi xml list mysession
</COMMAND_INPUT>
<COMMAND_RESULT>
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
<?xml version="1.0" encoding="UTF-8"?>
<command>
  <name>list</name>
  <output>
    <sessions>
      <session>
        <name>mysession</name>
        <path>/tmp</path>
        <enabled>false</enabled>
        <snapshot_mode>0</snapshot_mode>
        <live_timer_interval>0</live_timer_interval>
        <domains/>
      </session>
    </sessions>
  </output>
</command>
</COMMAND_OUTPUT>

<COMMAND_INPUT>
lttng --mi xml destroy mysession
</COMMAND_INPUT>
<COMMAND_RESULT>
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
<?xml version="1.0" encoding="UTF-8"?>
<command>
  <name>destroy</name>
  <output>
    <sessions>
      <session>
        <name>mysession</name>
        <path>/tmp</path>
        <enabled>false</enabled>
        <snapshot_mode>0</snapshot_mode>
        <live_timer_interval>0</live_timer_interval>
      </session>
    </sessions>
  </output>
  <success>true</success>
</command>
</COMMAND_OUTPUT>
</SCENARIO>

##################################################################
<SCENARIO>
CreateSessionControlData
<COMMAND_INPUT>
lttng --mi xml create mysession -C tcp://172.0.0.1 -D tcp://172.0.0.1:5343
</COMMAND_INPUT>
<COMMAND_RESULT>
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
<?xml version="1.0" encoding="UTF-8"?>
<command>
  <name>create</name>
  <output>
    <session>
      <name>mysession</name>
      <path>tcp4://172.0.0.1:5342/ [data: 5343]</path>
      <enabled>false</enabled>
      <snapshot_mode>0</snapshot_mode>
      <live_timer_interval>0</live_timer_interval>
    </session>
  </output>
  <success>true</success>
</command>
</COMMAND_OUTPUT>

<COMMAND_INPUT>
lttng --mi xml list mysession
</COMMAND_INPUT>
<COMMAND_RESULT>
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
<?xml version="1.0" encoding="UTF-8"?>
<command>
  <name>list</name>
  <output>
    <sessions>
      <session>
        <name>mysession</name>
        <path>tcp4://172.0.0.1:5342/ [data: 5343]</path>
        <enabled>false</enabled>
        <snapshot_mode>0</snapshot_mode>
        <live_timer_interval>0</live_timer_interval>
        <domains/>
      </session>
    </sessions>
  </output>
</command>
</COMMAND_OUTPUT>

<COMMAND_INPUT>
lttng --mi xml destroy mysession
</COMMAND_INPUT>
<COMMAND_RESULT>
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
<?xml version="1.0" encoding="UTF-8"?>
<command>
  <name>destroy</name>
  <output>
    <sessions>
      <session>
        <name>mysession</name>
        <path>tcp4://172.0.0.1:5342/ [data: 5343]</path>
        <enabled>false</enabled>
        <snapshot_mode>0</snapshot_mode>
        <live_timer_interval>0</live_timer_interval>
      </session>
    </sessions>
  </output>
  <success>true</success>
</command>
</COMMAND_OUTPUT>
</SCENARIO>

##################################################################
<SCENARIO>
CreateSessionNetwork
<COMMAND_INPUT>
lttng --mi xml create mysession -U net://172.0.0.1:1234:2345
</COMMAND_INPUT>
<COMMAND_RESULT>
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
<?xml version="1.0" encoding="UTF-8"?>
<command>
  <name>create</name>
  <output>
    <session>
      <name>mysession</name>
      <path>tcp4://172.0.0.1:1234/mysession-20140820-153527 [data: 2345]</path>
      <enabled>false</enabled>
      <snapshot_mode>0</snapshot_mode>
      <live_timer_interval>0</live_timer_interval>
    </session>
  </output>
  <success>true</success>
</command>
</COMMAND_OUTPUT>

<COMMAND_INPUT>
lttng --mi xml list mysession
</COMMAND_INPUT>
<COMMAND_RESULT>
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
<?xml version="1.0" encoding="UTF-8"?>
<command>
  <name>list</name>
  <output>
    <sessions>
      <session>
        <name>mysession</name>
        <path>tcp4://172.0.0.1:1234/mysession-20140820-153527 [data: 2345]</path>
        <enabled>false</enabled>
        <snapshot_mode>0</snapshot_mode>
        <live_timer_interval>0</live_timer_interval>
        <domains/>
      </session>
    </sessions>
  </output>
</command>
</COMMAND_OUTPUT>

<COMMAND_INPUT>
lttng --mi xml destroy mysession
</COMMAND_INPUT>
<COMMAND_RESULT>
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
<?xml version="1.0" encoding="UTF-8"?>
<command>
  <name>destroy</name>
  <output>
    <sessions>
      <session>
        <name>mysession</name>
        <path>tcp4://172.0.0.1:1234/mysession-20140820-153527 [data: 2345]</path>
        <enabled>false</enabled>
        <snapshot_mode>0</snapshot_mode>
        <live_timer_interval>0</live_timer_interval>
      </session>
    </sessions>
  </output>
  <success>true</success>
</command>
</COMMAND_OUTPUT>

</SCENARIO>

##################################################################
<SCENARIO>
CreateSessionNetwork2
<COMMAND_INPUT>
lttng --mi xml create mysession -U net6://[ffff::eeee:dddd:cccc:0]
</COMMAND_INPUT>
<COMMAND_RESULT>
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
<?xml version="1.0" encoding="UTF-8"?>
<command>
  <name>create</name>
  <output>
    <session>
      <name>mysession</name>
      <path>tcp6://[ffff::eeee:dddd:cccc:0]:5342/mysession-20140820-153801 [data: 5343]</path>
      <enabled>false</enabled>
      <snapshot_mode>0</snapshot_mode>
      <live_timer_interval>0</live_timer_interval>
    </session>
  </output>
  <success>true</success>
</command>
</COMMAND_OUTPUT>

<COMMAND_INPUT>
lttng --mi xml list mysession
</COMMAND_INPUT>
<COMMAND_RESULT>
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
<?xml version="1.0" encoding="UTF-8"?>
<command>
  <name>list</name>
  <output>
    <sessions>
      <session>
        <name>mysession</name>
        <path>tcp6://[ffff::eeee:dddd:cccc:0]:5342/mysession-20140820-153801 [data: 5343]</path>
        <enabled>false</enabled>
        <snapshot_mode>0</snapshot_mode>
        <live_timer_interval>0</live_timer_interval>
        <domains/>
      </session>
    </sessions>
  </output>
</command>
</COMMAND_OUTPUT>

<COMMAND_INPUT>
lttng --mi xml destroy mysession
</COMMAND_INPUT>
<COMMAND_RESULT>
0
</COMMAND_RESULT>
<COMMAND_OUTPUT>
<?xml version="1.0" encoding="UTF-8"?>
<command>
  <name>destroy</name>
  <output>
    <sessions>
      <session>
        <name>mysession</name>
        <path>tcp6://[ffff::eeee:dddd:cccc:0]:5342/mysession-20140820-153801 [data: 5343]</path>
        <enabled>false</enabled>
        <snapshot_mode>0</snapshot_mode>
        <live_timer_interval>0</live_timer_interval>
      </session>
    </sessions>
  </output>
  <success>true</success>
</command>
</COMMAND_OUTPUT>

</SCENARIO>