// fake_dmidecode simulates the subset of `dmidecode -t ` output // the Vetting probes actually parse. Dispatches on the argument after // `-t` so the same binary serves both firmware (BIOS) and inventory // (memory / system / baseboard / power-supply) probes under test. Exits // 0 for every supported type; prints nothing for unknown types. package main import ( "fmt" "os" ) func main() { t := "" for i, a := range os.Args { if a == "-t" && i+1 < len(os.Args) { t = os.Args[i+1] break } } switch t { case "bios": fmt.Println(biosFixture) case "memory", "17": fmt.Println(memoryFixture) case "system": fmt.Println(systemFixture) case "baseboard": fmt.Println(baseboardFixture) case "39": fmt.Println(psuFixture) default: // No-op: tests expecting "no data" for an unknown -t value get // an empty body and exit 0 (matches dmidecode behavior). } } const biosFixture = `# dmidecode 3.3 Getting SMBIOS data from sysfs. SMBIOS 3.2.0 present. Handle 0x0000, DMI type 0, 26 bytes BIOS Information Vendor: American Megatrends Inc. Version: 3.2 Release Date: 07/15/2021 Address: 0xF0000 Runtime Size: 64 kB ROM Size: 32 MB Characteristics: PCI is supported BIOS is upgradeable` const memoryFixture = `# dmidecode 3.3 Getting SMBIOS data from sysfs. SMBIOS 3.2.0 present. Handle 0x0032, DMI type 17, 84 bytes Memory Device Array Handle: 0x0031 Total Width: 64 bits Data Width: 64 bits Size: 16 GB Form Factor: DIMM Set: None Locator: DIMM_A1 Bank Locator: BANK 0 Type: DDR4 Type Detail: Synchronous Speed: 3200 MT/s Manufacturer: Micron Serial Number: 12345678 Asset Tag: None Part Number: 8ATF2G64AZ-3G2E1 Rank: 2 Configured Memory Speed: 3200 MT/s Handle 0x0033, DMI type 17, 84 bytes Memory Device Array Handle: 0x0031 Total Width: Unknown Data Width: Unknown Size: No Module Installed Form Factor: DIMM Set: None Locator: DIMM_A2 Bank Locator: BANK 1 Type: Unknown Type Detail: Unknown Speed: Unknown Manufacturer: Not Specified Part Number: Not Specified Handle 0x0034, DMI type 17, 84 bytes Memory Device Array Handle: 0x0031 Total Width: 64 bits Data Width: 64 bits Size: 16 GB Form Factor: DIMM Locator: DIMM_B1 Bank Locator: BANK 2 Type: DDR4 Speed: 3200 MT/s Manufacturer: Micron Part Number: 8ATF2G64AZ-3G2E1 Configured Memory Speed: 3200 MT/s Handle 0x0035, DMI type 17, 84 bytes Memory Device Array Handle: 0x0031 Size: No Module Installed Locator: DIMM_B2 Bank Locator: BANK 3 Manufacturer: Not Specified Part Number: Not Specified` const systemFixture = `# dmidecode 3.3 Getting SMBIOS data from sysfs. SMBIOS 3.2.0 present. Handle 0x0001, DMI type 1, 27 bytes System Information Manufacturer: Beelink Product Name: Mini S12 Pro Version: Default string Serial Number: SN-MINI-001 UUID: 03000200-0400-0500-0006-000700080009 Wake-up Type: Power Switch SKU Number: Default string Family: Default string` const baseboardFixture = `# dmidecode 3.3 Getting SMBIOS data from sysfs. SMBIOS 3.2.0 present. Handle 0x0002, DMI type 2, 15 bytes Base Board Information Manufacturer: Beelink Product Name: AZW SEi Version: 1.0 Serial Number: BB-0001 Asset Tag: Default string` const psuFixture = `# dmidecode 3.3 Getting SMBIOS data from sysfs. SMBIOS 3.2.0 present. Handle 0x0040, DMI type 39, 22 bytes System Power Supply Power Unit Group: 1 Location: PSU1 Name: PWR SPLY,760W Manufacturer: DELTA Serial Number: ABC123 Asset Tag: 00000000 Model Part Number: ABC760 Revision: 1.0 Max Power Capacity: 760 W Status: Present, OK Type: Switching Handle 0x0041, DMI type 39, 22 bytes System Power Supply Power Unit Group: 1 Location: PSU2 Name: PWR SPLY,760W Manufacturer: DELTA Serial Number: XYZ789 Model Part Number: ABC760 Max Power Capacity: 760 W Status: Present, OK Type: Switching`