Or we do something like: -use lib '/global/path/to/HA/Simulator'; +BEGIN { + if ($INC[0] eq '..') { + splice(@INC, 1, 0, '/usr/share/pve-ha-simulator'); + } else { + unshift @INC, '/usr/share/pve-ha-simulator'; + } +}
???? > On January 12, 2017 at 3:51 PM Thomas Lamprecht <t.lampre...@proxmox.com> > wrote: > > > sim.pl suggested to be a perl script, but was a bash script which > called ../pve-ha-simulator > It set the include directory to '..' as its intended to use the > currently developed code, not the pve-ha-simulator installed on the > system. > This did not work correctly as pve-ha-simulator has a > use lib '/global/path/to/HA/Simulator' > directive. > > Create a small perl script which runs the RTHardware. > > Changes which differ from the pve-ha-simulator script include that we > fall back to the 'simtest' directory if none is given. > Also the 'batch' option does not exists here, use the ha-tester > script if you want this behavior. > > Signed-off-by: Thomas Lamprecht <t.lampre...@proxmox.com> > --- > > changes since v1: > * removed unnecessary use clauses > * whitespace cleanup > > src/test/sim.pl | 41 ++++++++++++++++++++++++++++++++++++----- > 1 file changed, 36 insertions(+), 5 deletions(-) > rewrite src/test/sim.pl (98%) > > diff --git a/src/test/sim.pl b/src/test/sim.pl > dissimilarity index 98% > index 933c5ba..e5a8491 100755 > --- a/src/test/sim.pl > +++ b/src/test/sim.pl > @@ -1,5 +1,36 @@ > -#!/bin/sh > - > -rm -rf simtest > -mkdir simtest > -perl -I .. ../pve-ha-simulator simtest > +#!/usr/bin/perl > + > +use strict; > +use warnings; > + > +use lib '..'; > + > +use File::Path qw(remove_tree); > + > +use PVE::HA::Sim::RTHardware; > + > +sub show_usage { > + print "usage: $0 [testdir]\n"; > + exit(-1); > +}; > + > +my $testdir = shift; > + > +if (!defined($testdir)) { > + $testdir = "simtest"; > + remove_tree($testdir); > + mkdir $testdir; > +} > + > +my $hardware = PVE::HA::Sim::RTHardware->new($testdir); > + > +$hardware->log('info', "starting simulation"); > + > +eval { $hardware->run(); }; > +if (my $err = $@) { > + $hardware->log('err', "exit simulation - $err "); > +} else { > + $hardware->log('info', "exit simulation - done"); > +} > + > +exit(0); > -- > 2.1.4 > > > _______________________________________________ > pve-devel mailing list > pve-devel@pve.proxmox.com > http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel