Update NEWS
[ACE_TAO.git] / ACE / bin / PerlACE / TestTarget_WinCE.pm
blobb4144b9c3444587888df9a8e52ef28efa7e7c042
1 #!/usr/bin/env perl
2 package PerlACE::TestTarget_WinCE;
4 # ******************************************************************
5 # Description : Creates a PerlACE::WinCE
6 # Author : Johnny Willemsen
7 # Create Date : 29/20/2008
8 # ******************************************************************
10 # ******************************************************************
11 # Pragma Section
12 # ******************************************************************
14 use strict;
16 use PerlACE::TestTarget;
17 use PerlACE::ProcessVX;
18 use File::Copy;
19 use Cwd;
20 use English;
22 our @ISA = qw(PerlACE::TestTarget);
24 sub new
26 my $proto = shift;
27 my $config_name = shift;
28 my $class = ref ($proto) || $proto;
29 my $self = {};
30 bless ($self, $class);
31 $self->GetConfigSettings($config_name);
32 my $targethost;
33 my $env_name = $config_name.'_IPNAME';
34 if (exists $ENV{$env_name}) {
35 $targethost = $ENV{$env_name};
37 else {
38 print STDERR "You must define target hostname/IP with $env_name\n";
39 undef $self;
40 return undef;
43 $env_name = $config_name.'_FS_ROOT';
44 my $fsroot = '\network\temp\ACE\wince6';
45 if (exists $ENV{$env_name}) {
46 $fsroot = $ENV{$env_name};
48 else {
49 print STDERR "Warning: no $env_name variable; falling back ",
50 "to $fsroot\n";
52 $self->{FSROOT} = $fsroot;
54 $self->{REBOOT_CMD} = $ENV{'ACE_REBOOT_LVRT_CMD'};
55 if (!defined $self->{REBOOT_CMD}) {
56 $self->{REBOOT_CMD} = 'I_Need_A_Reboot_Command';
58 $self->{REBOOT_TIME} = $ENV{'ACE_LVRT_REBOOT_TIME'};
59 if (!defined $self->{REBOOT_TIME}) {
60 $self->{REBOOT_TIME} = 200;
63 $self->{REBOOT_TIME} = $ENV{'ACE_RUN_LVRT_REBOOT_TIME'};
64 if (!defined $self->{REBOOT_TIME}) {
65 $self->{REBOOT_TIME} = 200;
67 $self->{REBOOT_NEEDED} = undef;
69 my $telnet_port = $ENV{'ACE_RUN_VX_TGT_TELNET_PORT'};
70 my $telnet_host = $ENV{'ACE_RUN_VX_TGT_TELNET_HOST'};
71 if (!defined $telnet_host) {
72 $telnet_host = $ENV{'ACE_RUN_VX_TGTHOST'};
74 if (!defined $telnet_port) {
75 $telnet_port = 23;
77 if (!defined $self->{HOST_ROOT}) {
78 $self->{HOST_ROOT} = $self->{FSROOT};
81 $PerlACE::ProcessVX::ExeExt = '.exe';
83 return $self;
86 # ******************************************************************
87 # Subroutine Section
88 # ******************************************************************
90 sub LocalFile {
91 my $self = shift;
92 my $file = shift;
93 my $cwdrel = $file;
94 my $prjroot = defined $ENV{'ACE_RUN_VX_PRJ_ROOT'} ? $ENV{'ACE_RUN_VX_PRJ_ROOT'} : $ENV{'ACE_ROOT'};
95 if (length ($cwdrel) > 0) {
96 $cwdrel = File::Spec->abs2rel( cwd(), $prjroot );
98 else {
99 $cwdrel = File::Spec->abs2rel( $cwdrel, $prjroot );
101 my $newfile = $self->{FSROOT} . "/" . $cwdrel . "/" . $file;
102 if (defined $ENV{'ACE_TEST_VERBOSE'}) {
103 print STDERR "WinCE LocalFile for $file is $newfile\n";
105 return $newfile;
108 sub AddLibPath ($)
110 my $self = shift;
111 my $dir = shift;
112 if (defined $ENV{'ACE_TEST_VERBOSE'}) {
113 print STDERR "Adding libpath $dir\n";
115 PerlACE::add_lib_path ($dir);
118 sub CreateProcess
120 my $self = shift;
121 if ($OSNAME eq "MSWin32") {
122 my $process = new PerlACE::ProcessVX ($self, @_); return $process;
123 } else {
124 my $process = new PerlACE::ProcessVX (@_, $self); return $process;
128 # Need a reboot when this target is destroyed.
129 sub NeedReboot ($)
131 my $self = shift;
132 $self->{REBOOT_NEEDED} = 1;
135 # Reboot target
136 sub RebootNow ($)
138 my $self = shift;
139 $self->{REBOOT_NEEDED} = undef;
140 print STDERR "Attempting to reboot target...\n";
141 reboot ();
144 sub WaitForFileTimed ($)
146 my $self = shift;
147 my $file = shift;
148 my $timeout = shift;
149 my $cwdrel = $file;
150 my $prjroot = defined $ENV{'ACE_RUN_VX_PRJ_ROOT'} ? $ENV{'ACE_RUN_VX_PRJ_ROOT'} : $ENV{'ACE_ROOT'};
151 if (length ($cwdrel) > 0) {
152 $cwdrel = File::Spec->abs2rel( cwd(), $prjroot );
154 else {
155 $cwdrel = File::Spec->abs2rel( $cwdrel, $prjroot );
157 my $newfile = $self->{HOST_ROOT} . "/" . $cwdrel . "/" . $file;
158 if (defined $ENV{'ACE_TEST_VERBOSE'}) {
159 print STDERR "WinCE waits for $newfile timeout $timeout\n";
161 return PerlACE::waitforfile_timed ($newfile, $timeout);
164 # Put file from a to b
165 sub PutFile ($)
167 my $self = shift;
168 my $src = shift;
169 return 0;
172 sub DeleteFile ($)
174 my $self = shift;
175 my $file = shift;
176 my $newfile = $self->LocalFile($file);
177 if (defined $ENV{'ACE_TEST_VERBOSE'}) {
178 print STDERR "delete $newfile\n";
180 unlink ("$newfile");
183 sub KillAll ($)
185 my $self = shift;
186 my $procmask = shift;
187 PerlACE::ProcessVX::kill_all ($procmask, $self);