| 1 | package org.eclipse.linuxtools.lttng.stubs.service.shells; |
| 2 | |
| 3 | import java.util.ArrayList; |
| 4 | import java.util.List; |
| 5 | |
| 6 | import org.eclipse.core.commands.ExecutionException; |
| 7 | import org.eclipse.core.runtime.IProgressMonitor; |
| 8 | import org.eclipse.linuxtools.lttng.ui.views.control.service.CommandResult; |
| 9 | import org.eclipse.linuxtools.lttng.ui.views.control.service.ICommandResult; |
| 10 | |
| 11 | public class SessionNamesShell extends TestCommandShell { |
| 12 | @SuppressWarnings("nls") |
| 13 | @Override |
| 14 | public ICommandResult executeCommand(String command, IProgressMonitor monitor, boolean checkReturnValue) throws ExecutionException { |
| 15 | if ("lttng list ".equals(command)) { |
| 16 | String[] output = new String[5]; |
| 17 | output[0] = String.valueOf("Available tracing sessions:"); |
| 18 | output[1] = String.valueOf(" 1) mysession1 (/home/user/lttng-traces/mysession1-20120123-083928) [inactive]"); |
| 19 | output[2] = String.valueOf(" 2) mysession (/home/user/lttng-traces/mysession-20120123-083318) [inactive]"); |
| 20 | output[3] = String.valueOf(""); |
| 21 | output[4] = String.valueOf(" Use lttng list <session_name> for more details"); |
| 22 | // test constructor with null pointer parameter |
| 23 | CommandResult result = new CommandResult(0, null); |
| 24 | // test setOutput!!! |
| 25 | result.setOutput(output); |
| 26 | return result; |
| 27 | } else if ("lttng list mysession".equals(command)) { |
| 28 | List<String> list = new ArrayList<String>(); |
| 29 | list.add("Tracing session mysession: [active]"); |
| 30 | list.add(" Trace path: /home/user/lttng-traces/mysession-20120129-084256"); |
| 31 | list.add(""); |
| 32 | list.add("=== Domain: Kernel ==="); |
| 33 | list.add(""); |
| 34 | list.add("Channels:"); |
| 35 | list.add("-------------"); |
| 36 | list.add("- channel0: [enabled]"); |
| 37 | list.add(""); |
| 38 | list.add(" Attributes:"); |
| 39 | list.add(" overwrite mode: 0"); |
| 40 | list.add(" subbufers size: 262144"); |
| 41 | list.add(" number of subbufers: 4"); |
| 42 | list.add(" switch timer interval: 0"); |
| 43 | list.add(" read timer interval: 200"); |
| 44 | list.add(" output: splice()"); |
| 45 | list.add(""); |
| 46 | list.add(" Events:"); |
| 47 | list.add(" block_rq_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) [enabled]"); |
| 48 | list.add(" block_bio_remap (loglevel: TRACE_EMERG (0)) (type: tracepoint) [disabled]"); |
| 49 | list.add(""); |
| 50 | list.add("- channel1: [disabled]"); |
| 51 | list.add(""); |
| 52 | list.add(" Attributes:"); |
| 53 | list.add(" overwrite mode: 1"); |
| 54 | list.add(" subbufers size: 524288"); |
| 55 | list.add(" number of subbufers: 4"); |
| 56 | list.add(" switch timer interval: 100"); |
| 57 | list.add(" read timer interval: 400"); |
| 58 | list.add(" output: splice()"); |
| 59 | list.add(""); |
| 60 | list.add(" Events:"); |
| 61 | list.add(" None"); |
| 62 | list.add(""); |
| 63 | list.add("=== Domain: UST global ==="); |
| 64 | list.add(""); |
| 65 | list.add("Channels:"); |
| 66 | list.add("-------------"); |
| 67 | list.add("- mychannel1: [disabled]"); |
| 68 | list.add(""); |
| 69 | list.add(" Attributes:"); |
| 70 | list.add(" overwrite mode: 1"); |
| 71 | list.add(" subbufers size: 8192"); |
| 72 | list.add(" number of subbufers: 8"); |
| 73 | list.add(" switch timer interval: 200"); |
| 74 | list.add(" read timer interval: 100"); |
| 75 | list.add(" output: mmap()"); |
| 76 | list.add(""); |
| 77 | list.add(" Events:"); |
| 78 | list.add(" None"); |
| 79 | list.add(""); |
| 80 | list.add("- channel0: [enabled]"); |
| 81 | list.add(""); |
| 82 | list.add(" Attributes:"); |
| 83 | list.add(" overwrite mode: 0"); |
| 84 | list.add(" subbufers size: 4096"); |
| 85 | list.add(" number of subbufers: 4"); |
| 86 | list.add(" switch timer interval: 0"); |
| 87 | list.add(" read timer interval: 200"); |
| 88 | list.add(" output: mmap()"); |
| 89 | list.add(""); |
| 90 | list.add(" Events:"); |
| 91 | list.add(" ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_LINE (13)) (type: tracepoint) [disabled]"); |
| 92 | list.add(" * (type: tracepoint) [enabled]"); |
| 93 | list.add(""); |
| 94 | return new CommandResult(0, list.toArray(new String[list.size()])); |
| 95 | } else if ("lttng list -u".equals(command)) { |
| 96 | List<String> list = new ArrayList<String>(); |
| 97 | list.add("UST events:"); |
| 98 | list.add("-------------"); |
| 99 | list.add(""); |
| 100 | list.add("PID: 9379 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello"); |
| 101 | list.add(" ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint)"); |
| 102 | list.add(" ust_tests_hello:tptest (loglevel: TRACE_INFO (6)) (type: tracepoint)"); |
| 103 | list.add(""); |
| 104 | list.add("PID: 4852 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello"); |
| 105 | list.add(" ust_tests_hello:tptest_sighandler (loglevel: TRACE_WARNING (4)) (type: tracepoint)"); |
| 106 | list.add(" ust_tests_hello:tptest (loglevel: TRACE_DEBUG_FUNCTION (12)) (type: tracepoint)"); |
| 107 | list.add(""); |
| 108 | return new CommandResult(0, list.toArray(new String[list.size()])); |
| 109 | } else if ("lttng list -k".equals(command)) { |
| 110 | List<String> list = new ArrayList<String>(); |
| 111 | list.add("Kernel events:"); |
| 112 | list.add("-------------"); |
| 113 | list.add(" sched_kthread_stop (loglevel: TRACE_EMERG (0)) (type: tracepoint)"); |
| 114 | list.add(" sched_kthread_stop_ret (loglevel: TRACE_EMERG (0)) (type: tracepoint)"); |
| 115 | list.add(" sched_wakeup_new (loglevel: TRACE_EMERG (0)) (type: tracepoint)"); |
| 116 | list.add(""); |
| 117 | return new CommandResult(0, list.toArray(new String[list.size()])); |
| 118 | } else if ("lttng list mysession1".equals(command)) { |
| 119 | List<String> list = new ArrayList<String>(); |
| 120 | list.add("Tracing session mysession1: [inactive]"); |
| 121 | list.add(" Trace path: /home/user/lttng-traces/mysession1-20120203-133225"); |
| 122 | list.add(""); |
| 123 | return new CommandResult(0, list.toArray(new String[list.size()])); |
| 124 | } else if ("lttng create mysession2".equals(command)) { |
| 125 | List<String> list = new ArrayList<String>(); |
| 126 | list.add("Session mysession2 created."); |
| 127 | list.add("Traces will be written in /home/user/lttng-traces/mysession2-20120209-095418"); |
| 128 | return new CommandResult(0, list.toArray(new String[list.size()])); |
| 129 | } else if ("lttng destroy mysession2".equals(command)) { |
| 130 | List<String> list = new ArrayList<String>(); |
| 131 | list.add("Session mysession2 destrioyed."); |
| 132 | return new CommandResult(0, list.toArray(new String[list.size()])); |
| 133 | } |
| 134 | |
| 135 | String[] output = new String[1]; |
| 136 | output[0] = String.valueOf("Command not found"); |
| 137 | return new CommandResult(1, output); |
| 138 | } |
| 139 | } |