Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

238 lines
4.2 KiB

  1. package srTest;
  2. #
  3. # Manual Rename regression test using BSHELL
  4. #
  5. use integer;
  6. use English;
  7. use FileHandle;
  8. #
  9. #package definitions
  10. #
  11. use Exporter;
  12. @ISA = qw(Exporter);
  13. @EXPORT = qw(SrRun);
  14. @EXPORT_OK = ();
  15. #
  16. # Foward declarations
  17. #
  18. sub crfile;
  19. #
  20. # Set default location to run test
  21. #
  22. use strict 'vars';
  23. my $srch = "";
  24. my $verbose = 0;
  25. my $loopCnt = 0;
  26. my $currentCmd = 1;
  27. use vars qw($cmd $intcmd);
  28. #
  29. # Execute the specified tests.
  30. # The tests are an array passed in as a parameter. They have the
  31. # Following syntax:
  32. #
  33. # Operator defintions:
  34. # nnn: Text describing command to execute (NNN can be searched for)
  35. # ! internal PERL commands to be executed silently
  36. # ... anything else is a command to bshell
  37. #
  38. sub SrRun
  39. {
  40. open BSHELL, "| bshell -s -b" or die "can't start bshell, status=$ERRNO\n";
  41. autoflush BSHELL 1;
  42. #
  43. # Command execution loop
  44. #
  45. do
  46. {
  47. foreach $cmd (@_)
  48. {
  49. chomp($cmd);
  50. #
  51. # If searching is enabled keep searching until we find the desired line
  52. #
  53. if ($srch ne "")
  54. {
  55. if ($cmd =~ /^([0-9]+):.*/)
  56. {
  57. if ($srch eq $1)
  58. {
  59. $srch = "";
  60. }
  61. elsif ($srch =~ /^[lL]/)
  62. {
  63. print "$cmd\n";
  64. next;
  65. }
  66. else
  67. {
  68. next;
  69. }
  70. }
  71. else
  72. {
  73. next;
  74. }
  75. }
  76. #
  77. # look for DISPLAY commands
  78. #
  79. if ($cmd =~ /^([0-9]+):.*/)
  80. {
  81. sleep 1;
  82. $currentCmd = $1;
  83. select undef, undef, undef, 0.25;
  84. print "\n\n$cmd\n";
  85. GetInput();
  86. if ($srch ne "")
  87. {
  88. last; #causes scan to start at TOP of list
  89. }
  90. }
  91. #
  92. # look for the enable SR command
  93. #
  94. elsif ($cmd =~ /^!enableSr (.*)/)
  95. {
  96. system ("srrpc.exe", "1", "$1");
  97. print "\n";
  98. }
  99. #
  100. # look for the disable SR command
  101. #
  102. elsif ($cmd =~ /^!disableSr (.*)/)
  103. {
  104. system ("srrpc.exe", "2", "$1");
  105. print "\n";
  106. }
  107. #
  108. # look for internal commands to execute
  109. #
  110. elsif ($cmd =~ /^!.*/)
  111. {
  112. $intcmd = substr($cmd,1);
  113. eval $intcmd;
  114. if ($verbose && $ERRNO != 0)
  115. {
  116. print "\"$intcmd\", status=$ERRNO\n";
  117. }
  118. }
  119. #
  120. # send the command to the BSHELL
  121. #
  122. else
  123. {
  124. print BSHELL $cmd, "\n";
  125. }
  126. }
  127. if (++$loopCnt > 1)
  128. {
  129. if ($srch =~ /^[lL]$/)
  130. {
  131. $srch = $currentCmd;
  132. }
  133. else
  134. {
  135. print "\nUnknown test: $srch\n";
  136. $srch = $currentCmd;
  137. }
  138. }
  139. } until ($srch eq "");
  140. close BSHELL or die "bad BSHELL, status=$ERRNO childStatus=$?\n";
  141. }
  142. #
  143. # Get the next input. If it is numeric then set that value into
  144. # srch. If not set SRCH to nothing
  145. #
  146. sub GetInput
  147. {
  148. for (;;)
  149. {
  150. $srch = <STDIN>;
  151. chomp($srch);
  152. if ($srch eq "")
  153. {
  154. last;
  155. }
  156. elsif ($srch =~ /^[0-9]+$/)
  157. {
  158. print "\nSearching...\n";
  159. last;
  160. }
  161. elsif ($srch =~ /^[lL]$/)
  162. {
  163. print "\nListing all commands...\n";
  164. last;
  165. }
  166. else
  167. {
  168. print "\nUnknown command \"$srch\"\n";
  169. }
  170. }
  171. if ($verbose && $srch ne "")
  172. {
  173. print "srch=\"$srch\"\n";
  174. }
  175. $loopCnt = 0;
  176. }
  177. #
  178. # simply create a file and closes it
  179. #
  180. sub crfile
  181. {
  182. open(hFile, ">$_[0]");
  183. close(hFile);
  184. }
  185. #
  186. # creates a file and writes some data to that file.
  187. #
  188. sub crdatafile
  189. {
  190. open(hFile, ">$_[0]");
  191. print hFile "Here is some data\n";
  192. close(hFile);
  193. }
  194. 1;