1: %%
    2: %% %CopyrightBegin%
    3: %%
    4: %% Copyright Ericsson AB 1998-2011. All Rights Reserved.
    5: %%
    6: %% The contents of this file are subject to the Erlang Public License,
    7: %% Version 1.1, (the "License"); you may not use this file except in
    8: %% compliance with the License. You should have received a copy of the
    9: %% Erlang Public License along with this software. If not, it can be
   10: %% retrieved online at http://www.erlang.org/.
   11: %%
   12: %% Software distributed under the License is distributed on an "AS IS"
   13: %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
   14: %% the License for the specific language governing rights and limitations
   15: %% under the License.
   16: %%
   17: %% %CopyrightEnd%
   18: %%
   19: 
   20: %%
   21: -module(dbg_ui_SUITE).
   22: 
   23: 
   24: -include_lib("test_server/include/test_server.hrl").
   25: 
   26: 
   27: % Test server specific exports
   28: -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, 
   29: 	 init_per_group/2,end_per_group/2]).
   30: 
   31: % Test cases must be exported.
   32: -export ([dbg_ui/1]).
   33: 
   34: % Manual test suites/cases exports
   35: -export([start1/1, interpret1/1, quit1/1,
   36: 	 start2/1, interpret2/1, break2/1, options2/1, quit2/1,
   37: 	 interpret3/1, all_step3/1,all_next3/1,save3/1,restore3/1,finish3/1,
   38: 	 killinit3/1, killone3/1, killall3/1, deleteone3/1, deleteall3/1,
   39: 	 viewbreak4/1, delete4/1,
   40: 	 attach5/1, normal5/1, exit5/1, options5/1,
   41: 	 distsetup6/1, all_step6/1, all_next6/1]).
   42: 
   43: -export([init_per_testcase/2, end_per_testcase/2]).
   44: 
   45: init_per_testcase(_Func, Config) ->
   46:     Dog=test_server:timetrap(60*1000),
   47:     [{watchdog, Dog}|Config].
   48: 
   49: end_per_testcase(_Func, Config) ->
   50:     Dog=?config(watchdog, Config),
   51:     test_server:timetrap_cancel(Dog).
   52: 
   53: 
   54: suite() -> [{ct_hooks,[ts_install_cth]}].
   55: 
   56: all() -> 
   57:     [dbg_ui, {group, manual_tests}].
   58: 
   59: groups() -> 
   60:     [{manual_tests, [],
   61:       [start1, interpret1, quit1, start2, interpret2, break2,
   62:        options2, interpret3, all_step3, all_next3, save3,
   63:        restore3, finish3, killinit3, killone3, killall3,
   64:        deleteone3, deleteall3, viewbreak4, delete4, attach5,
   65:        normal5, exit5, options5, distsetup6, all_step6,
   66:        all_next6]}].
   67: 
   68: init_per_suite(Config) ->
   69:     Config.
   70: 
   71: end_per_suite(_Config) ->
   72:     ok.
   73: 
   74: init_per_group(_GroupName, Config) ->
   75:     Config.
   76: 
   77: end_per_group(_GroupName, Config) ->
   78:     Config.
   79: 
   80: dbg_ui (doc) ->
   81:     ["Debugger GUI"];
   82: 
   83: dbg_ui (suite) ->
   84:     [];
   85: 
   86: dbg_ui (_Config) ->
   87:     case os:getenv("DISPLAY") of
   88: 	false ->
   89: 	    {skipped,"No display"};
   90: 	Other when is_list(Other) ->
   91: %	    ?line {ok, Pid} = debugger:start (),
   92: %	    ?line ok = is_pid (Pid),
   93: %	    ?line true = erlang:is_process_alive(Pid),
   94: %	    ?line ok = debugger:stop(),
   95: %	    ?line false = erlang:is_process_alive(Pid)
   96: 	    {skipped,"Gunilla: Workaround"}
   97:     end.
   98: 
   99: %% check/2 - returns the result for the specified testcase.
  100: %% pass - means the user has run the case, and it passed
  101: %% fail - means the user has run the case, and it failed
  102: %% unknown - means the user has (tried to) run the case, and the result is unclear.
  103: %% skip - means the user has not yet run the case.
  104: 
  105: check(Case, Config) ->
  106: 
  107:     ?line DataDir = ?config(data_dir, Config),
  108:     ?line ResultFileName =  filename:join([DataDir, "manual_results.erl"]),
  109:     case file:consult(ResultFileName) of
  110: 	{ok, Results} ->
  111: 	    ?line io:format("Results: ~p~n",[Results]),
  112: 	    case Results of
  113: 		[] ->
  114: 		    no_result;
  115: 		%% Incomplete "sanity" check of file contents.
  116: 		[{_Key,_Value}|_Rest] ->
  117: 		    case lists:keysearch(Case, 1, Results) of
  118: 			{value, {Case, Value}} ->
  119: 			    Value;		% pass, fail, unknown
  120: 			false ->
  121: 			    no_result;				% skip
  122: 			_Otherwise ->
  123: 			    {error, "Contents of results file not valid"}
  124: 		    end;
  125: 		_Otherwise2 ->
  126: 		    {error, "Contents of results file not valid"}
  127: 	    end;
  128: 	_Otherwise3 ->
  129: 	    {error, "Problems reading results file"}
  130:     end.
  131: 
  132: 
  133: 
  134: 
  135: 
  136: 
  137: -define(MAN_CASE(Name,Doc, Description),
  138: 	Name(doc) -> [Doc];
  139: 	Name(suite) -> [];
  140: 	Name(Config) ->
  141: 	       ?line io:format("Checking ~p~n",[Name]),
  142: 	       ?line io:format("Config = ~p~n",[Config]),
  143: 	       case check(Name, Config) of
  144: 		   pass ->
  145: 		       ?line ok;
  146: 		   fail ->
  147: 		       ?line test_server:fail("Manual test failed");
  148: 		   unknown ->
  149: 		       ?line {skipped, "Manual test result unknown"};
  150: 
  151: 		   no_result ->
  152: 		       ?line {skipped, Description};
  153: 
  154: 		   {error, _Reason} ->
  155: %%		       Text = lists:flatten(
  156: %%				io_lib:format("[File problem: ~s]~s",
  157: %%		       [Reason,Description])),
  158: 		       ?line {skipped, Description}
  159: 	       end
  160: 		  ).
  161: 
  162: 
  163: %% SET 1
  164: ?MAN_CASE(start1, "Start the debugger from the toolbar",
  165: 	  "Before proceeding with the test cases, please move or remove
  166: the directory .erlang_tools/debugger in your home directory. Next,
  167: please start the debugger from the toolbar").
  168: 
  169: ?MAN_CASE(interpret1, "Interpreting modules",
  170: 	  "In this test case and all of the ones following, the source code
  171: files to use can be found in the test data directory for this debugger test
  172:  suite (probably in
  173: /clearcase/otp/tools/debugger/test/dbg_ui_SUITE_data/manual_data/src ).
  174: Interpret one module").
  175: 
  176: ?MAN_CASE(quit1, "Quit the debugger",
  177: "Quit the debugger using File->Exit in the main window").
  178: 
  179: 
  180: %% SET 2
  181: ?MAN_CASE(start2, "Start the debugger from the shell",
  182: "Start the debugger from the shell. Use debugger:start()").
  183: 
  184: ?MAN_CASE(interpret2, "Interpret all modules",
  185: "Interpret all modules").
  186: 
  187: ?MAN_CASE(break2, "Set break points",
  188: "Set break points").
  189: 
  190: ?MAN_CASE(options2, "Set options to attach on break",
  191: "Set options to attach on break").
  192: 
  193: ?MAN_CASE(quit2, "Quit the debugger",
  194: "Quit the debugger using the close box in the main window title frame").
  195: 
  196: 
  197: %% SET3
  198: ?MAN_CASE(interpret3, "Test attach options",
  199: "Start the debugger and interpret the modules [test, lists1, ordsets1]. Close the Interpret dialog. Set Attach on First Call and Attach on Break.").
  200: 
  201: ?MAN_CASE(all_step3, "Click Step through all evaluation",
  202: "In the shell, call test:test1(). Use the Step button, the Process->Step menu item and the ctrl-s shortcut to step through the *entire* execution of the call. (Approx 36 steps). Then close the Attach window. The result printed in the shell should be: {\"peter\",[1,2,4,a,b,c],\"olin\"}").
  203: 
  204: ?MAN_CASE(all_next3,"Click Next through all evaluation",
  205: "Again call test:test1() in the shell. This time Use the Next button,  the Process->Next menu and the ctrl-n shortcut to quickly step over the execution of the four lines in the test1-function. The result printed in the shell should be: {\"peter\",[1,2,4,a,b,c],\"olin\"}").
  206: 
  207: ?MAN_CASE(save3, "Save the debugger state",
  208: "Use File->Save Settings to save the debugger state with the name 'three.state'").
  209: 
  210: ?MAN_CASE(restore3,"Quit the debugger, restart and restore the state",
  211: "Quit the debugger. Start it again. Use File->Load Settings to restore the state saved in 'three.state'. Check that the Attach-options are the same as what you set them to in the interpret3 test case. Check that the three modules [test,lists1,ordsets1] are interpreted.").
  212: 
  213: 
  214: ?MAN_CASE(finish3, "Finish the current function body",
  215: "Call the fucntion test:test1() from the shell. Press Finish to evaluate the remaining lines in the function. The result printed in the shell should be: {\"peter\",[1,2,4,a,b,c],\"olin\"}").
  216: 
  217: ?MAN_CASE(killinit3,"Set up for killing and clearing processes",
  218: "Call test:test2() from the shell. Set a break point at the last line of test:test2. Click Continue. This should open three new attach windows. One for each spawn called in test:test2/0.   ").
  219: 
  220: ?MAN_CASE(killone3, "Kill a process and clear it",
  221: "In one of the newly openend Attach windows: select Process->Kill. A message should appear above the Code Area in the Attach window. Use Windows->Monitor to verify that the Monitor window also shows that the process has been killed. In the Monitor window: select Edit->Clear. This should do two things: 1) close/remove the window of the killed process. 2) Remove the entry of the killed process from the monitor window.").
  222: 
  223: ?MAN_CASE(killall3,"KIll all processes, and clear them",
  224: "In the Monitor window: Select Edit->Kill All. Verify that all processes have been killed (in their respective windows and in the monitor window). Windows will be raised as their processes die. Next select, Edit->Clear. All attach windows should now be closed. Their entris should also disappear from the monitor window. The shell should have reported: ** exited: killed **").
  225: 
  226: ?MAN_CASE(deleteone3,"Delete/uniterpret one module",
  227: "In the Monitor window: Select Module->test->Delete. This should remove the breakpoints set in the test module, and the test module should disappear from the Module menu.").
  228: 
  229: ?MAN_CASE(deleteall3,"Delete/uniterpret all modules",
  230: "In the Monitor window: Select Module->Delete All Modules. This should remove all modules from the Module menu. ").
  231: 
  232: %% SET 4
  233: 
  234: 
  235: 
  236: ?MAN_CASE(viewbreak4, "Test the View window",
  237: "Restore the settings from the three.state file again. In the Monitor window: Use Module->test->View to view the source code of the test module. In the View window, select Break->Line Break and set a break at line 53. Check that it appears in the View window and in the Monitor Window Break-menu. Also in the View window, select Break->Function Break and set a break at function test:test4. Check that the break (at line 59) appears in the View Window and in the Monitor Window Break-menu.").
  238: 
  239: ?MAN_CASE(delete4, "Remove breaks",
  240: "Use the Break->Delete All function in the View window to remove all breaks in the test module. Check that they are all removed. Close the View window.").
  241: 
  242: %% SET 5
  243: 
  244: ?MAN_CASE(attach5,"Set attach options",
  245: "Set the attach options to only attach on exit").
  246: 
  247: ?MAN_CASE(normal5, "Test normal exit",
  248: "Call test:test12(normal) in the shell. This should return the atom 'done', and no windows should be opened.").
  249: 
  250: ?MAN_CASE(exit5, "Test abnormal exit",
  251: "Call test:test12(crash) in the shell. This should give the error message ** exited: crash **, and an attach window should be opened highlighting the last line in the test12-function.").
  252: 
  253: ?MAN_CASE(options5, "Experiment with the frames in the attach window",
  254: "Try all possible configurations of the [Button, Evaluator, Bindings, Trace] Frames in the attach window and see that the expected frames are shown/hidden.").
  255: 
  256: 
  257: %% SET 6 (Distribution)
  258: 
  259: ?MAN_CASE(distsetup6,"Set up distribution",
  260: "Start two erlang systems [foo,bar] (with option -sname), make them aware of eachother using net_adm:ping/1. Start the debugger on foo. Interpret the modules [test, lists1, ordsets1]. Set attach on First call.  ").
  261: 
  262: 
  263: 
  264: 
  265: ?MAN_CASE(all_step6, "Click Step through all evaluation",
  266: "In the bar shell, call test:test1().This should open an attach window. Use the Step button, the Process->Step menu item and the ctrl-s shortcut to step through the *entire* execution of the call. (Approx 36 steps). Then close the Attach window. The result printed in the bar shell should be: {\"peter\",[1,2,4,a,b,c],\"olin\"}").
  267: 
  268: ?MAN_CASE(all_next6,"Click Next through all evaluation",
  269: "Again, in the bar shell, call test:test1(). This time Use the Next button,  the Process->Next menu and the ctrl-n shortcut to quickly step over the execution of the four lines in the test1-function. The result printed in the shell should be: {\"peter\",[1,2,4,a,b,c],\"olin\"}").