diff --git a/internal/collector/sysinfo/hardware/export_windows_test.go b/internal/collector/sysinfo/hardware/export_windows_test.go new file mode 100644 index 0000000..7b66661 --- /dev/null +++ b/internal/collector/sysinfo/hardware/export_windows_test.go @@ -0,0 +1,49 @@ +package hardware + +func WithProductInfo(cmd []string) Options { + return func(o *options) { + o.productCmd = cmd + } +} + +func WithCPUInfo(cmd []string) Options { + return func(o *options) { + o.cpuCmd = cmd + } +} + +func WithGPUInfo(cmd []string) Options { + return func(o *options) { + o.gpuCmd = cmd + } +} + +func WithMemoryInfo(cmd []string) Options { + return func(o *options) { + o.memoryCmd = cmd + } +} + +func WithDiskInfo(cmd []string) Options { + return func(o *options) { + o.diskCmd = cmd + } +} + +func WithPartitionInfo(cmd []string) Options { + return func(o *options) { + o.partitionCmd = cmd + } +} + +func WithScreenInfo(cmd []string) Options { + return func(o *options) { + o.screenCmd = cmd + } +} + +func WithArch(arch string) Options { + return func(o *options) { + o.arch = arch + } +} diff --git a/internal/collector/sysinfo/hardware/hardware.go b/internal/collector/sysinfo/hardware/hardware.go index 97af543..48c7c06 100644 --- a/internal/collector/sysinfo/hardware/hardware.go +++ b/internal/collector/sysinfo/hardware/hardware.go @@ -12,10 +12,10 @@ type Info struct { Screens []screen } -type product map[string]string -type cpu map[string]string -type gpu map[string]string -type memory map[string]int +type product = map[string]string +type cpu = map[string]string +type gpu = map[string]string +type memory = map[string]int // DiskInfo contains information of a disk or partition. type disk struct { diff --git a/internal/collector/sysinfo/hardware/hardware_windows.go b/internal/collector/sysinfo/hardware/hardware_windows.go index 632a799..91478b3 100644 --- a/internal/collector/sysinfo/hardware/hardware_windows.go +++ b/internal/collector/sysinfo/hardware/hardware_windows.go @@ -1,35 +1,337 @@ package hardware -import "log/slog" +import ( + "context" + "fmt" + "log/slog" + "regexp" + "runtime" + "strconv" + "strings" + "time" + + "github.com/ubuntu/ubuntu-insights/internal/cmdutils" +) type options struct { + productCmd []string + cpuCmd []string + gpuCmd []string + memoryCmd []string + + diskCmd []string + partitionCmd []string + + screenCmd []string + + arch string + log *slog.Logger } +// defaultOptions returns options for when running under a normal environment. func defaultOptions() *options { - return &options{} + return &options{ + productCmd: []string{"powershell.exe", "-Command", "Get-CIMInstance", "Win32_ComputerSystem", "|", "Format-List", "-Property", "*"}, + cpuCmd: []string{"powershell.exe", "-Command", "Get-CIMInstance", "Win32_Processor", "|", "Format-List", "-Property", "*"}, + gpuCmd: []string{"powershell.exe", "-Command", "Get-CIMInstance", "Win32_VideoController", "|", "Format-List", "-Property", "*"}, + memoryCmd: []string{"powershell.exe", "-Command", "Get-CIMInstance", "Win32_ComputerSystem", "|", "Format-List", "-Property", "TotalPhysicalMemory"}, + + diskCmd: []string{"powershell.exe", "-Command", "Get-CIMInstance", "Win32_DiskDrive", "|", "Format-List", "-Property", "*"}, + partitionCmd: []string{"powershell.exe", "-Command", "Get-CIMInstance", "Win32_DiskPartition", "|", "Format-List", "-Property", "*"}, + + screenCmd: []string{"powershell.exe", "-Command", "Get-CIMInstance", "Win32_DesktopMonitor", "|", "Format-List", "-Property", "*"}, + + arch: runtime.GOARCH, + + log: slog.Default(), + } } -func (s Collector) collectProduct() (product, error) { - return product{}, nil +var usedProductFields = map[string]struct{}{ + "Model": {}, + "Manufacturer": {}, + "SystemSKUNumber": {}, } -func (s Collector) collectCPU() (cpu, error) { - return cpu{}, nil +// collectProduct uses Win32_ComputerSystem to find information about the system. +func (s Collector) collectProduct() (product product, err error) { + products, err := s.runWMI(s.opts.productCmd, usedProductFields) + if err != nil { + return nil, err + } + if len(products) > 1 { + s.opts.log.Info("product information more than 1 products", "count", len(products)) + } + + product = products[0] + + product["Family"] = product["SystemSKUNumber"] + delete(product, "SystemSKUNumber") + + product["Vendor"] = product["Manufacturer"] + delete(product, "Manufacturer") + + return product, nil } -func (s Collector) collectGPUs() ([]gpu, error) { - return []gpu{}, nil +var usedCPUFields = map[string]struct{}{ + "NumberOfLogicalProcessors": {}, + "NumberOfCores": {}, + "Manufacturer": {}, + "Name": {}, } -func (s Collector) collectMemory() (memory, error) { - return memory{}, nil +// collectCPU uses Win32_Processor to collect information about the CPUs. +func (s Collector) collectCPU() (cpu cpu, err error) { + cpus, err := s.runWMI(s.opts.cpuCmd, usedCPUFields) + if err != nil { + return nil, err + } + + // we are assuming all CPUs are the same + cpus[0]["Sockets"] = strconv.Itoa(len(cpus)) + + cpus[0]["Architecture"] = s.opts.arch + + return cpus[0], nil } -func (s Collector) collectDisks() ([]disk, error) { - return []disk{}, nil +var usedGPUFields = map[string]struct{}{ + "Name": {}, + "InstalledDisplayDrivers": {}, + "AdapterCompatibility": {}, } -func (s Collector) collectScreens() ([]screen, error) { - return []screen{}, nil +// collectGPUs uses Win32_VideoController to collect information about the GPUs. +func (s Collector) collectGPUs() (gpus []gpu, err error) { + gpus, err = s.runWMI(s.opts.gpuCmd, usedGPUFields) + if err != nil { + return gpus, err + } + + for _, g := range gpus { + // InstalledDisplayDrivers is a comma separated list of paths to drivers + v, _, _ := strings.Cut(g["InstalledDisplayDrivers"], ",") + vs := strings.Split(v, `\`) + + g["Driver"] = vs[len(vs)-1] + delete(g, "InstalledDisplayDrivers") + + g["Vendor"] = g["AdapterCompatibility"] + delete(g, "AdapterCompatibility") + } + + return gpus, nil +} + +var usedMemoryFields = map[string]struct{}{ + "TotalPhysicalMemory": {}, +} + +// collectMemory uses Win32_ComputerSystem to collect information about RAM. +func (s Collector) collectMemory() (mem memory, err error) { + oses, err := s.runWMI(s.opts.memoryCmd, usedMemoryFields) + if err != nil { + return nil, err + } + + var size = 0 + for _, os := range oses { + sm := os["TotalPhysicalMemory"] + v, err := strconv.Atoi(sm) + if err != nil { + s.opts.log.Warn("memory info contained non-integer memory", "value", sm) + continue + } + if v < 0 { + s.opts.log.Warn("memory info contained negative memory", "value", sm) + continue + } + size += v + } + + return memory{ + "MemTotal": size, + }, nil +} + +var usedDiskFields = map[string]struct{}{ + "Name": {}, + "Size": {}, + "Partitions": {}, +} + +var usedPartitionFields = map[string]struct{}{ + "DiskIndex": {}, + "Index": {}, + "Name": {}, + "Size": {}, +} + +// collectDisks uses Win32_DiskDrive and Win32_DiskPartition to collect information about disks. +func (s Collector) collectDisks() (blks []disk, err error) { + disks, err := s.runWMI(s.opts.diskCmd, usedDiskFields) + if err != nil { + return nil, err + } + + const maxPartitions = 128 + + blks = make([]disk, 0, len(disks)) + for _, d := range disks { + parts, err := strconv.Atoi(d["Partitions"]) + if err != nil { + s.opts.log.Warn("disk partitions was not an integer", "error", err) + parts = 0 + } + if parts < 0 { + s.opts.log.Warn("disk partitions was negative", "value", parts) + parts = 0 + } + if parts > maxPartitions { + s.opts.log.Warn("disk partitions too large", "value", parts) + parts = maxPartitions + } + + c := disk{ + Name: d["Name"], + Size: d["Size"], + Partitions: make([]disk, parts), + } + for i := range c.Partitions { + c.Partitions[i].Partitions = []disk{} + } + blks = append(blks, c) + } + + parts, err := s.runWMI(s.opts.partitionCmd, usedPartitionFields) + if err != nil { + s.opts.log.Warn("can't get partitions", "error", err) + return blks, nil + } + + for _, p := range parts { + d, err := strconv.Atoi(p["DiskIndex"]) + if err != nil { + s.opts.log.Warn("partition disk index was not an integer", "error", err) + continue + } + if d < 0 { + s.opts.log.Warn("partition disk index was negative", "value", d) + continue + } + if d >= len(blks) { + s.opts.log.Warn("partition disk index was larger than disks", "value", d) + continue + } + + idx, err := strconv.Atoi(p["Index"]) + if err != nil { + s.opts.log.Warn("partition index was not an integer", "error", err, "disk", d) + continue + } + if idx < 0 { + s.opts.log.Warn("partition index was negative", "value", idx, "disk", d) + continue + } + if idx >= len(blks[d].Partitions) { + s.opts.log.Warn("partition index was larger than partitions", "value", idx, "disk", d) + continue + } + + blks[d].Partitions[idx] = disk{ + Name: p["Name"], + Size: p["Size"], + Partitions: []disk{}, + } + } + + return blks, nil +} + +var usedScreenFields = map[string]struct{}{ + "Name": {}, + "ScreenWidth": {}, + "ScreenHeight": {}, +} + +// collectScreens uses Win32_DesktopMonitor to collect information about screens. +func (s Collector) collectScreens() (screens []screen, err error) { + monitors, err := s.runWMI(s.opts.screenCmd, usedScreenFields) + if err != nil { + return nil, err + } + + screens = make([]screen, 0, len(monitors)) + + for _, s := range monitors { + screens = append(screens, screen{ + Name: s["Name"], + Resolution: fmt.Sprintf("%sx%s", s["ScreenWidth"], s["ScreenHeight"]), + }) + } + + return screens, nil +} + +// wmiEntryRegex matches the key and value (if any) from gwmi output. +// For example: "Status : OK " matches and has "Status", "OK". +// Or: "DitherType:" matches and has "DitherType", "". +// However: " : OK" does not match. +var wmiEntryRegex = regexp.MustCompile(`(?m)^\s*(\S+)\s*:[^\S\n]*(.*?)\s*$`) + +var wmiReplaceRegex = regexp.MustCompile(`\r?\n\s*`) + +// wmiSplitRegex splits on two consecutive newlines, but \r needs special handling. +var wmiSplitRegex = regexp.MustCompile(`\r?\n\r?\n`) + +// runWMI runs the cmdlet specified by args and only includes fields in the filter. +func (s Collector) runWMI(args []string, filter map[string]struct{}) (out []map[string]string, err error) { + defer func() { + if err == nil && len(out) == 0 { + err = fmt.Errorf("%v output contained no sections", args) + } + }() + + if len(filter) == 0 { + return nil, fmt.Errorf("empty filter will always produce nothing for cmdlet %v", args) + } + + stdout, stderr, err := cmdutils.RunWithTimeout(context.Background(), 15*time.Second, args[0], args[1:]...) + if err != nil { + return nil, err + } + if stderr.Len() > 0 { + s.opts.log.Info(fmt.Sprintf("%v output to stderr", args), "stderr", stderr) + } + + sections := wmiSplitRegex.Split(stdout.String(), -1) + out = make([]map[string]string, 0, len(sections)) + + for _, section := range sections { + if section == "" { + continue + } + + entries := wmiEntryRegex.FindAllStringSubmatch(section, -1) + if len(entries) == 0 { + s.opts.log.Info(fmt.Sprintf("%v output has malformed section", args), "section", section) + continue + } + + v := make(map[string]string, len(filter)) + for _, e := range entries { + if _, ok := filter[e[1]]; !ok { + continue + } + + // Get-WmiObject injects newlines and whitespace into values for formatting + v[e[1]] = wmiReplaceRegex.ReplaceAllString(e[2], "") + } + + out = append(out, v) + } + + return out, nil } diff --git a/internal/collector/sysinfo/hardware/hardware_windows_test.go b/internal/collector/sysinfo/hardware/hardware_windows_test.go new file mode 100644 index 0000000..440b072 --- /dev/null +++ b/internal/collector/sysinfo/hardware/hardware_windows_test.go @@ -0,0 +1,1112 @@ +package hardware_test + +import ( + "flag" + "fmt" + "log/slog" + "os" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/ubuntu/ubuntu-insights/internal/collector/sysinfo/hardware" + "github.com/ubuntu/ubuntu-insights/internal/testutils" +) + +func TestMain(m *testing.M) { + flag.Parse() + dir, ok := testutils.SetupHelperCoverdir() + + r := m.Run() + if ok { + os.Remove(dir) + } + os.Exit(r) +} + +func TestCollectWindows(t *testing.T) { + t.Parallel() + + tests := map[string]struct { + productInfo string + cpuInfo string + gpuInfo string + memoryInfo string + diskInfo string + partitionInfo string + screenInfo string + + logs map[slog.Level]uint + wantErr bool + }{ + "Regular hardware information": { + productInfo: "regular", + cpuInfo: "regular", + gpuInfo: "regular", + memoryInfo: "regular", + diskInfo: "regular", + partitionInfo: "regular", + screenInfo: "regular", + }, + + "Missing product information": { + productInfo: "missing", + cpuInfo: "regular", + gpuInfo: "regular", + memoryInfo: "regular", + diskInfo: "regular", + partitionInfo: "regular", + screenInfo: "regular", + + logs: map[slog.Level]uint{ + slog.LevelWarn: 1, + }, + }, + + "Error product information": { + productInfo: "error", + cpuInfo: "regular", + gpuInfo: "regular", + memoryInfo: "regular", + diskInfo: "regular", + partitionInfo: "regular", + screenInfo: "regular", + + logs: map[slog.Level]uint{ + slog.LevelWarn: 1, + }, + }, + + "Missing CPU information": { + productInfo: "regular", + cpuInfo: "missing", + gpuInfo: "regular", + memoryInfo: "regular", + diskInfo: "regular", + partitionInfo: "regular", + screenInfo: "regular", + + logs: map[slog.Level]uint{ + slog.LevelWarn: 1, + }, + }, + + "Error CPU information": { + productInfo: "regular", + cpuInfo: "error", + gpuInfo: "regular", + memoryInfo: "regular", + diskInfo: "regular", + partitionInfo: "regular", + screenInfo: "regular", + + logs: map[slog.Level]uint{ + slog.LevelWarn: 1, + }, + }, + + "Missing GPU information": { + productInfo: "regular", + cpuInfo: "regular", + gpuInfo: "missing", + memoryInfo: "regular", + diskInfo: "regular", + partitionInfo: "regular", + screenInfo: "regular", + + logs: map[slog.Level]uint{ + slog.LevelWarn: 1, + }, + }, + + "Error GPU information": { + productInfo: "regular", + cpuInfo: "regular", + gpuInfo: "error", + memoryInfo: "regular", + diskInfo: "regular", + partitionInfo: "regular", + screenInfo: "regular", + + logs: map[slog.Level]uint{ + slog.LevelWarn: 1, + }, + }, + + "Missing memory information": { + productInfo: "regular", + cpuInfo: "regular", + gpuInfo: "regular", + memoryInfo: "missing", + diskInfo: "regular", + partitionInfo: "regular", + screenInfo: "regular", + + logs: map[slog.Level]uint{ + slog.LevelWarn: 1, + }, + }, + + "Negative memory information": { + productInfo: "regular", + cpuInfo: "regular", + gpuInfo: "regular", + memoryInfo: "negative", + diskInfo: "regular", + partitionInfo: "regular", + screenInfo: "regular", + + logs: map[slog.Level]uint{ + slog.LevelWarn: 1, + }, + }, + + "Bad memory information": { + productInfo: "regular", + cpuInfo: "regular", + gpuInfo: "regular", + memoryInfo: "bad", + diskInfo: "regular", + partitionInfo: "regular", + screenInfo: "regular", + + logs: map[slog.Level]uint{ + slog.LevelWarn: 1, + }, + }, + + "Garbage memory information": { + productInfo: "regular", + cpuInfo: "regular", + gpuInfo: "regular", + memoryInfo: "garbage", + diskInfo: "regular", + partitionInfo: "regular", + screenInfo: "regular", + + logs: map[slog.Level]uint{ + slog.LevelWarn: 1, + }, + }, + + "Error memory information": { + productInfo: "regular", + cpuInfo: "regular", + gpuInfo: "regular", + memoryInfo: "error", + diskInfo: "regular", + partitionInfo: "regular", + screenInfo: "regular", + + logs: map[slog.Level]uint{ + slog.LevelWarn: 1, + }, + }, + + "Missing disk information": { + productInfo: "regular", + cpuInfo: "regular", + gpuInfo: "regular", + memoryInfo: "regular", + diskInfo: "missing", + partitionInfo: "regular", + screenInfo: "regular", + + logs: map[slog.Level]uint{ + slog.LevelWarn: 1, + }, + }, + + "Error disk information": { + productInfo: "regular", + cpuInfo: "regular", + gpuInfo: "regular", + memoryInfo: "regular", + diskInfo: "error", + partitionInfo: "regular", + screenInfo: "regular", + + logs: map[slog.Level]uint{ + slog.LevelWarn: 1, + }, + }, + + "Malicious disk information": { + productInfo: "regular", + cpuInfo: "regular", + gpuInfo: "regular", + memoryInfo: "regular", + diskInfo: "malicious", + partitionInfo: "regular", + screenInfo: "regular", + + logs: map[slog.Level]uint{ + slog.LevelWarn: 3, + }, + }, + + "Missing partition information": { + productInfo: "regular", + cpuInfo: "regular", + gpuInfo: "regular", + memoryInfo: "regular", + diskInfo: "regular", + partitionInfo: "missing", + screenInfo: "regular", + + logs: map[slog.Level]uint{ + slog.LevelWarn: 1, + }, + }, + + "Error partition information": { + productInfo: "regular", + cpuInfo: "regular", + gpuInfo: "regular", + memoryInfo: "regular", + diskInfo: "regular", + partitionInfo: "error", + screenInfo: "regular", + + logs: map[slog.Level]uint{ + slog.LevelWarn: 1, + }, + }, + + "Malicious partition information": { + productInfo: "regular", + cpuInfo: "regular", + gpuInfo: "regular", + memoryInfo: "regular", + diskInfo: "regular", + partitionInfo: "malicious", + screenInfo: "regular", + + logs: map[slog.Level]uint{ + slog.LevelWarn: 6, + }, + }, + + "Missing screen information": { + productInfo: "regular", + cpuInfo: "regular", + gpuInfo: "regular", + memoryInfo: "regular", + diskInfo: "regular", + partitionInfo: "regular", + screenInfo: "missing", + + logs: map[slog.Level]uint{ + slog.LevelWarn: 1, + }, + }, + + "Error screen information": { + productInfo: "regular", + cpuInfo: "regular", + gpuInfo: "regular", + memoryInfo: "regular", + diskInfo: "regular", + partitionInfo: "regular", + screenInfo: "error", + + logs: map[slog.Level]uint{ + slog.LevelWarn: 1, + }, + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + t.Parallel() + + l := testutils.NewMockHandler(slog.LevelDebug) + + options := []hardware.Options{ + hardware.WithLogger(&l), + hardware.WithArch("amd64"), + } + + if tc.productInfo != "-" { + cmdArgs := testutils.SetupFakeCmdArgs("TestFakeProductInfo", tc.productInfo) + options = append(options, hardware.WithProductInfo(cmdArgs)) + } + + if tc.cpuInfo != "-" { + cmdArgs := testutils.SetupFakeCmdArgs("TestFakeCPUInfo", tc.cpuInfo) + options = append(options, hardware.WithCPUInfo(cmdArgs)) + } + + if tc.gpuInfo != "-" { + cmdArgs := testutils.SetupFakeCmdArgs("TestFakeGPUInfo", tc.gpuInfo) + options = append(options, hardware.WithGPUInfo(cmdArgs)) + } + + if tc.memoryInfo != "-" { + cmdArgs := testutils.SetupFakeCmdArgs("TestFakeMemoryInfo", tc.memoryInfo) + options = append(options, hardware.WithMemoryInfo(cmdArgs)) + } + + if tc.diskInfo != "-" { + cmdArgs := testutils.SetupFakeCmdArgs("TestFakeDiskInfo", tc.diskInfo) + options = append(options, hardware.WithDiskInfo(cmdArgs)) + } + + if tc.partitionInfo != "-" { + cmdArgs := testutils.SetupFakeCmdArgs("TestFakePartitionInfo", tc.partitionInfo) + options = append(options, hardware.WithPartitionInfo(cmdArgs)) + } + + if tc.screenInfo != "-" { + cmdArgs := testutils.SetupFakeCmdArgs("TestFakeScreenInfo", tc.screenInfo) + options = append(options, hardware.WithScreenInfo(cmdArgs)) + } + + s := hardware.New(options...) + + got, err := s.Collect() + if tc.wantErr { + require.Error(t, err, "Collect should return an error and didn’t") + return + } + require.NoError(t, err, "Collect should not return an error") + + want := testutils.LoadWithUpdateFromGoldenYAML(t, got) + assert.Equal(t, want, got, "Collect should return expected sys information") + + if !l.AssertLevels(t, tc.logs) { + l.OutputLogs(t) + } + }) + } +} + +func TestFakeProductInfo(_ *testing.T) { + args, err := testutils.GetFakeCmdArgs() + if err != nil { + return + } + defer os.Exit(0) + + switch args[0] { + case "error": + fmt.Fprint(os.Stderr, "Error requested in fake product info") + os.Exit(1) + case "regular": + fmt.Println(` + +AdminPasswordStatus : 3 +BootupState : Normal boot +ChassisBootupState : 3 +KeyboardPasswordStatus : 3 +PowerOnPasswordStatus : 3 +PowerSupplyState : 3 +PowerState : 0 +FrontPanelResetStatus : 3 +ThermalState : 3 +Status : OK +Name : MSI +PowerManagementCapabilities : +PowerManagementSupported : +Caption : MSI +Description : AT/AT COMPATIBLE +InstallDate : +CreationClassName : Win32_ComputerSystem +NameFormat : +PrimaryOwnerContact : +PrimaryOwnerName : johndoe@internet.org +Roles : {LM_Workstation, LM_Server, NT} +InitialLoadInfo : +LastLoadInfo : +ResetCapability : 1 +AutomaticManagedPagefile : True +AutomaticResetBootOption : True +AutomaticResetCapability : True +BootOptionOnLimit : +BootOptionOnWatchDog : +BootROMSupported : True +BootStatus : {0, 0, 0, 0...} +ChassisSKUNumber : Default string +CurrentTimeZone : -300 +DaylightInEffect : False +DNSHostName : MSI +Domain : WORKGROUP +DomainRole : 0 +EnableDaylightSavingsTime : True +HypervisorPresent : True +InfraredSupported : False +Manufacturer : Micro-Star International Co., Ltd. +Model : Star 11 CPP +NetworkServerModeEnabled : True +NumberOfLogicalProcessors : 16 +NumberOfProcessors : 1 +OEMLogoBitmap : +OEMStringArray : { , $BIOSE1110000100000000200, , ...} +PartOfDomain : False +PauseAfterReset : -1 +PCSystemType : 2 +PCSystemTypeEx : 2 +ResetCount : -1 +ResetLimit : -1 +SupportContactDescription : +SystemFamily : GF +SystemSKUNumber : 1582.3 +SystemStartupDelay : +SystemStartupOptions : +SystemStartupSetting : +SystemType : x64-based PC +TotalPhysicalMemory : 68406489088 +UserName : MSI\johndo +WakeUpType : 6 +Workgroup : WORKGROUP`) + case "": + fallthrough + case "missing": + os.Exit(0) + } +} + +func TestFakeCPUInfo(_ *testing.T) { + args, err := testutils.GetFakeCmdArgs() + if err != nil { + return + } + defer os.Exit(0) + + switch args[0] { + case "error": + fmt.Fprint(os.Stderr, "Error requested in fake cpu info") + os.Exit(1) + case "regular": + fmt.Println(` + +Availability : 3 +CpuStatus : 1 +CurrentVoltage : 8 +DeviceID : CPU0 +ErrorCleared : +ErrorDescription : +LastErrorCode : +LoadPercentage : 4 +Status : OK +StatusInfo : 3 +AddressWidth : 64 +DataWidth : 64 +ExtClock : 100 +L2CacheSize : 10240 +L2CacheSpeed : +MaxClockSpeed : 2304 +PowerManagementSupported : False +ProcessorType : 3 +Revision : +SocketDesignation : U3E1 +Version : +VoltageCaps : +Caption : Intel64 Family 6 Model 141 Stepping 1 +Description : Intel64 Family 6 Model 141 Stepping 1 +InstallDate : +Name : 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz +ConfigManagerErrorCode : +ConfigManagerUserConfig : +CreationClassName : Win32_Processor +PNPDeviceID : +PowerManagementCapabilities : +SystemCreationClassName : Win32_ComputerSystem +SystemName : MSI +CurrentClockSpeed : 2304 +Family : 198 +OtherFamilyDescription : +Role : CPU +Stepping : +UniqueId : +UpgradeMethod : 1 +Architecture : 9 +AssetTag : To Be Filled By O.E.M. +Characteristics : 252 +L3CacheSize : 24576 +L3CacheSpeed : 0 +Level : 6 +Manufacturer : GenuineIntel +NumberOfCores : 8 +NumberOfEnabledCore : 8 +NumberOfLogicalProcessors : 16 +PartNumber : To Be Filled By O.E.M. +ProcessorId : BFEBFBFF000806D1 +SecondLevelAddressTranslationExtensions : False +SerialNumber : To Be Filled By O.E.M. +ThreadCount : 16 +VirtualizationFirmwareEnabled : False +VMMonitorModeExtensions : False`) + case "": + fallthrough + case "missing": + os.Exit(0) + } +} + +func TestFakeGPUInfo(_ *testing.T) { + args, err := testutils.GetFakeCmdArgs() + if err != nil { + return + } + defer os.Exit(0) + + switch args[0] { + case "error": + fmt.Fprint(os.Stderr, "Error requested in fake gpu info") + os.Exit(1) + case "regular": + fmt.Println(` + +AcceleratorCapabilities : +AdapterCompatibility : NVIDIA +AdapterDACType : Integrated RAMDAC +AdapterRAM : 4293918720 +Availability : 8 +CapabilityDescriptions : +Caption : NVIDIA GeForce RTX 3050 Ti Laptop GPU +ColorTableEntries : +ConfigManagerErrorCode : 0 +ConfigManagerUserConfig : False +CreationClassName : Win32_VideoController +CurrentBitsPerPixel : +CurrentHorizontalResolution : +CurrentNumberOfColors : +CurrentNumberOfColumns : +CurrentNumberOfRows : +CurrentRefreshRate : +CurrentScanMode : +CurrentVerticalResolution : +Description : NVIDIA GeForce RTX 3050 Ti Laptop GPU +DeviceID : VideoController1 +DeviceSpecificPens : +DitherType : +DriverDate : 20240926000000.000000-000 +DriverVersion : 32.0.15.6590 +ErrorCleared : +ErrorDescription : +ICMIntent : +ICMMethod : +InfFilename : oem316.inf +InfSection : Section181 +InstallDate : +InstalledDisplayDrivers : C:\Windows\System32\DriverStore\FileRepository\nvmii.inf_amd64_5b4deda8605cff46\nvldumdx.dll,C:\Windows\System32\DriverStore\FileRepository\nvmii.inf_amd64_5b4deda8605cff46\nvldumdx.dll,C + :\Windows\System32\DriverStore\FileRepository\nvmii.inf_amd64_5b4deda8605cff46\nvldumdx.dll,C:\Windows\System32\DriverStore\FileRepository\nvmii.inf_amd64_5b4deda8605cff46\nvldumdx.dll +LastErrorCode : +MaxMemorySupported : +MaxNumberControlled : +MaxRefreshRate : +MinRefreshRate : +Monochrome : False +Name : NVIDIA GeForce RTX 3050 Ti Laptop GPU +NumberOfColorPlanes : +NumberOfVideoPages : +PNPDeviceID : PCI\VEN_10DE&DEV_25A0&SUBSYS_12EC1462&REV_A1\4&36DBEA65&0&0008 +PowerManagementCapabilities : +PowerManagementSupported : +ProtocolSupported : +ReservedSystemPaletteEntries : +SpecificationVersion : +Status : OK +StatusInfo : +SystemCreationClassName : Win32_ComputerSystem +SystemName : MSI +SystemPaletteEntries : +TimeOfLastReset : +VideoArchitecture : 5 +VideoMemoryType : 2 +VideoMode : +VideoModeDescription : +VideoProcessor : NVIDIA GeForce RTX 3050 Ti Laptop GPU + +AcceleratorCapabilities : +AdapterCompatibility : Intel Corporation +AdapterDACType : Internal +AdapterRAM : 1073741824 +Availability : 3 +CapabilityDescriptions : +Caption : Intel(R) UHD Graphics +ColorTableEntries : +ConfigManagerErrorCode : 0 +ConfigManagerUserConfig : False +CreationClassName : Win32_VideoController +CurrentBitsPerPixel : 32 +CurrentHorizontalResolution : 1920 +CurrentNumberOfColors : 4294967296 +CurrentNumberOfColumns : 0 +CurrentNumberOfRows : 0 +CurrentRefreshRate : 144 +CurrentScanMode : 4 +CurrentVerticalResolution : 1080 +Description : Intel(R) UHD Graphics +DeviceID : VideoController2 +DeviceSpecificPens : +DitherType : 0 +DriverDate : 20220526000000.000000-000 +DriverVersion : 30.0.101.2079 +ErrorCleared : +ErrorDescription : +ICMIntent : +ICMMethod : +InfFilename : oem230.inf +InfSection : iTGLD_w10_DS +InstallDate : +InstalledDisplayDrivers : C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_357acc06f2c40efb\igdumdim0.dll,C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_357acc06f2c40efb\igd10i + umd32.dll,C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_357acc06f2c40efb\igd10iumd128.dll,C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_357acc06f2c4 + 0efb\igd12umd64.dll +LastErrorCode : +MaxMemorySupported : +MaxNumberControlled : +MaxRefreshRate : 144 +MinRefreshRate : 60 +Monochrome : False +Name : Intel(R) UHD Graphics +NumberOfColorPlanes : +NumberOfVideoPages : +PNPDeviceID : PCI\VEN_8086&DEV_9A60&SUBSYS_12EC1462&REV_01\3&11583659&2&10 +PowerManagementCapabilities : +PowerManagementSupported : +ProtocolSupported : +ReservedSystemPaletteEntries : +SpecificationVersion : +Status : OK +StatusInfo : +SystemCreationClassName : Win32_ComputerSystem +SystemName : MSI +SystemPaletteEntries : +TimeOfLastReset : +VideoArchitecture : 5 +VideoMemoryType : 2 +VideoMode : +VideoModeDescription : 1920 x 1080 x 4294967296 colors +VideoProcessor : Intel(R) UHD Graphics Family`) + case "": + fallthrough + case "missing": + os.Exit(0) + } +} + +func TestFakeMemoryInfo(_ *testing.T) { + args, err := testutils.GetFakeCmdArgs() + if err != nil { + return + } + defer os.Exit(0) + + switch args[0] { + case "error": + fmt.Fprint(os.Stderr, "Error requested in fake memory info") + os.Exit(1) + case "regular": + fmt.Println(` + +TotalPhysicalMemory : 68406489088`) + case "negative": + fmt.Println(` + +TotalPhysicalMemory : -68406489088`) + case "bad": + fmt.Println(` + +TotalPhysicalMemory : ONE BILLION!!!`) + case "garbage": + fmt.Println(` +TLB:active +Memory:mapped +Pages:paged`) + case "": + fallthrough + case "missing": + os.Exit(0) + } +} + +func TestFakeDiskInfo(_ *testing.T) { + args, err := testutils.GetFakeCmdArgs() + if err != nil { + return + } + defer os.Exit(0) + + switch args[0] { + case "error": + fmt.Fprint(os.Stderr, "Error requested in fake disk info") + os.Exit(1) + case "regular": + fmt.Println(` + +ConfigManagerErrorCode : 0 +LastErrorCode : +NeedsCleaning : +Status : OK +DeviceID : \\.\PHYSICALDRIVE0 +StatusInfo : +Partitions : 4 +BytesPerSector : 512 +ConfigManagerUserConfig : False +DefaultBlockSize : +Index : 0 +InstallDate : +InterfaceType : SCSI +MaxBlockSize : +MaxMediaSize : +MinBlockSize : +NumberOfMediaSupported : +SectorsPerTrack : 63 +Size : 2000396321280 +TotalCylinders : 243201 +TotalHeads : 255 +TotalSectors : 3907024065 +TotalTracks : 62016255 +TracksPerCylinder : 255 +Caption : WD Green SN350 2TB +Description : Disk drive +Name : \\.\PHYSICALDRIVE0 +Availability : +CreationClassName : Win32_DiskDrive +ErrorCleared : +ErrorDescription : +PNPDeviceID : SCSI\DISK&VEN_NVME&PROD_WD_GREEN_SN350_2\5&CD81A53&0&000000 +PowerManagementCapabilities : +PowerManagementSupported : +SystemCreationClassName : Win32_ComputerSystem +SystemName : MSI +Capabilities : {3, 4} +CapabilityDescriptions : {Random Access, Supports Writing} +CompressionMethod : +ErrorMethodology : +FirmwareRevision : 33006000 +Manufacturer : (Standard disk drives) +MediaLoaded : True +MediaType : Fixed hard disk media +Model : WD Green SN350 2TB +SCSIBus : 0 +SCSILogicalUnit : 0 +SCSIPort : 1 +SCSITargetId : 0 +SerialNumber : DEAD_BEEF_D34D_B33F_DEAD_B33F_D34D_BEEF. +Signature :`) + case "malicious": + fmt.Println(` + +Partitions : 999999999999 +BytesPerSector : 512 +Index : 0 +SectorsPerTrack : 63 +Size : 2000396321280 +TotalCylinders : 243201 +TotalHeads : 255 +TotalSectors : 3907024065 +TotalTracks : 62016255 +TracksPerCylinder : 255 +Caption : WD Green SN350 2TB +Description : Disk drive +Name : \\.\PHYSICALDRIVE0 +Model : WD Green SN350 2TB + +Partitions : -1 +BytesPerSector : 512 +Index : 1 +SectorsPerTrack : 63 +Size : 2000396321280 +TotalCylinders : 243201 +TotalHeads : 255 +TotalSectors : 3907024065 +TotalTracks : 62016255 +TracksPerCylinder : 255 +Caption : WD Green SN350 2TB +Description : Disk drive +Name : \\.\PHYSICALDRIVE0 +Model : WD Green SN350 2TB + +Partitions : one gazillion +BytesPerSector : 512 +Index : 2 +SectorsPerTrack : 63 +Size : 2000396321280 +TotalCylinders : 243201 +TotalHeads : 255 +TotalSectors : 3907024065 +TotalTracks : 62016255 +TracksPerCylinder : 255 +Caption : WD Green SN350 2TB +Description : Disk drive +Name : \\.\PHYSICALDRIVE0 +Model : WD Green SN350 2TB`) + case "": + fallthrough + case "missing": + os.Exit(0) + } +} + +func TestFakePartitionInfo(_ *testing.T) { + args, err := testutils.GetFakeCmdArgs() + if err != nil { + return + } + defer os.Exit(0) + + switch args[0] { + case "error": + fmt.Fprint(os.Stderr, "Error requested in fake partition info") + os.Exit(1) + case "regular": + fmt.Println(` + +Index : 0 +Status : +StatusInfo : +Name : Disk #0, Partition #0 +Caption : Disk #0, Partition #0 +Description : GPT: System +InstallDate : +Availability : +ConfigManagerErrorCode : +ConfigManagerUserConfig : +CreationClassName : Win32_DiskPartition +DeviceID : Disk #0, Partition #0 +ErrorCleared : +ErrorDescription : +LastErrorCode : +PNPDeviceID : +PowerManagementCapabilities : +PowerManagementSupported : +SystemCreationClassName : Win32_ComputerSystem +SystemName : MSI +Access : +BlockSize : 512 +ErrorMethodology : +NumberOfBlocks : 614400 +Purpose : +Bootable : True +PrimaryPartition : True +BootPartition : True +DiskIndex : 0 +HiddenSectors : +RewritePartition : +Size : 314572800 +StartingOffset : 1048576 +Type : GPT: System + +Index : 1 +Status : +StatusInfo : +Name : Disk #0, Partition #1 +Caption : Disk #0, Partition #1 +Description : GPT: Unknown +InstallDate : +Availability : +ConfigManagerErrorCode : +ConfigManagerUserConfig : +CreationClassName : Win32_DiskPartition +DeviceID : Disk #0, Partition #1 +ErrorCleared : +ErrorDescription : +LastErrorCode : +PNPDeviceID : +PowerManagementCapabilities : +PowerManagementSupported : +SystemCreationClassName : Win32_ComputerSystem +SystemName : MSI +Access : +BlockSize : 512 +ErrorMethodology : +NumberOfBlocks : 1843200 +Purpose : +Bootable : False +PrimaryPartition : False +BootPartition : False +DiskIndex : 0 +HiddenSectors : +RewritePartition : +Size : 943718400 +StartingOffset : 449839104 +Type : GPT: Unknown + +Index : 2 +Status : +StatusInfo : +Name : Disk #0, Partition #2 +Caption : Disk #0, Partition #2 +Description : GPT: Unknown +InstallDate : +Availability : +ConfigManagerErrorCode : +ConfigManagerUserConfig : +CreationClassName : Win32_DiskPartition +DeviceID : Disk #0, Partition #2 +ErrorCleared : +ErrorDescription : +LastErrorCode : +PNPDeviceID : +PowerManagementCapabilities : +PowerManagementSupported : +SystemCreationClassName : Win32_ComputerSystem +SystemName : MSI +Access : +BlockSize : 512 +ErrorMethodology : +NumberOfBlocks : 43268096 +Purpose : +Bootable : False +PrimaryPartition : False +BootPartition : False +DiskIndex : 0 +HiddenSectors : +RewritePartition : +Size : 22153265152 +StartingOffset : 1393557504 +Type : GPT: Unknown + +Index : 3 +Status : +StatusInfo : +Name : Disk #0, Partition #3 +Caption : Disk #0, Partition #3 +Description : GPT: Basic Data +InstallDate : +Availability : +ConfigManagerErrorCode : +ConfigManagerUserConfig : +CreationClassName : Win32_DiskPartition +DeviceID : Disk #0, Partition #3 +ErrorCleared : +ErrorDescription : +LastErrorCode : +PNPDeviceID : +PowerManagementCapabilities : +PowerManagementSupported : +SystemCreationClassName : Win32_ComputerSystem +SystemName : MSI +Access : +BlockSize : 512 +ErrorMethodology : +NumberOfBlocks : 3861037056 +Purpose : +Bootable : False +PrimaryPartition : True +BootPartition : False +DiskIndex : 0 +HiddenSectors : +RewritePartition : +Size : 1976850972672 +StartingOffset : 23546822656 +Type : GPT: Basic Data`) + case "malicious": + fmt.Println(` + +Index : -1 +Name : Disk #0, Partition #-1 +DiskIndex : 0 +Size : 314572800 + +Index : alpha +Name : Disk #0, Partition alpha +DiskIndex : 0 +Size : 943718400 + +Index : 4 +Name : Disk #0, Partition #4 +DiskIndex : 0 +Size : 22153265152 + +Index : 0 +Name : Disk #-1, Partition #0 +DiskIndex : -1 +Size : 22153265152 + +Index : 1 +Name : Disk #1, Partition #1 +DiskIndex : 1 +Size : 22153265152 + +Index : 2 +Name : Disk beta, Partition #2 +DiskIndex : beta +Size : 1976850972672`) + case "": + fallthrough + case "missing": + os.Exit(0) + } +} + +func TestFakeScreenInfo(_ *testing.T) { + args, err := testutils.GetFakeCmdArgs() + if err != nil { + return + } + defer os.Exit(0) + + switch args[0] { + case "error": + fmt.Fprint(os.Stderr, "Error requested in fake screen info") + os.Exit(1) + case "regular": + fmt.Println(` + +DeviceID : DesktopMonitor1 +Name : Default Monitor +PixelsPerXLogicalInch : 120 +PixelsPerYLogicalInch : 120 +ScreenHeight : 1080 +ScreenWidth : 1920 +IsLocked : +LastErrorCode : +Status : OK +StatusInfo : +Caption : Default Monitor +Description : Default Monitor +InstallDate : +Availability : 3 +ConfigManagerErrorCode : +ConfigManagerUserConfig : +CreationClassName : Win32_DesktopMonitor +ErrorCleared : +ErrorDescription : +PNPDeviceID : +PowerManagementCapabilities : +PowerManagementSupported : +SystemCreationClassName : Win32_ComputerSystem +SystemName : MSI +Bandwidth : +DisplayType : +MonitorManufacturer : +MonitorType : Default Monitor + +DeviceID : DesktopMonitor2 +Name : Generic PnP Monitor +PixelsPerXLogicalInch : 120 +PixelsPerYLogicalInch : 120 +ScreenHeight : 1080 +ScreenWidth : 1920 +IsLocked : +LastErrorCode : +Status : OK +StatusInfo : +Caption : Generic PnP Monitor +Description : Generic PnP Monitor +InstallDate : +Availability : 3 +ConfigManagerErrorCode : 0 +ConfigManagerUserConfig : False +CreationClassName : Win32_DesktopMonitor +ErrorCleared : +ErrorDescription : +PNPDeviceID : DISPLAY\AUOAF90\4&28FE40F5&0&UID8388688 +PowerManagementCapabilities : +PowerManagementSupported : +SystemCreationClassName : Win32_ComputerSystem +SystemName : MSI +Bandwidth : +DisplayType : +MonitorManufacturer : (Standard monitor types) +MonitorType : Generic PnP Monitor`) + case "": + fallthrough + case "missing": + os.Exit(0) + } +} diff --git a/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/bad_memory_information b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/bad_memory_information new file mode 100644 index 0000000..2b00898 --- /dev/null +++ b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/bad_memory_information @@ -0,0 +1,47 @@ +product: + Family: "1582.3" + Model: Star 11 CPP + Vendor: Micro-Star International Co., Ltd. +cpu: + Architecture: amd64 + Manufacturer: GenuineIntel + Name: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz + NumberOfCores: "8" + NumberOfLogicalProcessors: "16" + Sockets: "1" +gpus: + - Driver: nvldumdx.dll + Name: NVIDIA GeForce RTX 3050 Ti Laptop GPU + Vendor: NVIDIA + - Driver: igdumdim0.dll + Name: Intel(R) UHD Graphics + Vendor: Intel Corporation +mem: + MemTotal: 0 +blks: + - name: \\.\PHYSICALDRIVE0 + size: "2000396321280" + partitions: + - name: 'Disk #0, Partition #0' + size: "314572800" + partitions: [] + - name: 'Disk #0, Partition #1' + size: "943718400" + partitions: [] + - name: 'Disk #0, Partition #2' + size: "22153265152" + partitions: [] + - name: 'Disk #0, Partition #3' + size: "1976850972672" + partitions: [] +screens: + - name: Default Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" + - name: Generic PnP Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" diff --git a/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_cpu_information b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_cpu_information new file mode 100644 index 0000000..03ea2b3 --- /dev/null +++ b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_cpu_information @@ -0,0 +1,41 @@ +product: + Family: "1582.3" + Model: Star 11 CPP + Vendor: Micro-Star International Co., Ltd. +cpu: {} +gpus: + - Driver: nvldumdx.dll + Name: NVIDIA GeForce RTX 3050 Ti Laptop GPU + Vendor: NVIDIA + - Driver: igdumdim0.dll + Name: Intel(R) UHD Graphics + Vendor: Intel Corporation +mem: + MemTotal: 68406489088 +blks: + - name: \\.\PHYSICALDRIVE0 + size: "2000396321280" + partitions: + - name: 'Disk #0, Partition #0' + size: "314572800" + partitions: [] + - name: 'Disk #0, Partition #1' + size: "943718400" + partitions: [] + - name: 'Disk #0, Partition #2' + size: "22153265152" + partitions: [] + - name: 'Disk #0, Partition #3' + size: "1976850972672" + partitions: [] +screens: + - name: Default Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" + - name: Generic PnP Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" diff --git a/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_disk_information b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_disk_information new file mode 100644 index 0000000..afd0555 --- /dev/null +++ b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_disk_information @@ -0,0 +1,32 @@ +product: + Family: "1582.3" + Model: Star 11 CPP + Vendor: Micro-Star International Co., Ltd. +cpu: + Architecture: amd64 + Manufacturer: GenuineIntel + Name: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz + NumberOfCores: "8" + NumberOfLogicalProcessors: "16" + Sockets: "1" +gpus: + - Driver: nvldumdx.dll + Name: NVIDIA GeForce RTX 3050 Ti Laptop GPU + Vendor: NVIDIA + - Driver: igdumdim0.dll + Name: Intel(R) UHD Graphics + Vendor: Intel Corporation +mem: + MemTotal: 68406489088 +blks: [] +screens: + - name: Default Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" + - name: Generic PnP Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" diff --git a/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_gpu_information b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_gpu_information new file mode 100644 index 0000000..eb5e886 --- /dev/null +++ b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_gpu_information @@ -0,0 +1,41 @@ +product: + Family: "1582.3" + Model: Star 11 CPP + Vendor: Micro-Star International Co., Ltd. +cpu: + Architecture: amd64 + Manufacturer: GenuineIntel + Name: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz + NumberOfCores: "8" + NumberOfLogicalProcessors: "16" + Sockets: "1" +gpus: [] +mem: + MemTotal: 68406489088 +blks: + - name: \\.\PHYSICALDRIVE0 + size: "2000396321280" + partitions: + - name: 'Disk #0, Partition #0' + size: "314572800" + partitions: [] + - name: 'Disk #0, Partition #1' + size: "943718400" + partitions: [] + - name: 'Disk #0, Partition #2' + size: "22153265152" + partitions: [] + - name: 'Disk #0, Partition #3' + size: "1976850972672" + partitions: [] +screens: + - name: Default Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" + - name: Generic PnP Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" diff --git a/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_memory_information b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_memory_information new file mode 100644 index 0000000..f52be0b --- /dev/null +++ b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_memory_information @@ -0,0 +1,46 @@ +product: + Family: "1582.3" + Model: Star 11 CPP + Vendor: Micro-Star International Co., Ltd. +cpu: + Architecture: amd64 + Manufacturer: GenuineIntel + Name: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz + NumberOfCores: "8" + NumberOfLogicalProcessors: "16" + Sockets: "1" +gpus: + - Driver: nvldumdx.dll + Name: NVIDIA GeForce RTX 3050 Ti Laptop GPU + Vendor: NVIDIA + - Driver: igdumdim0.dll + Name: Intel(R) UHD Graphics + Vendor: Intel Corporation +mem: {} +blks: + - name: \\.\PHYSICALDRIVE0 + size: "2000396321280" + partitions: + - name: 'Disk #0, Partition #0' + size: "314572800" + partitions: [] + - name: 'Disk #0, Partition #1' + size: "943718400" + partitions: [] + - name: 'Disk #0, Partition #2' + size: "22153265152" + partitions: [] + - name: 'Disk #0, Partition #3' + size: "1976850972672" + partitions: [] +screens: + - name: Default Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" + - name: Generic PnP Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" diff --git a/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_partition_information b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_partition_information new file mode 100644 index 0000000..29198ee --- /dev/null +++ b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_partition_information @@ -0,0 +1,47 @@ +product: + Family: "1582.3" + Model: Star 11 CPP + Vendor: Micro-Star International Co., Ltd. +cpu: + Architecture: amd64 + Manufacturer: GenuineIntel + Name: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz + NumberOfCores: "8" + NumberOfLogicalProcessors: "16" + Sockets: "1" +gpus: + - Driver: nvldumdx.dll + Name: NVIDIA GeForce RTX 3050 Ti Laptop GPU + Vendor: NVIDIA + - Driver: igdumdim0.dll + Name: Intel(R) UHD Graphics + Vendor: Intel Corporation +mem: + MemTotal: 68406489088 +blks: + - name: \\.\PHYSICALDRIVE0 + size: "2000396321280" + partitions: + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] +screens: + - name: Default Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" + - name: Generic PnP Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" diff --git a/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_product_information b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_product_information new file mode 100644 index 0000000..99de3df --- /dev/null +++ b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_product_information @@ -0,0 +1,44 @@ +product: {} +cpu: + Architecture: amd64 + Manufacturer: GenuineIntel + Name: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz + NumberOfCores: "8" + NumberOfLogicalProcessors: "16" + Sockets: "1" +gpus: + - Driver: nvldumdx.dll + Name: NVIDIA GeForce RTX 3050 Ti Laptop GPU + Vendor: NVIDIA + - Driver: igdumdim0.dll + Name: Intel(R) UHD Graphics + Vendor: Intel Corporation +mem: + MemTotal: 68406489088 +blks: + - name: \\.\PHYSICALDRIVE0 + size: "2000396321280" + partitions: + - name: 'Disk #0, Partition #0' + size: "314572800" + partitions: [] + - name: 'Disk #0, Partition #1' + size: "943718400" + partitions: [] + - name: 'Disk #0, Partition #2' + size: "22153265152" + partitions: [] + - name: 'Disk #0, Partition #3' + size: "1976850972672" + partitions: [] +screens: + - name: Default Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" + - name: Generic PnP Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" diff --git a/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_screen_information b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_screen_information new file mode 100644 index 0000000..d9b697d --- /dev/null +++ b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/error_screen_information @@ -0,0 +1,37 @@ +product: + Family: "1582.3" + Model: Star 11 CPP + Vendor: Micro-Star International Co., Ltd. +cpu: + Architecture: amd64 + Manufacturer: GenuineIntel + Name: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz + NumberOfCores: "8" + NumberOfLogicalProcessors: "16" + Sockets: "1" +gpus: + - Driver: nvldumdx.dll + Name: NVIDIA GeForce RTX 3050 Ti Laptop GPU + Vendor: NVIDIA + - Driver: igdumdim0.dll + Name: Intel(R) UHD Graphics + Vendor: Intel Corporation +mem: + MemTotal: 68406489088 +blks: + - name: \\.\PHYSICALDRIVE0 + size: "2000396321280" + partitions: + - name: 'Disk #0, Partition #0' + size: "314572800" + partitions: [] + - name: 'Disk #0, Partition #1' + size: "943718400" + partitions: [] + - name: 'Disk #0, Partition #2' + size: "22153265152" + partitions: [] + - name: 'Disk #0, Partition #3' + size: "1976850972672" + partitions: [] +screens: [] diff --git a/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/garbage_memory_information b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/garbage_memory_information new file mode 100644 index 0000000..2b00898 --- /dev/null +++ b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/garbage_memory_information @@ -0,0 +1,47 @@ +product: + Family: "1582.3" + Model: Star 11 CPP + Vendor: Micro-Star International Co., Ltd. +cpu: + Architecture: amd64 + Manufacturer: GenuineIntel + Name: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz + NumberOfCores: "8" + NumberOfLogicalProcessors: "16" + Sockets: "1" +gpus: + - Driver: nvldumdx.dll + Name: NVIDIA GeForce RTX 3050 Ti Laptop GPU + Vendor: NVIDIA + - Driver: igdumdim0.dll + Name: Intel(R) UHD Graphics + Vendor: Intel Corporation +mem: + MemTotal: 0 +blks: + - name: \\.\PHYSICALDRIVE0 + size: "2000396321280" + partitions: + - name: 'Disk #0, Partition #0' + size: "314572800" + partitions: [] + - name: 'Disk #0, Partition #1' + size: "943718400" + partitions: [] + - name: 'Disk #0, Partition #2' + size: "22153265152" + partitions: [] + - name: 'Disk #0, Partition #3' + size: "1976850972672" + partitions: [] +screens: + - name: Default Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" + - name: Generic PnP Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" diff --git a/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/malicious_disk_information b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/malicious_disk_information new file mode 100644 index 0000000..4968b2c --- /dev/null +++ b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/malicious_disk_information @@ -0,0 +1,425 @@ +product: + Family: "1582.3" + Model: Star 11 CPP + Vendor: Micro-Star International Co., Ltd. +cpu: + Architecture: amd64 + Manufacturer: GenuineIntel + Name: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz + NumberOfCores: "8" + NumberOfLogicalProcessors: "16" + Sockets: "1" +gpus: + - Driver: nvldumdx.dll + Name: NVIDIA GeForce RTX 3050 Ti Laptop GPU + Vendor: NVIDIA + - Driver: igdumdim0.dll + Name: Intel(R) UHD Graphics + Vendor: Intel Corporation +mem: + MemTotal: 68406489088 +blks: + - name: \\.\PHYSICALDRIVE0 + size: "2000396321280" + partitions: + - name: 'Disk #0, Partition #0' + size: "314572800" + partitions: [] + - name: 'Disk #0, Partition #1' + size: "943718400" + partitions: [] + - name: 'Disk #0, Partition #2' + size: "22153265152" + partitions: [] + - name: 'Disk #0, Partition #3' + size: "1976850972672" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: \\.\PHYSICALDRIVE0 + size: "2000396321280" + partitions: [] + - name: \\.\PHYSICALDRIVE0 + size: "2000396321280" + partitions: [] +screens: + - name: Default Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" + - name: Generic PnP Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" diff --git a/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/malicious_partition_information b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/malicious_partition_information new file mode 100644 index 0000000..29198ee --- /dev/null +++ b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/malicious_partition_information @@ -0,0 +1,47 @@ +product: + Family: "1582.3" + Model: Star 11 CPP + Vendor: Micro-Star International Co., Ltd. +cpu: + Architecture: amd64 + Manufacturer: GenuineIntel + Name: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz + NumberOfCores: "8" + NumberOfLogicalProcessors: "16" + Sockets: "1" +gpus: + - Driver: nvldumdx.dll + Name: NVIDIA GeForce RTX 3050 Ti Laptop GPU + Vendor: NVIDIA + - Driver: igdumdim0.dll + Name: Intel(R) UHD Graphics + Vendor: Intel Corporation +mem: + MemTotal: 68406489088 +blks: + - name: \\.\PHYSICALDRIVE0 + size: "2000396321280" + partitions: + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] +screens: + - name: Default Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" + - name: Generic PnP Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" diff --git a/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_cpu_information b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_cpu_information new file mode 100644 index 0000000..03ea2b3 --- /dev/null +++ b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_cpu_information @@ -0,0 +1,41 @@ +product: + Family: "1582.3" + Model: Star 11 CPP + Vendor: Micro-Star International Co., Ltd. +cpu: {} +gpus: + - Driver: nvldumdx.dll + Name: NVIDIA GeForce RTX 3050 Ti Laptop GPU + Vendor: NVIDIA + - Driver: igdumdim0.dll + Name: Intel(R) UHD Graphics + Vendor: Intel Corporation +mem: + MemTotal: 68406489088 +blks: + - name: \\.\PHYSICALDRIVE0 + size: "2000396321280" + partitions: + - name: 'Disk #0, Partition #0' + size: "314572800" + partitions: [] + - name: 'Disk #0, Partition #1' + size: "943718400" + partitions: [] + - name: 'Disk #0, Partition #2' + size: "22153265152" + partitions: [] + - name: 'Disk #0, Partition #3' + size: "1976850972672" + partitions: [] +screens: + - name: Default Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" + - name: Generic PnP Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" diff --git a/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_disk_information b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_disk_information new file mode 100644 index 0000000..afd0555 --- /dev/null +++ b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_disk_information @@ -0,0 +1,32 @@ +product: + Family: "1582.3" + Model: Star 11 CPP + Vendor: Micro-Star International Co., Ltd. +cpu: + Architecture: amd64 + Manufacturer: GenuineIntel + Name: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz + NumberOfCores: "8" + NumberOfLogicalProcessors: "16" + Sockets: "1" +gpus: + - Driver: nvldumdx.dll + Name: NVIDIA GeForce RTX 3050 Ti Laptop GPU + Vendor: NVIDIA + - Driver: igdumdim0.dll + Name: Intel(R) UHD Graphics + Vendor: Intel Corporation +mem: + MemTotal: 68406489088 +blks: [] +screens: + - name: Default Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" + - name: Generic PnP Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" diff --git a/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_gpu_information b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_gpu_information new file mode 100644 index 0000000..eb5e886 --- /dev/null +++ b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_gpu_information @@ -0,0 +1,41 @@ +product: + Family: "1582.3" + Model: Star 11 CPP + Vendor: Micro-Star International Co., Ltd. +cpu: + Architecture: amd64 + Manufacturer: GenuineIntel + Name: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz + NumberOfCores: "8" + NumberOfLogicalProcessors: "16" + Sockets: "1" +gpus: [] +mem: + MemTotal: 68406489088 +blks: + - name: \\.\PHYSICALDRIVE0 + size: "2000396321280" + partitions: + - name: 'Disk #0, Partition #0' + size: "314572800" + partitions: [] + - name: 'Disk #0, Partition #1' + size: "943718400" + partitions: [] + - name: 'Disk #0, Partition #2' + size: "22153265152" + partitions: [] + - name: 'Disk #0, Partition #3' + size: "1976850972672" + partitions: [] +screens: + - name: Default Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" + - name: Generic PnP Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" diff --git a/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_memory_information b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_memory_information new file mode 100644 index 0000000..f52be0b --- /dev/null +++ b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_memory_information @@ -0,0 +1,46 @@ +product: + Family: "1582.3" + Model: Star 11 CPP + Vendor: Micro-Star International Co., Ltd. +cpu: + Architecture: amd64 + Manufacturer: GenuineIntel + Name: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz + NumberOfCores: "8" + NumberOfLogicalProcessors: "16" + Sockets: "1" +gpus: + - Driver: nvldumdx.dll + Name: NVIDIA GeForce RTX 3050 Ti Laptop GPU + Vendor: NVIDIA + - Driver: igdumdim0.dll + Name: Intel(R) UHD Graphics + Vendor: Intel Corporation +mem: {} +blks: + - name: \\.\PHYSICALDRIVE0 + size: "2000396321280" + partitions: + - name: 'Disk #0, Partition #0' + size: "314572800" + partitions: [] + - name: 'Disk #0, Partition #1' + size: "943718400" + partitions: [] + - name: 'Disk #0, Partition #2' + size: "22153265152" + partitions: [] + - name: 'Disk #0, Partition #3' + size: "1976850972672" + partitions: [] +screens: + - name: Default Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" + - name: Generic PnP Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" diff --git a/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_partition_information b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_partition_information new file mode 100644 index 0000000..29198ee --- /dev/null +++ b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_partition_information @@ -0,0 +1,47 @@ +product: + Family: "1582.3" + Model: Star 11 CPP + Vendor: Micro-Star International Co., Ltd. +cpu: + Architecture: amd64 + Manufacturer: GenuineIntel + Name: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz + NumberOfCores: "8" + NumberOfLogicalProcessors: "16" + Sockets: "1" +gpus: + - Driver: nvldumdx.dll + Name: NVIDIA GeForce RTX 3050 Ti Laptop GPU + Vendor: NVIDIA + - Driver: igdumdim0.dll + Name: Intel(R) UHD Graphics + Vendor: Intel Corporation +mem: + MemTotal: 68406489088 +blks: + - name: \\.\PHYSICALDRIVE0 + size: "2000396321280" + partitions: + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] + - name: "" + size: "" + partitions: [] +screens: + - name: Default Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" + - name: Generic PnP Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" diff --git a/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_product_information b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_product_information new file mode 100644 index 0000000..99de3df --- /dev/null +++ b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_product_information @@ -0,0 +1,44 @@ +product: {} +cpu: + Architecture: amd64 + Manufacturer: GenuineIntel + Name: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz + NumberOfCores: "8" + NumberOfLogicalProcessors: "16" + Sockets: "1" +gpus: + - Driver: nvldumdx.dll + Name: NVIDIA GeForce RTX 3050 Ti Laptop GPU + Vendor: NVIDIA + - Driver: igdumdim0.dll + Name: Intel(R) UHD Graphics + Vendor: Intel Corporation +mem: + MemTotal: 68406489088 +blks: + - name: \\.\PHYSICALDRIVE0 + size: "2000396321280" + partitions: + - name: 'Disk #0, Partition #0' + size: "314572800" + partitions: [] + - name: 'Disk #0, Partition #1' + size: "943718400" + partitions: [] + - name: 'Disk #0, Partition #2' + size: "22153265152" + partitions: [] + - name: 'Disk #0, Partition #3' + size: "1976850972672" + partitions: [] +screens: + - name: Default Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" + - name: Generic PnP Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" diff --git a/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_screen_information b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_screen_information new file mode 100644 index 0000000..d9b697d --- /dev/null +++ b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/missing_screen_information @@ -0,0 +1,37 @@ +product: + Family: "1582.3" + Model: Star 11 CPP + Vendor: Micro-Star International Co., Ltd. +cpu: + Architecture: amd64 + Manufacturer: GenuineIntel + Name: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz + NumberOfCores: "8" + NumberOfLogicalProcessors: "16" + Sockets: "1" +gpus: + - Driver: nvldumdx.dll + Name: NVIDIA GeForce RTX 3050 Ti Laptop GPU + Vendor: NVIDIA + - Driver: igdumdim0.dll + Name: Intel(R) UHD Graphics + Vendor: Intel Corporation +mem: + MemTotal: 68406489088 +blks: + - name: \\.\PHYSICALDRIVE0 + size: "2000396321280" + partitions: + - name: 'Disk #0, Partition #0' + size: "314572800" + partitions: [] + - name: 'Disk #0, Partition #1' + size: "943718400" + partitions: [] + - name: 'Disk #0, Partition #2' + size: "22153265152" + partitions: [] + - name: 'Disk #0, Partition #3' + size: "1976850972672" + partitions: [] +screens: [] diff --git a/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/negative_memory_information b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/negative_memory_information new file mode 100644 index 0000000..2b00898 --- /dev/null +++ b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/negative_memory_information @@ -0,0 +1,47 @@ +product: + Family: "1582.3" + Model: Star 11 CPP + Vendor: Micro-Star International Co., Ltd. +cpu: + Architecture: amd64 + Manufacturer: GenuineIntel + Name: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz + NumberOfCores: "8" + NumberOfLogicalProcessors: "16" + Sockets: "1" +gpus: + - Driver: nvldumdx.dll + Name: NVIDIA GeForce RTX 3050 Ti Laptop GPU + Vendor: NVIDIA + - Driver: igdumdim0.dll + Name: Intel(R) UHD Graphics + Vendor: Intel Corporation +mem: + MemTotal: 0 +blks: + - name: \\.\PHYSICALDRIVE0 + size: "2000396321280" + partitions: + - name: 'Disk #0, Partition #0' + size: "314572800" + partitions: [] + - name: 'Disk #0, Partition #1' + size: "943718400" + partitions: [] + - name: 'Disk #0, Partition #2' + size: "22153265152" + partitions: [] + - name: 'Disk #0, Partition #3' + size: "1976850972672" + partitions: [] +screens: + - name: Default Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" + - name: Generic PnP Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" diff --git a/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/regular_hardware_information b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/regular_hardware_information new file mode 100644 index 0000000..85fef30 --- /dev/null +++ b/internal/collector/sysinfo/hardware/testdata/TestCollectWindows/golden/regular_hardware_information @@ -0,0 +1,47 @@ +product: + Family: "1582.3" + Model: Star 11 CPP + Vendor: Micro-Star International Co., Ltd. +cpu: + Architecture: amd64 + Manufacturer: GenuineIntel + Name: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz + NumberOfCores: "8" + NumberOfLogicalProcessors: "16" + Sockets: "1" +gpus: + - Driver: nvldumdx.dll + Name: NVIDIA GeForce RTX 3050 Ti Laptop GPU + Vendor: NVIDIA + - Driver: igdumdim0.dll + Name: Intel(R) UHD Graphics + Vendor: Intel Corporation +mem: + MemTotal: 68406489088 +blks: + - name: \\.\PHYSICALDRIVE0 + size: "2000396321280" + partitions: + - name: 'Disk #0, Partition #0' + size: "314572800" + partitions: [] + - name: 'Disk #0, Partition #1' + size: "943718400" + partitions: [] + - name: 'Disk #0, Partition #2' + size: "22153265152" + partitions: [] + - name: 'Disk #0, Partition #3' + size: "1976850972672" + partitions: [] +screens: + - name: Default Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: "" + - name: Generic PnP Monitor + physicalresolution: "" + size: "" + resolution: 1920x1080 + refreshrate: ""