Skip to content

Commit 375f04b

Browse files
author
Ralph Castain
committed
Update the nightly builds to submit to coverity
1 parent dfbf2b7 commit 375f04b

File tree

4 files changed

+173
-22
lines changed

4 files changed

+173
-22
lines changed
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
#!/usr/bin/env perl
2+
3+
use warnings;
4+
use strict;
5+
6+
use Getopt::Long;
7+
use File::Temp qw/ tempfile tempdir /;
8+
use File::Basename;
9+
10+
my $filename_arg;
11+
my $coverity_token_arg;
12+
my $dry_run_arg = 0;
13+
my $verbose_arg = 0;
14+
my $debug_arg = 0;
15+
my $logfile_dir_arg;
16+
my $configure_args = "";
17+
my $make_args = "-j 32";
18+
my $help_arg = 0;
19+
20+
&Getopt::Long::Configure("bundling");
21+
my $ok = Getopt::Long::GetOptions("filename=s" => \$filename_arg,
22+
"coverity-token=s" => \$coverity_token_arg,
23+
"logfile-dir=s" => \$logfile_dir_arg,
24+
"configure-args=s" => \$configure_args,
25+
"make-args=s" => \$make_args,
26+
"dry-run!" => \$dry_run_arg,
27+
"verbose!" => \$verbose_arg,
28+
"debug!" => \$debug_arg,
29+
"help|h" => \$help_arg);
30+
31+
$ok = 0
32+
if (!defined($filename_arg));
33+
$ok = 0
34+
if (!defined($coverity_token_arg));
35+
if (!$ok || $help_arg) {
36+
print "Usage: $0 --filename=FILENAME --coverity-token=TOKEN [--dry-run] [--verbose] [--help]\n";
37+
exit($ok);
38+
}
39+
40+
die "Cannot read $filename_arg"
41+
if (! -r $filename_arg);
42+
43+
$verbose_arg = 1
44+
if ($debug_arg);
45+
46+
######################################################################
47+
48+
sub verbose {
49+
print @_
50+
if ($verbose_arg);
51+
}
52+
53+
# run a command and save the stdout / stderr
54+
sub safe_system {
55+
my $allowed_to_fail = shift;
56+
my $cmd = shift;
57+
my $stdout_file = shift;
58+
59+
# Redirect stdout if requested or not verbose
60+
if (defined($stdout_file)) {
61+
$stdout_file = "$logfile_dir_arg/$stdout_file";
62+
unlink($stdout_file);
63+
$cmd .= " >$stdout_file";
64+
} elsif (!$debug_arg) {
65+
$cmd .= " >/dev/null";
66+
}
67+
$cmd .= " 2>&1";
68+
69+
my $rc = system($cmd);
70+
if (0 != $rc && !$allowed_to_fail) {
71+
# If we die/fail, ensure to change out of the temp tree so
72+
# that it can be removed upon exit.
73+
chdir("/");
74+
print "Command $cmd failed: exit status $rc\n";
75+
if (-f $stdout_file) {
76+
print "Last command output:\n";
77+
system("cat $stdout_file");
78+
}
79+
die "Cannot continue";
80+
}
81+
system("cat $stdout_file")
82+
if ($debug_arg && defined($stdout_file) && -f $stdout_file);
83+
}
84+
85+
######################################################################
86+
87+
# Make an area to work
88+
89+
my $dir = tempdir(CLEANUP => 1);
90+
chdir($dir);
91+
verbose "*** Working in $dir\n";
92+
93+
######################################################################
94+
95+
# Get the coverity tool, put it in our path
96+
97+
verbose "*** Downloading coverity tool\n";
98+
safe_system(0, "wget https://scan.coverity.com/download/linux-64 --post-data \"token=$coverity_token_arg\&project=hwloc\" -O coverity_tool.tgz");
99+
safe_system(0, "tar xf coverity_tool.tgz");
100+
opendir(my $dh, ".") ||
101+
die "Can't opendir .";
102+
my @files = grep { /^cov/ && -d "./$_" } readdir($dh);
103+
closedir($dh);
104+
105+
my $cov_dir = "$dir/$files[0]/bin";
106+
$ENV{PATH} = "$cov_dir:$ENV{PATH}";
107+
108+
######################################################################
109+
110+
# Expand the HWLOC tarball, build it
111+
112+
verbose "*** Extracting HWLOC tarball\n";
113+
safe_system(0, "tar xf $filename_arg");
114+
my $tarball_filename = basename($filename_arg);
115+
$tarball_filename =~ m/^hwloc-(.+)\.tar.+$/;
116+
my $hwloc_ver = $1;
117+
chdir("hwloc-$hwloc_ver");
118+
119+
verbose "*** Configuring HWLOC tarball\n";
120+
safe_system(0, "./configure $configure_args", "configure");
121+
122+
verbose "*** Building HWLOC tarball\n";
123+
safe_system(0, "cov-build --dir cov-int make $make_args", "cov-build");
124+
125+
verbose "*** Checking HWLOC tarball\n";
126+
safe_system(0, "cov-build --dir cov-int make check $make_args", "cov-build-check");
127+
128+
# Tar up the Coverity results
129+
verbose "*** Tarring up results\n";
130+
safe_system(0, "tar jcf $hwloc_ver-analyzed.tar.bz2 cov-int");
131+
132+
# If not dry-run, submit to Coverity
133+
if ($dry_run_arg) {
134+
verbose "*** Would have submitted, but this is a dry run\n";
135+
} else {
136+
verbose "*** Submitting results\n";
137+
safe_system(0, "curl --form token=$coverity_token_arg " .
138+
"--form email=jsquyres\@cisco.com " .
139+
"--form file=\@$hwloc_ver-analyzed.tar.bz2 " .
140+
"--form version=$hwloc_ver " .
141+
"--form description=nightly-master " .
142+
"https://scan.coverity.com/builds?project=hwloc",
143+
"coverity-submit");
144+
}
145+
146+
verbose("*** All done\n");
147+
148+
# Chdir out of the tempdir so that it can be removed
149+
chdir("/");
150+
151+
exit(0);

contrib/build-server/hwloc-nightly-tarball.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ outputroot=$HOME/hwloc/nightly
2121
script_uri=contrib/nightly/make_snapshot_tarball
2222

2323
# helper scripts dir
24-
script_dir=$HOME/scripts
24+
script_dir=$HOME/ompi/contrib/build-server
2525

2626
# The tarballs to make
2727
if [ $# -eq 0 ] ; then
@@ -130,12 +130,12 @@ done
130130

131131
# If we had any new snapshots to send to coverity, process them now
132132

133-
#for tarball in `cat $pending_coverity`; do
134-
# /home/common/mpiteam/scripts/hwloc-nightly-coverity.pl \
135-
# --filename=$tarball \
136-
# --coverity-token=$coverity_token \
137-
# --verbose \
138-
# --logfile-dir=$HOME/coverity \
139-
# --make-args="-j8"
140-
#done
133+
for tarball in `cat $pending_coverity`; do
134+
${script_dir}/hwloc-nightly-coverity.pl \
135+
--filename=$tarball \
136+
--coverity-token=$coverity_token \
137+
--verbose \
138+
--logfile-dir=$HOME/coverity \
139+
--make-args="-j8"
140+
done
141141
rm -f $pending_coverity

contrib/build-server/openmpi-nightly-tarball.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ outputroot=$HOME/openmpi/nightly
2424
script_uri=contrib/nightly/create_tarball.sh
2525

2626
# helper scripts dir
27-
script_dir=$HOME/scripts
27+
script_dir=$HOME/ompi/contrib/build-server
2828

2929
# The tarballs to make
3030
if [ $# -eq 0 ] ; then
@@ -144,7 +144,7 @@ done
144144

145145
for tarball in `cat $pending_coverity`; do
146146
echo "=== Submitting $tarball to Coverity..."
147-
$HOME/scripts/openmpi-nightly-coverity.pl \
147+
${script_dir}/openmpi-nightly-coverity.pl \
148148
--filename=$tarball \
149149
--coverity-token=$coverity_token \
150150
--verbose \

contrib/build-server/pmix-nightly-tarball.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ outputroot=$HOME/pmix/nightly
2323
script_uri=contrib/nightly/create_tarball.sh
2424

2525
# helper scripts dir
26-
script_dir=$HOME/scripts
26+
script_dir=$HOME/ompi/contrib/build-server
2727

2828
# The tarballs to make
2929
if [ $# -eq 0 ] ; then
@@ -139,14 +139,14 @@ done
139139

140140
# If we had any new snapshots to send to coverity, process them now
141141

142-
#for tarball in `cat $pending_coverity`; do
143-
# echo "=== Submitting $tarball to Coverity..."
144-
# /home/common/mpiteam/scripts/pmix-nightly-coverity.pl \
145-
# --filename=$tarball \
146-
# --coverity-token=$coverity_token \
147-
# --verbose \
148-
# --logfile-dir=$HOME/coverity \
149-
# --make-args=-j8 \
150-
# --configure-args="$coverity_configure_args"
151-
#done
142+
for tarball in `cat $pending_coverity`; do
143+
echo "=== Submitting $tarball to Coverity..."
144+
${script_dir}/pmix-nightly-coverity.pl \
145+
--filename=$tarball \
146+
--coverity-token=$coverity_token \
147+
--verbose \
148+
--logfile-dir=$HOME/coverity \
149+
--make-args=-j8 \
150+
--configure-args="$coverity_configure_args"
151+
done
152152
rm -f $pending_coverity

0 commit comments

Comments
 (0)