@@ -2,29 +2,40 @@ use crate::cli::run::helpers::download_file;
22use crate :: executor:: helpers:: apt;
33use crate :: executor:: { ToolInstallStatus , ToolStatus } ;
44use crate :: prelude:: * ;
5- use crate :: system:: { Os , SupportedLinuxDistro , SystemInfo } ;
5+ use crate :: system:: { LinuxDistribution , SupportedOs , SystemInfo } ;
66use crate :: {
77 VALGRIND_CODSPEED_DEB_VERSION , VALGRIND_CODSPEED_VERSION , VALGRIND_CODSPEED_VERSION_STRING ,
88} ;
99use semver:: Version ;
1010use std:: { env, path:: Path , process:: Command } ;
1111use url:: Url ;
1212
13- fn get_codspeed_valgrind_filename ( system_info : & SystemInfo ) -> Result < String > {
14- let Os :: SupportedLinux { distro, version } = & system_info. os else {
13+ pub ( super ) fn get_codspeed_valgrind_filename ( system_info : & SystemInfo ) -> Result < String > {
14+ let SupportedOs :: Linux ( distro) = & system_info. os else {
1515 bail ! ( "Unsupported system" ) ;
1616 } ;
1717
18- let ( deb_ubuntu_version, architecture) =
19- match ( distro, version. as_str ( ) , system_info. arch . as_str ( ) ) {
20- ( SupportedLinuxDistro :: Ubuntu , "22.04" , "x86_64" )
21- | ( SupportedLinuxDistro :: Debian , "12" , "x86_64" ) => ( "22.04" , "amd64" ) ,
22- ( SupportedLinuxDistro :: Ubuntu , "24.04" , "x86_64" ) => ( "24.04" , "amd64" ) ,
23- ( SupportedLinuxDistro :: Ubuntu , "22.04" , "aarch64" )
24- | ( SupportedLinuxDistro :: Debian , "12" , "aarch64" ) => ( "22.04" , "arm64" ) ,
25- ( SupportedLinuxDistro :: Ubuntu , "24.04" , "aarch64" ) => ( "24.04" , "arm64" ) ,
26- _ => bail ! ( "Unsupported system" ) ,
27- } ;
18+ let ( deb_ubuntu_version, architecture) = match ( distro, system_info. arch . as_str ( ) ) {
19+ ( LinuxDistribution :: Ubuntu { version } , "x86_64" )
20+ | ( LinuxDistribution :: Debian { version } , "x86_64" )
21+ if version == "22.04" || version == "12" =>
22+ {
23+ ( "22.04" , "amd64" )
24+ }
25+ ( LinuxDistribution :: Ubuntu { version } , "x86_64" ) if version == "24.04" => {
26+ ( "24.04" , "amd64" )
27+ }
28+ ( LinuxDistribution :: Ubuntu { version } , "aarch64" )
29+ | ( LinuxDistribution :: Debian { version } , "aarch64" )
30+ if version == "22.04" || version == "12" =>
31+ {
32+ ( "22.04" , "arm64" )
33+ }
34+ ( LinuxDistribution :: Ubuntu { version } , "aarch64" ) if version == "24.04" => {
35+ ( "24.04" , "arm64" )
36+ }
37+ _ => bail ! ( "Unsupported system" ) ,
38+ } ;
2839
2940 Ok ( format ! (
3041 "valgrind_{}_ubuntu-{}_{}.deb" ,
@@ -178,7 +189,9 @@ mod tests {
178189 #[ test]
179190 fn test_system_info_to_codspeed_valgrind_version_ubuntu ( ) {
180191 let system_info = SystemInfo {
181- os : Os :: from_id ( "ubuntu" , "22.04" ) ,
192+ os : SupportedOs :: Linux ( LinuxDistribution :: Ubuntu {
193+ version : "22.04" . into ( ) ,
194+ } ) ,
182195 arch : "x86_64" . to_string ( ) ,
183196 ..SystemInfo :: test ( )
184197 } ;
@@ -191,7 +204,9 @@ mod tests {
191204 #[ test]
192205 fn test_system_info_to_codspeed_valgrind_version_ubuntu_24 ( ) {
193206 let system_info = SystemInfo {
194- os : Os :: from_id ( "ubuntu" , "24.04" ) ,
207+ os : SupportedOs :: Linux ( LinuxDistribution :: Ubuntu {
208+ version : "24.04" . into ( ) ,
209+ } ) ,
195210 arch : "x86_64" . to_string ( ) ,
196211 ..SystemInfo :: test ( )
197212 } ;
@@ -204,7 +219,9 @@ mod tests {
204219 #[ test]
205220 fn test_system_info_to_codspeed_valgrind_version_debian ( ) {
206221 let system_info = SystemInfo {
207- os : Os :: from_id ( "debian" , "12" ) ,
222+ os : SupportedOs :: Linux ( LinuxDistribution :: Debian {
223+ version : "12" . into ( ) ,
224+ } ) ,
208225 arch : "x86_64" . to_string ( ) ,
209226 ..SystemInfo :: test ( )
210227 } ;
@@ -217,7 +234,9 @@ mod tests {
217234 #[ test]
218235 fn test_system_info_to_codspeed_valgrind_version_ubuntu_arm ( ) {
219236 let system_info = SystemInfo {
220- os : Os :: from_id ( "ubuntu" , "22.04" ) ,
237+ os : SupportedOs :: Linux ( LinuxDistribution :: Ubuntu {
238+ version : "22.04" . into ( ) ,
239+ } ) ,
221240 arch : "aarch64" . to_string ( ) ,
222241 ..SystemInfo :: test ( )
223242 } ;
@@ -227,6 +246,28 @@ mod tests {
227246 ) ;
228247 }
229248
249+ #[ test]
250+ fn test_codspeed_valgrind_filename_unsupported_os ( ) {
251+ let system_info = SystemInfo {
252+ os : SupportedOs :: Macos {
253+ version : "14.0" . into ( ) ,
254+ } ,
255+ ..SystemInfo :: test ( )
256+ } ;
257+ assert ! ( get_codspeed_valgrind_filename( & system_info) . is_err( ) ) ;
258+ }
259+
260+ #[ test]
261+ fn test_codspeed_valgrind_filename_unsupported_distro ( ) {
262+ let system_info = SystemInfo {
263+ os : SupportedOs :: Linux ( LinuxDistribution :: Ubuntu {
264+ version : "20.04" . into ( ) ,
265+ } ) ,
266+ ..SystemInfo :: test ( )
267+ } ;
268+ assert ! ( get_codspeed_valgrind_filename( & system_info) . is_err( ) ) ;
269+ }
270+
230271 #[ test]
231272 fn test_parse_valgrind_codspeed_version_with_prefix ( ) {
232273 let version = parse_valgrind_codspeed_version ( "valgrind-3.25.1.codspeed" ) . unwrap ( ) ;
0 commit comments