@@ -2,7 +2,7 @@ use crate::cli::run::helpers::download_file;
22use crate :: executor:: helpers:: apt;
33use crate :: executor:: { ToolInstallStatus , ToolStatus } ;
44use crate :: prelude:: * ;
5- use crate :: system:: SystemInfo ;
5+ use crate :: system:: { Os , SupportedLinuxDistro , SystemInfo } ;
66use crate :: {
77 VALGRIND_CODSPEED_DEB_VERSION , VALGRIND_CODSPEED_VERSION , VALGRIND_CODSPEED_VERSION_STRING ,
88} ;
@@ -11,22 +11,25 @@ use std::{env, path::Path, process::Command};
1111use url:: Url ;
1212
1313fn get_codspeed_valgrind_filename ( system_info : & SystemInfo ) -> Result < String > {
14- let ( version, architecture) = match (
15- system_info. os . as_str ( ) ,
16- system_info. os_version . as_str ( ) ,
17- system_info. arch . as_str ( ) ,
18- ) {
19- ( "ubuntu" , "22.04" , "x86_64" ) | ( "debian" , "12" , "x86_64" ) => ( "22.04" , "amd64" ) ,
20- ( "ubuntu" , "24.04" , "x86_64" ) => ( "24.04" , "amd64" ) ,
21- ( "ubuntu" , "22.04" , "aarch64" ) | ( "debian" , "12" , "aarch64" ) => ( "22.04" , "arm64" ) ,
22- ( "ubuntu" , "24.04" , "aarch64" ) => ( "24.04" , "arm64" ) ,
23- _ => bail ! ( "Unsupported system" ) ,
14+ let Os :: SupportedLinux { distro, version } = & system_info. os else {
15+ bail ! ( "Unsupported system" ) ;
2416 } ;
2517
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+ } ;
28+
2629 Ok ( format ! (
2730 "valgrind_{}_ubuntu-{}_{}.deb" ,
2831 VALGRIND_CODSPEED_DEB_VERSION . as_str( ) ,
29- version ,
32+ deb_ubuntu_version ,
3033 architecture
3134 ) )
3235}
@@ -175,8 +178,7 @@ mod tests {
175178 #[ test]
176179 fn test_system_info_to_codspeed_valgrind_version_ubuntu ( ) {
177180 let system_info = SystemInfo {
178- os : "ubuntu" . to_string ( ) ,
179- os_version : "22.04" . to_string ( ) ,
181+ os : Os :: from_id ( "ubuntu" , "22.04" ) ,
180182 arch : "x86_64" . to_string ( ) ,
181183 ..SystemInfo :: test ( )
182184 } ;
@@ -189,8 +191,7 @@ mod tests {
189191 #[ test]
190192 fn test_system_info_to_codspeed_valgrind_version_ubuntu_24 ( ) {
191193 let system_info = SystemInfo {
192- os : "ubuntu" . to_string ( ) ,
193- os_version : "24.04" . to_string ( ) ,
194+ os : Os :: from_id ( "ubuntu" , "24.04" ) ,
194195 arch : "x86_64" . to_string ( ) ,
195196 ..SystemInfo :: test ( )
196197 } ;
@@ -203,8 +204,7 @@ mod tests {
203204 #[ test]
204205 fn test_system_info_to_codspeed_valgrind_version_debian ( ) {
205206 let system_info = SystemInfo {
206- os : "debian" . to_string ( ) ,
207- os_version : "12" . to_string ( ) ,
207+ os : Os :: from_id ( "debian" , "12" ) ,
208208 arch : "x86_64" . to_string ( ) ,
209209 ..SystemInfo :: test ( )
210210 } ;
@@ -217,8 +217,7 @@ mod tests {
217217 #[ test]
218218 fn test_system_info_to_codspeed_valgrind_version_ubuntu_arm ( ) {
219219 let system_info = SystemInfo {
220- os : "ubuntu" . to_string ( ) ,
221- os_version : "22.04" . to_string ( ) ,
220+ os : Os :: from_id ( "ubuntu" , "22.04" ) ,
222221 arch : "aarch64" . to_string ( ) ,
223222 ..SystemInfo :: test ( )
224223 } ;
0 commit comments