Add GPU recognition test (#19)

This commit is contained in:
ilyazzz 2021-03-07 21:17:55 +02:00 committed by GitHub
parent d38f1588d0
commit 884abbdaa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 2 deletions

View File

@ -19,8 +19,6 @@ jobs:
run: sudo apt update
- name: Install dependencies
run: sudo apt install libgtk-3-dev libvulkan-dev
- name: Update pci.ids
run: sudo sh -c "curl https://pci-ids.ucw.cz/v2.2/pci.ids > /usr/share/misc/pci.ids"
- name: Build
run: cargo build
- name: Run tests

View File

@ -472,3 +472,36 @@ pub enum DaemonError {
HWMonError,
ControllerError,
}
#[cfg(test)]
mod tests {
use super::*;
fn init() {
let _ = env_logger::builder().is_test(true).try_init();
}
#[test]
fn recognize_polaris() {
init();
let db = Daemon::get_pci_db_online().unwrap();
let vendor_data = db.get_by_ids("1002", "67df", "1da2", "e387").unwrap();
assert_eq!(
vendor_data.gpu_vendor,
Some("Advanced Micro Devices, Inc. [AMD/ATI]".to_string())
);
assert_eq!(
vendor_data.gpu_model,
Some("Ellesmere [Radeon RX 470/480/570/570X/580/580X/590]".to_string())
);
assert_eq!(
vendor_data.card_model,
Some("Radeon RX 580 Pulse 4GB".to_string())
);
}
}