001 // This file is part of the program FRYSK. 002 // 003 // Copyright 2007, 2008 Red Hat Inc. 004 // 005 // FRYSK is free software; you can redistribute it and/or modify it 006 // under the terms of the GNU General Public License as published by 007 // the Free Software Foundation; version 2 of the License. 008 // 009 // FRYSK is distributed in the hope that it will be useful, but 010 // WITHOUT ANY WARRANTY; without even the implied warranty of 011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 // General Public License for more details. 013 // 014 // You should have received a copy of the GNU General Public License 015 // along with FRYSK; if not, write to the Free Software Foundation, 016 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 017 // 018 // In addition, as a special exception, Red Hat, Inc. gives You the 019 // additional right to link the code of FRYSK with code not covered 020 // under the GNU General Public License ("Non-GPL Code") and to 021 // distribute linked combinations including the two, subject to the 022 // limitations in this paragraph. Non-GPL Code permitted under this 023 // exception must only link to the code of FRYSK through those well 024 // defined interfaces identified in the file named EXCEPTION found in 025 // the source code files (the "Approved Interfaces"). The files of 026 // Non-GPL Code may instantiate templates or use macros or inline 027 // functions from the Approved Interfaces without causing the 028 // resulting work to be covered by the GNU General Public 029 // License. Only Red Hat, Inc. may make changes or additions to the 030 // list of Approved Interfaces. You must obey the GNU General Public 031 // License in all respects for all of the FRYSK code and other code 032 // used in conjunction with FRYSK except the Non-GPL Code covered by 033 // this exception. If you modify this file, you may extend this 034 // exception to your version of the file, but you are not obligated to 035 // do so. If you do not wish to provide this exception without 036 // modification, you must delete this exception statement from your 037 // version and license this file solely under the GPL without 038 // exception. 039 040 package frysk.hpd; 041 042 import frysk.config.Prefix; 043 044 /** 045 * This class tests the "load" command basics of both loading a correct 046 * executable and trying to load a non-existent executable. 047 */ 048 049 public class TestLoadCommand extends TestLib { 050 public void testLoadCommand() { 051 e = new HpdTestbed(); 052 e.send("load " + Prefix.pkgDataFile("test-exe-x86").getPath() 053 + "\n"); 054 e.expect("\\[0\\.0\\] Loaded executable file.*"); 055 e.send("quit\n"); 056 e.expect("Quitting\\.\\.\\."); 057 e.close(); 058 } 059 060 public void testLoadCommandError() { 061 e = new HpdTestbed(); 062 e.send("load " + Prefix.pkgDataFile("test-exe-x86").getPath() 063 + "foo\n"); 064 e.expect("Error: open: No such file or directory.*"); 065 } 066 067 public void testLoadStart() { 068 e = new HpdTestbed(); 069 e.sendCommandExpectPrompt("load " + Prefix.pkgLibFile("funit-hello").getPath(), 070 "\\[0\\.0\\] Loaded executable file.*"); 071 e.sendCommandExpectPrompt("focus", "Target set.*\\[0\\.0\\]\t\t0\t0.*"); 072 e.sendCommandExpectPrompt("load " + Prefix.pkgLibFile("funit-hello").getPath(), 073 "\\[1\\.0] Loaded executable file.*"); 074 e.sendCommandExpectPrompt("focus", "Target set.*\\[0\\.0\\]\t\t0\t0.*"+ 075 "\\[1\\.0\\]\t\t0*\\t0.*"); 076 e.sendCommandExpectPrompt("start", "Attached to process.*Attached to process.*"); 077 e.sendCommandExpectPrompt("focus", "Target set.*\\[0\\.0\\].*\\[1\\.0\\].*"); 078 e.send("quit\n"); 079 e.expect("Quitting\\.\\.\\."); 080 e.close(); 081 } 082 083 public void testLoadRunRun() { 084 e = new HpdTestbed(); 085 e.sendCommandExpectPrompt("load " + Prefix.pkgLibFile("funit-threads-looper").getPath(), 086 "\\[0\\.0\\] Loaded executable file.*"); 087 e.sendCommandExpectPrompt("load " + Prefix.pkgLibFile("funit-threads-looper").getPath(), 088 "\\[1\\.0\\] Loaded executable file.*"); 089 e.sendCommandExpectPrompt("start", "Attached to process.*Attached to process.*"); 090 e.send("quit\n"); 091 e.expect("Quitting\\.\\.\\."); 092 e.close(); 093 } 094 095 public void testLoadNoneLoaded() { 096 e = new HpdTestbed(); 097 e.sendCommandExpectPrompt("load", "No loaded procs currently.*"); 098 e.send("quit\n"); 099 e.expect("Quitting\\.\\.\\."); 100 e.close(); 101 } 102 103 public void testLoadDisplay() { 104 e = new HpdTestbed(); 105 e.sendCommandExpectPrompt("load " + Prefix.pkgLibFile("funit-threads-looper").getPath(), 106 "\\[0\\.0\\] Loaded executable file.*"); 107 e.sendCommandExpectPrompt("load " + Prefix.pkgLibFile("funit-hello").getPath(), 108 "\\[1\\.0\\] Loaded executable file.*"); 109 e.sendCommandExpectPrompt("load", "Loaded procs.*\\[0\\.0\\].*\\[1\\.0\\].*"); 110 e.send("quit\n"); 111 e.expect("Quitting\\.\\.\\."); 112 e.close(); 113 } 114 115 public void testLoadExeArg() { 116 e = new HpdTestbed(); 117 e.sendCommandExpectPrompt("load /bin/ls arg0 arg1", 118 "/bin/ls\r\n"); 119 e.sendCommandExpectPrompt("info args", "The args.*/bin/ls.*arg0.*arg1.*"); 120 e.sendCommandExpectPrompt("info exe", "/bin/ls\r\n"); 121 e.send("quit\n"); 122 e.expect("Quitting\\.\\.\\."); 123 e.close(); 124 } 125 126 public void testLoadPath() { 127 e = new HpdTestbed(); 128 e.sendCommandExpectPrompt("load ls", "/bin/ls\r\n"); 129 e.send("quit\n"); 130 e.expect("Quitting\\.\\.\\."); 131 e.close(); 132 } 133 }