Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
can-latester
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
canbus
can-benchmark
can-latester
Commits
2d781596
Commit
2d781596
authored
10 years ago
by
Michal Sojka
Browse files
Options
Downloads
Patches
Plain Diff
Simplify run.pl
parent
1df7ce4d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
continuous/gw-setup/run.pl
+14
-44
14 additions, 44 deletions
continuous/gw-setup/run.pl
with
14 additions
and
44 deletions
continuous/gw-setup/run.pl
+
14
−
44
View file @
2d781596
#!/usr/bin/perl -w
use
FindBin
;
use
Expect
;
# Create startup script in ramdisk
my
$S99
=
"
$FindBin
::Bin/initramfs/etc/init.d/S99benchmark
";
system
("
rm -f
$S99
");
system
("
cat >
$S99
; chmod +x
$S99
")
unless
-
t
STDIN
;
# Boot gateway
my
$boot
;
my
$pid
=
&run_boot
;
$|
=
1
;
my
$ready
;
while
(
<
$boot
>
){
last
if
(
$ready
=
m/Welcome to Buildroot/
||
m/UGW started/
||
m/t...a...s...k...s... ...s...t...a...r...t...e...d/
);
# RTEMS has bug - it sends 4 characters instead of just one
}
die
"
Boot failed
"
unless
$ready
;
# Boot the gateway
# die("No boot command") if ($#ARGV eq -1);
my
$bootcmd
=
scalar
@ARGV
?
"
'
"
.
join
("
' '
",
@ARGV
)
.
"
'
"
:
"
$FindBin
::Bin/boot
";
$exp
=
Expect
->
spawn
(
$bootcmd
);
$exp
->
expect
(
120
,
'
Welcome to Buildroot
',
'
UGW started
',
'
-re
',
'
t...a...s...k...s... ...s...t...a...r...t...e...d
')
# RTEMS has bug - it sends 4 characters instead of just one
or
die
"
Cannot spawn
$bootcmd
: $!
";
# Measure latencies
my
$latester
=
<<'EOF';
set -x
rm -f tmp-stat.txt
echo "Starting latester"
sudo i
p l set eth0 down
sudo i
fdown eth0
sudo ~/bin/latester -d can0 -d can1 -d can2 -c 3200 -q --oneattime -n tmp
r=$?
sudo i
p l set
eth0
up
sudo i
fup
eth0
set -e
source tmp-stat.txt
for i in sent lost enobufs $(seq -f percentile%g 0 10 100); do keyval="$keyval $i=$((i))"; done
...
...
@@ -37,34 +36,5 @@ exit $r
EOF
my
$status
=
system
((
qw(ssh -T glab)
,
$latester
));
kill
('
TERM
',
-
$pid
);
$exp
->
soft_close
(
);
exit
(
$status
>>
8
);
# Helper functions
sub
kill_boot
()
{
kill
('
TERM
',
-
$pid
)
if
defined
$pid
;
}
sub
run_boot
()
{
# die("No boot command") if ($#ARGV eq -1);
my
$bootcmd
=
scalar
@ARGV
?
"
'
"
.
join
("
' '
",
@ARGV
)
.
"
'
"
:
"
$FindBin
::Bin/boot
";
$SIG
{
INT
}
=
sub
{
kill_boot
();
exit
;
};
$SIG
{
HUP
}
=
sub
{
kill_boot
();
exit
;
};
$SIG
{
ALRM
}
=
sub
{
kill_boot
();
exit
;
};
$SIG
{
TERM
}
=
sub
{
kill_boot
();
exit
;
};
$SIG
{
QUIT
}
=
sub
{
kill_boot
();
exit
;
};
pipe
(
$boot
,
$wh
)
||
die
("
pipe: $!
");
my
$pid
=
fork
()
//
die
("
fork: $!
");
if
(
$pid
==
0
)
{
setpgrp
();
# Start new process group so that we can kill all
# background processes at once
close
(
$boot
);
open
(
STDERR
,
"
>&
",
$wh
)
||
die
"
Can't dup STDERR: $!
";
my
$cmd
=
"
$bootcmd
2>&1 | tee /dev/stderr
";
exec
(
$cmd
)
||
die
"
Can't exec
$cmd
: $!
";
}
close
(
$wh
);
return
$pid
;
}
END
{
kill_boot
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment