77use  File::Temp qw/  tempfile tempdir / 
88use  File::Basename;
99
10+ my  $coverity_project  = " hwloc" 
11+ #  Coverity changes this URL periodically
12+ my  $coverity_tool_url  = " https://scan.coverity.com/download/cxx/linux64" 
13+ 
1014my  $filename_arg ;
1115my  $coverity_token_arg ;
1216my  $dry_run_arg  = 0;
@@ -72,7 +76,7 @@ sub safe_system {
7276        #  that it can be removed upon exit.
7377        chdir (" /" 
7478        print  " Command $cmd  failed: exit status $rc \n " 
75-         if  (-f  $stdout_file ) {
79+         if  (defined ( $stdout_file ) &&  -f  $stdout_file ) {
7680            print  " Last command output:\n " 
7781            system (" cat $stdout_file " 
7882        }
@@ -86,17 +90,32 @@ sub safe_system {
8690
8791#  Make an area to work
8892
89- my  $dir  = tempdir(CLEANUP  =>  1 );
93+ my  $dir  = tempdir(CLEANUP  =>  0 );
9094chdir ($dir );
9195verbose " *** Working in $dir \n " 
9296
9397# #####################################################################
9498
9599#  Get the coverity tool, put it in our path
96100
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" 
101+ my  $cdir  = " $ENV {HOME}/coverity" 
102+ safe_system(0, " mkdir $cdir " 
103+     if  (! -d  $cdir );
104+ 
105+ #  Optimization: the tool is pretty large.  If our local copy is less
106+ #  than a day old, just use that without re-downloading.
107+ my  ($dev ,$ino ,$mode ,$nlink ,$uid ,$gid ,$rdev ,$size ,
108+     $atime ,$mtime ,$ctime ,$blksize ,$blocks ) =
109+     stat (" $cdir /coverity_tool.tgz" 
110+ my  $now  = time ();
111+ if  (!defined ($mtime ) || $mtime  < $now  - 24*60*60) {
112+     verbose " *** Downloading new copy of the coverity tool\n " 
113+     safe_system(0, " wget $coverity_tool_url  --post-data \" token=$coverity_token_arg &project=$coverity_project \"  -O coverity_tool.tgz" 
114+     safe_system(0, " cp coverity_tool.tgz $cdir " 
115+ }
116+ 
117+ verbose " *** Expanding coverity tool tarball\n " 
118+ safe_system(0, " tar xf $cdir /coverity_tool.tgz" 
100119opendir (my  $dh , " ." 
101120    die  " Can't opendir ." 
102121my  @files  = grep  { / ^cov/ -d  " ./$_ " readdir ($dh );
@@ -122,9 +141,6 @@ sub safe_system {
122141verbose " *** Building HWLOC tarball\n " 
123142safe_system(0, " cov-build --dir cov-int make $make_args " " cov-build" 
124143
125- verbose " *** Checking HWLOC tarball\n " 
126- safe_system(0, " cov-build --dir cov-int make check $make_args " " cov-build-check" 
127- 
128144#  Tar up the Coverity results
129145verbose " *** Tarring up results\n " 
130146safe_system(0, " tar jcf $hwloc_ver -analyzed.tar.bz2 cov-int" 
@@ -135,7 +151,7 @@ sub safe_system {
135151} else  {
136152    verbose " *** Submitting results\n " 
137153    safe_system(0, " curl --form token=$coverity_token_arg  " 
138-                 " --form email=jsquyres \@ cisco.com  " 
154+                 " --form email=brice.goglin \@ labri.fr  " 
139155                " --form file=\@ $hwloc_ver -analyzed.tar.bz2 " 
140156                " --form version=$hwloc_ver  " 
141157                " --form description=nightly-master " 
0 commit comments